plugin_asciidoc.mk 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. # AsciiDoc plugin.
  2. ASCIIDOC_TARGETS = $(call list_targets,asciidoc)
  3. .PHONY: asciidoc $(ASCIIDOC_TARGETS)
  4. asciidoc: $(ASCIIDOC_TARGETS)
  5. # Disable the Asciidoc tests requiring the DocBook toolchain
  6. # when Asciidoc is not installed. The toolchain is too heavy for CI.
  7. ifneq ($(shell which a2x),)
  8. asciidoc-build: init
  9. $i "Bootstrap a new OTP application named $(APP)"
  10. $t mkdir $(APP)/
  11. $t cp ../erlang.mk $(APP)/
  12. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  13. $i "Add asciideck to the local dependencies"
  14. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = asciideck\n"}' $(APP)/Makefile
  15. $i "Run AsciiDoc"
  16. $t $(MAKE) -C $(APP) asciidoc $v
  17. $i "Check that no documentation was generated"
  18. $t test ! -e $(APP)/doc/guide.pdf
  19. $t test ! -e $(APP)/doc/html/
  20. $t test ! -e $(APP)/doc/man3/
  21. $t test ! -e $(APP)/doc/man7/
  22. $i "Generate AsciiDoc documentation"
  23. $t mkdir -p $(APP)/doc/src/guide/ $(APP)/doc/src/manual/
  24. $t printf "%s\n" \
  25. "= Erlang.mk tests" "" \
  26. "Hello world!" > $(APP)/doc/src/guide/book.asciidoc
  27. $t printf "%s\n" \
  28. "= erlang_mk(3)" "" \
  29. "== Name" "" \
  30. "erlang_mk - Erlang.mk test" "" \
  31. "== Description" "" \
  32. "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc
  33. $t printf "%s\n" \
  34. "= erlang_mk(7)" "" \
  35. "== Name" "" \
  36. "erlang_mk - Erlang.mk application" "" \
  37. "== Description" "" \
  38. "Summer is better than winter!" > $(APP)/doc/src/manual/erlang_mk_app.asciidoc
  39. $i "Run AsciiDoc"
  40. $t $(MAKE) -C $(APP) asciidoc $v
  41. $i "Check that the documentation was generated"
  42. $t test -f $(APP)/doc/guide.pdf
  43. $t test -d $(APP)/doc/html/
  44. $t test -f $(APP)/doc/man3/erlang_mk.3.gz
  45. $t test -f $(APP)/doc/man7/erlang_mk.7.gz
  46. $i "Distclean the application"
  47. $t $(MAKE) -C $(APP) distclean $v
  48. $i "Check that the generated documentation was removed"
  49. $t test ! -e $(APP)/doc/guide.pdf
  50. $t test ! -e $(APP)/doc/html/
  51. $t test ! -e $(APP)/doc/man3/
  52. $t test ! -e $(APP)/doc/man7/
  53. $i "Generate an invalid AsciiDoc file"
  54. $t printf "%s\n" \
  55. "= fail(3)" "" \
  56. "This will fail because the Name section is missing." > $(APP)/doc/src/manual/fail.asciidoc
  57. $i "Check that AsciiDoc errors out"
  58. $t ! $(MAKE) -C $(APP) asciidoc $v
  59. asciidoc-docs: init
  60. $i "Bootstrap a new OTP application named $(APP)"
  61. $t mkdir $(APP)/
  62. $t cp ../erlang.mk $(APP)/
  63. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  64. $i "Add asciideck to the local dependencies"
  65. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = asciideck\n"}' $(APP)/Makefile
  66. $i "Generate AsciiDoc documentation"
  67. $t mkdir -p $(APP)/doc/src/guide/
  68. $t printf "%s\n" \
  69. "= Erlang.mk tests" "" \
  70. "Hello world!" > $(APP)/doc/src/guide/book.asciidoc
  71. $i "Check that AsciiDoc runs on 'make docs'"
  72. $t $(MAKE) -C $(APP) docs $v
  73. $t test -f $(APP)/doc/guide.pdf
  74. $t test -d $(APP)/doc/html/
  75. asciidoc-guide: init
  76. $i "Bootstrap a new OTP application named $(APP)"
  77. $t mkdir $(APP)/
  78. $t cp ../erlang.mk $(APP)/
  79. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  80. $i "Add asciideck to the local dependencies"
  81. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = asciideck\n"}' $(APP)/Makefile
  82. $i "Generate AsciiDoc documentation"
  83. $t mkdir -p $(APP)/doc/src/guide/ $(APP)/doc/src/manual/
  84. $t printf "%s\n" \
  85. "= Erlang.mk tests" "" \
  86. "Hello world!" > $(APP)/doc/src/guide/book.asciidoc
  87. $t printf "%s\n" \
  88. "= erlang_mk(3)" "" \
  89. "== Name" "" \
  90. "erlang_mk - Erlang.mk test" "" \
  91. "== Description" "" \
  92. "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc
  93. $i "Check that only the guide is generated on 'make asciidoc-guide'"
  94. $t $(MAKE) -C $(APP) asciidoc-guide $v
  95. $t test -f $(APP)/doc/guide.pdf
  96. $t test -d $(APP)/doc/html/
  97. $t test ! -e $(APP)/doc/man3/
  98. endif
  99. asciidoc-install: init
  100. $i "Bootstrap a new OTP application named $(APP)"
  101. $t mkdir $(APP)/
  102. $t cp ../erlang.mk $(APP)/
  103. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  104. $i "Add asciideck to the local dependencies"
  105. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = asciideck\n"}' $(APP)/Makefile
  106. $i "Only enable man pages section 3"
  107. $t perl -ni.bak -e 'print;if ($$.==1) {print "MAN_SECTIONS = 3\n"}' $(APP)/Makefile
  108. $i "Generate AsciiDoc documentation"
  109. $t mkdir -p $(APP)/doc/src/manual/
  110. $t printf "%s\n" \
  111. "= erlang_mk(3)" "" \
  112. "== Name" "" \
  113. "erlang_mk - Erlang.mk test" "" \
  114. "== Description" "" \
  115. "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc
  116. $i "Build and install the man pages to $(APP)/installed/"
  117. $t $(MAKE) -C $(APP) install-docs MAN_INSTALL_PATH=installed/share $v
  118. $i "Check that the documentation was installed properly"
  119. $t test -f $(APP)/installed/share/man3/erlang_mk.3.gz
  120. asciidoc-manual: init
  121. $i "Bootstrap a new OTP application named $(APP)"
  122. $t mkdir $(APP)/
  123. $t cp ../erlang.mk $(APP)/
  124. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  125. $i "Add asciideck to the local dependencies"
  126. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = asciideck\n"}' $(APP)/Makefile
  127. $i "Only enable man pages section 3"
  128. $t perl -ni.bak -e 'print;if ($$.==1) {print "MAN_SECTIONS = 3\n"}' $(APP)/Makefile
  129. $i "Generate AsciiDoc documentation"
  130. $t mkdir -p $(APP)/doc/src/guide/ $(APP)/doc/src/manual/
  131. $t printf "%s\n" \
  132. "= Erlang.mk tests" "" \
  133. "Hello world!" > $(APP)/doc/src/guide/book.asciidoc
  134. $t printf "%s\n" \
  135. "= erlang_mk(3)" "" \
  136. "== Name" "" \
  137. "erlang_mk - Erlang.mk test" "" \
  138. "== Description" "" \
  139. "Hello world!" > $(APP)/doc/src/manual/erlang_mk.asciidoc
  140. $t printf "%s\n" \
  141. "= name_changed(3)" "" \
  142. "== Name" "" \
  143. "name_changed - Manual page name different than output" "" \
  144. "== Description" "" \
  145. "Name changed!" > $(APP)/doc/src/manual/change_name.asciidoc
  146. $i "Run 'make asciidoc-manual'"
  147. $t $(MAKE) -C $(APP) asciidoc-manual $v
  148. $i "Check that only the manual was generated"
  149. $t test ! -e $(APP)/doc/guide.pdf
  150. $t test ! -e $(APP)/doc/html/
  151. $t test -f $(APP)/doc/man3/erlang_mk.3.gz
  152. $t test -f $(APP)/doc/man3/name_changed.3.gz