allow ascii dependency map

This commit is contained in:
2025-08-18 01:37:40 +02:00
parent 3dface826f
commit d1a1146260

View File

@@ -6,7 +6,7 @@ FZF != command -v sk || command -v fzy || command -v fzf || \
spill_contents = sed -e '1,/---/d' spill_contents = sed -e '1,/---/d'
help: ## Print the help message help: .git/info/exclude ## Print the help message
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \ @awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \ sort | \
column -s ':' -t column -s ':' -t
@@ -19,6 +19,8 @@ categories = $(patsubst %/, %, $(dirs))
databases = $(patsubst %, .dbs/%.rec, $(categories)) databases = $(patsubst %, .dbs/%.rec, $(categories))
default += $(databases) default += $(databases)
default += db.rec
default += .dbs/map.fmt
$(foreach dir, $(categories), \ $(foreach dir, $(categories), \
$(eval .dbs/$(dir).rec: $(wildcard $(dir)/*)) \ $(eval .dbs/$(dir).rec: $(wildcard $(dir)/*)) \
@@ -26,6 +28,7 @@ $(foreach dir, $(categories), \
.dbs/: .dbs/:
mkdir $@ mkdir $@
$(databases): .dbs/%.rec: %/ | .dbs/ $(databases): .dbs/%.rec: %/ | .dbs/
$(info making $(@F)) $(info making $(@F))
for entry in $(shell find $< -type f -name "*.md") ; do \ for entry in $(shell find $< -type f -name "*.md") ; do \
@@ -56,10 +59,8 @@ db.rec: $(databases)
recfix --sort $@ recfix --sort $@
$(info Created main database: $@) $(info Created main database: $@)
default += db.rec
.git/info/exclude: $(default) .git/info/exclude: $(default)
echo $^ | tr ' ' '\n' > $@ @echo $^ | tr ' ' '\n' > $@
default += .git/info/exclude default += .git/info/exclude
@@ -77,6 +78,18 @@ article: ## Write an article
printf '%s\n\n' '---' >> $$path/$$filename.md ;\ printf '%s\n\n' '---' >> $$path/$$filename.md ;\
$(EDITOR) +5 "$$path/$$filename.md" $(EDITOR) +5 "$$path/$$filename.md"
.dbs/map.fmt:| .dbs/
printf '%s\n' '[ {{requires[0]}} ] --> [ {{title}} ] {border-style: dashed;}' > $@
printf '%s\n' '[ {{requires[1]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[2]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[3]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[4]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
.PHONY: map
map: db.rec .dbs/map.fmt ## Show knowledge dependency map
recsel -t guide $< -e 'requires != ""' -p title,requires | recfmt -f .dbs/map.fmt |\
grep -vF '[ ]' | graph-easy --boxart | $${PAGER}
.PHONY: clean .PHONY: clean
clean: ## Remove all generated files clean: ## Remove all generated files
$(RM) $(default) $(RM) $(default)