docs/options.md: use a separate table for each option group

pull/3460/head
Mike Fährmann 2 years ago
parent ed2d715019
commit 50d89d4acb
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -2,22 +2,14 @@
<!-- auto-generated by scripts/options.py -->
## General Options
<table>
<thead>
<tr>
<th></th>
<th width="26%"></th>
<th></th>
</tr>
</thead>
<tbody valign="top">
<tr>
<td colspan="4"><strong>General Options</strong></td>
</tr>
<tr>
<td><code>-h</code></td>
<td><code>--help</code></td>
<td width="28%"><code>--help</code></td>
<td>Print this help message and exit</td>
</tr>
<tr>
@ -75,13 +67,17 @@
<td><code>--cookies-from-browser</code></td>
<td>Name of the browser to load cookies from, with optional keyring name prefixed with <code>+</code>, profile prefixed with <code>:</code>, and container prefixed with <code>::</code> (<code>none</code> for no container)</td>
</tr>
</tbody>
</table>
<tr>
<td colspan="4"><strong>Output Options</strong></td>
</tr>
## Output Options
<table>
<tbody valign="top">
<tr>
<td><code>-q</code></td>
<td><code>--quiet</code></td>
<td width="28%"><code>--quiet</code></td>
<td>Activate quiet mode</td>
</tr>
<tr>
@ -144,13 +140,17 @@
<td><code>--write-pages</code></td>
<td>Write downloaded intermediary pages to files in the current directory to debug problems</td>
</tr>
</tbody>
</table>
<tr>
<td colspan="4"><strong>Downloader Options</strong></td>
</tr>
## Downloader Options
<table>
<tbody valign="top">
<tr>
<td><code>-r</code></td>
<td><code>--limit-rate</code></td>
<td width="28%"><code>--limit-rate</code></td>
<td>Maximum download rate (e.g. 500k or 2.5M)</td>
</tr>
<tr>
@ -223,32 +223,40 @@
<td><code>--no-check-certificate</code></td>
<td>Disable HTTPS certificate validation</td>
</tr>
</tbody>
</table>
<tr>
<td colspan="4"><strong>Configuration Options</strong></td>
</tr>
## Configuration Options
<table>
<tbody valign="top">
<tr>
<td><code>-c</code></td>
<td><code>--config</code></td>
<td width="28%"><code>--config</code></td>
<td>Additional configuration files</td>
</tr>
<tr>
<td><code>-o</code></td>
<td><code>--option</code></td>
<td>Additional <code><key>=<value></code> option values</td>
<td>Additional <code>&lt;key&gt;=&lt;value&gt;</code> option values</td>
</tr>
<tr>
<td></td>
<td><code>--ignore-config</code></td>
<td>Do not read default configuration files</td>
</tr>
</tbody>
</table>
<tr>
<td colspan="4"><strong>Authentication Options</strong></td>
</tr>
## Authentication Options
<table>
<tbody valign="top">
<tr>
<td><code>-u</code></td>
<td><code>--username</code></td>
<td width="28%"><code>--username</code></td>
<td>Username to login with</td>
</tr>
<tr>
@ -261,13 +269,17 @@
<td><code>--netrc</code></td>
<td>Enable .netrc authentication data</td>
</tr>
</tbody>
</table>
<tr>
<td colspan="4"><strong>Selection Options</strong></td>
</tr>
## Selection Options
<table>
<tbody valign="top">
<tr>
<td></td>
<td><code>--download-archive</code></td>
<td width="28%"><code>--download-archive</code></td>
<td>Record all downloaded or skipped files in FILE and skip downloading any file already in it</td>
</tr>
<tr>
@ -293,20 +305,24 @@
<tr>
<td></td>
<td><code>--filter</code></td>
<td>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 <code>-K</code>. Example: --filter "image_width >= 1000 and rating in (<code>s</code>, <code>q</code>)"</td>
<td>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 <code>-K</code>. Example: --filter "image_width &gt;= 1000 and rating in (<code>s</code>, <code>q</code>)"</td>
</tr>
<tr>
<td></td>
<td><code>--chapter-filter</code></td>
<td>Like <code>--filter</code>, but applies to manga chapters and other delegated URLs</td>
</tr>
</tbody>
</table>
<tr>
<td colspan="4"><strong>Post-processing Options</strong></td>
</tr>
## Post-processing Options
<table>
<tbody valign="top">
<tr>
<td></td>
<td><code>--zip</code></td>
<td width="28%"><code>--zip</code></td>
<td>Store downloaded files in a ZIP archive</td>
</tr>
<tr>
@ -361,3 +377,4 @@
</tr>
</tbody>
</table>

@ -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
<!-- auto-generated by {} -->
{}
"""
TABLE = """
## {}
<table>
<thead>
<tr>
<th></th>
<th width="26%"></th>
<th></th>
</tr>
</thead>
<tbody valign="top">
{}
</tbody>
</table>
"""
""".format
ROW = """<tr>
<td>{}</td>
<td{}>{}</td>
<td>{}</td>
</tr>""".format
tbody = []
append = tbody.append
sub = re.compile(r"'([^']+)'").sub
tables = []
for group in option.build_parser()._action_groups[2:]:
append('\n<tr>\n <td colspan="3"><strong>' +
group.title + '</strong></td>\n</tr>')
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 = "<code>" + short + "</code>"
if long:
long = '<code>' + long + "</code>"
if help:
help = help.replace("<", "&lt;").replace(">", "&gt;")
help = sub("<code>\\1</code>", help)
append(ROW(short, width, long, help))
width = ""
append("<tr>")
append(" <td>" + short + "</td>")
append(" <td>" + long + "</td>")
append(" <td>" + sub("<code>\\1</code>", help) + "</td>")
append("</tr>")
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),
))

Loading…
Cancel
Save