summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-02-01 00:30:09 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-02-01 00:30:09 +0900
commitaced2be1fb228f99284b5a0bca778e8769d3c7e5 (patch)
treebcac5836f0ff6f612e91bc52ae4a2a4186bef684
parentb73cc5652aee6e67316799c901116889a3c6736e (diff)
downloadsphinx-git-aced2be1fb228f99284b5a0bca778e8769d3c7e5.tar.gz
apidoc: Add ``-q`` option for quiet mode (refs: #6772)
-rw-r--r--CHANGES1
-rw-r--r--doc/man/sphinx-apidoc.rst5
-rw-r--r--sphinx/ext/apidoc.py15
3 files changed, 18 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index 663dd160b..74032a38c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -59,6 +59,7 @@ Features added
* SphinxTranslator now calls visitor/departure method for super node class if
visitor/departure method for original node class not found
* #6418: Add new event: :event:`object-description-transform`
+* #6772: apidoc: Add ``-q`` option for quiet mode
Bugs fixed
----------
diff --git a/doc/man/sphinx-apidoc.rst b/doc/man/sphinx-apidoc.rst
index 78c0735cb..30bfde0bb 100644
--- a/doc/man/sphinx-apidoc.rst
+++ b/doc/man/sphinx-apidoc.rst
@@ -39,6 +39,11 @@ Options
Directory to place the output files. If it does not exist, it is created.
+.. option:: -q
+
+ Do not output anything on standard output, only write warnings and errors to
+ standard error.
+
.. option:: -f, --force
Force overwriting of any existing generated files.
diff --git a/sphinx/ext/apidoc.py b/sphinx/ext/apidoc.py
index 0c70b4ec8..99cf67016 100644
--- a/sphinx/ext/apidoc.py
+++ b/sphinx/ext/apidoc.py
@@ -73,14 +73,19 @@ def module_join(*modnames: str) -> str:
def write_file(name: str, text: str, opts: Any) -> None:
"""Write the output file for module/package <name>."""
+ quiet = getattr(opts, 'quiet', None)
+
fname = path.join(opts.destdir, '%s.%s' % (name, opts.suffix))
if opts.dryrun:
- print(__('Would create file %s.') % fname)
+ if not quiet:
+ print(__('Would create file %s.') % fname)
return
if not opts.force and path.isfile(fname):
- print(__('File %s already exists, skipping.') % fname)
+ if not quiet:
+ print(__('File %s already exists, skipping.') % fname)
else:
- print(__('Creating file %s.') % fname)
+ if not quiet:
+ print(__('Creating file %s.') % fname)
with FileAvoidWrite(fname) as f:
f.write(text)
@@ -324,6 +329,8 @@ Note: By default this script will not overwrite already created files."""))
parser.add_argument('-o', '--output-dir', action='store', dest='destdir',
required=True,
help=__('directory to place all output'))
+ parser.add_argument('-q', action='store_true', dest='quiet',
+ help=__('no output on stdout, just warnings on stderr'))
parser.add_argument('-d', '--maxdepth', action='store', dest='maxdepth',
type=int, default=4,
help=__('maximum depth of submodules to show in the TOC '
@@ -451,6 +458,8 @@ def main(argv: List[str] = sys.argv[1:]) -> int:
}
if args.extensions:
d['extensions'].extend(args.extensions)
+ if args.quiet:
+ d['quiet'] = True
for ext in d['extensions'][:]:
if ',' in ext: