Add #![deny(missing_docs)] and comprehensive documentation - #41
Conversation
#![deny(missing_docs)] and comprehensive documentation
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
ab0d868 to
9ddbec7
Compare
It's not compiled anymore and a left-over from the previous implementation.
9ddbec7 to
9cc22ba
Compare
There was a problem hiding this comment.
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.
| /// * `before` - The token sequence from the first file, before changes | ||
| /// * `after` - The token sequence from the second file, after changes |
There was a problem hiding this comment.
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.
| /// * `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. |
| /// 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 |
There was a problem hiding this comment.
British spelling "minimisation" should use American spelling "minimization" for consistency with the rest of the codebase (e.g., "tokenize" is used instead of "tokenise").
| /// Useful for minimisation of allocation before calls to | |
| /// Useful for minimization of allocation before calls to |
Byron
left a comment
There was a problem hiding this comment.
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.
| /// Token does not occur in this file | ||
| /// Token does not occur in the other file. |
There was a problem hiding this comment.
I am not so sure about this one.
There was a problem hiding this comment.
@pascalkuthe This might be interesting for you.
| // 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 |
There was a problem hiding this comment.
No test fails when the condition is removed.
Enforces documentation for all public API surface and adds missing documentation throughout the codebase.
Changes
Enforcement
#![deny(missing_docs)]lint to prevent future undocumented public itemsPublic API Documentation
Diff: struct, all methods (count_additions,count_removals,is_removed,is_added, postprocessing methods)Hunk: struct fields (before,afterranges)Algorithm: enum variants with performance characteristicsTokenSource: trait, associated types, methodsInternedInput: struct fields (before,after,interner)Interner: all public methodsSliderHeuristic: trait, implementations (IndentHeuristic,NoSliderHeuristic)IndentLevel: struct and methodsUnifiedDiffPrintertrait,UnifiedDiffConfig,BasicLineDiffPrinterInternal Documentation
Myers,Postprocessor,FileSlice,Histogram)util.rs, algorithm modulesScore,Split,SearchResult,Occurrences,Lcs)Corrections
All tests pass, documentation builds cleanly.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.