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

feat(website): auto-generate rule docs pages #4640

Merged

Conversation

DonIsaac
Copy link
Contributor

@DonIsaac DonIsaac commented Aug 5, 2024

AI-generated description because I'm lazy

TL;DR

This PR introduces the ability to generate documentation for linter rules and adds new methods and metadata for rule fix capabilities.

To see what this looks like, please check out oxc-project/oxc-project.github.io#165.

Screenshots

Hyperlinks to rule doc pages in auto-generated rules table
image

Example of a docs page
image

What changed?

  • Added RuleFixMeta to indicate rule fix capabilities
  • Introduced methods is_none and is_pending in RuleFixMeta
  • Modified render_markdown_table in RuleTableSection to accept an optional link prefix
  • Created new modules for rule documentation and HTML rendering
  • Updated print_rules function to generate markdown for rules and detailed documentation pages

How to test?

Run the linter-rules task with appropriate arguments to generate the markdown table and documentation pages.
Verify the generated files for correctness and that all metadata is correctly displayed.

Why make this change?

To enhance the project documentation and provide clear rule fix capabilities, thereby improving the developer experience and easing the integration process.


Copy link

graphite-app bot commented Aug 5, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added the A-linter Area - Linter label Aug 5, 2024
Copy link
Contributor Author

DonIsaac commented Aug 5, 2024

@DonIsaac DonIsaac marked this pull request as ready for review August 5, 2024 01:16
@DonIsaac DonIsaac force-pushed the don/08-04-feat_website_auto-generate_rule_docs_pages branch from cb0b549 to 678b7d6 Compare August 5, 2024 01:18
@Boshen Boshen self-assigned this Aug 5, 2024
@Boshen Boshen self-requested a review August 5, 2024 01:18
@DonIsaac DonIsaac force-pushed the don/08-04-feat_website_auto-generate_rule_docs_pages branch 3 times, most recently from df3834c to 59e9965 Compare August 5, 2024 01:28
@DonIsaac
Copy link
Contributor Author

DonIsaac commented Aug 5, 2024

I think #1783 will help us add documentation for rule configs. We can implement JsonSchema for those configs, then add config_schema(&self) -> Option<Self::Schema> to RuleMeta to render config sections.

@DonIsaac
Copy link
Contributor Author

DonIsaac commented Aug 5, 2024

I think we also need tests on rule documentation to ensure they produce valid markdown. I'm seeing errors in the website's build pipeline.

Edit: Added this to a down-stack PR, but it doesn't run textlint. It just ensures the MD parses correctly.

@DonIsaac DonIsaac force-pushed the don/08-04-feat_website_auto-generate_rule_docs_pages branch 3 times, most recently from 2c1b7d8 to 4c3c1d2 Compare August 5, 2024 01:50
Copy link

codspeed-hq bot commented Aug 5, 2024

CodSpeed Performance Report

Merging #4640 will not alter performance

Comparing don/08-04-feat_website_auto-generate_rule_docs_pages (f629514) with main (d191823)

Summary

✅ 29 untouched benchmarks

@Boshen
Copy link
Member

Boshen commented Aug 5, 2024

Let me defer this merge to the next release. I'll work on releasing the current version first.

DonIsaac added a commit that referenced this pull request Aug 5, 2024
These are causing build errors in doc pages in PR #4640
DonIsaac added a commit that referenced this pull request Aug 5, 2024
These are causing build errors in doc pages in PR #4640
@DonIsaac DonIsaac force-pushed the don/08-04-feat_website_auto-generate_rule_docs_pages branch 4 times, most recently from a4131cc to ab59cff Compare August 5, 2024 19:23
@DonIsaac DonIsaac force-pushed the don/08-04-feat_website_auto-generate_rule_docs_pages branch 2 times, most recently from c34beee to 2fe39dd Compare August 9, 2024 19:59
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 10, 2024
Copy link

graphite-app bot commented Aug 10, 2024

Merge activity

  • Aug 9, 8:10 PM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 9, 8:10 PM EDT: Boshen added this pull request to the Graphite merge queue.
  • Aug 9, 8:17 PM EDT: Boshen merged this pull request with the Graphite merge queue.

> AI-generated description because I'm lazy
### TL;DR

This PR introduces the ability to generate documentation for linter rules and adds new methods and metadata for rule fix capabilities.

To see what this looks like, please check out oxc-project/oxc-project.github.io#165.

## Screenshots
Hyperlinks to rule doc pages in auto-generated rules table
<img width="809" alt="image" src="https://github.com/user-attachments/assets/e09eb47d-e86a-4ed1-b1f9-5034f33c71a2">

Example of a docs page
<img width="1273" alt="image" src="https://github.com/user-attachments/assets/78f7e9e6-f4dd-4cc9-aebc-1cdd64b024ec">

### What changed?

- Added `RuleFixMeta` to indicate rule fix capabilities
- Introduced methods `is_none` and `is_pending` in `RuleFixMeta`
- Modified `render_markdown_table` in `RuleTableSection` to accept an optional link prefix
- Created new modules for rule documentation and HTML rendering
- Updated `print_rules` function to generate markdown for rules and detailed documentation pages

### How to test?

Run the `linter-rules` task with appropriate arguments to generate the markdown table and documentation pages.
Verify the generated files for correctness and that all metadata is correctly displayed.

### Why make this change?

To enhance the project documentation and provide clear rule fix capabilities, thereby improving the developer experience and easing the integration process.

---
@Boshen Boshen force-pushed the don/08-04-feat_website_auto-generate_rule_docs_pages branch from 2fe39dd to f629514 Compare August 10, 2024 00:13
@graphite-app graphite-app bot merged commit f629514 into main Aug 10, 2024
24 checks passed
@graphite-app graphite-app bot deleted the don/08-04-feat_website_auto-generate_rule_docs_pages branch August 10, 2024 00:17
@oxc-bot oxc-bot mentioned this pull request Aug 12, 2024
Boshen added a commit that referenced this pull request Aug 12, 2024
## [0.7.1] - 2024-08-12

### Features

- 3d40528 linter: Add fix emoji to rules table and doc pages (#4715)
(DonIsaac)
- d2734f3 linter: Start fixer for no-unused-vars (#4718) (DonIsaac)
- 070ae53 linter: Add fixer for unicorn prefer-string-replace-all
(#4801) (camc314)
- b3c3125 linter: Overhaul unicorn/no-useless-spread (#4791) (DonIsaac)
- 5992b75 linter: Implement `eslint-plugin-promise/no-return-in-finally,
prefer-await-to-then` rule (#4318) (Jelle van der Waa)
- b259f47 linter: Add fixer for unicorn/no-length-as-slice-end (#4780)
(heygsc)
- abd83fa linter: Add fixer for jsx_ally/no_aria_hidden_on_focusable
(#4772) (heygsc)
- b20e335 linter: Add fixer for eslint/no-eq-null (#4758) (heygsc)
- 2f6c3b9 linter: Add fixer for eslint/no-compare-neg-zero (#4748)
(heygsc)
- eaddc8f linter: Add fixer for eslint/func_names (#4714) (DonIsaac)
- 80557a9 linter: Add fixer for eslint/for-direction (#4679) (heygsc)
- c3c5766 linter/eslint-plugin-promise: Implement valid-params (#4598)
(Jelle van der Waa)
- c509a21 linter/eslint-plugin-vitest: Implement prefer-to-be-falsy
(#4770) (dalaoshu)
- 41f861f linter/eslint-plugin-vitest: Implement prefer-to-be-truthy
(#4755) (dalaoshu)
- cc922f4 vscode: Provide config's schema to oxlint config files (#4826)
(Don Isaac)
- f629514 website: Auto-generate rule docs pages (#4640) (DonIsaac)

### Bug Fixes

- b22ed45 linter: Improve prefer_namespace_keyword rule (#4751) (Burlin)
- db68a6c linter: Fixer for eslint/for-direction (#4727) (heygsc)
- 6273994 linter: Block in eslint/no_cond_assign (#4721) (heygsc)
- b9d6aa5 linter: Fix false positives in no-confusing-non-null-assertion
(#4665) (Renée)
- cbf08d2 linter: Skip no-multi-str on jsx attributes (#4666) (heygsc)
- a6f9f96 linter: No unused errors should be warnings (Boshen)
- 7345bc9 linter/func-names: Handle ts accessibility when reporting
missing names (#4713) (DonIsaac)

### Performance

- d191823 linter: Optmize allocations in jest fn parsing (#4787) (lucab)
- e3abdfa linter: Reduce String allocations and clones (#4673)
(DonIsaac)

### Documentation

- 4b7dfd6 linter: Correct docs for no-unused-vars (#4716) (Don Isaac)

### Refactor

- 096ac7b linter: Clean up jsx-a11y/anchor-is-valid (#4831) (DonIsaac)
- 15a0fd4 linter: Use Option to reduce nested level in
`eslint/getter-return` (#4814) (IWANABETHATGUY)
- 63f274c linter: Simplify NoObjCalls resolution logic (#4765) (lucab)
- 6708680 linter: Replace Windows-style line breaks with Unix-style in
test fixture (#4768) (overlookmotel)
- e285903 linter: Clean up eslint/func_names (#4710) (DonIsaac)

### Testing

- 8f2a566 linter: Ensure rule docs have valid syntax (#4644) (DonIsaac)
- 4dd29db linter: Add fixer test for unicorn/no-zero-fractions (#4783)
(heygsc)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants