mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7078 from tk0miya/6772_apidoc_quiet_mode
apidoc: Add ``-q`` option for quiet mode (refs: #6772)
This commit is contained in:
commit
66e4897a05
1
CHANGES
1
CHANGES
@ -61,6 +61,7 @@ Features added
|
|||||||
* #6418: Add new event: :event:`object-description-transform`
|
* #6418: Add new event: :event:`object-description-transform`
|
||||||
* py domain: :rst:dir:`py:data` and :rst:dir:`py:attribute` take new options
|
* py domain: :rst:dir:`py:data` and :rst:dir:`py:attribute` take new options
|
||||||
named ``:type:`` and ``:value:`` to describe its type and initial value
|
named ``:type:`` and ``:value:`` to describe its type and initial value
|
||||||
|
* #6772: apidoc: Add ``-q`` option for quiet mode
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
@ -39,6 +39,11 @@ Options
|
|||||||
|
|
||||||
Directory to place the output files. If it does not exist, it is created.
|
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
|
.. option:: -f, --force
|
||||||
|
|
||||||
Force overwriting of any existing generated files.
|
Force overwriting of any existing generated files.
|
||||||
|
@ -73,14 +73,19 @@ def module_join(*modnames: str) -> str:
|
|||||||
|
|
||||||
def write_file(name: str, text: str, opts: Any) -> None:
|
def write_file(name: str, text: str, opts: Any) -> None:
|
||||||
"""Write the output file for module/package <name>."""
|
"""Write the output file for module/package <name>."""
|
||||||
|
quiet = getattr(opts, 'quiet', None)
|
||||||
|
|
||||||
fname = path.join(opts.destdir, '%s.%s' % (name, opts.suffix))
|
fname = path.join(opts.destdir, '%s.%s' % (name, opts.suffix))
|
||||||
if opts.dryrun:
|
if opts.dryrun:
|
||||||
print(__('Would create file %s.') % fname)
|
if not quiet:
|
||||||
|
print(__('Would create file %s.') % fname)
|
||||||
return
|
return
|
||||||
if not opts.force and path.isfile(fname):
|
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:
|
else:
|
||||||
print(__('Creating file %s.') % fname)
|
if not quiet:
|
||||||
|
print(__('Creating file %s.') % fname)
|
||||||
with FileAvoidWrite(fname) as f:
|
with FileAvoidWrite(fname) as f:
|
||||||
f.write(text)
|
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',
|
parser.add_argument('-o', '--output-dir', action='store', dest='destdir',
|
||||||
required=True,
|
required=True,
|
||||||
help=__('directory to place all output'))
|
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',
|
parser.add_argument('-d', '--maxdepth', action='store', dest='maxdepth',
|
||||||
type=int, default=4,
|
type=int, default=4,
|
||||||
help=__('maximum depth of submodules to show in the TOC '
|
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:
|
if args.extensions:
|
||||||
d['extensions'].extend(args.extensions)
|
d['extensions'].extend(args.extensions)
|
||||||
|
if args.quiet:
|
||||||
|
d['quiet'] = True
|
||||||
|
|
||||||
for ext in d['extensions'][:]:
|
for ext in d['extensions'][:]:
|
||||||
if ',' in ext:
|
if ',' in ext:
|
||||||
|
Loading…
Reference in New Issue
Block a user