Browse Source

Add Asciidoc documentation support

Loïc Hoguin 10 years ago
parent
commit
030041dc06
5 changed files with 78 additions and 20 deletions
  1. 2 0
      build.config
  2. 11 10
      core/core.mk
  3. 15 0
      core/docs.mk
  4. 46 0
      plugins/asciidoc.mk
  5. 4 10
      plugins/edoc.mk

+ 2 - 0
build.config

@@ -5,11 +5,13 @@
 core/core
 core/core
 core/deps
 core/deps
 core/erlc
 core/erlc
+core/docs
 core/test
 core/test
 
 
 # Plugins.
 # Plugins.
 #
 #
 # Comment to disable, uncomment to enable.
 # Comment to disable, uncomment to enable.
+plugins/asciidoc
 plugins/bootstrap
 plugins/bootstrap
 plugins/c_src
 plugins/c_src
 plugins/ct
 plugins/ct

+ 11 - 10
core/core.mk

@@ -12,7 +12,7 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 # 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
 ERLANG_MK_VERSION = 1
 
 
@@ -63,15 +63,16 @@ help::
 		"Usage: [V=1] make [-jNUM] [target]" \
 		"Usage: [V=1] make [-jNUM] [target]" \
 		"" \
 		"" \
 		"Core targets:" \
 		"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." \
 		"The target clean only removes files that are commonly removed." \
 		"Dependencies and releases are left untouched." \
 		"Dependencies and releases are left untouched." \

+ 15 - 0
core/docs.mk

@@ -0,0 +1,15 @@
+# Copyright (c) 2015, Viktor Söderqvist <viktor@zuiderkwast.se>
+# 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

+ 46 - 0
plugins/asciidoc.mk

@@ -0,0 +1,46 @@
+# Copyright (c) 2015, Loïc Hoguin <essen@ninenines.eu>
+# 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/

+ 4 - 10
plugins/edoc.mk

@@ -1,8 +1,7 @@
 # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
 # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
-# Copyright (c) 2015, Viktor Söderqvist <viktor@zuiderkwast.se>
 # This file is part of erlang.mk and subject to the terms of the ISC License.
 # 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.
 # Configuration.
 
 
@@ -10,19 +9,14 @@ EDOC_OPTS ?=
 
 
 # Core targets.
 # 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
 distclean:: distclean-edoc
 
 
 # Plugin-specific targets.
 # 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:
 distclean-edoc:
 	$(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info
 	$(gen_verbose) rm -f doc/*.css doc/*.html doc/*.png doc/edoc-info