diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-03-24 23:07:17 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-03-24 23:07:17 +0100 |
| commit | 355b77c1fff8132cd3445c375140cf51e736d8a0 (patch) | |
| tree | f622bf8adaf63a46c09b1dce984da643f762057f | |
| parent | d7d98af0080241600bf0198f5c0942c96f3d2f95 (diff) | |
| download | memory-leaks-355b77c1fff8132cd3445c375140cf51e736d8a0.tar.xz | |
Produce auto-generated indices on stdout
This way I can concatenate the output with regular indices.
| -rw-r--r-- | repo/www/Makefile | 2 | ||||
| -rwxr-xr-x | repo/www/make-index.py | 11 |
2 files changed, 6 insertions, 7 deletions
diff --git a/repo/www/Makefile b/repo/www/Makefile index 38a28d2..fc25ddb 100644 --- a/repo/www/Makefile +++ b/repo/www/Makefile @@ -29,7 +29,7 @@ $(pages) $(indices): # ⚠ When tweaking this rule, check whether it still works for the # top-level index.html, i.e. when there is no top-level README. $(autoindices): $(OUT_DIR)%/index.html: $(TOP_DIR)% make-index.py | $(OUT_DIR)% - python3 make-index.py "$(TEXT_FILES)" "$(*:/%=%)" $(OUT_DIR) + python3 make-index.py "$(TEXT_FILES)" "$(*:/%=%)" > $@ clean: -rm $(dependencies) diff --git a/repo/www/make-index.py b/repo/www/make-index.py index 07aa266..ef699f0 100755 --- a/repo/www/make-index.py +++ b/repo/www/make-index.py @@ -10,10 +10,10 @@ from helpers import compute_directories def parse_arguments(args): - if len(args) != 4: - exit(f'Usage: {argv[0]} EXTENSIONS FOLDER OUTPUT-DIR') + if len(args) != 3: + exit(f'Usage: {argv[0]} EXTENSIONS FOLDER') - return argv[1].split(), argv[2], argv[3] + return argv[1].split(), argv[2] def list_files(extensions, folder): @@ -38,7 +38,7 @@ def generate_index_page(title, directories, files): def main(arguments): - extensions, folder, out_dir = parse_arguments(arguments) + extensions, folder = parse_arguments(arguments) title = path.basename(folder) if folder else 'index' @@ -47,8 +47,7 @@ def main(arguments): parsed_filenames = (path.splitext(f) for f in files) names = tuple(name for name, _ in parsed_filenames) - with open(path.join(out_dir, folder, 'index.html'), 'w') as index: - index.write(generate_index_page(title, folders, names)) + print(generate_index_page(title, folders, names)) if __name__ == '__main__': |
