plugin_edoc.mk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # EDoc plugin.
  2. EDOC_TARGETS = $(call list_targets,edoc)
  3. .PHONY: edoc $(EDOC_TARGETS)
  4. edoc: $(EDOC_TARGETS)
  5. edoc-build: init
  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 "Run EDoc"
  11. $t $(MAKE) -C $(APP) edoc $v
  12. $i "Check that documentation was generated"
  13. $t test -f $(APP)/doc/index.html
  14. $t test -f $(APP)/doc/$(APP)_app.html
  15. $t test -f $(APP)/doc/$(APP)_sup.html
  16. $i "Distclean the application"
  17. $t $(MAKE) -C $(APP) distclean $v
  18. $i "Check that the generated documentation was removed"
  19. $t test ! -e $(APP)/doc/index.html
  20. $t test ! -e $(APP)/doc/$(APP)_app.html
  21. $t test ! -e $(APP)/doc/$(APP)_sup.html
  22. $i "Generate a module with EDoc comments"
  23. $t printf "%s\n" \
  24. "%% @doc erlang-mk-edoc-module" \
  25. "-module($(APP))." \
  26. "-export([ok/0])." \
  27. "" \
  28. "%% @doc erlang-mk-edoc-function" \
  29. "ok() -> ok." > $(APP)/src/$(APP).erl
  30. $i "Run EDoc"
  31. $t $(MAKE) -C $(APP) edoc $v
  32. $i "Check that the new module's documentation was generated"
  33. $t test -f $(APP)/doc/$(APP).html
  34. $i "Check that the EDoc comments are in the generated documentation"
  35. $t grep -q erlang-mk-edoc-module $(APP)/doc/$(APP).html
  36. $t grep -q erlang-mk-edoc-function $(APP)/doc/$(APP).html
  37. $i "Generate a module with an invalid EDoc comment"
  38. $t printf "%s\n" \
  39. "-module($(APP)_fail)." \
  40. "-export([fail/0])." \
  41. "%% @spec lol" \
  42. "fail() -> fail." > $(APP)/src/$(APP)_fail.erl
  43. $i "Check that EDoc errors out"
  44. $t ! $(MAKE) -C $(APP) edoc $v
  45. edoc-docs: init
  46. $i "Bootstrap a new OTP application named $(APP)"
  47. $t mkdir $(APP)/
  48. $t cp ../erlang.mk $(APP)/
  49. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  50. $i "Generate a doc/overview.edoc file"
  51. $t mkdir $(APP)/doc
  52. $t printf "%s\n" \
  53. "@author R. J. Hacker <rjh@acme.com>" \
  54. "@copyright 2007 R. J. Hacker" \
  55. "@version 1.0.0" \
  56. "@title Welcome to the 'frob' application!" \
  57. "@doc 'frob' is a highly advanced frobnicator with low latency," > $(APP)/doc/overview.edoc
  58. $i "Check that EDoc runs on 'make docs'"
  59. $t $(MAKE) -C $(APP) docs $v
  60. $t test -f $(APP)/doc/index.html
  61. $i "Check that the overview.edoc file was used"
  62. $t grep -q frobnicator $(APP)/doc/overview-summary.html
  63. edoc-no-overview: init
  64. $i "Bootstrap a new OTP application named $(APP)"
  65. $t mkdir $(APP)/
  66. $t cp ../erlang.mk $(APP)/
  67. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  68. $i "Check that EDoc doesn't run on 'make docs'"
  69. $t $(MAKE) -C $(APP) docs $v
  70. $t test ! -e $(APP)/doc/index.html
  71. edoc-opts: init
  72. $i "Bootstrap a new OTP application named $(APP)"
  73. $t mkdir $(APP)/
  74. $t cp ../erlang.mk $(APP)/
  75. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  76. $i "Add edown doclet for EDoc"
  77. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = edown\nEDOC_OPTS = {doclet, edown_doclet}\n"}' $(APP)/Makefile
  78. $i "Run EDoc"
  79. $t $(MAKE) -C $(APP) edoc $v
  80. $i "Check that the Markdown documentation was generated"
  81. $t test -f $(APP)/doc/README.md
  82. $t test -f $(APP)/doc/$(APP)_app.md
  83. $t test -f $(APP)/doc/$(APP)_sup.md
  84. edoc-src-dirs: init
  85. $i "Create a multi application repository with a root application"
  86. $t mkdir $(APP)/
  87. $t cp ../erlang.mk $(APP)/
  88. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  89. $i "Create a new application my_app"
  90. $t $(MAKE) -C $(APP) new-app in=my_app $v
  91. $i "Add apps directories to the list of EDoc source directories"
  92. $t echo 'EDOC_SRC_DIRS = $$(ALL_APPS_DIRS)' >> $(APP)/Makefile
  93. $i "Run EDoc"
  94. $t $(MAKE) -C $(APP) edoc $v
  95. $i "Check that the generated documentation includes modules from both apps"
  96. $t test -f $(APP)/doc/index.html
  97. $t test -f $(APP)/doc/$(APP)_app.html
  98. $t test -f $(APP)/doc/$(APP)_sup.html
  99. $t test -f $(APP)/doc/my_app_app.html
  100. $t test -f $(APP)/doc/my_app_sup.html