Skip to content

Commit efd9b75

Browse files
authored
Avoid reformatting comments in rules reference documentation (astral-sh#19093)
closes astral-sh/ty#754
1 parent 4cf56d7 commit efd9b75

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

crates/ruff_dev/src/generate_ty_rules.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ fn generate_markdown() -> String {
7373
for lint in lints {
7474
let _ = writeln!(&mut output, "## `{rule_name}`\n", rule_name = lint.name());
7575

76-
// Increase the header-level by one
76+
// Reformat headers as bold text
77+
let mut in_code_fence = false;
7778
let documentation = lint
7879
.documentation_lines()
7980
.map(|line| {
80-
if line.starts_with('#') {
81+
// Toggle the code fence state if we encounter a boundary
82+
if line.starts_with("```") {
83+
in_code_fence = !in_code_fence;
84+
}
85+
if !in_code_fence && line.starts_with('#') {
8186
Cow::Owned(format!(
8287
"**{line}**\n",
8388
line = line.trim_start_matches('#').trim_start()

crates/ty/docs/rules.md

Lines changed: 13 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)