memory-leaks

Still reachable: lots of words in many pages.
git clone https://git.kevinlegouguec.net/memory-leaks
Log | Files | Refs | README | LICENSE

commit 355b77c1fff8132cd3445c375140cf51e736d8a0
parent d7d98af0080241600bf0198f5c0942c96f3d2f95
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Tue, 24 Mar 2020 23:07:17 +0100

Produce auto-generated indices on stdout

This way I can concatenate the output with regular indices.

Diffstat:
Mrepo/www/Makefile | 2+-
Mrepo/www/make-index.py | 11+++++------
2 files changed, 6 insertions(+), 7 deletions(-)

diff --git 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 @@ -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__':