refactor(readme_parser): inline _is_leading_link at its call site

The helper was only called once and the bool(inline.children) guard
was redundant: first_link being non-None already implies inline.children
is non-empty.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-04-19 21:59:59 +08:00
parent 486fbf2185
commit 85b55efb28
+1 -6
View File
@@ -161,11 +161,6 @@ def _find_inline(node: SyntaxTreeNode) -> SyntaxTreeNode | None:
return _find_child(para, "inline") return _find_child(para, "inline")
def _is_leading_link(inline: SyntaxTreeNode, link: SyntaxTreeNode) -> bool:
"""Check if the link is the first child of inline (a real entry, not a subcategory label)."""
return bool(inline.children) and inline.children[0] is link
def _extract_description_html(inline: SyntaxTreeNode, first_link: SyntaxTreeNode) -> str: def _extract_description_html(inline: SyntaxTreeNode, first_link: SyntaxTreeNode) -> str:
"""Extract description HTML from inline content after the first link. """Extract description HTML from inline content after the first link.
@@ -206,7 +201,7 @@ def _parse_list_entries(
first_link = _find_child(inline, "link") first_link = _find_child(inline, "link")
if first_link is None or not _is_leading_link(inline, first_link): if first_link is None or inline.children[0] is not first_link:
# Subcategory label: take text before the first link, strip trailing separators # Subcategory label: take text before the first link, strip trailing separators
pre_link = [] pre_link = []
for child in inline.children: for child in inline.children: