From 86abb5757761ffb1122ab03e7b81cc09e863a9ea Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 2 Sep 2018 20:46:25 +0900 Subject: [PATCH] Fix #5362: apidoc: Add ``--toc`` option to change the filename of ToC --- CHANGES | 1 + doc/man/sphinx-apidoc.rst | 4 ++++ sphinx/ext/apidoc.py | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 27d3d4ab9..82a217b96 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,7 @@ Features added -------------- * #5388: Ensure frozen object descriptions are reproducible +* #5362: apidoc: Add ``--tocfile`` option to change the filename of ToC Bugs fixed ---------- diff --git a/doc/man/sphinx-apidoc.rst b/doc/man/sphinx-apidoc.rst index 97135d98e..15096d523 100644 --- a/doc/man/sphinx-apidoc.rst +++ b/doc/man/sphinx-apidoc.rst @@ -58,6 +58,10 @@ Options Maximum depth for the generated table of contents file. +.. option:: --tocfile + + Filename for a table of contents file. Defaults to ``modules``. + .. option:: -T, --no-toc Do not create a table of contents file. Ignored when :option:`--full` is diff --git a/sphinx/ext/apidoc.py b/sphinx/ext/apidoc.py index 8a7c68402..a154f6449 100644 --- a/sphinx/ext/apidoc.py +++ b/sphinx/ext/apidoc.py @@ -340,7 +340,9 @@ Note: By default this script will not overwrite already created files.""")) parser.add_argument('-P', '--private', action='store_true', dest='includeprivate', help=__('include "_private" modules')) - parser.add_argument('-T', '--no-toc', action='store_true', dest='notoc', + parser.add_argument('--tocfile', action='store', dest='tocfile', default='modules', + help=__("don't create a table of contents file")) + parser.add_argument('-T', '--no-toc', action='store_false', dest='tocfile', help=__("don't create a table of contents file")) parser.add_argument('-E', '--no-headings', action='store_true', dest='noheadings', @@ -453,8 +455,8 @@ def main(argv=sys.argv[1:]): if not args.dryrun: qs.generate(d, silent=True, overwrite=args.force) - elif not args.notoc: - create_modules_toc_file(modules, args) + elif args.tocfile: + create_modules_toc_file(modules, args, args.tocfile) return 0