Skip to content

Document runner file-IO and glob helpers; add theme example (#346)#382

Open
leynos wants to merge 2 commits into
mainfrom
issue-346-rustdoc-examples
Open

Document runner file-IO and glob helpers; add theme example (#346)#382
leynos wants to merge 2 commits into
mainfrom
issue-346-rustdoc-examples

Conversation

@leynos

@leynos leynos commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #346

First increment of the staged Rustdoc-coverage work. It fully delivers the issue's concrete "missing Rustdoc on public runner/glob helpers is filled in" acceptance item, plus a representative # Examples section on a highest-use public API.

Changes

  • src/runner/process/file_io.rs: document the six previously undocumented file-I/O helpers (create_temp_ninja_file, write_text_file_utf8, write_ninja_file, write_text_file, write_ninja_stdout, write_text_stdout) with summaries and # Errors sections. These are pub but only crate-reachable (the process module is private), so missing_docs never flagged them — exactly the "crate-visible helpers" the issue calls out.
  • src/manifest/glob/{normalize,validate}.rs: document normalize_separators, force_literal_escapes, and validate_brace_matching (including the brace-validation # Errors contract).
  • src/theme.rs: add a worked # Examples doctest to ThemePreference::parse_raw covering the trim/case-insensitive and error paths.

Scope note

Per the issue's "add examples to the highest-use public APIs first, then work through remaining," the broader # Examples coverage for src/status.rs, src/stdlib/config.rs, src/cli/parser.rs, src/runner/mod.rs, src/ast.rs, and the test_support env guards is staged as follow-up increments; this PR lands the missing-helper-docs item and a representative example.

Validation

  • make check-fmt / make lint (cargo doc, warnings denied) / make test (doctests) — pass (37 suites)

🤖 Generated with Claude Code

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @leynos, you have reached your weekly rate limit of 2500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Rustdoc comments are added to four files with no runtime or signature changes. The glob normalisation helpers (normalize_separators, force_literal_escapes), the brace-validation function, five file I/O helpers in the runner process module, and ThemePreference::parse_raw all receive new or expanded documentation including error conditions and usage examples.

Changes

Rustdoc Additions

Layer / File(s) Summary
Glob normalise and validate docs
src/manifest/glob/normalize.rs, src/manifest/glob/validate.rs
Adds doc comments to normalize_separators (separator normalisation and Unix backslash preservation), force_literal_escapes (bracket-class rewriting of metacharacter escapes), and validate_brace_matching (brace-balance rules, character-class treatment, and error shape).
File I/O rustdoc
src/runner/process/file_io.rs
Adds rustdoc to create_temp_ninja_file, write_text_file_utf8, write_ninja_file, write_text_file, write_ninja_stdout, and write_text_stdout, covering capability-scoped directory behaviour, flush/fsync semantics, and the explicit broken-pipe-as-success contract.
ThemePreference::parse_raw docs
src/theme.rs
Expands existing doc comment with case-insensitive, whitespace-trimming parsing rules, an # Errors section, and concrete assert_eq! doctest examples for valid (" UNICODE ", "ascii") and invalid ("solarized") inputs.

Suggested labels

Issue

🖊️ The docs lay down their words with care,
Each /// line a lantern in the air.
Broken pipes are silently blessed,
And brace-balancing rules confessed.
Now every function stands explained — hooray!


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Unit Architecture ❌ Error Documentation for normalize_separators and force_literal_escapes uses overly broad wording that obscures architectural boundaries. "Escaped metacharacters preserved" doesn't clarify it's for the ne... Tighten the documentation per the review feedback: clarify that normalize_separators preserves escapes for the follow-up pass, and specify that force_literal_escapes handles only selected (not all) escaped metacharacters.
✅ Passed checks (19 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main changes: documenting runner file-I/O and glob helpers, plus adding theme examples, aligned with the concrete acceptance criterion from #346.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the documentation additions across file_io.rs, glob helpers, and theme.rs, with appropriate scope notes and validation details.
Linked Issues check ✅ Passed The PR fully delivers the concrete acceptance criterion: missing Rustdoc on public runner/glob helpers is filled in (file_io.rs, normalize.rs, validate.rs), examples compile (theme.rs doctest), and all validation checks pass.
Out of Scope Changes check ✅ Passed All changes remain within scope: documentation additions to specified file-I/O and glob helpers, plus one representative example to ThemePreference::parse_raw, with broader API examples explicitly deferred.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Testing (Overall) ✅ Passed This PR introduces only documentation changes with no new functionality or behavioural modifications. All function signatures and implementations remain unchanged; only Rustdoc comments were added....
User-Facing Documentation ✅ Passed PR makes documentation-only changes to Rustdoc comments; no new or changed user-facing functionality or behaviour introduced, so users-guide.md update not required.
Developer Documentation ✅ Passed PR adds only Rustdoc comments to existing functions with unchanged signatures; no new APIs, architectural changes, tooling changes, or design decisions requiring developer documentation updates.
Module-Level Documentation ✅ Passed All four modified modules carry adequate module-level docstrings clearly explaining their purpose, utility, and (where applicable) relationships. normalize.rs and validate.rs are sub-modules of...
Testing (Unit And Behavioural) ✅ Passed This PR is purely documentation-only (adds Rustdoc and a doctest example) with no code logic changes. The custom check for unit/behavioural testing applies to code changes affecting observable beha...
Testing (Property / Proof) ✅ Passed This PR adds documentation-only changes (Rustdoc comments) to existing functions without introducing new logic, invariants, or state transitions. Property tests or formal proofs are not applicable...
Testing (Compile-Time / Ui) ✅ Passed PR adds only documentation (rustdoc comments and one doctest to theme.rs); no compile-time behaviour changes or text-based/UI output requiring trybuild or snapshot tests.
Domain Architecture ✅ Passed This PR is documentation-only: no code changes affect domain/infrastructure boundaries. File-I/O adapters remain in runner/process, glob adapters in manifest/glob, and domain logic in theme.rs. Doc...
Observability ✅ Passed PR contains purely documentation changes (Rustdoc comments and examples) with no modifications to runtime behaviour, function logic, or operational instrumentation.
Security And Privacy ✅ Passed PR adds documentation-only comments; no secrets, injection risks, unsafe code, or permission changes introduced. File-I/O docs properly mention cap_std capability confinement.
Performance And Resource Use ✅ Passed PR is documentation-only (+98/-1 lines, all in Rustdoc comments); no function signatures, implementations, algorithms, I/O, allocations, or performance-sensitive paths were modified. Zero performan...
Concurrency And State ✅ Passed PR is documentation-only (rustdoc comments); no functional code, shared state, async execution, locks, or concurrency patterns introduced.
Architectural Complexity And Maintainability ✅ Passed PR adds only Rustdoc comments to six file-I/O helpers, three glob helpers, and one theme parser—no new abstractions, dependencies, layers, traits, or architectural patterns introduced.
Rust Compiler Lint Integrity ✅ Passed PR adds documentation-only comments to public/crate-visible functions with no new lint suppressions, unnecessary clones, or artificial lint appeasement code.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-346-rustdoc-examples

Comment @coderabbitai help to get the list of available commands and usage tips.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos marked this pull request as ready for review June 16, 2026 17:35
@coderabbitai coderabbitai Bot added the Issue label Jun 16, 2026
First increment of the Rustdoc-coverage work, delivering the concrete
"missing Rustdoc on public/crate-visible helpers" acceptance item.

Document the previously undocumented runner process file-I/O helpers in
`src/runner/process/file_io.rs` (`create_temp_ninja_file`,
`write_text_file_utf8`, `write_ninja_file`, `write_text_file`,
`write_ninja_stdout`, `write_text_stdout`), each with a summary and an
`# Errors` section. These are `pub` but only crate-reachable (the
`process` module is private), so `missing_docs` never flagged them.

Document the glob helper functions `normalize_separators`,
`force_literal_escapes`, and `validate_brace_matching`, including the
brace-validation `# Errors` contract.

Add a worked `# Examples` doctest to the high-use public
`ThemePreference::parse_raw`, exercising the trim/case-insensitive and
error paths.

Remaining `# Examples` coverage for the other high-use public APIs is
staged as follow-up increments per the issue's "highest-use first"
guidance.
@lodyai lodyai Bot force-pushed the issue-346-rustdoc-examples branch from 41c456c to 0a7011e Compare June 16, 2026 17:40
codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/manifest/glob/normalize.rs`:
- Around line 3-8: The documentation comments for the `normalize_separators` and
`force_literal_escapes` functions in src/manifest/glob/normalize.rs are too
broad and conflate the responsibilities of separate steps in the glob pipeline.
Update the doc comment for `normalize_separators` (lines 3-8) to clarify that it
only rewrites forward slashes to the platform separator and preserves backslash
escapes for a follow-up literal-escape pass rather than treating them as
separators. Also update the doc comment for `force_literal_escapes` (lines
84-88) to specify that it only rewrites a small fixed set of selected escaped
metacharacters (not all escapes) into bracket character classes, and remove
language suggesting it expands all escapes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9334ccb0-2ce8-4246-97b6-30ba4fd3ce62

📥 Commits

Reviewing files that changed from the base of the PR and between ed38533 and 41c456c.

📒 Files selected for processing (4)
  • src/manifest/glob/normalize.rs
  • src/manifest/glob/validate.rs
  • src/runner/process/file_io.rs
  • src/theme.rs

Comment thread src/manifest/glob/normalize.rs Outdated
Comment on lines +3 to +8
/// Normalise path separators in a glob `pattern` to the platform-native one.
///
/// Forward slashes (and, on Unix, backslash sequences) are rewritten to
/// [`std::path::MAIN_SEPARATOR`] so manifests can use `/` portably. On Unix the
/// backslash also acts as an escape, so escaped metacharacters are preserved
/// rather than treated as separators.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Tighten the escape docs.

normalize_separators and force_literal_escapes are separate steps in the glob pipeline, but the current wording makes both sound broader than they are. normalize_separators does not own the later literal-escape rewrite, and force_literal_escapes only expands a small fixed set of metacharacters outside character classes.

Suggested wording
@@
-/// Forward slashes (and, on Unix, backslash sequences) are rewritten to
-/// [`std::path::MAIN_SEPARATOR`] so manifests can use `/` portably. On Unix the
-/// backslash also acts as an escape, so escaped metacharacters are preserved
-/// rather than treated as separators.
+/// Forward slashes are rewritten to [`std::path::MAIN_SEPARATOR`] so manifests
+/// can use `/` portably. On Unix, backslash escapes are preserved for the
+/// follow-up literal-escape pass rather than being treated as separators here.
@@
-/// Rewrite backslash escapes into bracket character classes (Unix only).
+/// Rewrite the Unix-only escaped metacharacters handled by this helper into
+/// bracket character classes.
@@
-/// The `glob` crate treats `\` literally on Unix, so an escaped metacharacter
-/// such as `\*` is converted to the single-element class `[*]` to match the
-/// literal character. Returns the pattern with all escapes expanded.
+/// The `glob` crate treats `\` literally on Unix, so selected escaped
+/// metacharacters such as `\*` are converted to the single-element class `[*]`
+/// to match the literal character.

Matches the GlobPattern::new pipeline and the glob tests.

Also applies to: 84-88

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/manifest/glob/normalize.rs` around lines 3 - 8, The documentation
comments for the `normalize_separators` and `force_literal_escapes` functions in
src/manifest/glob/normalize.rs are too broad and conflate the responsibilities
of separate steps in the glob pipeline. Update the doc comment for
`normalize_separators` (lines 3-8) to clarify that it only rewrites forward
slashes to the platform separator and preserves backslash escapes for a
follow-up literal-escape pass rather than treating them as separators. Also
update the doc comment for `force_literal_escapes` (lines 84-88) to specify that
it only rewrites a small fixed set of selected escaped metacharacters (not all
escapes) into bracket character classes, and remove language suggesting it
expands all escapes.

Tighten the Rustdoc for the glob separator and literal-escape helpers so each comment describes only its own pipeline step.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Rustdoc examples for public and test-support APIs

1 participant