Skip to content

[MRG] Avoid rendering module API members twice - #891

Open
j45856021-dev wants to merge 1 commit into
PythonOT:masterfrom
j45856021-dev:fix/api-documentation-duplicates
Open

j45856021-dev wants to merge 1 commit into
PythonOT:masterfrom
j45856021-dev:fix/api-documentation-duplicates

Conversation

@j45856021-dev

Copy link
Copy Markdown

Types of changes

Documentation bug fix.

Motivation and context / Related issue

Fixes #527.

The module template renders functions and classes through both automodule :members: and its explicit autofunction/autoclass loops. Exclude the explicitly rendered names from the automatic expansion, retaining the loops and their gallery backreferences.

Keeping :members: matters: package re-exports such as ot.bregman.sinkhorn, and the ot.utils.UndefinedParameter exception, are documented through that path rather than the function/class loops. Top-level aliases in all.rst are unchanged.

How has this been tested (if it applies)

Built native POT from c02a25cbb0536bd53ba071acd03733c52c2f3be5 and generated the complete HTML documentation before and after the change, using Python 3.13.16 and Sphinx 9.1.0 on macOS:

sphinx-build -D plot_gallery=0 -b html -E -a -q docs/source docs/build/html

A rendered-HTML regression fails on the original unif duplication and passes after the change. For example, after that build:

from pathlib import Path

html = Path("docs/build/html/gen_modules/ot.utils.html").read_text()
for name in ("unif", "tic", "toc", "toq", "DataScaler", "OTResult"):
    signature = f'class="sig-name descname"><span class="pre">{name}</span>'
    assert html.count(signature) == 1, name
assert 'id="ot.utils.UndefinedParameter"' in html
assert 'id="ot.unif"' in Path("docs/build/html/all.html").read_text()

The broader HTML comparison preserves all 992 distinct module API objects across 27 pages, their canonical anchors, all 116 gallery-backreference links, and all 53 top-level alias definitions. It removes 829 redundant rendered definitions. Local fragment-link checks find no new broken links. The applicable Codespell hook and git diff --check pass.

This is not a warning-free documentation build: warnings decrease from 1,785 to 679, and existing Docutils errors from 28 to 26. The remaining 21 duplicate-object warnings come from the unchanged OTResult/BaryResult Attributes sections also documenting their properties; those properties now appear twice rather than four times. Existing reference problems also remain, with some previously masked unreferenced-footnote diagnostics becoming visible. Gallery execution, the numerical test suite, and the full pre-commit wrapper were not run.

Prepared and validated by an autonomous AI agent (GPT-6 Astra); no independent human review before submission.

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

Exclude functions and classes already rendered by the autosummary
template's explicit directives from automodule's member expansion.
Keep re-exported APIs, exceptions and gallery backreferences intact.

Fixes PythonOT#527.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.00%. Comparing base (c02a25c) to head (220bca5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #891   +/-   ##
=======================================
  Coverage   97.00%   97.00%           
=======================================
  Files         130      130           
  Lines       26842    26842           
=======================================
  Hits        26039    26039           
  Misses        803      803           
🚀 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation Duplication

1 participant