Skip to content

Commit d837616

Browse files
Update design for PR rust-lang#16143: Add missing_examples_doc lint
1 parent 4d6fa3c commit d837616

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

pr-analysis-16143.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# PR #16143: Workflow Design Impact Analysis
2+
3+
## Affected Workflows
4+
- **lint-development** (Workflow 5): The PR introduces a new lint `missing_examples_doc` focused on ensuring public functions have an `# Examples` header in their documentation comments. Changes include modifications to `clippy_lints/src/doc/mod.rs` and `clippy_lints/src/doc/missing_headers.rs` for lint logic and declaration, update to generated `declared_lints.rs`, addition to CHANGELOG.md, and updates to UI test files. These align directly with the lint-development workflow's components for implementing, registering, documenting, and testing new lints.
5+
- **testing** (Workflow 4): Updates to `tests/ui/doc_examples.rs` and corresponding `.stderr` file to validate the new lint and refactored doc header detection. This impacts the UI tests component of the testing workflow.
6+
- **lintcheck** (Workflow 6): The addition of the new lint affects lintcheck runs by introducing new diagnostic outputs across external crates, with the PR noting over 1500 new instances. This impacts the output and analysis phase of the lintcheck workflow, potentially requiring group adjustments.
7+
8+
## lint-development Analysis (Workflow 5)
9+
10+
### Summary of design changes
11+
The PR extends the `Documentation` lint pass (in `clippy_lints/src/doc/`) by adding support for detecting missing `# Examples` headers. Specific changes:
12+
- Added new `declare_clippy_lint!` for `MISSING_EXAMPLES_DOC` in `mod.rs` (consistent with other doc lints).
13+
- Extended `DocHeaders` struct with `examples: bool`.
14+
- Refactored header detection in `check_doc` from multiple or-assignments to a match expression for cleaner code.
15+
- Added lint emission logic in `missing_headers.rs`'s `check` function if `!headers.examples`.
16+
- The PR implements these via manual edits to existing module files rather than scaffolding a new lint file, demonstrating flexibility in the workflow for related lints.
17+
18+
This does not alter the high-level scaffolding or integration sequences but adds a new rule to the existing doc lint group. Benefits: Aligns with Rust API Guidelines for examples in docs, improves code maintainability via refactor. Implications: High trigger rate may warrant category discussion (code shows `restriction`, description suggests `pedantic`).
19+
20+
No updates needed to existing Mermaid diagrams, as flows unchanged. Below is a diff visualization of affected components:
21+
22+
```mermaid
23+
flowchart TD
24+
subgraph "Before PR"
25+
Mod["clippy_lints/src/doc/mod.rs <br/> Existing declarations & header parsing"]
26+
MH["clippy_lints/src/doc/missing_headers.rs <br/> Existing checks for safety/errors/panics"]
27+
Decl["declared_lints.rs <br/> Existing LINTS"]
28+
end
29+
subgraph "After PR"
30+
Mod2["clippy_lints/src/doc/mod.rs <br/> + New lint declaration <br/> + Refactored match for headers <br/> + Added to pass list"]:::change
31+
MH2["clippy_lints/src/doc/missing_headers.rs <br/> + Import new lint <br/> + Check !headers.examples & span_lint"]:::change
32+
Decl2["declared_lints.rs <br/> + Added to doc section in LINTS"]:::addition
33+
Changelog["CHANGELOG.md <br/> + Link to new lint"]:::addition
34+
Tests["tests/ui/doc_examples.* <br/> + Updated for new behavior"]:::addition
35+
end
36+
classDef change fill:#ffff00,stroke:#333,stroke-width:4px
37+
classDef addition fill:#90ee90,stroke:#333,stroke-width:4px
38+
classDef removal fill:#ff9999,stroke:#333,stroke-width:4px
39+
```
40+
41+
## testing Analysis (Workflow 4)
42+
43+
### Summary of design changes
44+
The PR updates the `doc_examples` UI test to incorporate diagnostics from the new lint and adjustments from the header refactor. This maintains the correctness of the UI test suite, which verifies lint outputs against expected `.stderr`. No changes to test execution flow, compile-test binary, or other components. Benefits: Ensures the new lint is properly tested alongside related doc lints. Implications: None significant.
45+
46+
Diff visualization of affected components:
47+
48+
```mermaid
49+
flowchart TD
50+
subgraph "Before PR"
51+
TestRS["tests/ui/doc_examples.rs <br/> Existing test cases for doc lints"]
52+
TestStd["tests/ui/doc_examples.stderr <br/> Existing expected output"]
53+
CT["compile-test.rs <br/> Unchanged"]
54+
end
55+
subgraph "After PR"
56+
TestRS2["tests/ui/doc_examples.rs <br/> Updated cases for new lint"]:::change
57+
TestStd2["tests/ui/doc_examples.stderr <br/> Updated expected diagnostics"]:::change
58+
CT2["compile-test.rs <br/> Unchanged"]
59+
end
60+
classDef change fill:#ffff00,stroke:#333,stroke-width:4px
61+
classDef addition fill:#90ee90,stroke:#333,stroke-width:4px
62+
```
63+
64+
## lintcheck Analysis (Workflow 6)
65+
66+
### Summary of design changes
67+
No direct code modifications to lintcheck components. However, integration of the new lint into `clippy_lints` means it will be applied during `cargo lintcheck` executions on configured crates, generating additional diagnostics. The PR explicitly references running lintcheck, revealing high incidence (1500+ instances), which impacts log generation and diff analysis phases. Potential design implication: For lints with high false positive rates or broad triggers, workflow may benefit from configurable allows in crate configs or separate reporting. Benefits: Helps validate new lint's real-world applicability.
68+
69+
Diff visualization:
70+
71+
```mermaid
72+
flowchart TD
73+
subgraph "Before PR"
74+
LC["lintcheck/src/main.rs <br/> Unchanged"]
75+
Output["Logs/JSON outputs <br/> Existing lints only"]
76+
end
77+
subgraph "After PR"
78+
LC2["lintcheck/src/main.rs <br/> Unchanged"]
79+
Output2["Logs/JSON outputs <br/> + New missing_examples_doc diagnostics <br/> (1500+ instances)"]:::addition
80+
end
81+
classDef addition fill:#90ee90,stroke:#333,stroke-width:4px
82+
```

0 commit comments

Comments
 (0)