DOC improve API reference accuracy, structure, and readability#1469
Merged
romanlutz merged 4 commits intomicrosoft:mainfrom Mar 16, 2026
Merged
Conversation
Signed-off-by: biefan <70761325+biefan@users.noreply.github.com>
Contributor
Author
|
@microsoft-github-policy-service agree |
romanlutz
reviewed
Mar 15, 2026
Contributor
romanlutz
left a comment
There was a problem hiding this comment.
Looks good! Just want to try it out locally before merging
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the documentation build script that generates MyST API reference markdown from griffe JSON so that re-exported names (aliases) are represented and modules with no detected public members are handled more explicitly.
Changes:
- Add alias rendering and an “Aliases” section to per-module API pages.
- Generate per-module pages for all collected modules and show an explicit “no public API members” message when empty.
- Improve index previews to include functions and aliases (not just classes), with a fallback message for empty modules.
You can also share your feedback on Copilot code review. Take the survey.
The log message and index preview '(N total)' suffix previously used len(members), which includes nested submodules. This made the counts misleading since render_module() only renders classes, functions, and aliases. Now both the per-module log line and the index preview count only the kinds that are actually rendered. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Major improvements to gen_api_md.py: - Only generate pages for top-level public modules, not every nested submodule (324 pages -> ~28 pages) - Recursively expand pure-aggregate modules (e.g. pyrit.executor) into their children that have actual API surface - Resolve aliases to full class/function definitions using the definition index, eliminating the separate Aliases section - Filter out external imports (stdlib, third-party) from rendered pages - Exclude pyrit.backend from API docs (exports nothing) - Base member counts on rendered kinds only (class/function) Fix pydoc2json.py alias resolution: - Add _resolve_alias_from_source fallback using griffe.visit() to parse individual .py files when griffe cannot resolve aliases due to missing __init__.py in namespace packages (e.g. pyrit.datasets.seed_datasets) Rename banner modules to private: - pyrit/cli/banner.py -> pyrit/cli/_banner.py - pyrit/cli/banner_assets.py -> pyrit/cli/_banner_assets.py - Update all imports and mock patch paths Update doc/myst.yml TOC to match generated pages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
- Function/class headings now show only the name (no types/signatures) so the right sidebar stays clean and scannable - Full signatures are rendered in a code block below the heading - Class headings show bases on a separate line instead of in the heading - Doctest-style examples (>>> lines) are wrapped in python code fences to prevent broken markdown rendering Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
romanlutz
approved these changes
Mar 16, 2026
Contributor
Author
|
Ini telah ditemui dan diperbaiki oleh CODEX sendiri. Saya akan terus menghantar permintaan tarik kepada CODEX. |
riyosha
pushed a commit
to riyosha/PyRIT
that referenced
this pull request
Mar 24, 2026
…t#1469) Signed-off-by: biefan <70761325+biefan@users.noreply.github.com> Co-authored-by: Roman Lutz <romanlutz13@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
This updates
build_scripts/gen_api_md.pyandbuild_scripts/pydoc2json.pyto make generated API docs more complete, accurate, and readable.What changed
gen_api_md.py — major refactor:
classes as their parent.
pyrit.executor) into their children that have actual API surface."Alias of X" stubs.
pyrit.backendfrom API docs (__all__ = [], exports nothing).>>>examples in code fences for proper rendering.pydoc2json.py — alias resolution fix:
_resolve_alias_from_sourcefallback usinggriffe.visit()to parse individual.pyfiles when griffe cannot resolve aliases due to missing__init__.pyin namespace packages (e.g.pyrit.datasets.seed_datasets).Banner modules marked private:
pyrit/cli/banner.py→pyrit/cli/_banner.pypyrit/cli/banner_assets.py→pyrit/cli/_banner_assets.pydoc/myst.ymlTOC updated to match generated pages.Why
doc/api/index.md.SeedDatasetProvider,TextJailBreak, scorers, targets) to full documentation.Validation
uv run --with ruff ruff check build_scripts/gen_api_md.py build_scripts/pydoc2json.pypytest tests/unit/cli/test_banner.py tests/unit/cli/test_pyrit_shell.py— 70 tests passFixes #653