Validate code tags in documentation for potential params

Adds a check to make_rst to look for matches
between the text inside of the [code][/code] tag
and known param identifiers.
Fixes most of what was revealed.
This commit is contained in:
Yuri Sizov
2023-04-26 21:36:04 +02:00
parent e2e870c611
commit 391eccca76
44 changed files with 191 additions and 175 deletions

View File

@ -1678,6 +1678,26 @@ def format_text_block(
inside_code_tag = cmd
escape_pre = True
valid_context = isinstance(context, (MethodDef, SignalDef, AnnotationDef))
if valid_context:
endcode_pos = text.find("[/code]", endq_pos + 1)
if endcode_pos == -1:
print_error(
f"{state.current_class}.xml: Tag depth mismatch for [code]: no closing [/code] in {context_name}.",
state,
)
break
inside_code_text = text[endq_pos + 1 : endcode_pos]
context_params: List[ParameterDef] = context.parameters # type: ignore
for param_def in context_params:
if param_def.name == inside_code_text:
print_warning(
f'{state.current_class}.xml: Potential error inside of a code tag, found a string "{inside_code_text}" that matches one of the parameters in {context_name}.',
state,
)
break
# Cross-references to items in this or other class documentation pages.
elif is_in_tagset(cmd, RESERVED_CROSSLINK_TAGS):
link_type: str = ""