simplify 'docs/options.md' generation
use the plain text output from '--help' instead of trying to generate 'fancy' HTML with Markdown restrictions
This commit is contained in:
543
docs/options.md
543
docs/options.md
@@ -3,442 +3,119 @@
|
||||
<!-- auto-generated by scripts/options.py -->
|
||||
|
||||
|
||||
## General Options
|
||||
## General Options:
|
||||
-h, --help Print this help message and exit
|
||||
--version Print program version and exit
|
||||
-i, --input-file FILE Download URLs found in FILE ('-' for stdin).
|
||||
More than one --input-file can be specified
|
||||
-d, --destination PATH Target location for file downloads
|
||||
-D, --directory PATH Exact location for file downloads
|
||||
-f, --filename FORMAT Filename format string for downloaded files
|
||||
('/O' for "original" filenames)
|
||||
--proxy URL Use the specified proxy
|
||||
--source-address IP Client-side IP address to bind to
|
||||
--user-agent UA User-Agent request header
|
||||
--clear-cache MODULE Delete cached login sessions, cookies, etc. for
|
||||
MODULE (ALL to delete everything)
|
||||
--cookies FILE File to load additional cookies from
|
||||
--cookies-from-browser BROWSER[+KEYRING][:PROFILE][::CONTAINER]
|
||||
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)
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td><code>‑h</code></td>
|
||||
<td><code>‑‑help</code></td>
|
||||
<td></td>
|
||||
<td>Print this help message and exit</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑version</code></td>
|
||||
<td></td>
|
||||
<td>Print program version and exit</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑i</code></td>
|
||||
<td><code>‑‑input‑file</code></td>
|
||||
<td><code>FILE</code></td>
|
||||
<td>Download URLs found in FILE (<code>-</code> for stdin). More than one --input-file can be specified</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑d</code></td>
|
||||
<td><code>‑‑destination</code></td>
|
||||
<td><code>PATH</code></td>
|
||||
<td>Target location for file downloads</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑D</code></td>
|
||||
<td><code>‑‑directory</code></td>
|
||||
<td><code>PATH</code></td>
|
||||
<td>Exact location for file downloads</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑f</code></td>
|
||||
<td><code>‑‑filename</code></td>
|
||||
<td><code>FORMAT</code></td>
|
||||
<td>Filename format string for downloaded files (<code>/O</code> for "original" filenames)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑proxy</code></td>
|
||||
<td><code>URL</code></td>
|
||||
<td>Use the specified proxy</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑source‑address</code></td>
|
||||
<td><code>IP</code></td>
|
||||
<td>Client-side IP address to bind to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑user‑agent</code></td>
|
||||
<td><code>UA</code></td>
|
||||
<td>User-Agent request header</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑clear‑cache</code></td>
|
||||
<td><code>MODULE</code></td>
|
||||
<td>Delete cached login sessions, cookies, etc. for MODULE (ALL to delete everything)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑cookies</code></td>
|
||||
<td><code>FILE</code></td>
|
||||
<td>File to load additional cookies from</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑cookies‑from‑browser</code></td>
|
||||
<td><code>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>
|
||||
## Output Options:
|
||||
-q, --quiet Activate quiet mode
|
||||
-v, --verbose Print various debugging information
|
||||
-g, --get-urls Print URLs instead of downloading
|
||||
-G, --resolve-urls Print URLs instead of downloading; resolve
|
||||
intermediary URLs
|
||||
-j, --dump-json Print JSON information
|
||||
-s, --simulate Simulate data extraction; do not download
|
||||
anything
|
||||
-E, --extractor-info Print extractor defaults and settings
|
||||
-K, --list-keywords Print a list of available keywords and example
|
||||
values for the given URLs
|
||||
--list-modules Print a list of available extractor modules
|
||||
--list-extractors Print a list of extractor classes with
|
||||
description, (sub)category and example URL
|
||||
--write-log FILE Write logging output to FILE
|
||||
--write-unsupported FILE Write URLs, which get emitted by other
|
||||
extractors but cannot be handled, to FILE
|
||||
--write-pages Write downloaded intermediary pages to files in
|
||||
the current directory to debug problems
|
||||
|
||||
## Downloader Options:
|
||||
-r, --limit-rate RATE Maximum download rate (e.g. 500k or 2.5M)
|
||||
-R, --retries N Maximum number of retries for failed HTTP
|
||||
requests or -1 for infinite retries (default: 4)
|
||||
--http-timeout SECONDS Timeout for HTTP connections (default: 30.0)
|
||||
--sleep SECONDS Number of seconds to wait before each download.
|
||||
This can be either a constant value or a range
|
||||
(e.g. 2.7 or 2.0-3.5)
|
||||
--sleep-request SECONDS Number of seconds to wait between HTTP requests
|
||||
during data extraction
|
||||
--sleep-extractor SECONDS Number of seconds to wait before starting data
|
||||
extraction for an input URL
|
||||
--filesize-min SIZE Do not download files smaller than SIZE (e.g.
|
||||
500k or 2.5M)
|
||||
--filesize-max SIZE Do not download files larger than SIZE (e.g.
|
||||
500k or 2.5M)
|
||||
--chunk-size SIZE Size of in-memory data chunks (default: 32k)
|
||||
--no-part Do not use .part files
|
||||
--no-skip Do not skip downloads; overwrite existing files
|
||||
--no-mtime Do not set file modification times according to
|
||||
Last-Modified HTTP response headers
|
||||
--no-download Do not download any files
|
||||
--no-postprocessors Do not run any post processors
|
||||
--no-check-certificate Disable HTTPS certificate validation
|
||||
|
||||
## Output Options
|
||||
## Configuration Options:
|
||||
-c, --config FILE Additional configuration files
|
||||
-o, --option OPT Additional '<key>=<value>' option values
|
||||
--ignore-config Do not read default configuration files
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td><code>‑q</code></td>
|
||||
<td><code>‑‑quiet</code></td>
|
||||
<td></td>
|
||||
<td>Activate quiet mode</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑v</code></td>
|
||||
<td><code>‑‑verbose</code></td>
|
||||
<td></td>
|
||||
<td>Print various debugging information</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑g</code></td>
|
||||
<td><code>‑‑get‑urls</code></td>
|
||||
<td></td>
|
||||
<td>Print URLs instead of downloading</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑G</code></td>
|
||||
<td><code>‑‑resolve‑urls</code></td>
|
||||
<td></td>
|
||||
<td>Print URLs instead of downloading; resolve intermediary URLs</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑j</code></td>
|
||||
<td><code>‑‑dump‑json</code></td>
|
||||
<td></td>
|
||||
<td>Print JSON information</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑s</code></td>
|
||||
<td><code>‑‑simulate</code></td>
|
||||
<td></td>
|
||||
<td>Simulate data extraction; do not download anything</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑E</code></td>
|
||||
<td><code>‑‑extractor‑info</code></td>
|
||||
<td></td>
|
||||
<td>Print extractor defaults and settings</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑K</code></td>
|
||||
<td><code>‑‑list‑keywords</code></td>
|
||||
<td></td>
|
||||
<td>Print a list of available keywords and example values for the given URLs</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑list‑modules</code></td>
|
||||
<td></td>
|
||||
<td>Print a list of available extractor modules</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑list‑extractors</code></td>
|
||||
<td></td>
|
||||
<td>Print a list of extractor classes with description, (sub)category and example URL</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑write‑log</code></td>
|
||||
<td><code>FILE</code></td>
|
||||
<td>Write logging output to FILE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑write‑unsupported</code></td>
|
||||
<td><code>FILE</code></td>
|
||||
<td>Write URLs, which get emitted by other extractors but cannot be handled, to FILE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑write‑pages</code></td>
|
||||
<td></td>
|
||||
<td>Write downloaded intermediary pages to files in the current directory to debug problems</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
## Authentication Options:
|
||||
-u, --username USER Username to login with
|
||||
-p, --password PASS Password belonging to the given username
|
||||
--netrc Enable .netrc authentication data
|
||||
|
||||
## Selection Options:
|
||||
--download-archive FILE Record all downloaded or skipped files in FILE
|
||||
and skip downloading any file already in it
|
||||
-A, --abort N Stop current extractor run after N consecutive
|
||||
file downloads were skipped
|
||||
-T, --terminate N Stop current and parent extractor runs after N
|
||||
consecutive file downloads were skipped
|
||||
--range RANGE Index range(s) specifying which files to
|
||||
download. These can be either a constant value,
|
||||
range, or slice (e.g. '5', '8-20', or '1:24:3')
|
||||
--chapter-range RANGE Like '--range', but applies to manga chapters
|
||||
and other delegated URLs
|
||||
--filter EXPR 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 EXPR Like '--filter', but applies to manga chapters
|
||||
and other delegated URLs
|
||||
|
||||
## Downloader Options
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td><code>‑r</code></td>
|
||||
<td><code>‑‑limit‑rate</code></td>
|
||||
<td><code>RATE</code></td>
|
||||
<td>Maximum download rate (e.g. 500k or 2.5M)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑R</code></td>
|
||||
<td><code>‑‑retries</code></td>
|
||||
<td><code>N</code></td>
|
||||
<td>Maximum number of retries for failed HTTP requests or -1 for infinite retries (default: 4)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑http‑timeout</code></td>
|
||||
<td><code>SECONDS</code></td>
|
||||
<td>Timeout for HTTP connections (default: 30.0)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑sleep</code></td>
|
||||
<td><code>SECONDS</code></td>
|
||||
<td>Number of seconds to wait before each download. This can be either a constant value or a range (e.g. 2.7 or 2.0-3.5)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑sleep‑request</code></td>
|
||||
<td><code>SECONDS</code></td>
|
||||
<td>Number of seconds to wait between HTTP requests during data extraction</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑sleep‑extractor</code></td>
|
||||
<td><code>SECONDS</code></td>
|
||||
<td>Number of seconds to wait before starting data extraction for an input URL</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑filesize‑min</code></td>
|
||||
<td><code>SIZE</code></td>
|
||||
<td>Do not download files smaller than SIZE (e.g. 500k or 2.5M)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑filesize‑max</code></td>
|
||||
<td><code>SIZE</code></td>
|
||||
<td>Do not download files larger than SIZE (e.g. 500k or 2.5M)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑chunk‑size</code></td>
|
||||
<td><code>SIZE</code></td>
|
||||
<td>Size of in-memory data chunks (default: 32k)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑no‑part</code></td>
|
||||
<td></td>
|
||||
<td>Do not use .part files</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑no‑skip</code></td>
|
||||
<td></td>
|
||||
<td>Do not skip downloads; overwrite existing files</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑no‑mtime</code></td>
|
||||
<td></td>
|
||||
<td>Do not set file modification times according to Last-Modified HTTP response headers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑no‑download</code></td>
|
||||
<td></td>
|
||||
<td>Do not download any files</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑no‑postprocessors</code></td>
|
||||
<td></td>
|
||||
<td>Do not run any post processors</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑no‑check‑certificate</code></td>
|
||||
<td></td>
|
||||
<td>Disable HTTPS certificate validation</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Configuration Options
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td><code>‑c</code></td>
|
||||
<td><code>‑‑config</code></td>
|
||||
<td><code>FILE</code></td>
|
||||
<td>Additional configuration files</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑o</code></td>
|
||||
<td><code>‑‑option</code></td>
|
||||
<td><code>OPT</code></td>
|
||||
<td>Additional <code><key>=<value></code> option values</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑ignore‑config</code></td>
|
||||
<td></td>
|
||||
<td>Do not read default configuration files</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Authentication Options
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td><code>‑u</code></td>
|
||||
<td><code>‑‑username</code></td>
|
||||
<td><code>USER</code></td>
|
||||
<td>Username to login with</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑p</code></td>
|
||||
<td><code>‑‑password</code></td>
|
||||
<td><code>PASS</code></td>
|
||||
<td>Password belonging to the given username</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑netrc</code></td>
|
||||
<td></td>
|
||||
<td>Enable .netrc authentication data</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Selection Options
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑download‑archive</code></td>
|
||||
<td><code>FILE</code></td>
|
||||
<td>Record all downloaded or skipped files in FILE and skip downloading any file already in it</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑A</code></td>
|
||||
<td><code>‑‑abort</code></td>
|
||||
<td><code>N</code></td>
|
||||
<td>Stop current extractor run after N consecutive file downloads were skipped</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑T</code></td>
|
||||
<td><code>‑‑terminate</code></td>
|
||||
<td><code>N</code></td>
|
||||
<td>Stop current and parent extractor runs after N consecutive file downloads were skipped</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑range</code></td>
|
||||
<td><code>RANGE</code></td>
|
||||
<td>Index range(s) specifying which files to download. These can be either a constant value, range, or slice (e.g. <code>5</code>, <code>8-20</code>, or <code>1:24:3</code>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑chapter‑range</code></td>
|
||||
<td><code>RANGE</code></td>
|
||||
<td>Like <code>--range</code>, but applies to manga chapters and other delegated URLs</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑filter</code></td>
|
||||
<td><code>EXPR</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>. <br />Example: --filter "image_width >= 1000 and rating in ('s', 'q')"</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑chapter‑filter</code></td>
|
||||
<td><code>EXPR</code></td>
|
||||
<td>Like <code>--filter</code>, but applies to manga chapters and other delegated URLs</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
## Post-processing Options
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑zip</code></td>
|
||||
<td></td>
|
||||
<td>Store downloaded files in a ZIP archive</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑ugoira‑conv</code></td>
|
||||
<td></td>
|
||||
<td>Convert Pixiv Ugoira to WebM (requires FFmpeg)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑ugoira‑conv‑lossless</code></td>
|
||||
<td></td>
|
||||
<td>Convert Pixiv Ugoira to WebM in VP9 lossless mode</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑ugoira‑conv‑copy</code></td>
|
||||
<td></td>
|
||||
<td>Convert Pixiv Ugoira to MKV without re-encoding any frames</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑write‑metadata</code></td>
|
||||
<td></td>
|
||||
<td>Write metadata to separate JSON files</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑write‑info‑json</code></td>
|
||||
<td></td>
|
||||
<td>Write gallery metadata to a info.json file</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑write‑tags</code></td>
|
||||
<td></td>
|
||||
<td>Write image tags to separate text files</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑mtime‑from‑date</code></td>
|
||||
<td></td>
|
||||
<td>Set file modification times according to <code>date</code> metadata</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑exec</code></td>
|
||||
<td><code>CMD</code></td>
|
||||
<td>Execute CMD for each downloaded file. <br />Example: --exec "convert {} {}.png && rm {}"</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><code>‑‑exec‑after</code></td>
|
||||
<td><code>CMD</code></td>
|
||||
<td>Execute CMD after all files were downloaded successfully. <br />Example: --exec-after "cd {} && convert * ../doc.pdf"</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>‑P</code></td>
|
||||
<td><code>‑‑postprocessor</code></td>
|
||||
<td><code>NAME</code></td>
|
||||
<td>Activate the specified post processor</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Post-processing Options:
|
||||
--zip Store downloaded files in a ZIP archive
|
||||
--ugoira-conv Convert Pixiv Ugoira to WebM (requires FFmpeg)
|
||||
--ugoira-conv-lossless Convert Pixiv Ugoira to WebM in VP9 lossless
|
||||
mode
|
||||
--ugoira-conv-copy Convert Pixiv Ugoira to MKV without re-encoding
|
||||
any frames
|
||||
--write-metadata Write metadata to separate JSON files
|
||||
--write-info-json Write gallery metadata to a info.json file
|
||||
--write-tags Write image tags to separate text files
|
||||
--mtime-from-date Set file modification times according to 'date'
|
||||
metadata
|
||||
--exec CMD Execute CMD for each downloaded file. Example:
|
||||
--exec "convert {} {}.png && rm {}"
|
||||
--exec-after CMD Execute CMD after all files were downloaded
|
||||
successfully. Example: --exec-after "cd {} &&
|
||||
convert * ../doc.pdf"
|
||||
-P, --postprocessor NAME Activate the specified post processor
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
|
||||
"""Generate a Markdown document listing gallery-dl's command-line arguments"""
|
||||
"""Generate a document listing gallery-dl's command-line arguments"""
|
||||
|
||||
import os
|
||||
import re
|
||||
from argparse import SUPPRESS
|
||||
import sys
|
||||
|
||||
import util
|
||||
from gallery_dl import option
|
||||
@@ -21,71 +21,22 @@ TEMPLATE = """# Command-Line Options
|
||||
|
||||
<!-- auto-generated by {} -->
|
||||
|
||||
{}
|
||||
"""
|
||||
|
||||
TABLE = """
|
||||
## {}
|
||||
|
||||
<table>
|
||||
<tbody valign="top">
|
||||
{}
|
||||
</tbody>
|
||||
</table>
|
||||
""".format
|
||||
|
||||
ROW = """<tr>
|
||||
<td>{}</td>
|
||||
<td>{}</td>
|
||||
<td>{}</td>
|
||||
<td>{}</td>
|
||||
</tr>""".format
|
||||
{}"""
|
||||
|
||||
|
||||
tables = []
|
||||
sub = re.compile(r"'([^']+)'").sub
|
||||
nb_hyphen = "‑" # non-breaking hyphen
|
||||
parser = option.build_parser()
|
||||
parser.usage = ""
|
||||
|
||||
for group in option.build_parser()._action_groups[2:]:
|
||||
|
||||
tbody = []
|
||||
|
||||
for action in group._group_actions:
|
||||
help = action.help
|
||||
if help == SUPPRESS:
|
||||
continue
|
||||
meta = action.metavar or ""
|
||||
|
||||
try:
|
||||
short, long = action.option_strings
|
||||
except ValueError:
|
||||
try:
|
||||
long = action.option_strings[0]
|
||||
except IndexError:
|
||||
continue
|
||||
short = ""
|
||||
|
||||
if short:
|
||||
short = "<code>" + short.replace("-", nb_hyphen) + "</code>"
|
||||
if long:
|
||||
long = "<code>" + long.replace("-", nb_hyphen) + "</code>"
|
||||
if meta:
|
||||
meta = "<code>" + meta.partition("[")[0] + "</code>"
|
||||
if help:
|
||||
help = help.replace("<", "<").replace(">", ">")
|
||||
if "Example: " in help:
|
||||
help, sep, example = help.partition("Example: ")
|
||||
help = sub("<code>\\1</code>", help) + "<br />" + sep + example
|
||||
else:
|
||||
help = sub("<code>\\1</code>", help)
|
||||
|
||||
tbody.append(ROW(short, long, meta, help))
|
||||
|
||||
tables.append(TABLE(group.title, "\n".join(tbody)))
|
||||
opts = parser.format_help()
|
||||
opts = opts[8:] # strip 'usage'
|
||||
opts = re.sub(r"(?m)^(\w+.*)", "## \\1", opts) # group names to headings
|
||||
opts = opts.replace("\n ", "\n ") # indent by 4
|
||||
|
||||
|
||||
with open(util.path("docs", "options.md"), "w", encoding="utf-8") as fp:
|
||||
outfile = sys.argv[1] if len(sys.argv) > 1 else util.path("docs", "options.md")
|
||||
with open(outfile, "w", encoding="utf-8") as fp:
|
||||
|
||||
fp.write(TEMPLATE.format(
|
||||
"/".join(os.path.normpath(__file__).split(os.sep)[-2:]),
|
||||
"\n".join(tables),
|
||||
opts,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user