Updated docs build to use cog
This commit is contained in:
@@ -5,13 +5,8 @@ from click.testing import CliRunner
|
||||
|
||||
from osxphotos.cli import cli_main
|
||||
from osxphotos.cli.help import strip_html_comments
|
||||
from osxphotos.phototemplate import (
|
||||
FILTER_VALUES,
|
||||
TEMPLATE_SUBSTITUTIONS,
|
||||
TEMPLATE_SUBSTITUTIONS_MULTI_VALUED,
|
||||
)
|
||||
from osxphotos.phototemplate import get_template_field_table, get_template_help
|
||||
|
||||
TEMPLATE_HELP = "osxphotos/phototemplate.md"
|
||||
TUTORIAL_HELP = "osxphotos/tutorial.md"
|
||||
TEMPLATE_HELP_DOC = "docsrc/source/template_help.md"
|
||||
|
||||
@@ -25,26 +20,6 @@ TEMPLATE_HELP_START = (
|
||||
)
|
||||
TEMPLATE_HELP_STOP = "<!-- OSXPHOTOS-TEMPLATE-HELP:END -->"
|
||||
|
||||
TEMPLATE_FILTER_TABLE_START = (
|
||||
"!-- OSXPHOTOS-FILTER-TABLE:START - Do not remove or modify this section -->"
|
||||
)
|
||||
TEMPLATE_FILTER_TABLE_STOP = "<!-- OSXPHOTOS-FILTER-TABLE:END -->"
|
||||
|
||||
|
||||
def generate_template_table():
|
||||
"""generate template substitution table for README.md"""
|
||||
|
||||
template_table = "| Substitution | Description |"
|
||||
template_table += "\n|--------------|-------------|"
|
||||
for subst, descr in [
|
||||
*TEMPLATE_SUBSTITUTIONS.items(),
|
||||
*TEMPLATE_SUBSTITUTIONS_MULTI_VALUED.items(),
|
||||
]:
|
||||
# replace '|' with '\|' to avoid markdown parsing issues (e.g. in {pipe} description)
|
||||
descr = descr.replace("'|'", "'\|'")
|
||||
template_table += f"\n|{subst}|{descr}|"
|
||||
return template_table
|
||||
|
||||
|
||||
def replace_text(text, start_tag, stop_tag, replacement_text, prefix="", postfix=""):
|
||||
"""replace text between start/stop tags with new text
|
||||
@@ -81,27 +56,14 @@ def replace_text(text, start_tag, stop_tag, replacement_text, prefix="", postfix
|
||||
def main():
|
||||
"""generate docsrc/source/template_help.md"""
|
||||
|
||||
# update phototemplate.md with info on filters
|
||||
filter_help = "\n".join(f"- `{f}`: {descr}" for f, descr in FILTER_VALUES.items())
|
||||
with open(TEMPLATE_HELP) as file:
|
||||
template_help = file.read()
|
||||
|
||||
template_help = replace_text(
|
||||
template_help,
|
||||
TEMPLATE_FILTER_TABLE_START,
|
||||
TEMPLATE_FILTER_TABLE_STOP,
|
||||
filter_help,
|
||||
prefix="\n",
|
||||
postfix="\n",
|
||||
)
|
||||
|
||||
template_help = get_template_help()
|
||||
# Add header
|
||||
template_help = "# osxphotos Template System\n\n" + template_help
|
||||
template_help = "# OSXPhotos Template System\n\n" + template_help
|
||||
|
||||
# Add the template substitution table
|
||||
print("Adding template substitution table")
|
||||
template_help += "\n\n## Template Substitutions\n\n"
|
||||
template_table = generate_template_table()
|
||||
template_table = get_template_field_table()
|
||||
template_help += template_table
|
||||
|
||||
template_help = strip_html_comments(template_help)
|
||||
|
||||
Reference in New Issue
Block a user