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

docs: auto-generate configuration options for each lint rule #9617

Open
camchenry opened this issue Mar 8, 2025 · 2 comments
Open

docs: auto-generate configuration options for each lint rule #9617

camchenry opened this issue Mar 8, 2025 · 2 comments
Labels
A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation

Comments

@camchenry
Copy link
Member

currently, the website is missing almost all of the configuration options for lint rules generally, unless we remembered to include this in the description.

Since most lint rules have a configuration struct specific to the rule, and a struct field for each option, maybe we could auto-generate these?

@therewillbecode
Copy link
Contributor

therewillbecode commented Mar 8, 2025

Do you mean auto generating the doc comments for the option configuration by parsing the configuration struct for each rule? Or could we be using the test cases to generate the options docs?

@camchenry camchenry added A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation labels Mar 12, 2025
@camchenry
Copy link
Member Author

@therewillbecode I'm not completely sure on this one yet, I don't think it's clear to me. I think something that like allowing annotations on a config struct, or perhaps a trait that can be implemented like:

pub struct RuleConfig {
  /// Allows accepting some cases
  ///
  /// Example: ...
  #[rename = "someOption"]
  #[type = bool, default = false]
  some_option: serde_json::Value,
}
impl Rule for RuleName {
  type Config = RuleConfig

  // ...
}

and then using the Config type and generating the docs from that like:

## Option: `someOption` (default: false)

Allows accepting some cases.

Example: ...

Maybe there is a good way to use macros for this, but I'm not much of a macro expert. Or else we could use serde directly maybe? If anyone else has ideas on this, I'd be interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation
Projects
None yet
Development

No branches or pull requests

2 participants