plugin_sphinx.mk 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. # Sphinx plugin.
  2. # Disable this test suite when sphinx is not installed.
  3. ifeq ($(shell which sphinx-build),)
  4. SPHINX_TARGETS =
  5. else
  6. SPHINX_TARGETS = $(call list_targets,sphinx)
  7. endif
  8. .PHONY: sphinx $(SPHINX_TARGETS)
  9. sphinx: $(SPHINX_TARGETS)
  10. sphinx-build: init
  11. $i "Bootstrap a new OTP application named $(APP)"
  12. $t mkdir $(APP)/
  13. $t cp ../erlang.mk $(APP)/
  14. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  15. $i "Generate Sphinx config"
  16. $(call sphinx-generate-doc-skeleton)
  17. $i "Run Sphinx"
  18. $t $(MAKE) -C $(APP) sphinx $v
  19. $i "Check that documentation was generated"
  20. $t test -f $(APP)/html/index.html
  21. $t test -f $(APP)/html/manpage.html
  22. $i "Distclean the application"
  23. $t $(MAKE) -C $(APP) distclean $v
  24. $i "Check that the generated documentation was removed"
  25. $t test ! -e $(APP)/html/index.html
  26. $t test ! -e $(APP)/html/manpage.html
  27. $i "Set 'today' macro with command-line options"
  28. $t echo "SPHINX_OPTS = -D 'today=erlang_mk_sphinx_today'" >> $(APP)/Makefile
  29. $i "Run Sphinx"
  30. $t $(MAKE) -C $(APP) sphinx $v
  31. $i "Check that the 'today' macro was defined"
  32. $t grep -q erlang_mk_sphinx_today $(APP)/html/manpage.html
  33. sphinx-source-dir: init
  34. $i "Bootstrap a new OTP application named $(APP)"
  35. $t mkdir $(APP)/
  36. $t cp ../erlang.mk $(APP)/
  37. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  38. $i "Change documentation source directory"
  39. $t echo "SPHINX_SOURCE = documentation" >> $(APP)/Makefile
  40. $i "Generate Sphinx config"
  41. $(call sphinx-generate-doc-skeleton,documentation)
  42. $i "Run Sphinx (html)"
  43. $t $(MAKE) -C $(APP) sphinx $v
  44. $i "Check that documentation was generated"
  45. $t test -f $(APP)/html/index.html
  46. $t test -f $(APP)/html/manpage.html
  47. sphinx-formats: init
  48. $i "Bootstrap a new OTP application named $(APP)"
  49. $t mkdir $(APP)/
  50. $t cp ../erlang.mk $(APP)/
  51. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  52. $i "Define formats generated by Sphinx"
  53. $t echo "SPHINX_FORMATS = html man" >> $(APP)/Makefile
  54. $i "Generate Sphinx config"
  55. $(call sphinx-generate-doc-skeleton)
  56. $i "Run Sphinx (html + man)"
  57. $t $(MAKE) -C $(APP) sphinx $v
  58. $i "Check that documentation was generated"
  59. $t test -f $(APP)/man/sphinx_$(APP).1
  60. $t test -f $(APP)/html/index.html
  61. $t test -f $(APP)/html/manpage.html
  62. $i "Distclean the application"
  63. $t $(MAKE) -C $(APP) distclean $v
  64. $i "Check that the generated documentation was removed"
  65. $t test ! -e $(APP)/man/sphinx_$(APP).1
  66. $t test ! -e $(APP)/html/index.html
  67. $t test ! -e $(APP)/html/manpage.html
  68. $i "Change documentation output directories"
  69. $t echo "sphinx_html_output = sphinx/html_output" >> $(APP)/Makefile
  70. $t echo "sphinx_man_output = sphinx/man_output" >> $(APP)/Makefile
  71. $i "Run Sphinx (html + man)"
  72. $t $(MAKE) -C $(APP) sphinx $v
  73. $i "Check that documentation was generated"
  74. $t test -f $(APP)/sphinx/man_output/sphinx_$(APP).1
  75. $t test -f $(APP)/sphinx/html_output/index.html
  76. $t test -f $(APP)/sphinx/html_output/manpage.html
  77. $i "Distclean the application"
  78. $t $(MAKE) -C $(APP) distclean $v
  79. $i "Check that the generated documentation was removed"
  80. $t test ! -e $(APP)/sphinx/man_output/sphinx_$(APP).1
  81. $t test ! -e $(APP)/sphinx/html_output/index.html
  82. $t test ! -e $(APP)/sphinx/html_output/manpage.html
  83. sphinx-format-opts: init
  84. $i "Bootstrap a new OTP application named $(APP)"
  85. $t mkdir $(APP)/
  86. $t cp ../erlang.mk $(APP)/
  87. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  88. $i "Define formats generated by Sphinx"
  89. $t echo "SPHINX_FORMATS = html man" >> $(APP)/Makefile
  90. $i "Change format-specific options"
  91. $t echo "sphinx_html_opts = -D 'today=erlang_mk_sphinx_html_today'" >> $(APP)/Makefile
  92. $t echo "sphinx_man_opts = -D 'today=erlang_mk_sphinx_man_today'" >> $(APP)/Makefile
  93. $i "Generate Sphinx config"
  94. $(call sphinx-generate-doc-skeleton)
  95. $i "Run Sphinx (html + man)"
  96. $t $(MAKE) -C $(APP) sphinx $v
  97. $i "Check that the 'today' macro was defined correctly"
  98. $t grep -q erlang_mk_sphinx_html_today $(APP)/html/manpage.html
  99. $t grep -q erlang_mk_sphinx_man_today $(APP)/man/sphinx_$(APP).1
  100. define sphinx-generate-doc-skeleton
  101. $t mkdir $(APP)/$(if $1,$1,doc)/
  102. $t printf "%s\n" \
  103. "project = '$(APP)'" \
  104. "master_doc = 'index'" \
  105. "source_suffix = '.rst'" \
  106. "man_pages = [('manpage', 'sphinx_$(APP)', 'Man Page', [], 1)]" \
  107. "" > $(APP)/$(if $1,$1,doc)/conf.py
  108. $t printf "%s\n" \
  109. "***********" \
  110. "Sphinx Docs" \
  111. "***********" \
  112. "" \
  113. "ToC" \
  114. "===" \
  115. "" \
  116. ".. toctree::" \
  117. "" \
  118. " manpage" \
  119. "" \
  120. "Indices" \
  121. "=======" \
  122. "" \
  123. '* :ref:`genindex`' \
  124. '* :ref:`modindex`' \
  125. '* :ref:`search`' \
  126. "" > $(APP)/$(if $1,$1,doc)/index.rst
  127. $t printf "%s\n" \
  128. "********" \
  129. "Man Page" \
  130. "********" \
  131. "" \
  132. "Synopsis" \
  133. "========" \
  134. "" \
  135. ".. code-block:: none" \
  136. "" \
  137. " erlang-sphinx-mk-man [--help]" \
  138. "" \
  139. "today = |today|" \
  140. "" > $(APP)/$(if $1,$1,doc)/manpage.rst
  141. endef