mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #10406 from AA-Turner/apidoc-duplicates
Ensure submodules are unique in `sphinx.ext.apidoc`
This commit is contained in:
commit
2f29f0a96e
2
CHANGES
2
CHANGES
@ -72,6 +72,8 @@ Features added
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #10200: apidoc: Duplicated submodules are shown for modules having both .pyx
|
||||
and .so files
|
||||
* #10279: autodoc: Default values for keyword only arguments in overloaded
|
||||
functions are rendered as a string literal
|
||||
* #10280: autodoc: :confval:`autodoc_docstring_signature` unexpectedly generates
|
||||
|
@ -117,6 +117,7 @@ def create_package_file(root: str, master_package: str, subroot: str, py_files:
|
||||
submodules = [sub.split('.')[0] for sub in py_files
|
||||
if not is_skipped_module(path.join(root, sub), opts, excludes) and
|
||||
not is_initpy(sub)]
|
||||
submodules = sorted(set(submodules))
|
||||
submodules = [module_join(master_package, subroot, modname)
|
||||
for modname in submodules]
|
||||
options = copy(OPTIONS)
|
||||
|
@ -4,6 +4,7 @@ from collections import namedtuple
|
||||
|
||||
import pytest
|
||||
|
||||
import sphinx.ext.apidoc
|
||||
from sphinx.ext.apidoc import main as apidoc_main
|
||||
from sphinx.testing.path import path
|
||||
|
||||
@ -639,3 +640,31 @@ def test_namespace_package_file(tempdir):
|
||||
" :members:\n"
|
||||
" :undoc-members:\n"
|
||||
" :show-inheritance:\n")
|
||||
|
||||
|
||||
def test_no_duplicates(rootdir, tempdir):
|
||||
"""Make sure that a ".pyx" and ".so" don't cause duplicate listings.
|
||||
|
||||
We can't use pytest.mark.apidoc here as we use a different set of arguments
|
||||
to apidoc_main
|
||||
"""
|
||||
|
||||
original_suffixes = sphinx.ext.apidoc.PY_SUFFIXES
|
||||
try:
|
||||
# Ensure test works on Windows
|
||||
sphinx.ext.apidoc.PY_SUFFIXES += ('.so',)
|
||||
|
||||
package = rootdir / 'test-apidoc-duplicates' / 'fish_licence'
|
||||
outdir = tempdir / 'out'
|
||||
apidoc_main(['-o', outdir, "-T", package, "--implicit-namespaces"])
|
||||
|
||||
# Ensure the module has been documented
|
||||
assert (outdir / 'fish_licence.rst').isfile()
|
||||
|
||||
# Ensure the submodule only appears once
|
||||
text = (outdir / 'fish_licence.rst').read_text(encoding="utf-8")
|
||||
count_submodules = text.count(r'fish\_licence.halibut module')
|
||||
assert count_submodules == 1
|
||||
|
||||
finally:
|
||||
sphinx.ext.apidoc.PY_SUFFIXES = original_suffixes
|
||||
|
Loading…
Reference in New Issue
Block a user