From: Shane Jaroch Date: Thu, 8 Jan 2026 22:32:22 +0000 (-0500) Subject: tidy makefile, gen_docs.py X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=2b6699996605c19d9350c8affed93e5ddf7aad71;p=gamesguru%2Fgit-remote-gcrypt.git tidy makefile, gen_docs.py --- diff --git a/Makefile b/Makefile index 79f42ba..50fbae5 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,6 @@ _help: print ""; \ }' $(MAKEFILE_LIST) -.PHONY: _all -_all: lint test/installer test/system - @$(call print_success,All checks passed!) - .PHONY: vars vars: ##H Display all Makefile variables (simple) $(info === Makefile Variables (file/command/line origin) ===) @@ -33,6 +29,7 @@ vars: ##H Display all Makefile variables (simple) ) \ ) + define print_err printf "\033[1;31m%s\033[0m\n" "$(1)" endef @@ -86,6 +83,7 @@ lint: ##H Run shellcheck -ruff check $(LINT_LOCS_PY) @$(call print_success,OK.) + # --- Test Config --- PWD := $(shell pwd) COV_ROOT := $(PWD)/.coverage @@ -109,7 +107,7 @@ test/installer: check/deps ##H Test installer logic .PHONY: test/purity -test/purity: check/deps ##H Run logic tests with native shell (As Shipped Integrity Check) +test/purity: check/deps ##H Run logic tests (with native /bin/sh) @echo "running system tests (native /bin/sh)..." @export GPG_TTY=$$(tty); \ [ -n "$(DEBUG)$(V)" ] && export GCRYPT_DEBUG=1; \ @@ -119,7 +117,7 @@ test/purity: check/deps ##H Run logic tests with native shell (As Shipped Integr done .PHONY: test/system -test/system: check/deps ##H Run coverage tests (Dynamic Bash) +test/system: check/deps ##H Run logic tests (with bash & coverage) @echo "running system tests (coverage/bash)..." @rm -rf $(COV_SYSTEM) @mkdir -p $(COV_SYSTEM) @@ -153,6 +151,7 @@ CHECK_COVERAGE = $(if $(call find_coverage_xml,$(1)), \ echo "Error: No coverage report found for $(2) in $(1)" ; \ exit 1) + .PHONY: test/cov _test_cov_internal test/cov: ##H Show coverage gaps $(MAKE) _test_cov_internal @@ -164,9 +163,18 @@ _test_cov_internal: exit $$err + # Version from git describe (or fallback) __VERSION__ := $(shell git describe --tags --always --dirty 2>/dev/null || echo "@@DEV_VERSION@@") + +.PHONY: generate +generate: ##H Autogen man docs & shell completions + @$(call print_info,Generating documentation and completions...) + python3 completions/gen_docs.py + @$(call print_success,Generated.) + + .PHONY: install/, install install/: install install: ##H Install system-wide @@ -179,10 +187,12 @@ install: ##H Install system-wide install/user: ##H make install prefix=~/.local $(MAKE) install prefix=~/.local + .PHONY: check/install check/install: ##H Verify installation works bash ./tests/verify-system-install.sh + .PHONY: uninstall/, uninstall uninstall/: uninstall uninstall: ##H Uninstall @@ -199,10 +209,3 @@ uninstall/user: ##H make uninstall prefix=~/.local .PHONY: clean clean: ##H Clean up rm -rf .coverage .build_tmp - -# --- Autogeneration --- -.PHONY: generate -generate: ##H Autogenerate README usage & completions - @$(call print_info,Generating documentation and completions...) - python3 completions/gen_docs.py - @$(call print_success,Generated.) diff --git a/completions/gen_docs.py b/completions/gen_docs.py index bc46bce..217a731 100755 --- a/completions/gen_docs.py +++ b/completions/gen_docs.py @@ -43,7 +43,7 @@ def update_readme(path, template_path): if not os.path.exists(template_path): print(f"Error: Template not found at {template_path}", file=sys.stderr) sys.exit(1) - + with open(template_path, "r") as f: template_content = f.read() @@ -64,39 +64,39 @@ def update_readme(path, template_path): def update_bash_completion(path, template_path, commands): os.makedirs(os.path.dirname(path), exist_ok=True) - + with open(template_path, "r") as f: template = f.read() - + cmd_str = " ".join(commands) content = template.replace("{commands}", cmd_str) - + with open(path, "w") as f: f.write(content) def update_zsh_completion(path, template_path, commands): os.makedirs(os.path.dirname(path), exist_ok=True) - + with open(template_path, "r") as f: template = f.read() - + cmd_str = " ".join(commands) content = template.replace("{commands}", cmd_str) - + with open(path, "w") as f: f.write(content) def update_fish_completion(path, template_path, commands): os.makedirs(os.path.dirname(path), exist_ok=True) - + with open(template_path, "r") as f: template = f.read() - + cmd_str = " ".join(commands) content = template.replace("{not_sc_list}", cmd_str) - + with open(path, "w") as f: f.write(content) @@ -116,7 +116,7 @@ def main(): ) print(f"Detected commands: {' '.join(comp_commands)}") - + # Bash bash_path = os.path.join(root_dir, "completions/bash/git-remote-gcrypt") bash_tmpl = os.path.join(templates_dir, "bash.in") @@ -134,7 +134,7 @@ def main(): fish_tmpl = os.path.join(templates_dir, "fish.in") print(f"Updating Fish completions at: {fish_path}") update_fish_completion(fish_path, fish_tmpl, comp_commands) - + readme_path = os.path.join(root_dir, "README.rst") readme_tmpl = os.path.join(templates_dir, "README.rst.in") update_readme(readme_path, readme_tmpl)