From 030041dc06f80371aecc929e43fdf870d1f09973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 7 May 2015 21:00:53 +0300 Subject: Add Asciidoc documentation support --- build.config | 2 ++ core/core.mk | 21 +++++++++++---------- core/docs.mk | 15 +++++++++++++++ plugins/asciidoc.mk | 46 ++++++++++++++++++++++++++++++++++++++++++++++ plugins/edoc.mk | 14 ++++---------- 5 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 core/docs.mk create mode 100644 plugins/asciidoc.mk diff --git a/build.config b/build.config index 7ceca41..c49f40f 100644 --- a/build.config +++ b/build.config @@ -5,11 +5,13 @@ core/core core/deps core/erlc +core/docs core/test # Plugins. # # Comment to disable, uncomment to enable. +plugins/asciidoc plugins/bootstrap plugins/c_src plugins/ct diff --git a/core/core.mk b/core/core.mk index fdef354..0de45fd 100644 --- a/core/core.mk +++ b/core/core.mk @@ -12,7 +12,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.PHONY: all deps app rel docs tests clean distclean help erlang-mk +.PHONY: all deps app rel docs install-docs tests clean distclean help erlang-mk ERLANG_MK_VERSION = 1 @@ -63,15 +63,16 @@ help:: "Usage: [V=1] make [-jNUM] [target]" \ "" \ "Core targets:" \ - " all Run deps, app and rel targets in that order" \ - " deps Fetch dependencies (if needed) and compile them" \ - " app Compile the project" \ - " rel Build a release for this project, if applicable" \ - " docs Build the documentation for this project" \ - " tests Run the tests for this project" \ - " clean Delete temporary and output files from most targets" \ - " distclean Delete all temporary and output files" \ - " help Display this help and exit" \ + " all Run deps, app and rel targets in that order" \ + " deps Fetch dependencies (if needed) and compile them" \ + " app Compile the project" \ + " rel Build a release for this project, if applicable" \ + " docs Build the documentation for this project" \ + " install-docs Install the man pages for this project" \ + " tests Run the tests for this project" \ + " clean Delete temporary and output files from most targets" \ + " distclean Delete all temporary and output files" \ + " help Display this help and exit" \ "" \ "The target clean only removes files that are commonly removed." \ "Dependencies and releases are left untouched." \ diff --git a/core/docs.mk b/core/docs.mk new file mode 100644 index 0000000..9637d32 --- /dev/null +++ b/core/docs.mk @@ -0,0 +1,15 @@ +# Copyright (c) 2015, Viktor Söderqvist +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: docs-deps + +# Configuration. + +ALL_DOC_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(DOC_DEPS)) + +# Targets. + +$(foreach dep,$(DOC_DEPS),$(eval $(call dep_target,$(dep)))) + +doc-deps: $(ALL_DOC_DEPS_DIRS) + @for dep in $(ALL_DOC_DEPS_DIRS) ; do $(MAKE) -C $$dep; done diff --git a/plugins/asciidoc.mk b/plugins/asciidoc.mk new file mode 100644 index 0000000..baf4d3b --- /dev/null +++ b/plugins/asciidoc.mk @@ -0,0 +1,46 @@ +# Copyright (c) 2015, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: asciidoc asciidoc-guide asciidoc-manual install-asciidoc distclean-asciidoc + +MAN_INSTALL_PATH ?= /usr/local/share/man +MAN_SECTIONS ?= 3 7 + +docs:: asciidoc + +asciidoc: distclean-asciidoc doc-deps asciidoc-guide asciidoc-manual + +ifeq ($(wildcard doc/src/guide/book.asciidoc),) +asciidoc-guide: +else +asciidoc-guide: + a2x -v -f pdf doc/src/guide/book.asciidoc && mv doc/src/guide/book.pdf doc/guide.pdf + a2x -v -f chunked doc/src/guide/book.asciidoc && mv doc/src/guide/book.chunked/ doc/html/ +endif + +ifeq ($(wildcard doc/src/manual/*.asciidoc),) +asciidoc-manual: +else +asciidoc-manual: + for f in doc/src/manual/*.asciidoc ; do \ + a2x -v -f manpage $$f ; \ + done + for s in $(MAN_SECTIONS); do \ + mkdir -p doc/man$$s/ ; \ + mv doc/src/manual/*.$$s doc/man$$s/ ; \ + gzip doc/man$$s/*.$$s ; \ + done + +install-docs:: install-asciidoc + +install-asciidoc: asciidoc-manual + for s in $(MAN_SECTIONS); do \ + mkdir -p $(MAN_INSTALL_PATH)/man$$s/ ; \ + install -g 0 -o 0 -m 0644 doc/man$$s/*.gz $(MAN_INSTALL_PATH)/man$$s/ ; \ + done +endif + +distclean:: distclean-asciidoc + +distclean-asciidoc: + $(gen_verbose) rm -rf doc/html/ doc/guide.pdf doc/man3/ doc/man7/ diff --git a/plugins/edoc.mk b/plugins/edoc.mk index d9b1d70..6f0a82d 100644 --- a/plugins/edoc.mk +++ b/plugins/edoc.mk @@ -1,8 +1,7 @@ # Copyright (c) 2013-2015, Loïc Hoguin -# Copyright (c) 2015, Viktor Söderqvist # This file is part of erlang.mk and subject to the terms of the ISC License. -.PHONY: distclean-edoc build-doc-deps +.PHONY: distclean-edoc edoc # Configuration. @@ -10,19 +9,14 @@ EDOC_OPTS ?= # Core targets. -docs:: distclean-edoc build-doc-deps - $(gen_verbose) $(ERL) -eval 'edoc:application($(PROJECT), ".", [$(EDOC_OPTS)]), halt().' +docs:: distclean-edoc edoc distclean:: distclean-edoc # Plugin-specific targets. -DOC_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(DOC_DEPS)) - -$(foreach dep,$(DOC_DEPS),$(eval $(call dep_target,$(dep)))) - -build-doc-deps: $(DOC_DEPS_DIRS) - @for dep in $(DOC_DEPS_DIRS) ; do $(MAKE) -C $$dep; done +edoc: doc-deps + $(gen_verbose) $(ERL) -eval 'edoc:application($(PROJECT), ".", [$(EDOC_OPTS)]), halt().' distclean-edoc: $(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info -- cgit v1.2.3