From 629664bd50ed4e72cffc33bf2e7082119d483469 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Sun, 12 Apr 2020 20:00:08 +0200 Subject: Finish fixing some files being inaccessible Make generate-deps.py compute the list of indices instead of relying on the list of source folders that contain text files, otherwise we will miss intermediate folders that do not contain any file. Remove TODO entry to maintain Makefile dependencies to scripts: that sounds too tedious. Let's assume that at some point the Makefile and these scripts will be bundled together into a proper package. --- repo/www/generate-deps.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'repo/www/generate-deps.py') diff --git a/repo/www/generate-deps.py b/repo/www/generate-deps.py index f17e950..8388c40 100755 --- a/repo/www/generate-deps.py +++ b/repo/www/generate-deps.py @@ -5,11 +5,17 @@ We want to compute: - a list of leaf pages, -- a list of auto-generated indices, -- dependencies for leaf pages: + +- a list of indices, + +- dependencies for leaf pages (READMEs excluded): OUTPUT/foo/bar.html: foo/bar.txt | OUTPUT/foo - - special case for READMEs: - OUTPUT/foo/index.html: foo/README.txt foo | OUTPUT/foo + +- dependencies for READMEs: + OUTPUT/foo/index.html: foo/README.txt foo | OUTPUT/foo + +- dependencies for autogenerated indices: + OUTPUT/foo/index.html: foo | OUTPUT/foo """ from os import path @@ -36,7 +42,8 @@ def pjoin(directory, item): def write_dependencies(deps_file, directories, top_dir, out_dir): - pages = list() + pages = [] + readmes = {} for dpath, d in directories.items(): src_dir = pjoin(top_dir, dpath) @@ -47,8 +54,7 @@ def write_dependencies(deps_file, directories, top_dir, out_dir): name, _ = path.splitext(f) if name == 'README': - html_path = path.join(html_dir, 'index.html') - print(f'{html_path}: {src_path}', file=deps_file) + readmes[dpath] = f continue html_path = path.join(html_dir, name+'.html') @@ -56,8 +62,26 @@ def write_dependencies(deps_file, directories, top_dir, out_dir): pages.append(html_path) print(file=deps_file) + + for dpath in directories: + src_dir = pjoin(top_dir, dpath) + html_dir = pjoin(out_dir, dpath) + html_path = path.join(html_dir, 'index.html') + + if dpath in readmes: + src_path = path.join(src_dir, readmes[dpath]) + print(f'{html_path}: {src_path} {src_dir} | {html_dir}', file=deps_file) + continue + + print(f'{html_path}: {src_dir} | {html_dir}', file=deps_file) + + print(file=deps_file) + print(f'pages = {" ".join(pages)}', file=deps_file) + indices = (path.join(out_dir, dpath, 'index.html') for dpath in directories) + print(f'indices = {" ".join(indices)}', file=deps_file) + def main(arguments): extensions, out_dir = parse_arguments(arguments) -- cgit v1.2.3