mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-08 17:41:31 +00:00
Avoid reformatting comments in rules reference documentation (#19093)
closes https://github.com/astral-sh/ty/issues/754
This commit is contained in:
parent
4cf56d7ad4
commit
efd9b75352
2 changed files with 20 additions and 28 deletions
|
@ -73,11 +73,16 @@ fn generate_markdown() -> String {
|
|||
for lint in lints {
|
||||
let _ = writeln!(&mut output, "## `{rule_name}`\n", rule_name = lint.name());
|
||||
|
||||
// Increase the header-level by one
|
||||
// Reformat headers as bold text
|
||||
let mut in_code_fence = false;
|
||||
let documentation = lint
|
||||
.documentation_lines()
|
||||
.map(|line| {
|
||||
if line.starts_with('#') {
|
||||
// Toggle the code fence state if we encounter a boundary
|
||||
if line.starts_with("```") {
|
||||
in_code_fence = !in_code_fence;
|
||||
}
|
||||
if !in_code_fence && line.starts_with('#') {
|
||||
Cow::Owned(format!(
|
||||
"**{line}**\n",
|
||||
line = line.trim_start_matches('#').trim_start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue