123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- # Sphinx plugin.
- # Disable this test suite when sphinx is not installed.
- ifeq ($(shell which sphinx-build),)
- SPHINX_TARGETS =
- else
- SPHINX_TARGETS = $(call list_targets,sphinx)
- endif
- .PHONY: sphinx $(SPHINX_TARGETS)
- sphinx: $(SPHINX_TARGETS)
- sphinx-build: init
- $i "Bootstrap a new OTP application named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
- $i "Generate Sphinx config"
- $(call sphinx-generate-doc-skeleton)
- $i "Run Sphinx"
- $t $(MAKE) -C $(APP) sphinx $v
- $i "Check that documentation was generated"
- $t test -f $(APP)/html/index.html
- $t test -f $(APP)/html/manpage.html
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Check that the generated documentation was removed"
- $t test ! -e $(APP)/html/index.html
- $t test ! -e $(APP)/html/manpage.html
- $i "Set 'today' macro with command-line options"
- $t echo "SPHINX_OPTS = -D 'today=erlang_mk_sphinx_today'" >> $(APP)/Makefile
- $i "Run Sphinx"
- $t $(MAKE) -C $(APP) sphinx $v
- $i "Check that the 'today' macro was defined"
- $t grep -q erlang_mk_sphinx_today $(APP)/html/manpage.html
- sphinx-source-dir: init
- $i "Bootstrap a new OTP application named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
- $i "Change documentation source directory"
- $t echo "SPHINX_SOURCE = documentation" >> $(APP)/Makefile
- $i "Generate Sphinx config"
- $(call sphinx-generate-doc-skeleton,documentation)
- $i "Run Sphinx (html)"
- $t $(MAKE) -C $(APP) sphinx $v
- $i "Check that documentation was generated"
- $t test -f $(APP)/html/index.html
- $t test -f $(APP)/html/manpage.html
- sphinx-formats: init
- $i "Bootstrap a new OTP application named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
- $i "Define formats generated by Sphinx"
- $t echo "SPHINX_FORMATS = html man" >> $(APP)/Makefile
- $i "Generate Sphinx config"
- $(call sphinx-generate-doc-skeleton)
- $i "Run Sphinx (html + man)"
- $t $(MAKE) -C $(APP) sphinx $v
- $i "Check that documentation was generated"
- $t test -f $(APP)/man/sphinx_$(APP).1
- $t test -f $(APP)/html/index.html
- $t test -f $(APP)/html/manpage.html
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Check that the generated documentation was removed"
- $t test ! -e $(APP)/man/sphinx_$(APP).1
- $t test ! -e $(APP)/html/index.html
- $t test ! -e $(APP)/html/manpage.html
- $i "Change documentation output directories"
- $t echo "sphinx_html_output = sphinx/html_output" >> $(APP)/Makefile
- $t echo "sphinx_man_output = sphinx/man_output" >> $(APP)/Makefile
- $i "Run Sphinx (html + man)"
- $t $(MAKE) -C $(APP) sphinx $v
- $i "Check that documentation was generated"
- $t test -f $(APP)/sphinx/man_output/sphinx_$(APP).1
- $t test -f $(APP)/sphinx/html_output/index.html
- $t test -f $(APP)/sphinx/html_output/manpage.html
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Check that the generated documentation was removed"
- $t test ! -e $(APP)/sphinx/man_output/sphinx_$(APP).1
- $t test ! -e $(APP)/sphinx/html_output/index.html
- $t test ! -e $(APP)/sphinx/html_output/manpage.html
- sphinx-format-opts: init
- $i "Bootstrap a new OTP application named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
- $i "Define formats generated by Sphinx"
- $t echo "SPHINX_FORMATS = html man" >> $(APP)/Makefile
- $i "Change format-specific options"
- $t echo "sphinx_html_opts = -D 'today=erlang_mk_sphinx_html_today'" >> $(APP)/Makefile
- $t echo "sphinx_man_opts = -D 'today=erlang_mk_sphinx_man_today'" >> $(APP)/Makefile
- $i "Generate Sphinx config"
- $(call sphinx-generate-doc-skeleton)
- $i "Run Sphinx (html + man)"
- $t $(MAKE) -C $(APP) sphinx $v
- $i "Check that the 'today' macro was defined correctly"
- $t grep -q erlang_mk_sphinx_html_today $(APP)/html/manpage.html
- $t grep -q erlang_mk_sphinx_man_today $(APP)/man/sphinx_$(APP).1
- define sphinx-generate-doc-skeleton
- $t mkdir $(APP)/$(if $1,$1,doc)/
- $t printf "%s\n" \
- "project = '$(APP)'" \
- "master_doc = 'index'" \
- "source_suffix = '.rst'" \
- "man_pages = [('manpage', 'sphinx_$(APP)', 'Man Page', [], 1)]" \
- "" > $(APP)/$(if $1,$1,doc)/conf.py
- $t printf "%s\n" \
- "***********" \
- "Sphinx Docs" \
- "***********" \
- "" \
- "ToC" \
- "===" \
- "" \
- ".. toctree::" \
- "" \
- " manpage" \
- "" \
- "Indices" \
- "=======" \
- "" \
- '* :ref:`genindex`' \
- '* :ref:`modindex`' \
- '* :ref:`search`' \
- "" > $(APP)/$(if $1,$1,doc)/index.rst
- $t printf "%s\n" \
- "********" \
- "Man Page" \
- "********" \
- "" \
- "Synopsis" \
- "========" \
- "" \
- ".. code-block:: none" \
- "" \
- " erlang-sphinx-mk-man [--help]" \
- "" \
- "today = |today|" \
- "" > $(APP)/$(if $1,$1,doc)/manpage.rst
- endef
|