summaryrefslogtreecommitdiff
path: root/sphinx/ext/apidoc.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-01-26 02:13:21 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-01-30 23:17:59 +0900
commit09cf37eebec88ed3c81e78b25138a870eae85d31 (patch)
tree631ceaf841727d8a19f78b45f467719f04d3196c /sphinx/ext/apidoc.py
parent0cc625a82c029d59a443f17df9fa31eaf83bf336 (diff)
downloadsphinx-git-09cf37eebec88ed3c81e78b25138a870eae85d31.tar.gz
Fix #6899: apidoc: private members are not shown even if --private given
Diffstat (limited to 'sphinx/ext/apidoc.py')
-rw-r--r--sphinx/ext/apidoc.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/sphinx/ext/apidoc.py b/sphinx/ext/apidoc.py
index 1d12ac6a6..0c70b4ec8 100644
--- a/sphinx/ext/apidoc.py
+++ b/sphinx/ext/apidoc.py
@@ -20,6 +20,7 @@ import locale
import os
import sys
import warnings
+from copy import copy
from fnmatch import fnmatch
from importlib.machinery import EXTENSION_SUFFIXES
from os import path
@@ -107,12 +108,16 @@ def format_directive(module: str, package: str = None) -> str:
def create_module_file(package: str, basename: str, opts: Any,
user_template_dir: str = None) -> None:
"""Build the text of the file and write the file."""
+ options = copy(OPTIONS)
+ if opts.includeprivate and 'private-members' not in options:
+ options.append('private-members')
+
qualname = module_join(package, basename)
context = {
'show_headings': not opts.noheadings,
'basename': basename,
'qualname': qualname,
- 'automodule_options': OPTIONS,
+ 'automodule_options': options,
}
text = ReSTRenderer([user_template_dir, template_dir]).render('module.rst_t', context)
write_file(qualname, text, opts)
@@ -133,6 +138,9 @@ def create_package_file(root: str, master_package: str, subroot: str, py_files:
sub != INITPY]
submodules = [module_join(master_package, subroot, modname)
for modname in submodules]
+ options = copy(OPTIONS)
+ if opts.includeprivate and 'private-members' not in options:
+ options.append('private-members')
pkgname = module_join(master_package, subroot)
context = {
@@ -142,7 +150,7 @@ def create_package_file(root: str, master_package: str, subroot: str, py_files:
'is_namespace': is_namespace,
'modulefirst': opts.modulefirst,
'separatemodules': opts.separatemodules,
- 'automodule_options': OPTIONS,
+ 'automodule_options': options,
'show_headings': not opts.noheadings,
}
text = ReSTRenderer([user_template_dir, template_dir]).render('package.rst_t', context)