summaryrefslogtreecommitdiff
path: root/sphinx/ext/apidoc.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-02-12 16:20:00 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-02-12 16:20:00 +0900
commit6cf0698b0c6bde9fdcf4a606838552e1e7e20663 (patch)
treec954c3de58de875d0ca5071feecb52a7cd9e7e79 /sphinx/ext/apidoc.py
parente5adf8ce91cd1bc408a6c37ce4d1088a79e9653f (diff)
parent419021e82f543c40e921b784445aeb5f97303caa (diff)
downloadsphinx-git-6cf0698b0c6bde9fdcf4a606838552e1e7e20663.tar.gz
Merge branch '1.7'
Diffstat (limited to 'sphinx/ext/apidoc.py')
-rw-r--r--sphinx/ext/apidoc.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/sphinx/ext/apidoc.py b/sphinx/ext/apidoc.py
index 14207ef37..22974c638 100644
--- a/sphinx/ext/apidoc.py
+++ b/sphinx/ext/apidoc.py
@@ -108,8 +108,8 @@ def create_module_file(package, module, opts):
write_file(makename(package, module), text, opts)
-def create_package_file(root, master_package, subroot, py_files, opts, subs, is_namespace):
- # type: (unicode, unicode, unicode, List[unicode], Any, List[unicode], bool) -> None
+def create_package_file(root, master_package, subroot, py_files, opts, subs, is_namespace, excludes=[]): # NOQA
+ # type: (unicode, unicode, unicode, List[unicode], Any, List[unicode], bool, List[unicode]) -> None # NOQA
"""Build the text of the file and write the file."""
text = format_heading(1, ('%s package' if not is_namespace else "%s namespace")
% makename(master_package, subroot))
@@ -123,7 +123,7 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs, is_
# source files in that folder.
# (depending on settings - but shall_skip() takes care of that)
subs = [sub for sub in subs if not
- shall_skip(path.join(root, sub, INITPY), opts)]
+ shall_skip(path.join(root, sub, INITPY), opts, excludes)]
# if there are some package directories, add a TOC for theses subpackages
if subs:
text += format_heading(2, 'Subpackages')
@@ -133,7 +133,7 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs, is_
text += '\n'
submods = [path.splitext(sub)[0] for sub in py_files
- if not shall_skip(path.join(root, sub), opts) and
+ if not shall_skip(path.join(root, sub), opts, excludes) and
sub != INITPY]
if submods:
text += format_heading(2, 'Submodules')
@@ -187,8 +187,8 @@ def create_modules_toc_file(modules, opts, name='modules'):
write_file(name, text, opts)
-def shall_skip(module, opts):
- # type: (unicode, Any) -> bool
+def shall_skip(module, opts, excludes=[]):
+ # type: (unicode, Any, List[unicode]) -> bool
"""Check if we want to skip this module."""
# skip if the file doesn't exist and not using implicit namespaces
if not opts.implicit_namespaces and not path.exists(module):
@@ -196,16 +196,14 @@ def shall_skip(module, opts):
# skip it if there is nothing (or just \n or \r\n) in the file
if path.exists(module) and path.getsize(module) <= 2:
- skip = True
if os.path.basename(module) == '__init__.py':
- pattern = path.join(path.dirname(module), '*.py')
# We only want to skip packages if they do not contain any
# .py files other than __init__.py.
- other_modules = list(glob.glob(pattern))
- other_modules.remove(module)
- skip = not other_modules
-
- if skip:
+ basemodule = path.dirname(module)
+ for module in glob.glob(path.join(basemodule, '*.py')):
+ if not is_excluded(path.join(basemodule, module), excludes):
+ return True
+ else:
return True
# skip if it has a "private" name and this is selected
@@ -267,7 +265,7 @@ def recurse_tree(rootpath, excludes, opts):
# a namespace and there is something there to document
if not is_namespace or len(py_files) > 0:
create_package_file(root, root_package, subpackage,
- py_files, opts, subs, is_namespace)
+ py_files, opts, subs, is_namespace, excludes)
toplevels.append(makename(root_package, subpackage))
else:
# if we are at the root level, we don't require it to be a package