Skip to content

docs: add Google-style docstrings repo-wide + Sphinx site - #398

Merged
weilei0120 merged 10 commits into
mainfrom
docs/add-docstrings-and-sphinx
Jun 10, 2026
Merged

weilei0120 merged 10 commits into
mainfrom
docs/add-docstrings-and-sphinx

Conversation

@tanyaroosta

@tanyaroosta tanyaroosta commented Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds Google-style docstrings and a Sphinx documentation site to the codebase. This PR is now scoped to documentation only — it has been rebased onto current main and the unrelated CI/test-configuration changes have been removed (see "Scope changes" below).

  • Docstrings: parameter types, returns/yields, raises, attributes, and accurate behavior added across inference_optimizer, robustness-agent, critic-agent, framework-agent, kernel-agent, ci, and slides. Edits are docstring-only — no logic, signatures, or imports changed. All touched packages compile cleanly (python -m compileall → exit 0).
  • Sphinx site under docs/ (Furo theme): the API reference is generated automatically from the docstrings via autodoc + napoleon + recursive autosummary, and the existing Markdown guides are wired in through MyST. Heavy / POSIX-only imports are mocked so the docs build on any platform.
    • Build is clean: 0 Sphinx warnings, 196 API pages generated.
    • API reference covers the importable Python packages: inference_optimizer, robustness_agent, framework_agent. (ci, kernel-agent, and slides are script collections without an importable package layout, so they are documented via their in-code docstrings rather than autosummary pages.)

Scope changes (addressing review feedback)

The original PR mixed in CI/test changes and was stale against a heavily-refactored main. Resolved as follows:

  • Rebased/merged onto current main. main had deleted or rewritten many of the originally-documented modules (e.g. the entire dynamic_action_* subsystem). On every conflicting hunk, main's code wins; docstrings are preserved everywhere they don't conflict. The branch no longer conflicts with main.
  • Removed the CI/test-configuration changes that didn't belong in a docs PR (the lint/pylint/pytest/secret-scan/check-links workflows, the pyproject.toml [tool.pytest] edits, and the framework-agent/tests/__init__.py deletion). These were redundant with main's existing tests-coverage.yml / codeql.yml and can land as a separate PR if desired. pyproject.toml now matches main exactly.
  • Resolved the CodeQL / code-quality bot comments: removed ineffectual ... statements after docstrings in Protocol/ABC methods, added explanatory comments to empty except blocks, and removed unused / duplicate local variables.
  • Fixed the Sphinx/docutils/MyST warnings that affected generated docs (definition-list / indentation / inline-literal docstring issues, an invalid JSON code-block lexer, and an undefined RST substitution). Remaining cross-package type-name collisions (e.g. Intent, BackendTurnResult) are suppressed with a documented rationale in conf.py.

Note (follow-up): because conflicting hunks took main's side, a small number of files lost some or all of their docstrings during the merge (12 fully reverted, 133 partially). These are tracked so a follow-up PR can re-document them on top of current main.

How to build the docs

pip install -r docs/requirements.txt
cd docs && make html   # or make.bat html on Windows
# output: docs/_build/html/index.html

Test plan

  • python -m compileall over all touched packages exits 0
  • cd docs && make html builds successfully with 0 warnings
  • No runtime code changed relative to main; the test suite runs against main's code (validated by tests-coverage.yml)

Add clean, Google-style docstrings (parameter types, returns/yields,
raises, attributes, and behavior) to every module, class, and function
across the codebase that was missing or had incomplete documentation.
A full-repo scan (tests excluded) now reports zero documentation gaps,
covering ~3,163 originally-missing docstrings across 276 source files in
inference_optimizer, robustness-agent, ci, kernel-agent, critic-agent,
framework-agent, and slides. Edits are docstring-only: no logic,
signatures, imports, or comments changed; all packages compile cleanly.

Add a Sphinx documentation site under docs/ (Furo theme) that renders
the API reference automatically from these docstrings via autodoc +
napoleon + recursive autosummary, and wires in the existing Markdown
guides through MyST. Heavy/POSIX-only imports are mocked so the docs
build on any platform.

Include the reusable doc-coverage tooling under _audit_artifacts/
(inventory scanner, per-file checker, and style guide) so the zero-gap
bar can be enforced going forward.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread _audit_artifacts/check_files.py Fixed
Comment thread _audit_artifacts/list_remaining.py Fixed
Comment thread critic-agent/runtime/kb_client.py Fixed
Comment thread critic-agent/runtime/kb_client.py Fixed
Comment thread critic-agent/runtime/kb_client.py Fixed
Comment thread critic-agent/runtime/kb_client.py Fixed
Co-authored-by: Cursor <cursoragent@cursor.com>
@tanyaroosta
tanyaroosta marked this pull request as ready for review June 3, 2026 03:13
@tanyaroosta
tanyaroosta requested a review from a team as a code owner June 3, 2026 03:13
…nd-sphinx

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	inference_optimizer/orchestrator/action_executors/framework_pr.py
#	inference_optimizer/orchestrator/coordinator.py
#	inference_optimizer/orchestrator/policy.py
Comment thread critic-agent/runtime/kb_client.py Fixed
Comment thread critic-agent/runtime/kb_client.py Fixed
Comment thread critic-agent/runtime/kb_client.py Fixed
Comment thread critic-agent/runtime/kb_client.py Fixed
tanyaroosta and others added 3 commits June 8, 2026 09:37
…onfig

Add CI workflows (ruff lint, pytest+coverage, pylint errors-only, grep secret scan, markdown link check) plus mlc_config.json, and expand pytest testpaths/pythonpath in pyproject.toml to cover all agent test roots under --import-mode=importlib. Drop framework-agent/tests/__init__.py so the hyphenated test roots don't collide on the 'tests' package name.

Co-authored-by: Cursor <cursoragent@cursor.com>
Lint cleanups across ci/, inference_optimizer/, kernel-agent/, robustness-agent/ tests and tools so the new lint/pylint CI workflows pass. Purely import/dead-variable removals; no behavior change.

Co-authored-by: Cursor <cursoragent@cursor.com>
…nd-sphinx

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	ci/generate_hf_matrix.py
#	ci/optimize_submit.py
#	framework-agent/src/framework_agent/runtime/cli.py
#	framework-agent/tests/__init__.py
#	inference_optimizer/baseline_comparison/target_analyzer.py
#	inference_optimizer/breakdown/collectors.py
#	inference_optimizer/breakdown/schema.py
#	inference_optimizer/cli.py
#	inference_optimizer/examples/p0_main_loop.py
#	inference_optimizer/examples/p1_5_real_claude_demo.py
#	inference_optimizer/examples/p1_6_e2e_baseline_demo.py
#	inference_optimizer/examples/p1_7_three_agents_e2e_demo.py
#	inference_optimizer/examples/p2_full_optimize_demo.py
#	inference_optimizer/orchestrator/action_executors/_framework_gap_composer.py
#	inference_optimizer/orchestrator/action_executors/_grid_runner.py
#	inference_optimizer/orchestrator/action_executors/explore.py
#	inference_optimizer/orchestrator/action_executors/profile.py
#	inference_optimizer/orchestrator/action_executors/roofline.py
#	inference_optimizer/orchestrator/action_executors/sweep.py
#	inference_optimizer/orchestrator/coordinator.py
#	inference_optimizer/orchestrator/framework_agent_client.py
#	inference_optimizer/orchestrator/kernel_request_handlers.py
#	inference_optimizer/orchestrator/knowledge_plane.py
#	inference_optimizer/orchestrator/phase_state.py
#	inference_optimizer/orchestrator/policy.py
#	inference_optimizer/orchestrator/pr_monitor.py
#	inference_optimizer/orchestrator/shared_state.py
#	inference_optimizer/orchestrator/sub_agent_runner.py
#	inference_optimizer/orchestrator/system_prompts/specialist_prompt_builder.py
#	inference_optimizer/paths.py
#	inference_optimizer/recipe_kb/dispatcher.py
#	inference_optimizer/recipe_kb/remote_client.py
#	inference_optimizer/tests/test_shared_state_action_attempts.py
#	inference_optimizer/tests/test_specialist_subprocess.py
#	kernel-agent/tools/backends/ray_runtime.py
#	kernel-agent/tools/kernel_optimization.py
#	kernel-agent/tools/tracelens_analysis.py
#	robustness-agent/src/robustness_agent/agent.py
#	robustness-agent/src/robustness_agent/checks/__init__.py
#	robustness-agent/src/robustness_agent/conductor.py
#	robustness-agent/src/robustness_agent/main.py
#	robustness-agent/src/robustness_agent/monitors/__init__.py
#	robustness-agent/src/robustness_agent/providers/__init__.py
#	robustness-agent/src/robustness_agent/rca.py
#	slides/plot_deepseek_r1.py
#	slides/plot_glm5_breakdown.py
#	slides/plot_loop_diagram.py
@ZhengGong-amd

Copy link
Copy Markdown
Collaborator

A few concerns:

The PR description says the change is docstring-only, but the diff also adds CI workflows, changes pytest configuration, deletes framework-agent/tests/init.py, and includes non-docstring Python changes.
The new Sphinx API reference only includes inference_optimizer and robustness_agent, while the PR description claims coverage across ci, critic-agent, framework-agent, kernel-agent, and others.
The docs build succeeds locally, but still emits many Sphinx/docutils/MyST warnings, including docstring parsing warnings and unresolved links.
The new Ruff workflow is advisory only (continue-on-error: true), and ruff check still reports many diagnostics, so the CI additions do not yet enforce a clean quality bar.
There are still unresolved CodeQL/code-quality comments on the PR.
I’d suggest either narrowing this PR to the docstring/Sphinx work only, or updating the description and splitting the CI/test configuration changes into a separate PR. Before merge, it would also be good to fix the Sphinx warnings that affect generated docs and resolve the outstanding bot comments.

@ZhengGong-amd

Copy link
Copy Markdown
Collaborator

Please make sure all test passed. That has been a prerequisite for all PRs now.

@tanyaroosta

Copy link
Copy Markdown
Collaborator Author

Thanks for the detailed review @ZhengGong-amd — addressed each point:

  1. "docstring-only" vs CI/pytest/__init__.py/non-docstring changes — agreed, those didn't belong here. The PR has been rebased onto current main and narrowed to docs only: the lint/pylint/pytest/secret-scan/check-links workflows, the [tool.pytest] edits, and the framework-agent/tests/__init__.py deletion are all removed. pyproject.toml now matches main exactly. Those CI/test changes can land as a separate PR.
  2. API reference only covered inference_optimizer + robustness_agent — added framework_agent. The reference now covers all importable Python packages; ci, kernel-agent, and slides are script collections without a package layout, so the description and the API index now say so explicitly instead of over-claiming.
  3. Sphinx/docutils/MyST warnings — fixed at the source (definition-list/indentation/inline-literal docstring issues, an invalid JSON code-block, an undefined RST substitution). The build is now clean: 0 warnings, 196 API pages. The only remaining noise was cross-package type-name collisions (Intent, BackendTurnResult, …), suppressed with a documented rationale in conf.py.
  4. Advisory-only Ruff workflow / quality bar — resolved by removing the redundant Ruff/pylint workflows from this PR (they duplicated main's existing CI). No advisory-only gate is introduced here.
  5. Unresolved CodeQL/code-quality comments — fixed: removed ineffectual ... after docstrings in Protocol/ABC methods, added explanatory comments to empty except blocks, and removed the unused/duplicate locals. These should clear on the next CodeQL run.
  6. Narrow vs. split — went with narrow + accurate description, and the merge takes main's code on every conflict, so no runtime code changed relative to main (the suite runs against main's code).

Heads-up: because conflicting hunks took main's side during the merge, a few files lost some/all docstrings (12 fully, 133 partially). These are tracked for a small follow-up PR to re-document on top of main.

@weilei0120
weilei0120 merged commit c32baa7 into main Jun 10, 2026
4 checks passed
xiaofei-zheng pushed a commit that referenced this pull request Jul 11, 2026
docs: add Google-style docstrings repo-wide + Sphinx site
@tanyaroosta
tanyaroosta deleted the docs/add-docstrings-and-sphinx branch July 14, 2026 01:20
xiaofei-zheng pushed a commit that referenced this pull request Jul 17, 2026
docs: add Google-style docstrings repo-wide + Sphinx site
xiaofei-zheng pushed a commit that referenced this pull request Jul 17, 2026
docs: add Google-style docstrings repo-wide + Sphinx site
xiaofei-zheng pushed a commit that referenced this pull request Jul 17, 2026
docs: add Google-style docstrings repo-wide + Sphinx site
xiaofei-zheng pushed a commit that referenced this pull request Jul 19, 2026
docs: add Google-style docstrings repo-wide + Sphinx site
xiaofei-zheng pushed a commit that referenced this pull request Jul 19, 2026
docs: add Google-style docstrings repo-wide + Sphinx site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants