Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add doc-renderer for generating & updating detailed rule docs #442

Merged
merged 1 commit into from
Nov 1, 2024

Commits on Oct 31, 2024

  1. chore: add doc-renderer for generating & updating detailed rule docs

    ### Problems:
    
    - The new rule document (generated by `npm run new`) was unclear about which part is the header and which part is the body.
           
    - In `tools/update-docs.ts`, when generating notes and adding them to the header section:
      - The process is too much like cutting and pasting manually on the string, it reduces the readability
      - The code for producing the new header (with notes included) is quite fragmented and long
      - Includes legacy/redundant code `header.replace(/\$/g, "$$$$")`
      - Inefficient code, it creates two new items for the notes then `join()` it with `'\n'` later to create the trailing `'\n\n'`
      
       ```ts
           if (notes.length >= 1) {
             notes.push("", "")
           }
           ...
           const header = `\n${title}\n\n${notes.join("\n")}`
    
        ```
    
    ### This PR:
      - Create renderRuleHeader function and a RuleDocHeader type to clarify the structure of the header. Then applies this to both the generation and update tools for the detailed rule Markdown files
    
    ```ts
    type RuleDocHeader = {
      ruleId: string
      description: string
      notes: string[]
    }
    const header = renderRuleHeader({ ruleId, description, notes })
    ```
     - Make it clear there are `\n\n` between each part of the header in the `renderRuleHeader` function
    Foxeye-Rinx committed Oct 31, 2024
    Configuration menu
    Copy the full SHA
    0f44c8a View commit details
    Browse the repository at this point in the history