Skip to content

Add #![deny(missing_docs)] and comprehensive documentation - #41

Merged
Byron merged 3 commits into
masterfrom
copilot/add-docs-and-review-spelling
Dec 7, 2025
Merged

Add #![deny(missing_docs)] and comprehensive documentation#41
Byron merged 3 commits into
masterfrom
copilot/add-docs-and-review-spelling

Conversation

Copilot AI commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

Enforces documentation for all public API surface and adds missing documentation throughout the codebase.

Changes

Enforcement

  • Added #![deny(missing_docs)] lint to prevent future undocumented public items

Public API Documentation

  • Diff: struct, all methods (count_additions, count_removals, is_removed, is_added, postprocessing methods)
  • Hunk: struct fields (before, after ranges)
  • Algorithm: enum variants with performance characteristics
  • TokenSource: trait, associated types, methods
  • InternedInput: struct fields (before, after, interner)
  • Interner: all public methods
  • SliderHeuristic: trait, implementations (IndentHeuristic, NoSliderHeuristic)
  • IndentLevel: struct and methods
  • Unified diff: UnifiedDiffPrinter trait, UnifiedDiffConfig, BasicLineDiffPrinter

Internal Documentation

  • Private fields in core structs (Myers, Postprocessor, FileSlice, Histogram)
  • Internal helpers in util.rs, algorithm modules
  • Private types (Score, Split, SearchResult, Occurrences, Lcs)
  • Algorithm constants and thresholds

Corrections

  • Fixed spelling: pathologic→pathological, then→than (comparisons), linux→Linux
  • Fixed typos: bvhunks→hunks, insertation→insertion, intutive→intuitive
  • Improved grammar and punctuation throughout existing docs

All tests pass, documentation builds cleanly.

Original prompt

Add #![deny(missing_docs)] and document all public fields and methods. Review all existing documentation for spelling and grammar.
While at it, also document all private fields.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add documentation for public and private fields and methods Add #![deny(missing_docs)] and comprehensive documentation Dec 7, 2025
Copilot AI requested a review from Byron December 7, 2025 14:01
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
@Byron
Byron force-pushed the copilot/add-docs-and-review-spelling branch from ab0d868 to 9ddbec7 Compare December 7, 2025 15:41
@Byron
Byron requested a review from Copilot December 7, 2025 15:41
@Byron
Byron marked this pull request as ready for review December 7, 2025 15:41
Byron added 2 commits December 7, 2025 16:42
- cargo fmt
- smaller fixes
It's not compiled anymore and a left-over from the previous implementation.
@Byron
Byron force-pushed the copilot/add-docs-and-review-spelling branch from 9ddbec7 to 9cc22ba Compare December 7, 2025 15:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR enforces comprehensive documentation across the entire codebase by adding #![deny(missing_docs)] and documenting all public and private API surfaces. The changes improve code maintainability by ensuring all functionality is properly explained for both users and contributors.

  • Added documentation enforcement with #![deny(missing_docs)] lint
  • Documented all public APIs including traits, structs, methods, and fields
  • Added internal documentation for private fields and helper functions
  • Fixed spelling errors (pathologic→pathological, insertation→insertion, intutive→intuitive, etc.)
  • Improved grammar and consistency throughout existing documentation

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lib.rs Added comprehensive module-level docs, documented public Diff, Hunk, and Algorithm APIs; fixed spelling and grammar
src/intern.rs Documented TokenSource trait, InternedInput, and Interner with all public methods and fields
src/unified_diff.rs Documented UnifiedDiffPrinter trait, UnifiedDiffConfig, BasicLineDiffPrinter, and UnifiedDiff struct
src/slider_heuristic.rs Documented SliderHeuristic trait and implementations (NoSliderHeuristic, IndentHeuristic, IndentLevel)
src/postprocess.rs Added documentation for postprocessing methods and internal Postprocessor struct
src/myers.rs Documented Myers algorithm implementation, internal state, and helper structs
src/myers/preprocess.rs Documented preprocessing logic, Occurrences enum, and PreprocessedFile
src/myers/middle_snake.rs Documented MiddleSnakeSearch and SearchResult with algorithm constants
src/myers/slice.rs Documented FileSlice struct and its fields
src/histogram.rs Documented histogram algorithm entry point and internal Histogram state
src/histogram/lcs.rs Documented LCS finding logic, Lcs struct, and LcsSearch state
src/util.rs Added documentation for utility functions (common prefix/postfix, strip operations, hunk finding)
src/sources.rs Added module-level documentation and fixed minor grammar issues
src/tests.rs Fixed spelling errors in comments and renamed test function for clarity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/postprocess.rs
Comment on lines +15 to +16
/// * `before` - The token sequence from the first file, before changes
/// * `after` - The token sequence from the second file, after changes

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent punctuation in parameter descriptions. Line 15 should not have a trailing space, and line 16 is missing a period at the end. For consistency with other similar documentation in the codebase (e.g., histogram.rs lines 25-26, unified_diff.rs lines 32-33), both parameter descriptions should end with periods.

Suggested change
/// * `before` - The token sequence from the first file, before changes
/// * `after` - The token sequence from the second file, after changes
/// * `before` - The token sequence from the first file, before changes.
/// * `after` - The token sequence from the second file, after changes.

Copilot uses AI. Check for mistakes.
Comment thread src/intern.rs
/// to allocate if their [`estimate_tokens`](TokenSource::estimate_tokens)
/// would represent an exact match of their actual tokens.
///
/// Useful for minimisation of allocation before calls to

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

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

British spelling "minimisation" should use American spelling "minimization" for consistency with the rest of the codebase (e.g., "tokenize" is used instead of "tokenise").

Suggested change
/// Useful for minimisation of allocation before calls to
/// Useful for minimization of allocation before calls to

Copilot uses AI. Check for mistakes.

@Byron Byron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I looked through everything vigorously and think it's a huge step up from what it was before. There is one spot that I think could be looked at, but I am happy to fix it in a follow-up PR or address anything that comes up.

For context, I am currently on a track to make imara-diff v2 usable in gitoxide, and for that I have to get to know it which I do by … making changes like these 😁.

Next up is an attempt to add a fuzz testing, as a quick way to gain incredible coverage and maybe eek out some panics, long runtimes, or high memory. My hope is that this makes clear why TODO: why is this needed is needed.

Comment thread src/myers/preprocess.rs
Comment on lines -62 to +67
/// Token does not occur in this file
/// Token does not occur in the other file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am not so sure about this one.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@pascalkuthe This might be interesting for you.

Comment thread src/slider_heuristic.rs
// This is a pure insertion that can be moved freely up and down.
// To get more intuitive results, apply a heuristic.
let mut top_slider_end = earliest_end;
// TODO: why is this needed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No test fails when the condition is removed.

@Byron
Byron merged commit d3068e6 into master Dec 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants