Skip to content

Commit 101f9fb

Browse files
sbryngelsonclaude
andcommitted
Fix Doxygen % consumption with split <code> tag workaround
Doxygen consumes %<word> as "suppress auto-link" even inside backtick and <code> spans, and \% leaves a visible backslash. Split Fortran % accessor tokens into adjacent <code> tags so % is never followed by a word character: <code>bc_y%</code><code>beg</code> renders as bc_y%beg. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 55dcb47 commit 101f9fb

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

toolchain/mfc/gen_physics_docs.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,18 @@ def _format_message(msg: str) -> str:
8888
msg = re.sub(r"for (support|pulse) = \1\b", r"for the given \1", msg)
8989
msg = re.sub(r"for (support|pulse) = (\d+)", r"for \1 = \2", msg)
9090

91-
# Wrap code-like tokens in backticks
92-
msg = _CODE_RE.sub(r"`\1`", msg)
93-
94-
# Escape % inside backtick code spans for Doxygen.
95-
# Doxygen treats %<word> as "suppress auto-link" and consumes the %.
96-
# \% produces a literal % in Doxygen output.
97-
msg = re.sub(
98-
r"`([^`]*%[^`]*)`",
99-
lambda m: "`" + m.group(1).replace("%", "\\%") + "`",
100-
msg,
101-
)
91+
# Wrap code-like tokens in backticks (or <code> for Fortran % accessors).
92+
# Doxygen treats %<word> as "suppress auto-link" and consumes the %,
93+
# even inside backtick and <code> spans. To preserve the Fortran %
94+
# accessor, split into adjacent <code> tags so % is never followed
95+
# by a word character: <code>bc_y%</code><code>beg</code>.
96+
def _wrap_code(match: re.Match) -> str:
97+
token = match.group(1)
98+
if "%" in token:
99+
return "<code>" + token.replace("%", "%</code><code>") + "</code>"
100+
return f"`{token}`"
101+
102+
msg = _CODE_RE.sub(_wrap_code, msg)
102103

103104
return msg
104105

0 commit comments

Comments
 (0)