aboutsummaryrefslogtreecommitdiffstats
path: root/test/plugin_edoc.mk
blob: 575f6df1db340b31095c79d563bd9e1816fefc40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# EDoc plugin.

EDOC_TARGETS = $(call list_targets,edoc)

.PHONY: edoc $(EDOC_TARGETS)

edoc: $(EDOC_TARGETS)

edoc-build: init

	$i "Bootstrap a new OTP application named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v

	$i "Run EDoc"
	$t $(MAKE) -C $(APP) edoc $v

	$i "Check that documentation was generated"
	$t test -f $(APP)/doc/index.html
	$t test -f $(APP)/doc/$(APP)_app.html
	$t test -f $(APP)/doc/$(APP)_sup.html

	$i "Distclean the application"
	$t $(MAKE) -C $(APP) distclean $v

	$i "Check that the generated documentation was removed"
	$t test ! -e $(APP)/doc/index.html
	$t test ! -e $(APP)/doc/$(APP)_app.html
	$t test ! -e $(APP)/doc/$(APP)_sup.html

	$i "Generate a module with EDoc comments"
	$t printf "%s\n" \
		"%% @doc erlang-mk-edoc-module" \
		"-module($(APP))." \
		"-export([ok/0])." \
		"" \
		"%% @doc erlang-mk-edoc-function" \
		"ok() -> ok." > $(APP)/src/$(APP).erl

	$i "Run EDoc"
	$t $(MAKE) -C $(APP) edoc $v

	$i "Check that the new module's documentation was generated"
	$t test -f $(APP)/doc/$(APP).html

	$i "Check that the EDoc comments are in the generated documentation"
	$t grep -q erlang-mk-edoc-module $(APP)/doc/$(APP).html
	$t grep -q erlang-mk-edoc-function $(APP)/doc/$(APP).html

	$i "Generate a module with an invalid EDoc comment"
	$t printf "%s\n" \
		"-module($(APP)_fail)." \
		"-export([fail/0])." \
		"%% @spec lol" \
		"fail() -> fail." > $(APP)/src/$(APP)_fail.erl

	$i "Check that EDoc errors out"
	$t ! $(MAKE) -C $(APP) edoc $v

edoc-docs: init

	$i "Bootstrap a new OTP application named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v

	$i "Generate a doc/overview.edoc file"
	$t mkdir $(APP)/doc
	$t printf "%s\n" \
		"@author R. J. Hacker <[email protected]>" \
		"@copyright 2007 R. J. Hacker" \
		"@version 1.0.0" \
		"@title Welcome to the 'frob' application!" \
		"@doc 'frob' is a highly advanced frobnicator with low latency," > $(APP)/doc/overview.edoc

	$i "Check that EDoc runs on 'make docs'"
	$t $(MAKE) -C $(APP) docs $v
	$t test -f $(APP)/doc/index.html

	$i "Check that the overview.edoc file was used"
	$t grep -q frobnicator $(APP)/doc/overview-summary.html

edoc-no-overview: init

	$i "Bootstrap a new OTP application named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v

	$i "Check that EDoc doesn't run on 'make docs'"
	$t $(MAKE) -C $(APP) docs $v
	$t test ! -e $(APP)/doc/index.html

edoc-opts: init

	$i "Bootstrap a new OTP application named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v

	$i "Add edown doclet for EDoc"
	$t perl -ni.bak -e 'print;if ($$.==1) {print "DOC_DEPS = edown\nEDOC_OPTS = {doclet, edown_doclet}\n"}' $(APP)/Makefile

	$i "Run EDoc"
	$t $(MAKE) -C $(APP) edoc $v

	$i "Check that the Markdown documentation was generated"
	$t test -f $(APP)/doc/README.md
	$t test -f $(APP)/doc/$(APP)_app.md
	$t test -f $(APP)/doc/$(APP)_sup.md

edoc-src-dirs: init

	$i "Create a multi application repository with a root application"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v

	$i "Create a new application my_app"
	$t $(MAKE) -C $(APP) new-app in=my_app $v

	$i "Add apps directories to the list of EDoc source directories"
	$t echo 'EDOC_SRC_DIRS = $$(ALL_APPS_DIRS)' >> $(APP)/Makefile

	$i "Run EDoc"
	$t $(MAKE) -C $(APP) edoc $v

	$i "Check that the generated documentation includes modules from both apps"
	$t test -f $(APP)/doc/index.html
	$t test -f $(APP)/doc/$(APP)_app.html
	$t test -f $(APP)/doc/$(APP)_sup.html
	$t test -f $(APP)/doc/my_app_app.html
	$t test -f $(APP)/doc/my_app_sup.html

edoc-src-subdirs: init

	$i "Bootstrap a new OTP application named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v

	$i "Add current directory to the list of EDoc source directories"
	$t echo 'EDOC_SRC_DIRS = $$(CURDIR)' >> $(APP)/Makefile

	$i "Generate a module in a subdirectory with EDoc comments"
	$t mkdir $(APP)/src/subdir/
	$t printf "%s\n" \
		"%% @doc erlang-mk-edoc-subdir-module" \
		"-module($(APP))." \
		"-export([ok/0])." \
		"" \
		"%% @doc erlang-mk-edoc-subdir-function" \
		"ok() -> ok." > $(APP)/src/subdir/$(APP).erl

	$i "Run EDoc"
	$t $(MAKE) -C $(APP) edoc $v

	$i "Check that the new module's documentation was generated"
	$t test -f $(APP)/doc/$(APP).html

	$i "Check that the EDoc comments are in the generated documentation"
	$t grep -q erlang-mk-edoc-subdir-module $(APP)/doc/$(APP).html
	$t grep -q erlang-mk-edoc-subdir-function $(APP)/doc/$(APP).html

edoc-src-multiapp-subdirs: init

	$i "Bootstrap a multi application repository with a root application"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v

	$i "Create a new application my_app"
	$t $(MAKE) -C $(APP) new-app in=my_app $v

	$i "Add apps directories to the list of EDoc source directories"
	$t echo 'EDOC_SRC_DIRS = $$(ALL_APPS_DIRS)' >> $(APP)/Makefile

	$i "Generate a module in a subdirectory with EDoc comments"
	$t mkdir $(APP)/apps/my_app/src/subdir/
	$t printf "%s\n" \
		"%% @doc erlang-mk-edoc-subdir-module" \
		"-module($(APP))." \
		"-export([ok/0])." \
		"" \
		"%% @doc erlang-mk-edoc-subdir-function" \
		"ok() -> ok." > $(APP)/apps/my_app/src/subdir/$(APP).erl

	$i "Run EDoc"
	$t $(MAKE) -C $(APP) edoc $v

	$i "Check that the new module's documentation was generated"
	$t test -f $(APP)/doc/$(APP).html

	$i "Check that the EDoc comments are in the generated documentation"
	$t grep -q erlang-mk-edoc-subdir-module $(APP)/doc/$(APP).html
	$t grep -q erlang-mk-edoc-subdir-function $(APP)/doc/$(APP).html