update docs/supportedsites
- use Markdown with inline HTML instead of reStructuredText - move file from docs/supportedsites.rst to docs/supportedsites.md - update Makefile, README, etc
This commit is contained in:
@@ -128,7 +128,7 @@ upload-pypi() {
|
||||
ROOTDIR="$(realpath "$(dirname "$0")/..")/"
|
||||
README="README.rst"
|
||||
CHANGELOG="CHANGELOG.md"
|
||||
SUPPORTEDSITES="./docs/supportedsites.rst"
|
||||
SUPPORTEDSITES="./docs/supportedsites.md"
|
||||
|
||||
LASTTAG="$(git describe --abbrev=0 --tags)"
|
||||
OLDVERSION="${LASTTAG#v}"
|
||||
|
||||
@@ -167,11 +167,14 @@ SUBCATEGORY_MAP = {
|
||||
},
|
||||
}
|
||||
|
||||
_OAUTH = "`OAuth <https://github.com/mikf/gallery-dl#oauth>`__"
|
||||
_COOKIES = "`Cookies <https://github.com/mikf/gallery-dl#cookies>`__"
|
||||
_APIKEY_DB = "`API Key <configuration.rst#extractorderpibooruapi-key>`__"
|
||||
_APIKEY_WH = "`API Key <configuration.rst#extractorwallhavenapi-key>`__"
|
||||
_APIKEY_WY = "`API Key <configuration.rst#extractorweasylapi-key>`__"
|
||||
_OAUTH = '<a href="https://github.com/mikf/gallery-dl#oauth">OAuth</a>'
|
||||
_COOKIES = '<a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a>'
|
||||
_APIKEY_DB = \
|
||||
'<a href="configuration.rst#extractorderpibooruapi-key">API Key</a>'
|
||||
_APIKEY_WH = \
|
||||
'<a href="configuration.rst#extractorwallhavenapi-key">API Key</a>'
|
||||
_APIKEY_WY = \
|
||||
'<a href="configuration.rst#extractorweasylapi-key">API Key</a>'
|
||||
|
||||
AUTH_MAP = {
|
||||
"aryion" : "Supported",
|
||||
@@ -314,55 +317,48 @@ COLUMNS = (
|
||||
)
|
||||
|
||||
|
||||
def write_output(fp, columns, categories, domains):
|
||||
def generate_output(columns, categories, domains):
|
||||
|
||||
def pad(output, col, category=None):
|
||||
size = col[1]
|
||||
output = output if isinstance(output, str) else col[2](output)
|
||||
thead = []
|
||||
append = thead.append
|
||||
append("<tr>")
|
||||
for column in columns:
|
||||
append(" <th>" + column[0] + "</th>")
|
||||
append("</tr>")
|
||||
|
||||
if len(output) > size and col[0][0] != "A":
|
||||
sub = "|{}-{}|".format(category, col[0][0])
|
||||
subs.append((sub, output))
|
||||
output = sub
|
||||
|
||||
return output + " " * (size - len(output))
|
||||
|
||||
w = fp.write
|
||||
subs = []
|
||||
|
||||
# caption
|
||||
w("Supported Sites\n")
|
||||
w("===============\n")
|
||||
w("..\n generated by {}\n\n".format(
|
||||
"/".join(os.path.normpath(__file__).split(os.sep)[-2:])))
|
||||
w("Consider all sites to be NSFW, unless otherwise known.\n\n")
|
||||
|
||||
# table head
|
||||
sep = " ".join("=" * c[1] for c in columns) + "\n"
|
||||
w(sep)
|
||||
w(" ".join(pad(c[0], c) for c in columns).strip() + "\n")
|
||||
w(sep)
|
||||
|
||||
# table body
|
||||
tbody = []
|
||||
append = tbody.append
|
||||
clist = sorted(categories.items(), key=category_key)
|
||||
for category, subcategories in clist:
|
||||
domain = domains[category]
|
||||
w(" ".join(
|
||||
pad(col[2](category, subcategories, domain), col, category)
|
||||
for col in columns
|
||||
).strip())
|
||||
w("\n")
|
||||
append("<tr>")
|
||||
for column in columns:
|
||||
domain = domains[category]
|
||||
content = column[2](category, subcategories, domain)
|
||||
append(" <td>" + content + "</td>")
|
||||
append("</tr>")
|
||||
|
||||
# table bottom
|
||||
w(sep)
|
||||
w("\n")
|
||||
TEMPLATE = """# Supported Sites
|
||||
|
||||
# substitutions
|
||||
for sub, value in subs:
|
||||
w(".. {} replace:: {}\n".format(sub, value))
|
||||
<!-- auto-generated by {} -->
|
||||
Consider all sites to be NSFW unless otherwise known.
|
||||
|
||||
<table>
|
||||
<thead valign="bottom">
|
||||
{}
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
{}
|
||||
</tbody>
|
||||
</table>
|
||||
"""
|
||||
return TEMPLATE.format(
|
||||
"/".join(os.path.normpath(__file__).split(os.sep)[-2:]),
|
||||
"\n".join(thead),
|
||||
"\n".join(tbody),
|
||||
)
|
||||
|
||||
|
||||
categories, domains = build_extractor_list()
|
||||
outfile = sys.argv[1] if len(sys.argv) > 1 else "supportedsites.rst"
|
||||
with open(util.path("docs", outfile), "w") as file:
|
||||
write_output(file, COLUMNS, categories, domains)
|
||||
outfile = sys.argv[1] if len(sys.argv) > 1 else "supportedsites.md"
|
||||
with open(util.path("docs", outfile), "w") as fp:
|
||||
fp.write(generate_output(COLUMNS, categories, domains))
|
||||
|
||||
Reference in New Issue
Block a user