From 86c54575bef74c4140e2c2efcb88e953ea76c28b Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 6 Nov 2016 09:36:33 +0900 Subject: [PATCH] Closes #930: sphinx-apidoc allow wildcards for excluding paths. --- CHANGES | 1 + sphinx/apidoc.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index cd00371d9..2ab276671 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,7 @@ Features added :confval:`linkcheck_anchors_ignore` * #3083: let Unicode no-break space act like LaTeX ``~`` (fixed #3019) * #3116: allow word wrap in PDF output for inline literals (ref #3110) +* #930: sphinx-apidoc allow wildcards for excluding paths. Thanks to Nick Coghlan. Bugs fixed ---------- diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py index 6b140260d..05928be81 100644 --- a/sphinx/apidoc.py +++ b/sphinx/apidoc.py @@ -21,6 +21,7 @@ import sys import optparse from os import path from six import binary_type +from fnmatch import fnmatch from sphinx.util.osutil import FileAvoidWrite, walk from sphinx import __display_version__ @@ -257,7 +258,7 @@ def is_excluded(root, excludes): e.g. an exlude "foo" also accidentally excluding "foobar". """ for exclude in excludes: - if root == exclude: + if fnmatch(root, exclude): return True return False @@ -266,13 +267,13 @@ def main(argv=sys.argv): """Parse and check the command line arguments.""" parser = optparse.OptionParser( usage="""\ -usage: %prog [options] -o [exclude_path, ...] +usage: %prog [options] -o [exclude_pattern, ...] Look recursively in for Python modules and packages and create one reST file with automodule directives per package in the . -The s can be files and/or directories that will be excluded -from generation. +The s can be file and/or directory patterns that will be +excluded from generation. Note: By default this script will not overwrite already created files.""")