|
| 1 | +# PR #16144: Workflow Design Impact Analysis |
| 2 | + |
| 3 | +## Affected Workflows |
| 4 | +- Workflow 5 (lint-development): Justification - The PR introduces a new pattern for implementing documentation lints by refactoring `doc_link_code` and `doc_paragraphs_missing_punctuation` into state machines that process events from a centralized markdown parser in `check_doc` (in `clippy_lints/src/doc/mod.rs`). This optimizes parsing (once per doc comment) and modularizes lint logic, impacting the documented lint implementation design in workflow 5. Evidence from PR changes to lint files and tests, matching relevant_files like \`clippy_lints/src/\` and \`tests/ui/\`. |
| 5 | + |
| 6 | +No other workflows are affected, as changes are internal to specific lint implementations and do not alter scaffolding, registration, testing execution, or other high-level flows. |
| 7 | + |
| 8 | +## Workflow 5 Analysis |
| 9 | +### Summary of design changes |
| 10 | +The PR affects the \`clippy_lints\` component, specifically the implementation pattern for documentation lints in \`src/doc/\`. Previously, \`doc_link_code\` logic was inline in \`mod.rs\` with its own event processing via \`check_for_code_clusters\`, and \`doc_paragraphs_missing_punctuation\` performed its own markdown parsing. The PR extracts \`doc_link_code\` to a new file with a \`LinkCode\` state machine struct and refactors the other to a \`MissingPunctuation\` state machine. These now process events from a single parsing in \`check_doc\`, called from the \`Documentation\` late lint pass via \`check_attrs\`. |
| 11 | + |
| 12 | +This changes the design by introducing: |
| 13 | +- Centralized event generation to avoid redundant \`pulldown_cmark\` parsing. |
| 14 | +- Stateful, event-driven processing for modularity and efficiency. |
| 15 | +- Modular files for sub-lint logic within the doc module. |
| 16 | + |
| 17 | +The PR implements this by updating \`mod.rs\` to instantiate the state machines and invoke their \`check\` methods in the event loop of \`check_doc\`, removing old redundant code. Benefits include performance improvement (single parse), easier maintenance, and a reusable pattern for future doc lints. Implications: Developers implementing new doc lints should follow this event-processing state machine pattern; the design doc for workflow 5 has been updated accordingly. |
| 18 | + |
| 19 | +The affected diagram is the \"Integration and Execution Sequence Diagram\", where during \"execute lint passes during compilation phases\", for doc lints, the flow now includes event dispatching to state machines. Below is a diagram highlighting the differences in the doc lint processing sub-flow. |
| 20 | + |
| 21 | +### Diagram showing changes |
| 22 | +```mermaid |
| 23 | +flowchart TD |
| 24 | + subgraph before[\"Before PR - Redundant Processing (to be removed)\"] |
| 25 | + Parse1[pulldown_cmark Parser in check_for_code_clusters] |
| 26 | + Parse2[pulldown_cmark Parser in doc_paragraphs_missing_punctuation::check] |
| 27 | + Inline[Inline state in mod.rs for doc_link_code] |
| 28 | + style Parse1 fill:#ffcccc,stroke:#ff0000 |
| 29 | + style Parse2 fill:#ffcccc,stroke:#ff0000 |
| 30 | + style Inline fill:#ffcccc,stroke:#ff0000 |
| 31 | + end |
| 32 | +
|
| 33 | + subgraph changed[\"Modified - Central Dispatch (yellow)\"] |
| 34 | + CheckDoc[check_doc function in mod.rs] |
| 35 | + EventLoop[event loop over events] |
| 36 | + Dispatch[dispatches to state machines via .check(event)] |
| 37 | + style CheckDoc fill:#ffff99,stroke:#ffff00 |
| 38 | + style EventLoop fill:#ffff99,stroke:#ffff00 |
| 39 | + style Dispatch fill:#ffff99,stroke:#ffff00 |
| 40 | + end |
| 41 | +
|
| 42 | + subgraph after[\"After PR - Additions (green)\"] |
| 43 | + SingleParse[single pulldown_cmark Parser in check_doc] |
| 44 | + SM1[LinkCode state machine - new file doc_link_code.rs] |
| 45 | + SM2[MissingPunctuation state machine - refactored file] |
| 46 | + Modul[Modular state accumulation across events] |
| 47 | + style SingleParse fill:#ccffcc,stroke:#00ff00 |
| 48 | + style SM1 fill:#ccffcc,stroke:#00ff00 |
| 49 | + style SM2 fill:#ccffcc,stroke:#00ff00 |
| 50 | + style Modul fill:#ccffcc,stroke:#00ff00 |
| 51 | + end |
| 52 | +
|
| 53 | + before -.->|replaced by| changed |
| 54 | + changed -.->|enhanced with| after |
| 55 | +
|
| 56 | + classDef removal fill:#ffcccc,stroke:#ff0000,stroke-width:2px |
| 57 | + classDef change fill:#ffff99,stroke:#ffff00,stroke-width:2px |
| 58 | + classDef addition fill:#ccffcc,stroke:#00ff00,stroke-width:2px |
| 59 | +``` |
0 commit comments