mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
Fix Options
section of rule docs (#5741)
## Summary
Fix: #5740
A trailing line-break are needed for the anchor.
## Test Plan
http://127.0.0.1:8000/docs/rules/line-too-long/#options
|before|after|
|--|--|
||
This commit is contained in:
parent
fee0f43925
commit
06a04c10e2
1 changed files with 11 additions and 7 deletions
|
@ -81,7 +81,7 @@ fn process_documentation(documentation: &str, out: &mut String) {
|
||||||
// a non-CommonMark-compliant Markdown parser, which doesn't support code
|
// a non-CommonMark-compliant Markdown parser, which doesn't support code
|
||||||
// tags in link definitions
|
// tags in link definitions
|
||||||
// (see https://github.com/Python-Markdown/markdown/issues/280).
|
// (see https://github.com/Python-Markdown/markdown/issues/280).
|
||||||
let documentation = Regex::new(r"\[`(.*?)`\]($|[^\[])").unwrap().replace_all(
|
let documentation = Regex::new(r"\[`(.*?)`]($|[^\[])").unwrap().replace_all(
|
||||||
documentation,
|
documentation,
|
||||||
|caps: &Captures| {
|
|caps: &Captures| {
|
||||||
format!(
|
format!(
|
||||||
|
@ -106,7 +106,7 @@ fn process_documentation(documentation: &str, out: &mut String) {
|
||||||
|
|
||||||
let anchor = option.replace('.', "-");
|
let anchor = option.replace('.', "-");
|
||||||
out.push_str(&format!("- [`{option}`][{option}]\n"));
|
out.push_str(&format!("- [`{option}`][{option}]\n"));
|
||||||
after.push_str(&format!("[{option}]: ../../settings#{anchor}"));
|
after.push_str(&format!("[{option}]: ../../settings#{anchor}\n"));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -115,10 +115,10 @@ fn process_documentation(documentation: &str, out: &mut String) {
|
||||||
out.push_str(line);
|
out.push_str(line);
|
||||||
}
|
}
|
||||||
if !after.is_empty() {
|
if !after.is_empty() {
|
||||||
out.push_str("\n\n");
|
out.push('\n');
|
||||||
|
out.push('\n');
|
||||||
out.push_str(&after);
|
out.push_str(&after);
|
||||||
}
|
}
|
||||||
out.push('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -130,11 +130,12 @@ mod tests {
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
process_documentation(
|
process_documentation(
|
||||||
"
|
"
|
||||||
See also [`mccabe.max-complexity`].
|
See also [`mccabe.max-complexity`] and [`task-tags`].
|
||||||
Something [`else`][other].
|
Something [`else`][other].
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
|
- `task-tags`
|
||||||
- `mccabe.max-complexity`
|
- `mccabe.max-complexity`
|
||||||
|
|
||||||
[other]: http://example.com.",
|
[other]: http://example.com.",
|
||||||
|
@ -143,16 +144,19 @@ Something [`else`][other].
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
output,
|
output,
|
||||||
"
|
"
|
||||||
See also [`mccabe.max-complexity`][mccabe.max-complexity].
|
See also [`mccabe.max-complexity`][mccabe.max-complexity] and [`task-tags`][task-tags].
|
||||||
Something [`else`][other].
|
Something [`else`][other].
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
|
- [`task-tags`][task-tags]
|
||||||
- [`mccabe.max-complexity`][mccabe.max-complexity]
|
- [`mccabe.max-complexity`][mccabe.max-complexity]
|
||||||
|
|
||||||
[other]: http://example.com.
|
[other]: http://example.com.
|
||||||
|
|
||||||
[mccabe.max-complexity]: ../../settings#mccabe-max-complexity\n"
|
[task-tags]: ../../settings#task-tags
|
||||||
|
[mccabe.max-complexity]: ../../settings#mccabe-max-complexity
|
||||||
|
"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue