Skip empty doc files and prune dead type-index entries

- render_header() returns "" when a header has no documented content
  (no /** */ comments on any class, property, function, enum, or delegate)
- generate.py skips writing those files and tracks which were written
- type-index.txt is filtered to only include types from written files,
  preventing dead entries that would cause get_class_overview to fail
- Summary line now reports how many files were skipped

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 10:38:29 -05:00
parent 0bb96dca54
commit 3d075cea20
4 changed files with 25 additions and 9 deletions

View File

@@ -135,6 +135,8 @@ def main():
# --- Pass 2: render all ---
success = 0
skipped = 0
written_mds: set[str] = set()
for h, base, parsed in parsed_list:
print(f"Rendering {h} ...")
current_md = _md_rel(h, base)
@@ -143,13 +145,20 @@ def main():
try:
md = render_header(parsed, type_index=type_index, current_md=current_md)
if not md:
skipped += 1
continue
out_path.write_text(md, encoding='utf-8')
written_mds.add(current_md)
success += 1
except Exception as exc:
print(f" ERROR rendering {h}: {exc}", file=sys.stderr)
# Remove type-index entries whose files were not written (no documented content)
type_index = {name: path for name, path in type_index.items() if path in written_mds}
write_type_index(type_index, output_dir)
print(f"\nGenerated {success}/{len(parsed_list)} files + type-index.txt in {output_dir}/")
print(f"\nGenerated {success}/{len(parsed_list)} files "
f"({skipped} skipped — no documented content) + type-index.txt in {output_dir}/")
if __name__ == '__main__':

View File

@@ -361,14 +361,13 @@ def _render_namespace(ns: NamespaceInfo) -> str:
def render_header(parsed: ParsedHeader,
type_index: dict[str, str] = None,
current_md: str = "") -> str:
"""
Render a ParsedHeader to Markdown. Returns empty string if the header
has no documented content (so callers can skip writing the file).
"""
if type_index is None:
type_index = {}
lines = []
lines.append(f"# `{parsed.filename}`")
lines.append(f"**Module**: `{parsed.module_name}`")
lines.append("")
sections = []
d_sec = _render_delegates(parsed.delegates)
@@ -400,6 +399,13 @@ def render_header(parsed: ParsedHeader,
ff_lines.append(_render_ff_compact(fn))
sections.append('\n'.join(ff_lines))
lines.append('\n\n---\n\n'.join(sections))
if not sections:
return ""
lines = [
f"# `{parsed.filename}`",
f"**Module**: `{parsed.module_name}`",
"",
'\n\n---\n\n'.join(sections),
]
return '\n'.join(lines)