plugin_edoc.mk 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # EDoc plugin.
  2. EDOC_CASES = build docs no-overview opts
  3. EDOC_TARGETS = $(addprefix edoc-,$(EDOC_CASES))
  4. .PHONY: edoc $(EDOC_TARGETS)
  5. edoc: $(EDOC_TARGETS)
  6. edoc-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 "Run EDoc"
  12. $t $(MAKE) -C $(APP) edoc $v
  13. $i "Check that documentation was generated"
  14. $t test -f $(APP)/doc/index.html
  15. $t test -f $(APP)/doc/$(APP)_app.html
  16. $t test -f $(APP)/doc/$(APP)_sup.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)/doc/index.html
  21. $t test ! -e $(APP)/doc/$(APP)_app.html
  22. $t test ! -e $(APP)/doc/$(APP)_sup.html
  23. $i "Generate a module with EDoc comments"
  24. $t printf "%s\n" \
  25. "%% @doc erlang-mk-edoc-module" \
  26. "-module($(APP))." \
  27. "-export([ok/0])." \
  28. "" \
  29. "%% @doc erlang-mk-edoc-function" \
  30. "ok() -> ok." > $(APP)/src/$(APP).erl
  31. $i "Run EDoc"
  32. $t $(MAKE) -C $(APP) edoc $v
  33. $i "Check that the new module's documentation was generated"
  34. $t test -f $(APP)/doc/$(APP).html
  35. $i "Check that the EDoc comments are in the generated documentation"
  36. $t grep -q erlang-mk-edoc-module $(APP)/doc/$(APP).html
  37. $t grep -q erlang-mk-edoc-function $(APP)/doc/$(APP).html
  38. $i "Generate a module with an invalid EDoc comment"
  39. $t printf "%s\n" \
  40. "-module($(APP)_fail)." \
  41. "-export([fail/0])." \
  42. "%% @spec lol" \
  43. "fail() -> fail." > $(APP)/src/$(APP)_fail.erl
  44. $i "Check that EDoc errors out"
  45. $t ! $(MAKE) -C $(APP) edoc $v
  46. edoc-docs: build clean
  47. $i "Bootstrap a new OTP application named $(APP)"
  48. $t mkdir $(APP)/
  49. $t cp ../erlang.mk $(APP)/
  50. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  51. $i "Generate a doc/overview.edoc file"
  52. $t mkdir $(APP)/doc
  53. $t printf "%s\n" \
  54. "@author R. J. Hacker <rjh@acme.com>" \
  55. "@copyright 2007 R. J. Hacker" \
  56. "@version 1.0.0" \
  57. "@title Welcome to the 'frob' application!" \
  58. "@doc 'frob' is a highly advanced frobnicator with low latency," > $(APP)/doc/overview.edoc
  59. $i "Check that EDoc runs on 'make docs'"
  60. $t $(MAKE) -C $(APP) docs $v
  61. $t test -f $(APP)/doc/index.html
  62. $i "Check that the overview.edoc file was used"
  63. $t grep -q frobnicator $(APP)/doc/overview-summary.html
  64. edoc-no-overview: build clean
  65. $i "Bootstrap a new OTP application named $(APP)"
  66. $t mkdir $(APP)/
  67. $t cp ../erlang.mk $(APP)/
  68. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  69. $i "Check that EDoc doesn't run on 'make docs'"
  70. $t $(MAKE) -C $(APP) docs $v
  71. $t test ! -e $(APP)/doc/index.html
  72. edoc-opts: 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 edown doclet for EDoc"
  78. $t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = edown\nEDOC_OPTS = {doclet, edown_doclet}\n"}' $(APP)/Makefile
  79. $i "Run EDoc"
  80. $t $(MAKE) -C $(APP) edoc $v
  81. $i "Check that the Markdown documentation was generated"
  82. $t test -f $(APP)/doc/README.md
  83. $t test -f $(APP)/doc/$(APP)_app.md
  84. $t test -f $(APP)/doc/$(APP)_sup.md