sphinx-doc / sphinx-doc/sphinx

sphinx-apidoc duplicate lines in genrated rst files if module is a cpython extension module

Open
#9,614 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

extensions:apidoc type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

sphinx-apidoc -M -o modules/pkg pkg generates files that contain duplicate entries if pkg.wrapper is an cpython extension module (.so file). The generated rst file looks like

pkg package
===========

.. automodule:: pkg
   :members:
   :show-inheritance:

Submodules
----------


pkg.lockable\_plugin module
---------------------------

.. automodule:: pkg.lockable_plugin
   :members:
   :show-inheritance:

pkg.wrapper module
------------------

.. automodule:: pkg.wrapper
   :members:
   :show-inheritance:

pkg.wrapper module
------------------

.. automodule:: pkg.wrapper
   :members:
   :show-inheritance:

How to Reproduce

Build a python library that contains a cpython extension using multiple interpreters, s.t. the source tree of the python lib contains so files for multiple interpreters

./pkg/wrapper.cpython-39-x86_64-linux-gnu.so
./pkg/wrapper.cpython-37m-x86_64-linux-gnu.so

(./pkg is the source directory)

Expected behavior

The generated rst file must not contain duplicate entries.

Your project
Screenshots

No response

OS

Linux

Python version

3.7

Sphinx version

4.1.2

Sphinx extensions

autodoc

Extra tools

No response

Additional context

FYI I've reported a similar (apidoc related) issue in the past: https://github.com/sphinx-doc/sphinx/issues/6986

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported sphinx-apidoc -M reproduction using a package containing multiple CPython extension .so files. Inspect how the generated rst file includes modules and confirm that pkg.wrapper appears twice; done means the generated rst contains only one entry for each module.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.