sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

sphinx-apidoc: add ability to exclude specific files or filepatterns

Open shimizukawa opened this issue 11 years ago • 9 comments

I'm using sphinx-apidoc to generate rst files for a project that contains multiple packages.

Some of these packages contain SCons scripts and helper .py files for building Python extensions.

These builder scripts are really not part of the produced extension module, so I'd like to be able to exclude them from being processed by sphinx-apidoc but currently there doesn't seem to be a way.

I'm requesting the ability to add exclude patterns so specific files can be excluded.


  • Bitbucket: https://bitbucket.org/birkenfeld/sphinx/issue/944
  • Originally reported by: Anonymous
  • Originally created at: 2012-06-08T02:19:38.305

shimizukawa avatar Jan 03 '15 01:01 shimizukawa

From James Mills on 2013-06-21 06:05:36+00:00

+1

shimizukawa avatar Jan 03 '15 01:01 shimizukawa

From setrofim on 2013-07-15 16:16:22+00:00

+1

shimizukawa avatar Jan 03 '15 01:01 shimizukawa

was this ever done?

deserat avatar Nov 04 '16 23:11 deserat

Yeah, excluding feature has been provided since sphinx-1.1 by #98.

$ sphinx-apidoc -h
Usage: sphinx-apidoc [options] -o <output_path> <module_path> [exclude_path, ...]

and do

$ sphinx-apidoc -o doc/api src/ src/spam.py src/ham.py src/egg.py

shimizukawa avatar Nov 05 '16 22:11 shimizukawa

If I am trying to exclude __init__.py, it is throwing AssertionError. I executed following command:

_sphinx-apidoc -o source/plugin ../plugins/ ../plugins/echo.py ../plugins/__init__.py -f_
error thrown:
Traceback (most recent call last):
  File "/Users/srivastk/virtualenv/proton/bin/sphinx-apidoc", line 11, in <module>
    sys.exit(main())
  File "/Users/srivastk/virtualenv/proton/lib/python3.5/site-packages/sphinx/apidoc.py", line 343, in main
    modules = recurse_tree(rootpath, excludes, opts)
  File "/Users/srivastk/virtualenv/proton/lib/python3.5/site-packages/sphinx/apidoc.py", line 230, in recurse_tree
    assert root == rootpath and root_package is None
AssertionError

kanchansrivastava avatar Nov 23 '16 07:11 kanchansrivastava

@kanchan1991 please make another issue.

shimizukawa avatar Nov 23 '16 07:11 shimizukawa

+1

magican avatar Aug 08 '18 07:08 magican

See https://github.com/sphinx-doc/sphinx/issues/3177

micahjsmith avatar Sep 21 '18 18:09 micahjsmith

I am trying to ignore all directories inside src and to have apidocs only for .py files in /src folder

$ sphinx-apidoc -o doc/api src/ src/*/

but its generating nothing other than module.rst

SooluThomas avatar Aug 07 '19 20:08 SooluThomas