plugin_asciidoc.mk 5.7 KB

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