From 50d89d4acb0d8f95118a5b28c376e1b1190286f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 3 Jan 2023 16:04:48 +0100 Subject: [PATCH] docs/options.md: use a separate table for each option group --- docs/options.md | 93 +++++++++++++++++++++++++++------------------- scripts/options.py | 46 +++++++++++++---------- 2 files changed, 82 insertions(+), 57 deletions(-) diff --git a/docs/options.md b/docs/options.md index fb96ce8b..4f6c1458 100644 --- a/docs/options.md +++ b/docs/options.md @@ -2,22 +2,14 @@ + +## General Options + - - - - - - - - - - - - + @@ -75,13 +67,17 @@ + +
General Options
-h--help--help Print this help message and exit
--cookies-from-browser Name of the browser to load cookies from, with optional keyring name prefixed with +, profile prefixed with :, and container prefixed with :: (none for no container)
- - Output Options - + +## Output Options + + + - + @@ -144,13 +140,17 @@ + +
-q--quiet--quiet Activate quiet mode
--write-pages Write downloaded intermediary pages to files in the current directory to debug problems
- - Downloader Options - + +## Downloader Options + + + - + @@ -223,32 +223,40 @@ + +
-r--limit-rate--limit-rate Maximum download rate (e.g. 500k or 2.5M)
--no-check-certificate Disable HTTPS certificate validation
- - Configuration Options - + +## Configuration Options + + + - + - + + +
-c--config--config Additional configuration files
-o --optionAdditional = option valuesAdditional <key>=<value> option values
--ignore-config Do not read default configuration files
- - Authentication Options - + +## Authentication Options + + + - + @@ -261,13 +269,17 @@ + +
-u--username--username Username to login with
--netrc Enable .netrc authentication data
- - Selection Options - + +## Selection Options + + + - + @@ -293,20 +305,24 @@ - + + +
--download-archive--download-archive Record all downloaded or skipped files in FILE and skip downloading any file already in it
--filterPython expression controlling which files to download. Files for which the expression evaluates to False are ignored. Available keys are the filename-specific ones listed by -K. Example: --filter "image_width >= 1000 and rating in (s, q)"Python expression controlling which files to download. Files for which the expression evaluates to False are ignored. Available keys are the filename-specific ones listed by -K. Example: --filter "image_width >= 1000 and rating in (s, q)"
--chapter-filter Like --filter, but applies to manga chapters and other delegated URLs
- - Post-processing Options - + +## Post-processing Options + + + - + @@ -361,3 +377,4 @@
--zip--zip Store downloaded files in a ZIP archive
+ diff --git a/scripts/options.py b/scripts/options.py index b3b676e4..66b7b3fc 100755 --- a/scripts/options.py +++ b/scripts/options.py @@ -11,6 +11,7 @@ import os import re +from argparse import SUPPRESS import util from gallery_dl import option @@ -20,33 +21,38 @@ TEMPLATE = """# Command-Line Options +{} +""" + +TABLE = """ +## {} + - - - - - - - {}
-""" +""".format + +ROW = """ + {} + {} + {} +""".format -tbody = [] -append = tbody.append sub = re.compile(r"'([^']+)'").sub +tables = [] for group in option.build_parser()._action_groups[2:]: - append('\n\n ' + - group.title + '\n') + tbody = [] + append = tbody.append + width = ' width="28%"' for action in group._group_actions: help = action.help - if help == "==SUPPRESS==": + if help == SUPPRESS: continue try: @@ -62,16 +68,18 @@ for group in option.build_parser()._action_groups[2:]: short = "" + short + "" if long: long = '' + long + "" + if help: + help = help.replace("<", "<").replace(">", ">") + help = sub("\\1", help) + + append(ROW(short, width, long, help)) + width = "" - append("") - append(" " + short + "") - append(" " + long + "") - append(" " + sub("\\1", help) + "") - append("") + tables.append(TABLE(group.title, "\n".join(tbody))) with open(util.path("docs", "options.md"), "w", encoding="utf-8") as fp: fp.write(TEMPLATE.format( "/".join(os.path.normpath(__file__).split(os.sep)[-2:]), - "\n".join(tbody), + "\n".join(tables), ))