#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2023 Mike Fährmann # # 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 # published by the Free Software Foundation. """Generate a Markdown document listing gallery-dl's command-line arguments""" import os import re from argparse import SUPPRESS import util from gallery_dl import option TEMPLATE = """# Command-Line Options {} """ TABLE = """ ## {}
" + short.replace("-", nb_hyphen) + ""
if long:
long = "" + long.replace("-", nb_hyphen) + ""
if meta:
meta = "" + meta.partition("[")[0] + ""
if help:
help = help.replace("<", "<").replace(">", ">")
if "Example: " in help:
help, sep, example = help.partition("Example: ")
help = sub("\\1", help) + "\\1", help)
tbody.append(ROW(short, long, meta, help))
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(tables),
))