Skip to content

Instantly share code, notes, and snippets.

@cr0hn
Created August 1, 2014 07:24
Show Gist options
  • Save cr0hn/ca7d17b1ff011067ac81 to your computer and use it in GitHub Desktop.
Save cr0hn/ca7d17b1ff011067ac81 to your computer and use it in GitHub Desktop.
Locate automatically all .py files in your project to add to sphinx engine to generate documentation.
# Source code base directory
PROJECT_DIR = os.path.abspath(os.path.join(os.path.join(os.getcwd()), "../../."))
# Insert Base project dir
sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_DIR, "../.")))
# Run!
for root, dirs, files in os.walk(PROJECT_DIR):
# Looking for .py files and packages
if any(x.endswith(".py") for x in files) and any("__init__.py" in x for x in files):
sys.path.insert(0, os.path.join(root))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment