[docs/options] add Table of Contents
This commit is contained in:
@@ -3,6 +3,20 @@
|
|||||||
<!-- auto-generated by scripts/options.py -->
|
<!-- auto-generated by scripts/options.py -->
|
||||||
|
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
* [General Options](#general-options)
|
||||||
|
* [Update Options](#update-options)
|
||||||
|
* [Input Options](#input-options)
|
||||||
|
* [Output Options](#output-options)
|
||||||
|
* [Networking Options](#networking-options)
|
||||||
|
* [Downloader Options](#downloader-options)
|
||||||
|
* [Configuration Options](#configuration-options)
|
||||||
|
* [Authentication Options](#authentication-options)
|
||||||
|
* [Cookie Options](#cookie-options)
|
||||||
|
* [Selection Options](#selection-options)
|
||||||
|
* [Post-processing Options](#post-processing-options)
|
||||||
|
|
||||||
## General Options:
|
## General Options:
|
||||||
-h, --help Print this help message and exit
|
-h, --help Print this help message and exit
|
||||||
--version Print program version and exit
|
--version Print program version and exit
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2023 Mike Fährmann
|
# Copyright 2023-2026 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -29,23 +29,36 @@ class Formatter(option.Formatter):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def repl(match):
|
||||||
|
cat = match[1].rstrip(":")
|
||||||
|
toc.append(f"* [{cat}](#{cat.lower().replace(' ', '-')})")
|
||||||
|
return f"## {cat}:"
|
||||||
|
|
||||||
|
|
||||||
parser = option.build_parser()
|
parser = option.build_parser()
|
||||||
parser.formatter_class = Formatter
|
parser.formatter_class = Formatter
|
||||||
parser.format_usage = lambda: ""
|
parser.format_usage = lambda: ""
|
||||||
|
|
||||||
|
toc = []
|
||||||
opts = parser.format_help()
|
opts = parser.format_help()
|
||||||
opts = re.sub(r"(?m)^(\w+.*)", "## \\1", opts) # group names to headings
|
opts = re.sub(r"(?m)^(\w+.*)", repl, opts) # group names to headings
|
||||||
opts = opts.replace("\n ", "\n ") # indent by 4
|
opts = opts.replace("\n ", "\n ") # indent by 4
|
||||||
|
toc = "\n".join(toc)
|
||||||
|
|
||||||
SELF = "/".join(os.path.normpath(__file__).split(os.sep)[-2:])
|
SELF = "/".join(os.path.normpath(__file__).split(os.sep)[-2:])
|
||||||
PATH = (sys.argv[1] if len(sys.argv) > 1 else
|
PATH = (sys.argv[1] if len(sys.argv) > 1 else
|
||||||
util.path("docs", "options.md"))
|
util.path("docs", "options.md"))
|
||||||
|
|
||||||
with util.lazy(PATH) as fp:
|
with util.lazy(PATH) as fp:
|
||||||
fp.write(f"""# Command-Line Options
|
fp.write(f"""\
|
||||||
|
# Command-Line Options
|
||||||
|
|
||||||
<!-- auto-generated by {SELF} -->
|
<!-- auto-generated by {SELF} -->
|
||||||
|
|
||||||
|
|
||||||
{opts}""")
|
## Table of Contents
|
||||||
|
|
||||||
|
{toc}
|
||||||
|
|
||||||
|
{opts}\
|
||||||
|
""")
|
||||||
|
|||||||
Reference in New Issue
Block a user