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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
|
# tag:docs
TOUCH_DOCS=$YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${kv;hide:"p DC"} ${kv;hide:"pc light-cyan"} $TARGET
TOUCH_DOCS_MF=$TOUCH_DOCS && $GENERATE_MF
# tag:docs
### @usage: DOCS_COPY_FILE(FROM src_dir [NAMESPCE dst_dir] files...)
###
### Copy files from src_dir to $BINDIR/dst_dir
macro DOCS_COPY_FILES(FROM="${CURDIR}", NAMESPACE=".", FILES...) {
.CMD=$YMAKE_PYTHON ${input:"build/scripts/copy_docs_files.py"} --source-root $ARCADIA_ROOT --build-root $ARCADIA_BUILD_ROOT --src-dir $FROM --dst-dir $BINDIR/$NAMESPACE $FILES ${input;hide;context=TEXT;pre=${FROM}/:FILES} ${output;hide;pre=${NAMESPACE}/:FILES}
}
# tag:docs
_DOCS_USE_PLANTUML=no
_DOCS_EXTRA_TOOLS=
_DOCS_EXTRA_INPUTS=
_DOCS_ENV=
_DOCS_KV=${kv;hide:"p DO"} ${kv;hide:"pc light-cyan"} ${kv;hide:"show_out yes"}
_DOCS_PLANTUML_ENV=\
${env:"JAVA_PATH=$JDK_RESOURCE_GLOBAL/bin/java"} \
${env:"PLANTUML_PATH=${ARCADIA_BUILD_ROOT}/contrib/tools/plantuml/plantuml.run.cp.jar"} \
${env:"_JAVA_OPTIONS='-Dsun.awt.fontconfig=$BINDIR/fontconfig.properties -Djava.awt.headless=true'"} \
${env:"LANG=en_US.UTF-8"} \
${env:"LC_ALL=C.UTF-8"}
_DOCS_SRCS_VALUE=
_DOCS_VARS_FLAG=
_DOCS_YFM_OUTPUT_FORMAT=
_DOCS_YFM_BOOK_OUTPUT_FORMAT=--output-format html --allowHTML
_DOCS_YFM_LIB_OUTPUT_FORMAT=--output-format md --add-map-file
_DOCS_YFM_CMDLINE=\
${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/extract_docs.py"} --skip-prefix $ARCADIA_BUILD_ROOT --dest-dir $BINDIR/__s ${rootrel:PEERS} \
&& $YMAKE_PYTHON ${input:"build/scripts/stdout2stderr.py"} $YFM_TOOL_RESOURCE_GLOBAL/yfm-docs --input $BINDIR/__s --output $BINDIR/__docsbuild $_DOCS_VARS_FLAG $_DOCS_YFM_OUTPUT_FORMAT --config ${input:CONFIG} $_DOCS_EXTRA_TOOLS ${hide;input:EXTRA_INPUTS} $_DOCS_ENV \
&& $YMAKE_PYTHON ${input:"build/scripts/tar_sources.py"} --output $TARGET --input $BINDIR/__docsbuild $_DOCS_KV
# tag:internal tag:docs
macro _DOCS_YFM_CMD_IMPL(CONFIG, INCLUDE_SRCS[], EXTRA_INPUTS[]) {
.CMD=$_DOCS_YFM_CMDLINE
}
_DOCS_YFM_CMD=$_DOCS_YFM_CMD_IMPL($_DOCS_CONFIG_VALUE INCLUDE_SRCS $_DOCS_INCLUDE_SOURCES_VALUE EXTRA_INPUTS $_DOCS_EXTRA_INPUTS)
# tag:docs
### This module is intended for internal use only. Common parts for DOCS and MKDOCS multimodules
### should be defined here.
module _DOCS_BARE_UNIT: _BARE_UNIT {
.ALLOWED=DOCS_DIR DOCS_CONFIG DOCS_VARS
.CMD=TOUCH_DOCS_MF
.FINAL_TARGET=no
.PEERDIR_POLICY=as_include
ENABLE(_DOCS_BARE_UNIT)
SET(MODULE_SUFFIX .tar.gz)
SET(MODULE_LANG DOCS)
}
# tag:docs tag:internal
_DOCS_DIR_INTERNAL_NAMESPACE=
# tag:internal tag:docs
_DOCS_LIBRARY_CMDLINE=\
$YMAKE_PYTHON ${input:"build/scripts/copy_docs_files_to_dir.py"} $_DOCS_SRCS_VALUE $_DOCS_DIR_VALUE $_DOCS_BIN_DIR_VALUE --dest-dir $BINDIR/__s --source-root $ARCADIA_ROOT --build-root $ARCADIA_BUILD_ROOT ${input;context=TEXT:INCLUDE_SRCS} \
&& $YMAKE_PYTHON ${input:"build/scripts/tar_sources.py"} --output $TARGET --input $BINDIR/__s $_DOCS_KV
# tag:internal tag:docs
macro _DOCS_LIBRARY_CMD_IMPL(INCLUDE_SRCS[], EXTRA_INPUTS[]) {
.CMD=$_DOCS_LIBRARY_CMDLINE
}
_DOCS_LIBRARY_CMD=$_DOCS_LIBRARY_CMD_IMPL(INCLUDE_SRCS $_DOCS_INCLUDE_SOURCES_VALUE)
# tag:docs
module DOCS_LIBRARY: _DOCS_BARE_UNIT {
.CMD=_DOCS_LIBRARY_CMD
.ALIASES=SRCS=_DOCS_SRCS DOCS_DIR=_YFM_DOCS_DIR
.EPILOGUE=_DOCS_LIBRARY_EPILOGUE
ENABLE(DOCS_LIBRARY)
SET(MODULE_TYPE LIBRARY)
SET(MODULE_TAG DOCS_LIBRARY)
SET(PEERDIR_TAGS DOCS_LIBRARY)
SET(MODULE_SUFFIX .docslib)
}
# tag:docs
macro _DOCS_SRCS(SRCDIR=".", EXCLUDE[], INCLUDE...) {
SET(_VAR_DOCS_SRCS_SALT $SRCDIR $EXCLUDE $INCLUDE)
SET(_DOCS_SRCS_GLOB uniq_docs_${hash:_VAR_DOCS_SRCS_SALT})
_LATE_GLOB(${_DOCS_SRCS_GLOB} ${pre=${SRCDIR}/:INCLUDE} EXCLUDE ${EXCLUDE})
SET_APPEND(_DOCS_INCLUDE_SOURCES_VALUE \${input:$_DOCS_SRCS_GLOB})
}
# tag:docs
macro _DOCS_LIBRARY_EPILOGUE() {
_YFM_DOCS_DIR($_YFM_DOCS_DIR_DEFAULT_VALUE)
_SET_DOCS_BIN_DIR_FLAG($_DOCS_DIR_INTERNAL_NAMESPACE $MODDIR)
}
# tag:docs
### This module is intended for internal use only. Common parts for submodules of DOCS multimodule
### should be defined here.
module _DOCS_BASE_UNIT: _DOCS_BARE_UNIT {
.ALIASES=DOCS_DIR=_YFM_DOCS_DIR
ENABLE(_DOCS_BASE_UNIT)
PEERDIR+=build/platform/yfm
DOCS_CONFIG($_DOCS_YFM_DEFAULT_CONFIG)
}
# tag:internal tag:docs
### _DOCS_YFM_USE_PLANTUML() # internal
###
### This macr sets appropriate dependencies for use of plantuml plugin
macro _DOCS_YFM_USE_PLANTUML() {
PEERDIR(build/platform/java/jdk contrib/java/openjdk-fontconfig)
COPY_FILE(${ARCADIA_BUILD_ROOT}/contrib/java/openjdk-fontconfig/fontconfig.properties fontconfig.properties)
SET_APPEND(_DOCS_EXTRA_TOOLS \${hide;tool:"contrib/tools/plantuml"})
SET_APPEND(_DOCS_EXTRA_INPUTS fontconfig.properties)
# It's rather strange that a commented statement below doesn't work
# SET_APPEND(_DOCS_ENV ${_DOCS_PLANTUML_ENV})
when ($_DOCS_USE_PLANTUML) {
_DOCS_ENV+=$_DOCS_PLANTUML_ENV
}
}
# tag:docs
### @usage: DOCS()
###
### Documentation project multimodule.
###
### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site.
### When PEERDIRed from other DOCS() module behaves like a UNION (supplying own content and dependencies to build target).
### Peerdirs from modules other than DOCS are not accepted.
### Most usual macros are not accepted, only used with the macros DOCS_DIR(), DOCS_CONFIG(), DOCS_VARS().
###
### @see: [DOCS_DIR()](#macro_DOCS_DIR), [DOCS_CONFIG()](#macro_DOCS_CONFIG), [DOCS_VARS()](#macro_DOCS_VARS).
multimodule DOCS {
module DOCSBOOK: _DOCS_BASE_UNIT {
.CMD=_DOCS_YFM_CMD
.FINAL_TARGET=yes
.PEERDIR_POLICY=as_build_from
.IGNORED=DOCS_DIR DOCS_INCLUDE_SOURCES PEERDIR
.PEERDIRSELF=DOCSLIB_INTERNAL
ENABLE(DOCSBOOK)
SET(MODULE_TYPE PROGRAM)
SET(MODULE_TAG DOCSBOOK)
SET(PEERDIR_TAGS DOCSLIB_INTERNAL)
_DOCS_YFM_OUTPUT_FORMAT=$_DOCS_YFM_BOOK_OUTPUT_FORMAT
PROCESS_DOCS()
}
module DOCSLIB: _DOCS_BASE_UNIT {
.CMD=_DOCS_YFM_CMD
.FINAL_TARGET=yes
.PEERDIR_POLICY=as_build_from
.IGNORED=DOCS_DIR DOCS_INCLUDE_SOURCES PEERDIR
.PEERDIRSELF=DOCSLIB_INTERNAL
ENABLE(DOCSLIB)
SET(MODULE_TYPE PROGRAM)
SET(MODULE_TAG DOCSLIB)
SET(PEERDIR_TAGS DOCSLIB_INTERNAL)
REALPRJNAME=preprocessed
_DOCS_YFM_OUTPUT_FORMAT=$_DOCS_YFM_LIB_OUTPUT_FORMAT
PROCESS_DOCS()
}
module DOCSLIB_INTERNAL: DOCS_LIBRARY {
.IGNORED=DOCS_CONFIG
.EPILOGUE=_DOCS_LIBRARY_EPILOGUE
ENABLE(DOCSLIB_INTERNAL)
DISABLE(START_TARGET)
SET(MODULE_TYPE LIBRARY)
SET(MODULE_TAG DOCSLIB_INTERNAL)
SET(PEERDIR_TAGS DOCSLIB_EXTERNAL DOCS_LIBRARY)
# additional .fake extension make this output suppressed by ya-bin
SET(MODULE_SUFFIX .docslib.fake)
SET(_DOCS_DIR_INTERNAL_NAMESPACE .)
REALPRJNAME=__docs_internal
}
module DOCSLIB_EXTERNAL: DOCS_LIBRARY {
.IGNORED=DOCS_CONFIG
.EPILOGUE=_DOCS_LIBRARY_EPILOGUE
ENABLE(DOCSLIB_EXTERNAL)
DISABLE(START_TARGET)
SET(MODULE_TYPE LIBRARY)
SET(MODULE_TAG DOCSLIB_EXTERNAL)
SET(PEERDIR_TAGS DOCSLIB_EXTERNAL DOCS_LIBRARY)
REALPRJNAME=__docs_external
}
}
_DOCS_MKDOCS_CMDLINE_SUFFIX=
_DOCS_MKDOCS_BOOK_CMDLINE_SUFFIX=${pre=--dep ;ext=preprocessed.tar.gz:PEERS}
_DOCS_MKDOCS_LIB_CMDLINE_SUFFIX=--preprocess-md-only
_DOCS_MKDOCS_CMDLINE=\
${cwd:ARCADIA_ROOT} $FS_TOOLS copy_all_files $_MKDOCS_DOCS_DIR_VALUE $BINDIR/__s $_DOCS_SRCS_VALUE \
&& $YMAKE_PYTHON ${input:"build/scripts/copy_files_to_dir.py"} --dest-dir $BINDIR/__s --skip-prefix $ARCADIA_ROOT --skip-prefix $ARCADIA_BUILD_ROOT ${input;context=TEXT:INCLUDE_SRCS} \
&& ${cwd:BINDIR} $YMAKE_PYTHON ${input:"build/scripts/mkdocs_builder_wrapper.py"} $ARCADIA_BUILD_ROOT ${tool:"tools/mkdocs_builder"} --docs-dir $BINDIR/__s --output-tar $TARGET --config ${input:CONFIG} $_DOCS_VARS_FLAG $_DOCS_MKDOCS_CMDLINE_SUFFIX $_DOCS_EXTRA_TOOLS ${hide;input:EXTRA_INPUTS} $_DOCS_ENV $_DOCS_KV
# tag:internal tag:docs
macro _DOCS_MKDOCS_CMD_IMPL(CONFIG, INCLUDE_SRCS[], EXTRA_INPUTS[]) {
.CMD=$_DOCS_MKDOCS_CMDLINE
}
_DOCS_MKDOCS_CMD=$_DOCS_MKDOCS_CMD_IMPL($_DOCS_CONFIG_VALUE INCLUDE_SRCS $_DOCS_INCLUDE_SOURCES_VALUE)
_DOCS_YFM_DEFAULT_CONFIG=$MODDIR/.yfm
_DOCS_MKDOCS_DEFAULT_CONFIG=$MODDIR/mkdocs.yml
# tag:docs
### This module is intended for internal use only. Common parts for submodules of MKDOCS multimodule
### should be defined here.
module _MKDOCS_BASE_UNIT: _DOCS_BARE_UNIT {
.RESTRICTED=DOCS_BUILDER
.ALIASES=DOCS_DIR=_MKDOCS_DOCS_DIR
ENABLE(_MKDOCS_BASE_UNIT)
DOCS_CONFIG($_DOCS_MKDOCS_DEFAULT_CONFIG)
}
# tag:internal tag:docs
### _MKDOCS_EPILOOGUE() # internal
###
### This macro executes macros which should be envoked after all user
### specified macros in the ya.make file
macro _MKDOCS_EPILOGUE() {
_LATE_GLOB(_DOCS_SRCS_GLOB ${pre=${ARCADIA_ROOT}/;suf=/**/*:_MKDOCS_DOCS_DIR_VALUE})
SET(_DOCS_SRCS_VALUE \${input;hide:_DOCS_SRCS_GLOB})
}
# tag:docs
### @usage: MKDOCS()
###
### Documentation project multimodule.
###
### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site (using mkdocs as builder).
### When PEERDIRed from other MKDOCS() module behaves like a UNION (supplying own content and dependencies to build target).
### Peerdirs from modules other than MKDOCS are not accepted.
### Most usual macros are not accepted, only used with the macros DOCS_DIR(), DOCS_CONFIG(), DOCS_VARS().
###
### @see: [DOCS_DIR()](#macro_DOCS_DIR), [DOCS_CONFIG()](#macro_DOCS_CONFIG), [DOCS_VARS()](#macro_DOCS_VARS).
multimodule MKDOCS {
module MKDOCSBOOK: _MKDOCS_BASE_UNIT {
.CMD=_DOCS_MKDOCS_CMD
.EPILOGUE=_MKDOCS_EPILOGUE
.FINAL_TARGET=yes
.PEERDIR_POLICY=as_build_from
ENABLE(MKDOCSBOOK)
SET(MODULE_TYPE PROGRAM)
SET(PEERDIR_TAGS MKDOCSLIB)
SET(MODULE_TAG MKDOCSBOOK)
_DOCS_MKDOCS_CMDLINE_SUFFIX=$_DOCS_MKDOCS_BOOK_CMDLINE_SUFFIX
PROCESS_MKDOCS()
}
module MKDOCSLIB: _MKDOCS_BASE_UNIT {
.CMD=_DOCS_MKDOCS_CMD
.EPILOGUE=_MKDOCS_EPILOGUE
.PEERDIR_POLICY=as_include
ENABLE(MKDOCSLIB)
SET(MODULE_TYPE LIBRARY)
SET(PEERDIR_TAGS MKDOCSLIB)
SET(MODULE_TAG MKDOCSLIB)
REALPRJNAME=preprocessed
_DOCS_MKDOCS_CMDLINE_SUFFIX=$_DOCS_MKDOCS_LIB_CMDLINE_SUFFIX
PROCESS_MKDOCS()
}
}
# tag:docs
_DOCS_USE_PLANTUML=
### @usage: USE_PLANTUML()
###
### Use PlantUML plug-in for yfm builder to render UML diagrams into documentation
macro USE_PLANTUML() {
ENABLE(_DOCS_USE_PLANTUML)
}
# tag:docs tag:deprecated
### @usage: DOCS_BUILDER(tool) # deprecated
macro DOCS_BUILDER(DocsTool) {
ENABLE(UNUSED_MACRO)
}
# tag:docs
_DOCS_DIR_VALUE=
_DOCS_BIN_DIR_VALUE=
### @usage: DOCS_DIR(path)
###
### Specify directory with source .md files for DOCS multimodule if it differs from project directory.
### Path must be Arcadia root relative.
###
### @see: [DOCS](#multimodule_DOCS)
macro DOCS_DIR(Dir) {
ENABLE(UNUSED_MACRO)
}
# tag:docs tag:internal
macro _APPEND_DOCS_DIR_FLAG(DIR, NAMESPACE, DYMMY...) {
SET_APPEND(_DOCS_DIR_VALUE --docs-dir $DIR $NAMESPACE)
}
# tag:docs tag:internal
macro _SET_DOCS_BIN_DIR_FLAG(NAMESPACE, DUMMY...) {
SET(_DOCS_BIN_DIR_VALUE --bin-dir $BINDIR $NAMESPACE $AUTO_INPUT)
}
# tag:docs tag:internal
_YFM_DOCS_DIR_DEFAULT_VALUE=$MODDIR
_YFM_DEFAULT_NAMESPACE=
### @usage: DOCS_DIR(path) # internal
macro _YFM_DOCS_DIR(DIR) {
_APPEND_DOCS_DIR_FLAG($DIR $_DOCS_DIR_INTERNAL_NAMESPACE $DIR)
SET(_VAR_DOCS_DIR_SALT $MODDIR $DIR)
SET(_DOCS_DIR_GLOB uniq_docs_dir_${hash:_VAR_DOCS_DIR_SALT})
_LATE_GLOB(${_DOCS_DIR_GLOB} ${ARCADIA_ROOT}/$DIR/**/*)
SET_APPEND(_DOCS_SRCS_VALUE \${input;hide:$_DOCS_DIR_GLOB})
# We set the value of var _YFM_DOCS_DIR_DEFAULT_VALUE to some non-existing dir. This value
# will be used in _DOCS_LIBRARY_EPILOGUE calls. In case when this macro _YFM_DOCS_DIR is
# explicitly called in DOCS_LIBRARY module $MODDIR as default DOCS_DIR for DOCS_LIBRARY will
# be ignore.
SET(_YFM_DOCS_DIR_DEFAULT_VALUE __dummy_dir__)
}
# tag:docs tag:internal
_MKDOCS_DOCS_DIR_VALUE=$MODDIR
### @usage: DOCS_DIR(path) # internal
macro _MKDOCS_DOCS_DIR(Dir) {
SET(_MKDOCS_DOCS_DIR_VALUE $Dir)
}
# tag:docs
_DOCS_DEFAULT_CONFIG=
_DOCS_CONFIG_VALUE=$_DOCS_DEFAULT_CONFIG
### @usage: DOCS_CONFIG(path)
###
### Specify path to config file for DOCS multimodule if it differs from default path.
### If used for [MKDOCS](#multimodule_MKDOCS) multimodule the default path is "%%project_directory%%/mkdocs.yml".
### If used for [DOCS](#multimodule_DOCS) multimodule the default path is "%%project_directory%%/.yfm".
### Path must be either Arcadia root relative.
###
### @see: [DOCS](#multimodule_DOCS)
macro DOCS_CONFIG(File) {
SET(_DOCS_CONFIG_VALUE $File)
}
# tag:docs
_DOCS_VARS_VALUE=
### @usage: DOCS_VARS(variable1=value1 variable2=value2 ...)
###
### Specify a set of default values of template variables for DOCS multimodule.
### There must be no spaces around "=". Values will be treated as strings.
###
### @see: [DOCS](#multimodule_DOCS)
macro DOCS_VARS(Args...) {
SET_APPEND(_DOCS_VARS_VALUE $Args)
}
# tag:docs
_DOCS_INCLUDE_SOURCES_VALUE=
### @usage: DOCS_INCLUDE_SOURCES(path...)
###
### Specify a list of paths to source code files which will be used as text includes in a documentation project.
### Paths must be Arcadia root relative.
###
### @see: [DOCS](#multimodule_DOCS)
macro DOCS_INCLUDE_SOURCES(Args...) {
SET_APPEND(_DOCS_INCLUDE_SOURCES_VALUE $Args)
}
|