]> Nishi Git Mirror - gwion.git/commitdiff
:art: Make docs no longer a submodule
authorfennecdjay <astor.jeremie@wanadoo.fr>
Wed, 19 Jun 2019 23:09:20 +0000 (01:09 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Wed, 19 Jun 2019 23:09:20 +0000 (01:09 +0200)
Makefile
docs.mk [new file with mode: 0644]

index 20b3fde9ad27faafffa6b5cddcf666135cae39e1..cd7ed00ac357fb55a8dbba0c8926cdbcec2f047c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -109,3 +109,5 @@ test:
 include $(wildcard .d/*.d)
 include util/target.mk
 include util/intl.mk
+include docs/config.mk
+include docs.mk
diff --git a/docs.mk b/docs.mk
new file mode 100644 (file)
index 0000000..1dd0e68
--- /dev/null
+++ b/docs.mk
@@ -0,0 +1,61 @@
+mdr_list = $(shell find -regextype posix-egrep -regex '.*.mdr$$')
+md_list  = $(mdr_list:.mdr=.md)
+
+_docserver_launch = $(DOCTOOL) -q serve & echo $$! > .server_pid
+_docserver_kill   = [ -f .server_pid ] && (kill $$(cat .server_pid); rm .server_pid) || true
+
+_mdr_wait=$$(inotifywait -q -r docs --format "%w%f" | tail -n1)
+
+doc-run:
+       @bash -c "trap 'trap - SIGINT SIGTERM ERR; $(MAKE) -s doc-clean; exit 1' SIGINT SIGTERM ERR; $(MAKE) -s doc-watch"
+
+doc-watch: $(md_list)
+       @$(call _docserver_launch)
+       @while true; do file=$(call _mdr_wait); echo $$file | grep '\.mdr$$' && mdr $$file; done
+
+doc-serve:
+       @(call _docserver_launch)
+
+doc-clean:
+       -@$(call _docserver_kill)
+       @rm -rf *.gw vlog log $(md_list) .tmp_list .mdr_list site
+
+doc-build: $(md_list)
+       $(DOCTOOL) build
+
+doc-deploy: $(md_list)
+       @$(DOCTOOL) gh-deploy
+       @$(MAKE) -s doc-clean
+
+.PHONY: mdr_loop watch serve clean run
+
+.SUFFIXES: .mdr .md
+.mdr.md:
+       $(info compiling $<)
+       @mdr $< ||:
+
+ifeq ($(VALGRIND), NO_VALGRIND)
+VALGRIND     =
+VALGRIND_OPT =
+endif
+
+include config.mk
+
+.SUFFIXES: .gw .test
+.gw.test:
+       @${VALGRIND} ${VALGRIND_OPT} gwion $< &> log
+       @[ -t 1 ] && $(call _interm) || $(call _noterm)
+
+define _test_check
+       for a in $(CONTAINS); do grep "$$a" log >/dev/null; done && valgrind_parse vlog
+endef
+
+_interm_status=echo -e "$(INTERM_OK)" || echo -e "$(INTERM_NOT_OK)"
+_interm=(cat log; $(call _test_check) && $(call _interm_status))
+
+_noterm_log=sed 's/$$/\<br\/>/' log
+_noterm_status=echo -e "$(NOTERM_OK)" || echo -e "$(NOTERM_NOT_OK)"
+_noterm_header=echo '<blockquote><p style=$(CSS)>'
+_noterm_test=$(call _test_check) && $(call _noterm_status)
+_noterm_footer=echo '</p></blockquote>'
+_noterm=($(call _noterm_header); $(call _noterm_log); $(call _noterm_test); $(call _noterm_footer))