mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-24 02:53:08 +00:00
Update option anchors to include group name (#4711)
This commit is contained in:
parent
68db74b3c5
commit
6425fe8c12
2 changed files with 14 additions and 3 deletions
|
@ -104,7 +104,7 @@ fn process_documentation(documentation: &str, out: &mut String) {
|
|||
"unknown option {option}"
|
||||
);
|
||||
|
||||
let anchor = option.rsplit('.').next().unwrap();
|
||||
let anchor = option.replace('.', "-");
|
||||
out.push_str(&format!("- [`{option}`][{option}]\n"));
|
||||
after.push_str(&format!("[{option}]: ../../settings#{anchor}"));
|
||||
|
||||
|
@ -152,7 +152,7 @@ Something [`else`][other].
|
|||
|
||||
[other]: http://example.com.
|
||||
|
||||
[mccabe.max-complexity]: ../../settings#max-complexity\n"
|
||||
[mccabe.max-complexity]: ../../settings#mccabe-max-complexity\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,18 @@ use ruff::settings::options::Options;
|
|||
use ruff::settings::options_base::{OptionEntry, OptionField};
|
||||
|
||||
fn emit_field(output: &mut String, name: &str, field: &OptionField, group_name: Option<&str>) {
|
||||
output.push_str(&format!("#### [`{name}`](#{name})\n"));
|
||||
// if there's a group name, we need to add it to the anchor
|
||||
if let Some(group_name) = group_name {
|
||||
// the anchor used to just be the name, but now it's the group name
|
||||
// for backwards compatibility, we need to keep the old anchor
|
||||
output.push_str(&format!("<span id=\"{name}\"></span>\n"));
|
||||
|
||||
output.push_str(&format!(
|
||||
"#### [`{name}`](#{group_name}-{name}) {{: #{group_name}-{name} }}\n"
|
||||
));
|
||||
} else {
|
||||
output.push_str(&format!("#### [`{name}`](#{name})\n"));
|
||||
}
|
||||
output.push('\n');
|
||||
output.push_str(field.doc);
|
||||
output.push_str("\n\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue