mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-08 03:20:54 +00:00
Remove options from README
This commit is contained in:
parent
b0d72c47b4
commit
d658bfc024
5 changed files with 10 additions and 1997 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::{generate_cli_help, generate_docs, generate_json_schema, generate_options};
|
||||
use crate::{generate_cli_help, generate_docs, generate_json_schema};
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub struct Args {
|
||||
|
@ -18,9 +18,6 @@ pub fn main(args: &Args) -> Result<()> {
|
|||
generate_json_schema::main(&generate_json_schema::Args {
|
||||
dry_run: args.dry_run,
|
||||
})?;
|
||||
generate_options::main(&generate_options::Args {
|
||||
dry_run: args.dry_run,
|
||||
})?;
|
||||
generate_cli_help::main(&generate_cli_help::Args {
|
||||
dry_run: args.dry_run,
|
||||
})?;
|
||||
|
|
|
@ -1,23 +1,8 @@
|
|||
//! Generate a Markdown-compatible listing of configuration options.
|
||||
#![allow(clippy::print_stdout, clippy::print_stderr)]
|
||||
|
||||
use anyhow::Result;
|
||||
use itertools::Itertools;
|
||||
use ruff::settings::options::Options;
|
||||
use ruff::settings::options_base::{ConfigurationOptions, OptionEntry, OptionField};
|
||||
|
||||
use crate::utils::replace_readme_section;
|
||||
|
||||
const BEGIN_PRAGMA: &str = "<!-- Begin auto-generated options sections. -->\n";
|
||||
const END_PRAGMA: &str = "<!-- End auto-generated options sections. -->";
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub struct Args {
|
||||
/// Write the generated table to stdout (rather than to `README.md`).
|
||||
#[arg(long)]
|
||||
pub(crate) dry_run: bool,
|
||||
}
|
||||
|
||||
fn emit_field(output: &mut String, name: &str, field: &OptionField, group_name: Option<&str>) {
|
||||
output.push_str(&format!("#### [`{0}`](#{0})\n", name));
|
||||
output.push('\n');
|
||||
|
@ -39,7 +24,7 @@ fn emit_field(output: &mut String, name: &str, field: &OptionField, group_name:
|
|||
output.push('\n');
|
||||
}
|
||||
|
||||
pub fn main(args: &Args) -> Result<()> {
|
||||
pub fn generate() -> String {
|
||||
let mut output: String = "### Top-level\n\n".into();
|
||||
|
||||
let mut sorted_options = Options::get_available_options();
|
||||
|
@ -64,11 +49,5 @@ pub fn main(args: &Args) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
if args.dry_run {
|
||||
print!("{output}");
|
||||
} else {
|
||||
replace_readme_section(&output, BEGIN_PRAGMA, END_PRAGMA)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
output
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ enum Command {
|
|||
/// Generate a Markdown-compatible table of supported lint rules.
|
||||
GenerateRulesTable,
|
||||
/// Generate a Markdown-compatible listing of configuration options.
|
||||
GenerateOptions(generate_options::Args),
|
||||
GenerateOptions,
|
||||
/// Generate CLI help.
|
||||
GenerateCliHelp(generate_cli_help::Args),
|
||||
/// Generate Markdown docs.
|
||||
|
@ -58,7 +58,7 @@ fn main() -> Result<()> {
|
|||
Command::GenerateAll(args) => generate_all::main(args)?,
|
||||
Command::GenerateJSONSchema(args) => generate_json_schema::main(args)?,
|
||||
Command::GenerateRulesTable => println!("{}", generate_rules_table::generate()),
|
||||
Command::GenerateOptions(args) => generate_options::main(args)?,
|
||||
Command::GenerateOptions => println!("{}", generate_options::generate()),
|
||||
Command::GenerateCliHelp(args) => generate_cli_help::main(args)?,
|
||||
Command::GenerateDocs(args) => generate_docs::main(args)?,
|
||||
Command::PrintAST(args) => print_ast::main(args)?,
|
||||
|
|
|
@ -49,6 +49,10 @@ def main() -> None:
|
|||
# Split the README.md into sections.
|
||||
for title, filename in SECTIONS:
|
||||
with Path(f"docs/{filename}").open("w+") as f:
|
||||
if filename == "settings.md":
|
||||
f.write(subprocess.check_output(["cargo", "dev", "generate-options"], encoding="utf-8"))
|
||||
continue
|
||||
|
||||
block = content.split(f"<!-- Begin section: {title} -->")
|
||||
if len(block) != 2:
|
||||
msg = f"Section {title} not found in README.md"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue