datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

ci: add check for doc comment formatting

Open CuteChuanChuan opened this issue 1 month ago • 1 comments

Which issue does this PR close?

Closes #16915.

Rationale for this change

This PR adds CI enforcement to ensure all code examples in documentation comments are properly formatted to maintain consistent code formatting, including examples in doc comments.

What changes are included in this PR?

This PR adds a new CI check in the check-fmt job that:

  1. Installs the nightly Rust toolchain
  2. Runs cargo +nightly fmt --all -- --check --config format_code_in_doc_comments=true

Note: format_code_in_doc_comments is currently an unstable feature.

Are these changes tested?

The command is tested locally with:

Are there any user-facing changes?

No user-facing changes.

CuteChuanChuan avatar Nov 08 '25 05:11 CuteChuanChuan

Hi @alamb ,

Following the discussion in PR #16916, I've prepared this PR to enable CI enforcement for doc comment formatting.

As you mentioned, we need to use the same version of cargo fmt to avoid conflicts. Since format_code_in_doc_comments is only available in nightly, this PR uses cargo +nightly fmt consistently in CI.

This PR contains two commits:

  1. CI change: Install nightly toolchain and use cargo +nightly fmt --all -- --check --config format_code_in_doc_comments=true
  2. Format fixes: Apply nightly rustfmt formatting to all existing doc comment code examples

PTAL when you have chance. Thank you!

CuteChuanChuan avatar Dec 10 '25 17:12 CuteChuanChuan

Hi @alamb ,

Sorry for the late response. I've moved the nightly fmt command to ci/scripts/rust_fmt.sh as suggested.
PTAL when you have chances, thanks!

CuteChuanChuan avatar Dec 20 '25 14:12 CuteChuanChuan