-
Notifications
You must be signed in to change notification settings - Fork 16
/
documentation.make
262 lines (231 loc) · 10.8 KB
/
documentation.make
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#
# Etoile Documentation Makefile
#
# Inlude it right after etoile.make, like that:
# -include path/to/repository/root/etoile.make
# -include path/to/repository/root/documentation.make
#
# Any doc-related overriden variables should be put before these include
# statements.
#
# Usually this should be enough to build the doc. If not, you can override with
# documentation-related variables in the project GNUmakefile:
# $(DOC_NAME)_DOC_FILES = .h and .m paths relative to $(PROJECT_DIR)
# $(DOC_NAME)_EXCLUDED_DOC_FILES = .h and .m paths relative to $(PROJECT_DIR)
# $(DOC_NAME)_AGSDOC_EXTRA_FLAGS = autogsdoc options
# where $(DOC_NAME) is your project name suffixed with 'Doc'.
# For example, to get a more verbose output:
# EtoileFoundationDoc_AGSDOC_EXTRA_FLAGS = -Verbose YES
#
# $(DOC_NAME) is not defined before 'include documentation.make', that's why
# 'ProjectNameDoc' (in the example EtoileFoundationDoc) must be used. If you
# prefer, you can redefine DOC_NAME.
#
# Few additional variables are provided:
# $(DOC_NAME)_DOCUMENTATION_DIR = ./Documentation
# $(DOC_NAME)_HEADER_DIRS = '.' and './Headers'
# $(DOC_NAME)_SOURCE_DIRS = '.' and './Source'
# If you override a variable above such as $(DOC_NAME)_SOURCE_DIRS and still
# want to use the project directory as a search path, you must redeclare it:
# $(DOC_NAME)_SOURCE_DIRS = . SourceCodeDir1 SourceCodeDir2
#
# The .h and .m files found in the directories provided with
# $(DOC_NAME)_HEADER_DIRS and $(DOC_NAME)_SOURCE_DIRS are appended to
# $(DOC_NAME)_DOC_FILES.
#
# You can use $(DOC_NAME)_DOC_FILES to declare explicitly every .h and .m files
# to be processed, but you must then prevent the header and source directories
# to be visited by documentation.make as done below:
# $(DOC_NAME)_HEADER_DIRS=
# $(DOC_NAME)_SOURCE_DIRS=
#
# Files named TestXXX.m or TestXXX.c are not included in $(DOC_NAME)_DOC_FILES
#
# HTML templates can be customized to use other template paths:
# $(DOC_NAME)_MAIN_TEMPLATE_FILE = Developer/DocGenerator/Templates/etoile-documentation-template.html
# $(DOC_NAME)_MENU_TEMPLATE_FILE = Developer/Services/DocGenerator/Templates/menu.html
#
# Presentation, Installation and Revision History sections in the default menu
# represent respectively the Markdown files below if not overriden:
# $(DOC_NAME)_README_FILES = ./README
# $(DOC_NAME)_INSTALL_FILES = ./INSTALL
# $(DOC_NAME)_NEWS_FILES = ./NEWS
#
# This makefile creates a Documentation directory inside your project unless
# you override $(DOC_NAME)_DOCUMENTATION_DIR.
# The html ouput is also copied to Developer/Documentation/yourProjectName.
#
# To get some debug infos, append 'debug-doc=yes' to 'make doc' or
# 'make documentation=yes'. Use 'make debug-doc' to print out documentation
# variables and return immediately (no documentation generation).
#
DOC_NAME ?= $(PROJECT_NAME)Doc
$(DOC_NAME)_DOCUMENTATION_DIR ?= $(PROJECT_DIR)/Documentation
$(DOC_NAME)_HEADER_DIRS ?= $(PROJECT_DIR)/Headers $(PROJECT_DIR)
$(DOC_NAME)_SOURCE_DIRS ?= $(PROJECT_DIR)/Source $(PROJECT_DIR)
# Some shortcut variables
DEV_DOC_DIR = $(PREFIX)/Developer/Documentation
PROJECT_DOC_DIR = $($(DOC_NAME)_DOCUMENTATION_DIR)
# Expand relative paths in variables which allows it
ifdef $(DOC_NAME)_DOC_FILES
$(DOC_NAME)_DOC_FILES := $(foreach file, $($(DOC_NAME)_DOC_FILES), $(PROJECT_DIR)/$(wildcard $(file)))
endif
$(DOC_NAME)_EXCLUDED_DOC_FILES := $(foreach file, $($(DOC_NAME)_EXCLUDED_DOC_FILES), $(PROJECT_DIR)/$(wildcard $(file)))
ifdef $(DOC_NAME)_README_FILES
$(DOC_NAME)_README_FILES := $(foreach file, $($(DOC_NAME)_README_FILES), $(PROJECT_DIR)/$(wildcard $(file)))
endif
ifdef $(DOC_NAME)_INSTALL_FILES
$(DOC_NAME)_INSTALL_FILES := $(foreach file, $($(DOC_NAME)_INSTALL_FILES), $(PROJECT_DIR)/$(wildcard $(file)))
endif
ifdef $(DOC_NAME)_NEWS_FILES
$(DOC_NAME)_NEWS_FILES := $(foreach file, $($(DOC_NAME)_NEWS_FILES), $(PROJECT_DIR)/$(wildcard $(file)))
endif
# Collect .h and .m paths in header and source directories
$(DOC_NAME)_DOC_FILES += $(foreach headerdir, $($(DOC_NAME)_HEADER_DIRS), $(wildcard $(headerdir)/*.h))
$(DOC_NAME)_DOC_FILES += $(foreach sourcedir, $($(DOC_NAME)_SOURCE_DIRS), $(wildcard $(sourcedir)/[^T]?[^e]?[^s]?[^t]?*.m))
$(DOC_NAME)_DOC_FILES += $(foreach sourcedir, $($(DOC_NAME)_SOURCE_DIRS), $(wildcard $(sourcedir)/[^T]?[^e]?[^s]?[^t]?*.c))
# Remove .h and .m paths for which no doc should be generated
$(DOC_NAME)_DOC_FILES := $(foreach file, $($(DOC_NAME)_DOC_FILES), \
$(if $(findstring $(file), $($(DOC_NAME)_EXCLUDED_DOC_FILES)),, $(file)))
# autogsdoc variables (do not use or override)
# Without rewriting, $(DOC_NAME)_AGSDOC_FILES := $($(DOC_NAME)_DOC_FILES)
$(DOC_NAME)_AGSDOC_FILES := $(foreach file, $($(DOC_NAME)_DOC_FILES), $(PROJECT_DOC_DIR)/ObjC/$(notdir $(file)))
# etdocgen variables
$(DOC_NAME)_IMAGES_DIR ?= $(PREFIX)/Developer/Services/DocGenerator/Templates/images
$(DOC_NAME)_WEBINCLUDES_DIR ?= $(PREFIX)/Developer/Services/DocGenerator/Templates/_includes
$(DOC_NAME)_MAIN_TEMPLATE_FILE ?= $(PREFIX)/Developer/Services/DocGenerator/Templates/etoile-documentation-template.html
$(DOC_NAME)_MENU_TEMPLATE_FILE ?= $(PREFIX)/Developer/Services/DocGenerator/Templates/menu.html
$(DOC_NAME)_EXTERNAL_INDEX_UNIT_FILES += $(PREFIX)/Developer/Services/DocGenerator/TestFiles/class-mapping.plist
$(DOC_NAME)_GSDOC_FILES += $(foreach sourcedir, $($(DOC_NAME)_DOCUMENTATION_DIR)/GSDoc, $(wildcard $(sourcedir)/*.gsdoc))
$(DOC_NAME)_GSDOC_FILES += $(foreach sourcedir, $($(DOC_NAME)_DOCUMENTATION_DIR)/GSDoc, $(wildcard $(sourcedir)/*.gsdoc))
$(DOC_NAME)_README_FILES ?= $(wildcard $(PROJECT_DIR)/README*)
$(DOC_NAME)_INSTALL_FILES ?= $(wildcard $(PROJECT_DIR)/INSTALL*)
$(DOC_NAME)_NEWS_FILES ?= $(wildcard $(PROJECT_DIR)/NEWS*)
# An optional rewriter for supporting Objective-C properties (objcrewriter.io is
# bundled in DocGenerator but must be installed manually in the shell PATH)
OBJC_REWRITER = objcrewriter.io
# We pass -Project otherwise the title is DOC_NAME with the Doc suffix
$(DOC_NAME)_AGSDOC_FLAGS = \
-Project $(PROJECT_NAME) \
-MakeFrames YES \
-DocumentationDirectory $($(DOC_NAME)_DOCUMENTATION_DIR)/GSDoc \
-GenerateParagraphMarkup YES \
-Warn NO
.PHONY: doc before-doc objcrewriter gsdocgen etdocgen after-doc debug-doc
# The user-visible target used to build the documentation
doc: before-doc objcrewriter gsdoc etdoc after-doc
objcrewriter:
$(ECHO_NOTHING) \
if command -v $(OBJC_REWRITER) >/dev/null 2>&1; then \
cd $(PROJECT_DOC_DIR)/ObjC && $(OBJC_REWRITER); \
else \
echo ""; \
echo "WARNING: Found no $(OBJC_REWRITER) installed. Objective-C properties won't be rewritten into accessors."; \
echo ""; \
fi \
$(END_ECHO)
# The main target that invokes autogsdoc to output .gsdoc and .html files
gsdoc:
autogsdoc $($(DOC_NAME)_AGSDOC_FLAGS) $($(DOC_NAME)_AGSDOC_EXTRA_FLAGS) -Files $($(DOC_NAME)_DOCUMENTATION_DIR)/doc-make-dependencies
etdoc:
etdocgen -n $(PROJECT_NAME) -c $(PROJECT_DOC_DIR)/GSDoc -t $($(DOC_NAME)_MAIN_TEMPLATE_FILE) -m $($(DOC_NAME)_MENU_TEMPLATE_FILE) -e $($(DOC_NAME)_EXTERNAL_INDEX_UNIT_FILES) -o $(PROJECT_DOC_DIR) $($(DOC_NAME)_README_FILES) $($(DOC_NAME)_INSTALL_FILES) $($(DOC_NAME)_NEWS_FILES)
# A debugging target useful to print out the documentation.make variables without
# any tool invocation
debug-doc:
export debug-doc=yes
# Build the plist array saved as doc-make-dependencies in before-doc and
# passed to autogsdoc with -Files in internal-doc
comma := ,
blank :=
space := $(blank) $(blank)
$(DOC_NAME)_AGSDOC_FILES := $(strip $($(DOC_NAME)_AGSDOC_FILES))
AGSDOC_FILE_ARRAY := $(subst $(space),$(comma)$(space),($($(DOC_NAME)_AGSDOC_FILES)))
PROJECT_DOC_FILES := $(strip $($(DOC_NAME)_DOC_FILES))
ifeq ($(debug-doc), yes)
$(warning $(DOC_NAME)_HEADER_DIRS=$($(DOC_NAME)_HEADER_DIRS))
$(warning $(DOC_NAME)_SOURCE_DIRS=$($(DOC_NAME)_SOURCE_DIRS))
$(warning $(DOC_NAME)_EXCLUDED_DOC_FILES=$($(DOC_NAME)_EXCLUDED_DOC_FILES))
$(warning $(DOC_NAME)_DOC_FILES=$($(DOC_NAME)_DOC_FILES))
$(warning $(DOC_NAME)_AGSDOC_FLAGS=$($(DOC_NAME)_AGSDOC_FLAGS))
$(warning AGSDOC_FILE_ARRAY = $(AGSDOC_FILE_ARRAY))
$(warning DEV_DOC_DIR = $(DEV_DOC_DIR))
$(warning PROJECT_DOC_DIR = $(PROJECT_DOC_DIR))
$(warning PROJECT_DIR = $(PROJECT_DIR))
$(warning PREFIX = $(PREFIX))
endif
# Create the Documentation directory and a file that contains the .h and .m file list
before-doc:
$(ECHO_NOTHING) \
if [ ! -d $(PROJECT_DOC_DIR) ]; then \
mkdir $(PROJECT_DOC_DIR); \
fi; \
if [ ! -d $(PROJECT_DOC_DIR)/GSDoc ]; then \
mkdir $(PROJECT_DOC_DIR)/GSDoc; \
fi; \
if [ ! -d $(PROJECT_DOC_DIR)/ObjC ]; then \
mkdir $(PROJECT_DOC_DIR)/ObjC; \
fi; \
if [ ! -e $(PROJECT_DOC_DIR)/../images ]; then \
ln -s $($(DOC_NAME)_IMAGES_DIR) $(PROJECT_DOC_DIR)/../images; \
fi; \
if [ ! -e $(PROJECT_DOC_DIR)/../_includes ]; then \
ln -s $($(DOC_NAME)_WEBINCLUDES_DIR) $(PROJECT_DOC_DIR)/../_includes; \
fi; \
rm -f $(PROJECT_DOC_DIR)/ObjC/*.h; \
rm -f $(PROJECT_DOC_DIR)/ObjC/*.m; \
rm -f $(PROJECT_DOC_DIR)/ObjC/*.c; \
for sourceFile in $(PROJECT_DOC_FILES); do \
cp $$sourceFile $(PROJECT_DOC_DIR)/ObjC; \
done; \
echo "$(AGSDOC_FILE_ARRAY)" > $(PROJECT_DOC_DIR)/doc-make-dependencies \
$(END_ECHO)
# Create the project doc index.html
# Export the generated doc to Developer/Documentation and recreate the index.html
# that enumerates the documented projects
after-doc:
$(ECHO_NOTHING) \
if [ -f $(PROJECT_DOC_DIR)/README.html ]; then \
ln -s ./README.html $(PROJECT_DOC_DIR)/index.html; \
fi; \
if [ ! -d $(DEV_DOC_DIR) ]; then \
mkdir $(DEV_DOC_DIR); \
fi; \
if [ ! -d $(DEV_DOC_DIR)/$(PROJECT_NAME) ]; then \
mkdir $(DEV_DOC_DIR)/$(PROJECT_NAME); \
fi; \
for file in $(PROJECT_DOC_DIR)/*.html; do \
if [ -f $$file ]; then \
cp $$file $(DEV_DOC_DIR)/$(PROJECT_NAME); \
fi; \
done; \
if [ -x $(DEV_DOC_DIR)/create-project-doc-index.sh ]; then \
cd $(DEV_DOC_DIR) && $(DEV_DOC_DIR)/create-project-doc-index.sh > $(DEV_DOC_DIR)/index.html; \
fi; \
$(END_ECHO)
# The user-visible target to remove generated content
# autogsdoc -Clean YES doesn't work well, it removes the html files if I pass *
# but that's it, so let's do it with rm...
# We also remove stuff previously copied to Developer/Documentation
clean-doc:
$(ECHO_NOTHING) \
rm $(PROJECT_DOC_DIR)/../_includes \
rm $(PROJECT_DOC_DIR)/../images \
rm -f $(PROJECT_DOC_DIR)/doc-make-dependencies \
rm -f $(PROJECT_DOC_DIR)/GSDoc/*.igsdoc \
rm -f $(PROJECT_DOC_DIR)/GSDoc/*.gsdoc \
rm -f $(PROJECT_DOC_DIR)/GSDoc/*.html \
rm -f $(PROJECT_DOC_DIR)/GSDoc/*.plist \
rm -f $(PROJECT_DOC_DIR)/ObjC/*.h \
rm -f $(PROJECT_DOC_DIR)/ObjC/*.m \
rm -f $(PROJECT_DOC_DIR)/ObjC/*.c \
rm -f $(PROJECT_DOC_DIR)/*.igsdoc \
rm -f $(PROJECT_DOC_DIR)/*.gsdoc \
rm -f $(PROJECT_DOC_DIR)/*.html \
rm -f $(PROJECT_DOC_DIR)/*.png \
rm -f $(DEV_DOC_DIR)/$(PROJECT_NAME)/*.html \
$(END_ECHO)
# GNUstep Make Integration
ifeq ($(documentation), yes)
after-all:: doc
endif
after-distclean:: clean-doc