summaryrefslogtreecommitdiff
path: root/repo/www/make-deps.py
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-03-25 18:48:12 +0100
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-03-25 21:13:44 +0100
commit1b7eebb3563dab36584247bcab1d8e3b4e78833b (patch)
treedfff7b3bf09b749795cf7d451c2a1fa8a4f60334 /repo/www/make-deps.py
parent355b77c1fff8132cd3445c375140cf51e736d8a0 (diff)
downloadmemory-leaks-1b7eebb3563dab36584247bcab1d8e3b4e78833b.tar.xz
Split index generation and HTML conversion
So that I can re-use generate-index.py for READMEs.
Diffstat (limited to 'repo/www/make-deps.py')
-rwxr-xr-xrepo/www/make-deps.py91
1 files changed, 0 insertions, 91 deletions
diff --git a/repo/www/make-deps.py b/repo/www/make-deps.py
deleted file mode 100755
index d88d333..0000000
--- a/repo/www/make-deps.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python3
-
-"""Write dependencies for all website pages in makefile syntax.
-
-We want to compute:
-
-- a list of leaf pages,
-- a list of auto-generated indices,
-- dependencies for leaf pages:
- OUTPUT/foo/bar.html: foo/bar.txt | OUTPUT/foo
- - special case for READMEs:
- OUTPUT/foo/index.html: foo/README.txt foo | OUTPUT/foo
-"""
-
-from os import path
-from sys import argv, exit
-
-from git import Repo
-
-from helpers import compute_directories
-
-
-def parse_arguments(args):
- if len(args) != 3:
- exit(f'Usage: {argv[0]} EXTENSIONS OUTPUT-DIR')
-
- return argv[1].split(), argv[2]
-
-
-def pjoin(directory, item):
- return (
- path.join(directory, item)
- if item # Avoid trailing slash for top-level files.
- else directory
- )
-
-
-def write_dependencies(deps_file, directories, top_dir, out_dir):
- pages = list()
- indices = list()
- autoindices = list()
-
- for dpath, d in directories.items():
- autoindex = True
-
- src_dir = pjoin(top_dir, dpath)
-
- for f in d.files:
- src_path = path.join(src_dir, f)
-
- name, _ = path.splitext(f)
- deps = [src_path]
- target = pages
-
- if name == 'README':
- name = 'index'
- deps.append(src_dir)
- target = indices
- autoindex = False
-
- html_dir = pjoin(out_dir, dpath)
- html_path = path.join(html_dir, name+'.html')
-
- print(f'{html_path}: {" ".join(deps)} | {html_dir}', file=deps_file)
- target.append(html_path)
-
- if autoindex:
- autoindices.append(
- path.join(out_dir, dpath, 'index.html')
- )
-
- print(file=deps_file)
- print(f'pages = {" ".join(pages)}', file=deps_file)
- print(f'indices = {" ".join(indices)}', file=deps_file)
- print(f'autoindices = {" ".join(autoindices)}', file=deps_file)
-
-
-def main(arguments):
- extensions, out_dir = parse_arguments(arguments)
-
- repository = Repo(search_parent_directories=True)
- top_dir = path.relpath(repository.working_dir, path.curdir)
-
- directories = compute_directories(extensions, repository)
-
- with open('deps.mk', 'w') as deps:
- write_dependencies(deps, directories, top_dir, out_dir)
-
-
-if __name__ == '__main__':
- main(argv)