Publish pages to .publish/
This commit is contained in:
@@ -33,6 +33,7 @@ default += .dbs/map.fmt
|
|||||||
echo '*' > $@.gitignore
|
echo '*' > $@.gitignore
|
||||||
|
|
||||||
include cmd.mk
|
include cmd.mk
|
||||||
|
include pub.mk
|
||||||
|
|
||||||
.dbs/head.rec: | .dbs/
|
.dbs/head.rec: | .dbs/
|
||||||
printf '%s\n' '%rec: guide' > $@
|
printf '%s\n' '%rec: guide' > $@
|
||||||
@@ -100,7 +101,7 @@ map: .dbs/requires.rec .dbs/map.fmt ## Show knowledge dependency map
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## Remove all generated files
|
clean: ## Remove all generated files
|
||||||
$(RM) -r $(default) .dbs/
|
$(RM) -r $(default) .dbs/ .publish/
|
||||||
|
|
||||||
.PHONY: article
|
.PHONY: article
|
||||||
article: */ */*/ ## Write a new article
|
article: */ */*/ ## Write a new article
|
||||||
|
|||||||
@@ -1,23 +1,4 @@
|
|||||||
|
|
||||||
cmds != recsel command.rec -t command -G bin -CP bin | sort -u
|
|
||||||
lists = $(patsubst %,lists/%.md, $(cmds))
|
|
||||||
|
|
||||||
get_title = printf 'title: %s\n' '${1}'
|
|
||||||
get_tags = recsel -t $(basename $<) $< -G bin \
|
|
||||||
-e 'bin = "$(1)"' -U -CP tag,bin | \
|
|
||||||
sed 's/.*/- &/'
|
|
||||||
|
|
||||||
list_commands = recsel -t $(basename $<) $< -e 'bin = "$(1)"' | \
|
|
||||||
recfmt -f lists.fmt
|
|
||||||
|
|
||||||
$(lists): lists/%.md: command.rec | lists/
|
|
||||||
@printf '%s\n' '---' > $@
|
|
||||||
@$(call get_title,$(basename $(notdir $@))) >> $@
|
|
||||||
@printf '%s\n' 'tags: ' >> $@
|
|
||||||
@$(call get_tags,$(basename $(notdir $@))) >> $@
|
|
||||||
@printf '%s\n' '---' >> $@
|
|
||||||
@$(call list_commands,$(basename $(notdir $@))) >> $@
|
|
||||||
|
|
||||||
.PHONY: function
|
.PHONY: function
|
||||||
function: ## Output a search function for .bashrc
|
function: ## Output a search function for .bashrc
|
||||||
${MAKE} --silent --touch query
|
${MAKE} --silent --touch query
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
markdown = $(wildcard */*.md */*/*.md)
|
||||||
|
|
||||||
|
publish = $(patsubst %, .publish/%, $(markdown))
|
||||||
|
|
||||||
|
.dbs/requires.fmt: | .dbs/
|
||||||
|
echo "- [{{requires_title}}]({{requires_path}})" > $@
|
||||||
|
|
||||||
|
$(publish): .publish/%.md: %.md | .dbs/notes.rec .dbs/requires.fmt
|
||||||
|
mkdir -p $(@D)
|
||||||
|
sed -n '1,/^---$$/p' $< > $@
|
||||||
|
test "$$(recsel -t guide -j requires .dbs/notes.rec -e "path = '$<'" -c)" -lt 1 \
|
||||||
|
|| { printf '\n---\n%s\n\n' "**Requirements**" >> $@ \
|
||||||
|
&& recsel -t guide -j requires .dbs/notes.rec -e "path = '$<'" -p requires_title,requires_path | recfmt -f .dbs/requires.fmt >> $@ \
|
||||||
|
&& printf '\n%s\n\n' '---' >> $@ ;}
|
||||||
|
sed '1,/---/d' $< >> $@
|
||||||
|
|
||||||
|
cmds != recsel command.rec -t command -G bin -CP bin | sort -u
|
||||||
|
lists = $(patsubst %,.publish/lists/%.md, $(cmds))
|
||||||
|
|
||||||
|
get_title = printf 'title: %s\n' '${1}'
|
||||||
|
get_tags = recsel -t $(basename $<) $< -G bin \
|
||||||
|
-e 'bin = "$(1)"' -U -CP tag,bin | \
|
||||||
|
sed 's/.*/- &/'
|
||||||
|
|
||||||
|
list_commands = recsel -t $(basename $<) $< -e 'bin = "$(1)"' | \
|
||||||
|
recfmt -f lists.fmt
|
||||||
|
|
||||||
|
.publish/lists/:| .publish/
|
||||||
|
|
||||||
|
$(lists): .publish/lists/%.md: command.rec | .publish/lists/
|
||||||
|
@printf '%s\n' '---' > $@
|
||||||
|
@$(call get_title,$(basename $(notdir $@))) >> $@
|
||||||
|
@printf '%s\n' 'tags: ' >> $@
|
||||||
|
@$(call get_tags,$(basename $(notdir $@))) >> $@
|
||||||
|
@printf '%s\n' '---' >> $@
|
||||||
|
@$(call list_commands,$(basename $(notdir $@))) >> $@
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: publish
|
||||||
|
publish: $(lists) $(publish) ## Web publishable web pages
|
||||||
|
|
||||||
Reference in New Issue
Block a user