pythontestingdocumentationpython-sphinxdocumentation-generation

Sphinx still generating documentation for test folders despite exclusion in conf.py


I'm using Sphinx to generate documentation for my Python project, and I want to exclude test folders from being included in the generated documentation. I've added "**/tests/*" to the exclude_patterns list in my conf.py file as follows:

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**/tests/*"]

thats is my project strucuture :

├───docs
├───Project
│   ├───Module1
│   │   │   file1.py
│   │   ├───tests
│   ├───reports
│   ├───tests
│   │   ├───tests
└───reports

However, despite this configuration, Sphinx is still generating documentation for the test folders.

I've double-checked the syntax and ensured that the test folders are located within the project directory structure. I've also tried regenerating the documentation after deleting the existing build files, but the issue persists.

Is there something I'm missing or any additional steps I should take to ensure that Sphinx excludes the test folders from documentation generation?

Any help or insights into resolving this issue would be greatly appreciated. Thank you in advance!


Solution

  • You should delete any init.py in your tests folder this way sphinx does not count it.