plugin_asciidoc.mk 5.6 KB

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