26

I'm generating documentation with Sphinx for project with structure like this :

+ project
|
+- docs
|
+- tests
|
+- workflow -+- definitions -+- <some folders>
             | 
             +- <rest of the project>

I want to exclude tests, and workflow/definition from documentation.

I tried exclude pattern in docs/conf.py

exclude_patterns = ['**/workflow/definitions', 'workflow/definitions', '*workflow/definitions', 'workflow/definitions*', 'workflow/definitions/*', 'workflow/definitions/*.*']

But even though workflow/definitions are still automatically generated.

Could someone show me correct exclude pattern how to ignore 'definitions' folder ?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
jmt
  • 719
  • 1
  • 9
  • 28
  • 1
    `exclude_patterns` can be used to exclude RST files only (when running sphinx-build). Does the workflow/definitions directory contain Python files or RST files? – mzjn May 05 '17 at 10:51

3 Answers3

22

exclude_patterns can be used to exclude source files (reStructuredText files) from processing by sphinx-build.

exclude_patterns has no effect when using sphinx-apidoc to generate reStructuredText files from Python modules (but you can tell sphinx-apidoc that certain pathnames should be excluded from the generation).

mzjn
  • 48,958
  • 13
  • 128
  • 248
  • 7
    `but you can tell sphinx-apidoc that certain pathnames should be excluded from the generation` How do you do that? I can't find anything in neither the the [apidoc pages](http://www.sphinx-doc.org/en/stable/man/sphinx-apidoc.html) nor the [autodoc config docs](http://www.sphinx-doc.org/en/stable/usage/extensions/autodoc.html#module-sphinx.ext.autodoc). – Arne Apr 18 '19 at 10:09
  • 5
    See `EXCLUDE_PATTERN` at http://www.sphinx-doc.org/en/stable/man/sphinx-apidoc.html – mzjn Apr 18 '19 at 10:12
  • 14
    For anyone else who ran into a similar issue as I, `EXCLUDE_PATTERN` also needs to include module path. e.g `sphinx-apidoc -f -o source .. *setup*` still generated setup.rst from setup.py, but `sphinx-apidoc -f -o source .. ../*setup*` worked as expected. – Jake Stevens-Haas Aug 06 '19 at 04:07
2

Docs for exclude_patterns indicate that 'workflow/definitions' should ignore that directory, assuming that the source files all end with .rst.

You can configure the source file suffices as a list:

source_suffix = ['.rst', '.txt']
Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
1

See EXCLUDE_PATTERN in sphinx-apidoc --help

usage: sphinx-apidoc [OPTIONS] -o <OUTPUT_PATH> <MODULE_PATH> [EXCLUDE_PATTERN, ...]

The <EXCLUDE_PATTERN>s can be file and/or directory patterns that will be excluded from generation.
smido
  • 771
  • 6
  • 14