Skip to content

Add automatically generated API reference to the documentation - #973

Open
mcepl wants to merge 1 commit into
masterfrom
api-docs-autoapi
Open

mcepl wants to merge 1 commit into
masterfrom
api-docs-autoapi

Conversation

@mcepl

@mcepl mcepl commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Replaces #797 by @smheidrich, which went stale (credited as co-author). There is no API reference at the moment, and the library docs tell users to read the source of rope.refactor. This PR generates one with sphinx-autoapi.

Fixes #796

What changed

  • docs/conf.py: adds autoapi.extension, sphinx.ext.intersphinx (links to the Python docs) and sphinx.ext.napoleon.
    • Public members only, plus members inherited from private base classes, so Project shows do(), get_resource(), history, … from _Project.
    • No imported members, otherwise rope.base.ast would document the whole stdlib ast again.
    • napoleon parses NumPy-style Parameters/Returns sections, which otherwise became headings with duplicate labels.
    • An autoapi-skip-member hook documents only the first of names that are deliberately defined several times (try/except fallbacks, operator handlers in type_hinting.evaluate). Without it Sphinx reports duplicate object descriptions.
    • Suppresses autoapi.python_import_resolution: autoapi can't follow the from ast import * re-export in rope.base.ast.
  • docs/api.rst: a short "API reference" page, linked from the main table of contents right after "Using rope as a library". It points to the main entry points and to the generated tree.
  • docs/library.rst: fully qualified rope names in running text now link to the reference (:mod:, :class:, :func:). Section titles are unchanged, so their autosectionlabel anchors stay stable. Unlike Add auto-generated API docs #797, this doesn't set default_role = "any", so existing single-backtick text keeps its meaning.
  • pyproject.toml: sphinx-autoapi>=3 in the doc extra, which Read the Docs installs.

Validation

sphinx-build -b html docs <out>, with Sphinx 8.2.3, sphinx-autoapi 3.9.0, sphinx-rtd-theme 3.1.0 and sphinx-autodoc-typehints 3.13.2:

  • master: 0 warnings. This branch: 0 warnings, for both a full and an incremental build. 97 API pages, about 2.4 MB of HTML.
  • With -n (nitpicky): every new cross-reference in library.rst and api.rst resolves. The remaining nitpicky warnings come from existing docstrings that mention private helper classes such as _Generate and _Inliner; Read the Docs doesn't build in nitpicky mode.
  • The generated .rst files are deleted after the build (autoapi_keep_files defaults to False) and never show up in the source tree.

Read the Docs preview: https://rope--973.org.readthedocs.build/en/973/ — the API reference page is linked from the navigation and leads to the generated tree, e.g. rope.base.project.

The documentation tells library users to read the source of
rope.refactor and friends, because there is no API reference.
Generate one from the docstrings with sphinx-autoapi, which,
unlike autosummary, does not need hand-written stubs for every
module, and link it from the table of contents through a short
"API reference" page that points to the main entry points.

The reference documents public members, including those
inherited from private base classes (e.g. Project gets do(),
get_resource(), history, ... from _Project), but leaves imported
members out, so that rope.base.ast does not document the whole
stdlib ast again. napoleon parses the NumPy-style docstring
sections, which would otherwise become section titles with
duplicate labels, and an autoapi-skip-member hook documents only
the first of names that are intentionally defined several times
(try/except fallbacks, operator handlers in type_hinting). The
documentation build stays free of warnings.

library.rst now uses cross-references to the reference instead
of literal names where it mentions rope modules, classes and
functions in running text; section titles are left unchanged to
keep their autosectionlabel anchors.

This replaces the stale PR #797 and takes its idea and its
sphinx-autoapi and intersphinx setup.

Fixes: #796
Co-authored-by: Shahriar Heidrich <smheidrich@weltenfunktion.de>
@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.44%. Comparing base (ff8a306) to head (7e02654).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #973   +/-   ##
=======================================
  Coverage   95.44%   95.44%           
=======================================
  Files         134      134           
  Lines       26910    26910           
=======================================
  Hits        25685    25685           
  Misses       1225     1225           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

Automatically generated API docs would be nice

1 participant