plugin_sphinx.mk 4.6 KB

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