@@ -7,9 +7,13 @@ versions: ">=0.3"
77
88# Docs Linting
99
10+ Documentation problems tend to be invisible until someone encounters them: a function with no
11+ docstring, a cross-reference pointing to a symbol that was renamed, or a directive that's
12+ misspelled. These issues don't produce build errors, so they can persist across many releases.
13+
1014Great Docs includes a built-in linter that analyzes your package's public API for documentation
1115quality issues. It catches missing docstrings, broken cross-references, inconsistent formatting, and
12- malformed directives ( before your users ever see them) .
16+ malformed directives before your users ever see them.
1317
1418## Basic Usage
1519
@@ -60,9 +64,14 @@ When issues are found, they are grouped by check type with clear indicators:
6064❌ 2 error(s), 4 warning(s)
6165```
6266
67+ Errors represent problems that will produce gaps or broken content on the rendered site. Warnings
68+ flag inconsistencies that are worth investigating but won't break anything.
69+
6370## Checks Performed
6471
65- The linter runs four categories of checks. Each can be run individually or together.
72+ The linter runs four categories of checks, each targeting a different class of documentation
73+ problem. All four run by default, and each can be run individually using ` --check ` (described
74+ below).
6675
6776### Missing Docstrings
6877
@@ -74,11 +83,14 @@ Finds public exports and class methods that lack docstrings.
7483| ` missing-docstring ` | Warning | A public method on a documented class has no docstring |
7584
7685Private methods (names starting with ` _ ` ) and constructor dunders (` __init__ ` , ` __new__ ` ) are
77- skipped automatically.
86+ skipped automatically. The linter only flags symbols that would appear (or be expected to appear) in
87+ the rendered documentation.
7888
7989### Broken Cross-References
8090
81- Validates that ` %seealso ` directives reference symbols that actually exist in your public API.
91+ Cross-references that point to nonexistent symbols produce dead links on the rendered site. The
92+ linter validates that ` %seealso ` directives reference symbols that actually exist in your public
93+ API.
8294
8395| Finding | Severity | Description |
8496| ---------| ----------| -------------|
@@ -97,7 +109,8 @@ def process(data):
97109```
98110
99111If ` validate_input ` exists in your public API but ` transform_data ` does not, the linter reports
100- ` transform_data ` as a broken cross-reference.
112+ ` transform_data ` as a broken cross-reference. This is especially useful after renaming or removing
113+ functions.
101114
102115### Style Consistency
103116
@@ -118,11 +131,14 @@ The linter detects style by looking for characteristic patterns:
118131- ** Google** : Section headers with colons (` Args: ` , ` Returns: ` )
119132- ** Sphinx** : Field markers (` :param x: ` , ` :returns: ` )
120133
121- Short docstrings without structured sections are not flagged.
134+ Short docstrings without structured sections are not flagged, since they don't contain enough signal
135+ to determine a style.
122136
123137### Directive Consistency
124138
125- Checks for malformed or unrecognized Great Docs directives in docstrings.
139+ Great Docs uses ` % ` -prefixed directives in docstrings for features like cross-references and
140+ documentation exclusion. This check catches misspelled or unrecognized directives that would
141+ otherwise be silently ignored.
126142
127143| Finding | Severity | Description |
128144| ---------| ----------| -------------|
@@ -131,14 +147,16 @@ Checks for malformed or unrecognized Great Docs directives in docstrings.
131147
132148Great Docs recognizes these directives:
133149
134- - ` %seealso ` : Cross -reference related items (see [ Cross-Referencing] ( cross-referencing.qmd ) )
135- - ` %nodoc ` : Exclude an item from documentation (see [ Writing Docstrings] ( writing-docstrings.qmd#nodoc-exclude-an-item-from-documentation ) )
150+ - ` %seealso ` : cross -reference related items (see [ Cross-Referencing] ( cross-referencing.qmd ) )
151+ - ` %nodoc ` : exclude an item from documentation (see [ Writing Docstrings] ( writing-docstrings.qmd#nodoc-exclude-an-item-from-documentation ) )
136152
137- Any other ` % ` -prefixed token (e.g., ` %deprecated ` , ` %internal ` ) is flagged as unknown.
153+ Any other ` % ` -prefixed token (e.g., ` %deprecated ` , ` %internal ` ) is flagged as unknown. If you see a
154+ false positive, check for typos in the directive name.
138155
139156## Running Specific Checks
140157
141- Use ` --check ` to run only the checks you need. This option can be repeated:
158+ When diagnosing a particular class of issue, you can run a subset of checks instead of the full
159+ suite. Use ` --check ` to select only the checks you need (this option can be repeated):
142160
143161``` {.bash filename="Terminal"}
144162# Only check for missing docstrings
@@ -160,9 +178,11 @@ Available check names:
160178| ` style ` | Docstring style consistency with configured parser |
161179| ` directives ` | Unknown or malformed ` % ` directives |
162180
181+ When no ` --check ` flags are given, all four categories run.
182+
163183## JSON Output
164184
165- For CI/CD integration, use ` --json ` to get machine-readable output:
185+ For CI/CD integration or programmatic analysis , use ` --json ` to get machine-readable output:
166186
167187``` {.bash filename="Terminal"}
168188great-docs lint --json
@@ -215,20 +235,25 @@ great-docs lint --json | jq '.issues[] | select(.severity == "error")'
215235great-docs lint --json | jq ' .issues | group_by(.check) | map({check: .[0].check, count: length})'
216236```
217237
238+ The JSON format is stable across releases, so you can build tooling around it.
239+
218240## Exit Codes
219241
220- The linter uses exit codes for CI integration :
242+ The linter uses exit codes to indicate whether action is needed :
221243
222244| Code | Meaning |
223245| ------| ---------|
224246| ` 0 ` | No errors (warnings are allowed) |
225247| ` 1 ` | At least one error was found |
226248
227249This means you can use ` great-docs lint ` directly in CI pipelines and it will fail the build only
228- when there are errors.
250+ when there are errors. Warnings appear in the output but do not block the pipeline.
229251
230252## CI/CD Integration
231253
254+ Running the linter in CI ensures that documentation quality is enforced on every pull request, not
255+ just when someone remembers to check.
256+
232257### GitHub Actions
233258
234259Add documentation linting to your CI workflow:
@@ -296,13 +321,16 @@ Run linting alongside other Great Docs quality tools in CI:
296321 run: great-docs seo
297322```
298323
324+ Running all four together gives you a comprehensive pre-deployment quality gate.
325+
299326## Next Steps
300327
301328The linter catches structural problems early: missing docstrings, malformed directives, broken
302- cross-references, and inconsistencies that would otherwise surface as confusing gaps in the rendered
303- site. Run it in CI to enforce documentation quality alongside code quality.
329+ cross-references, and style inconsistencies that would otherwise surface as confusing gaps in the
330+ rendered site. Run it in CI to enforce documentation quality alongside code quality.
304331
305- - [ Link Checker] ( link-checker.qmd ) validates that all links resolve correctly
306- - [ Proofreading] ( proofreading.qmd ) checks spelling, grammar, and style
332+ - [ Link Checker] ( link-checker.qmd ) validates that all links in the built site resolve correctly
333+ - [ Proofreading] ( proofreading.qmd ) checks spelling, grammar, and style in your prose
307334- [ Writing Docstrings] ( writing-docstrings.qmd ) covers the docstring format and directives that the
308335linter validates
336+ - [ SEO Optimization] ( seo.qmd ) audits generated metadata that complements documentation quality
0 commit comments