diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-02-01 00:30:09 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-02-01 00:30:09 +0900 |
commit | aced2be1fb228f99284b5a0bca778e8769d3c7e5 (patch) | |
tree | bcac5836f0ff6f612e91bc52ae4a2a4186bef684 /sphinx/ext/apidoc.py | |
parent | b73cc5652aee6e67316799c901116889a3c6736e (diff) | |
download | sphinx-git-aced2be1fb228f99284b5a0bca778e8769d3c7e5.tar.gz |
apidoc: Add ``-q`` option for quiet mode (refs: #6772)
Diffstat (limited to 'sphinx/ext/apidoc.py')
-rw-r--r-- | sphinx/ext/apidoc.py | 15 |
1 files changed, 12 insertions, 3 deletions
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: |