summaryrefslogtreecommitdiff
path: root/repo/www
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-08-18 22:30:19 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-08-18 22:30:19 +0200
commitb5205f3253e745083f55f40f4a5e64cb2da39aac (patch)
treec754b027780304bccfe114789839b312b96b8952 /repo/www
parent205b6d12ff5673bd8ae59f827f07b69771b9dfee (diff)
downloadmemory-leaks-b5205f3253e745083f55f40f4a5e64cb2da39aac.tar.xz
Pass filters to generation scripts explicitly
Diffstat (limited to 'repo/www')
-rw-r--r--repo/www/Makefile3
-rwxr-xr-xrepo/www/generate-index.py6
-rwxr-xr-xrepo/www/generate-page.py5
-rw-r--r--repo/www/helpers.py5
4 files changed, 16 insertions, 3 deletions
diff --git a/repo/www/Makefile b/repo/www/Makefile
index d4392d1..9a804db 100644
--- a/repo/www/Makefile
+++ b/repo/www/Makefile
@@ -14,6 +14,7 @@ text_patterns = $(foreach ext,$(TEXT_FILES),'$(TOP_DIR)/**.$(ext)')
text_folders = $(call dirnames,$(shell git ls-files $(text_patterns)))
top_readme = $(shell git ls-files $(addprefix $(TOP_DIR)/README.,$(TEXT_FILES)))
html_template = template.html
+lua_filters = convert-internal-links.lua
all: site
@@ -53,6 +54,7 @@ $(pages) $(indices): $(html_template)
$(pages): $(OUT_DIR)/%.html:
$(call v,PAGE,$*) TEXT_FILES="$(TEXT_FILES)" \
./generate-page.py --site-title="$$(cat $(title))" --title="$*" \
+ $(foreach f,$(lua_filters),--lua-filter $(f)) \
--template=$(html_template) $< $@
top_index = $(OUT_DIR)/index.html
@@ -66,6 +68,7 @@ $(subindices): index_options = --site-title="$$(cat $(title))"
$(indices): $(OUT_DIR)/%index.html:
$(call v,INDEX,$*) TEXT_FILES="$(TEXT_FILES)" \
./generate-index.py $(index_options) --template=$(html_template) \
+ $(foreach f,$(lua_filters),--lua-filter $(f)) \
$(site_tree) "$(patsubst %/,%,$*)" $@
clean:
diff --git a/repo/www/generate-index.py b/repo/www/generate-index.py
index 7eed97a..316a0f3 100755
--- a/repo/www/generate-index.py
+++ b/repo/www/generate-index.py
@@ -21,6 +21,10 @@ def parse_arguments():
'--site-title', help='Prefix to add to <title>.'
)
parser.add_argument(
+ '--lua-filter', dest='filters', action='append',
+ help='Lua filter to run the page through.'
+ )
+ parser.add_argument(
'site_tree', help='JSON file describing the page tree.'
)
parser.add_argument(
@@ -111,7 +115,7 @@ def main(arguments):
page.flush()
pandoc(page.name, arguments.output, arguments.template,
- site_title=arguments.site_title)
+ arguments.filters, site_title=arguments.site_title)
if __name__ == '__main__':
diff --git a/repo/www/generate-page.py b/repo/www/generate-page.py
index 372e8a2..c9fa0e4 100755
--- a/repo/www/generate-page.py
+++ b/repo/www/generate-page.py
@@ -14,6 +14,10 @@ def parse_arguments():
'--site-title', help='Prefix to add to <title>.'
)
parser.add_argument(
+ '--lua-filter', dest='filters', action='append',
+ help='Lua filter to run the page through.'
+ )
+ parser.add_argument(
'--title', help='Page title.'
)
parser.add_argument(
@@ -30,6 +34,7 @@ def main(arguments):
arguments.page,
arguments.output,
arguments.template,
+ arguments.filters,
title=arguments.title,
site_title=arguments.site_title
)
diff --git a/repo/www/helpers.py b/repo/www/helpers.py
index 16cd496..434ef6c 100644
--- a/repo/www/helpers.py
+++ b/repo/www/helpers.py
@@ -1,5 +1,6 @@
from collections import defaultdict
from dataclasses import dataclass, field
+from itertools import chain
from os import path
from subprocess import run
from typing import Iterator
@@ -55,10 +56,10 @@ def deserialize_directories(directories):
}
-def pandoc(page, output, template, title=None, site_title=None):
+def pandoc(page, output, template, filters, title=None, site_title=None):
cmd = (
'pandoc', '-s', page, '-o', output, '--template', template,
- '--lua-filter', 'convert-internal-links.lua'
+ *chain(*(('--lua-filter', f) for f in filters))
)
if title is not None: