docs.conf 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. #
  2. # Documentation build support
  3. #
  4. # tag:docs
  5. TOUCH_DOCS=$YMAKE_PYTHON3 ${input:"build/scripts/touch.py"} ${kv;hide:"p DC"} ${kv;hide:"pc light-cyan"} $TARGET
  6. TOUCH_DOCS_MF=$TOUCH_DOCS && $GENERATE_MF
  7. # tag:docs
  8. ### @usage: DOCS_COPY_FILES(FROM src_dir [NAMESPCE dst_dir] files...)
  9. ###
  10. ### Copy files from src_dir to $BINDIR/dst_dir
  11. macro DOCS_COPY_FILES(FROM="${CURDIR}", NAMESPACE=".", FILES...) {
  12. .CMD=$YMAKE_PYTHON3 ${input:"build/scripts/copy_docs_files.py"} ${input;hide:"build/scripts/process_command_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}
  13. }
  14. # tag:docs
  15. _DOCS_USE_PLANTUML=no
  16. _DOCS_EXTRA_TOOLS=
  17. _DOCS_EXTRA_INPUTS=
  18. _DOCS_ENV=
  19. _DOCS_KV=${kv;hide:"p DO"} ${kv;hide:"pc light-cyan"} ${kv;hide:"show_out yes"}
  20. _DOCS_PLANTUML_ENV=\
  21. ${env:"JAVA_PATH=$JDK21_RESOURCE_GLOBAL/bin/java"} \
  22. ${env:"PLANTUML_PATH=contrib/tools/plantuml/plantuml.run.cp.jar"} \
  23. ${env:"_JAVA_OPTIONS='-Dsun.awt.fontconfig=contrib/java/openjdk-fontconfig/fontconfig.properties -Djava.awt.headless=true'"} \
  24. ${env:"LANG=en_US.UTF-8"} \
  25. ${env:"LC_ALL=C.UTF-8"}
  26. _DOCS_IMPLICIT_SRCS_VALUE=
  27. _DOCS_SOURCES_VALUE=
  28. _DOCS_VARS_FLAG=
  29. _DOCS_YFM_OUTPUT_FORMAT=
  30. _DOCS_YFM_BOOK_OUTPUT_FORMAT=--output-format html --allowHTML
  31. _DOCS_YFM_LIB_OUTPUT_FORMAT=--output-format md --add-map-file --allow-custom-resources
  32. _DOCS_YFM_CMDLINE=\
  33. ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${input:"build/scripts/extract_docs.py"} ${input;hide:"build/scripts/process_command_files.py"} --skip-prefix $ARCADIA_BUILD_ROOT --dest-dir $BINDIR/__s ${rootrel:PEERS} \
  34. && ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON3 ${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 \
  35. && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --output $TARGET --input $BINDIR/__docsbuild $_DOCS_KV
  36. # tag:internal tag:docs
  37. macro _DOCS_YFM_CMD_IMPL(CONFIG, EXTRA_INPUTS[]) {
  38. .CMD=$_DOCS_YFM_CMDLINE
  39. }
  40. _DOCS_YFM_CMD=$_DOCS_YFM_CMD_IMPL($_DOCS_CONFIG_VALUE EXTRA_INPUTS $_DOCS_EXTRA_INPUTS)
  41. # tag:docs
  42. ### This module is intended for internal use only. Common parts for DOCS and MKDOCS multimodules
  43. ### should be defined here.
  44. module _DOCS_BARE_UNIT: _BARE_UNIT {
  45. .ALLOWED=DOCS_DIR DOCS_CONFIG DOCS_VARS
  46. .CMD=TOUCH_DOCS_MF
  47. .FINAL_TARGET=no
  48. .NODE_TYPE=Bundle
  49. .PEERDIR_POLICY=as_include
  50. ENABLE(_DOCS_BARE_UNIT)
  51. SET(MODULE_SUFFIX .tar.gz)
  52. SET(MODULE_LANG DOCS)
  53. }
  54. # tag:docs tag:internal
  55. _DOCS_DIR_INTERNAL_NAMESPACE=
  56. _DOCS_SKIP_NAMESPACE=
  57. # tag:internal tag:docs
  58. _DOCS_LIBRARY_CMDLINE=\
  59. $YMAKE_PYTHON3 ${input:"build/scripts/copy_docs_files_to_dir.py"} ${input;hide:"build/scripts/process_command_files.py"} $_DOCS_IMPLICIT_SRCS_VALUE $_DOCS_DIR_VALUE $_DOCS_BIN_DIR_VALUE --dest-dir $BINDIR/__s --source-root $ARCADIA_ROOT --build-root $ARCADIA_BUILD_ROOT --srcs ${input;context=TEXT:SOURCES} --include-srcs ${input;context=TEXT:INCLUDE_SOURCES} $_DOCS_SKIP_NAMESPACE \
  60. && $YMAKE_PYTHON3 ${input:"build/scripts/tar_sources.py"} --output $TARGET --input $BINDIR/__s $_DOCS_KV
  61. # tag:internal tag:docs
  62. macro _DOCS_LIBRARY_CMD_IMPL(SOURCES[], INCLUDE_SOURCES[], EXTRA_INPUTS[]) {
  63. .CMD=$_DOCS_LIBRARY_CMDLINE
  64. }
  65. _DOCS_LIBRARY_CMD=$_DOCS_LIBRARY_CMD_IMPL(SOURCES $_DOCS_SOURCES_VALUE INCLUDE_SOURCES $_DOCS_INCLUDE_SOURCES_VALUE)
  66. # tag:docs
  67. module DOCS_LIBRARY: _DOCS_BARE_UNIT {
  68. .CMD=_DOCS_LIBRARY_CMD
  69. .ALIASES=SRCS=_DOCS_SRCS DOCS_DIR=_YFM_DOCS_DIR
  70. .EPILOGUE=_DOCS_LIBRARY_EPILOGUE
  71. .NODE_TYPE=Library
  72. ENABLE(DOCS_LIBRARY)
  73. SET(MODULE_TYPE LIBRARY)
  74. SET(MODULE_TAG DOCS_LIBRARY)
  75. SET(PEERDIR_TAGS DOCS_LIBRARY)
  76. SET(MODULE_SUFFIX .docslib)
  77. }
  78. # tag:docs
  79. macro _DOCS_SRCS(SRCDIR=".", EXCLUDE[], INCLUDE...) {
  80. SET(_VAR_DOCS_SRCS_SALT __SRCDIR__ $SRCDIR __EXCLUDE__ $EXCLUDE __INCLUDE__ $INCLUDE)
  81. SET(_DOCS_SRCS_GLOB uniq_docs_${hash:_VAR_DOCS_SRCS_SALT})
  82. _GLOB(${_DOCS_SRCS_GLOB} ${pre=${SRCDIR}/:INCLUDE} EXCLUDE ${EXCLUDE})
  83. SET_APPEND(_DOCS_SOURCES_VALUE ${input:$_DOCS_SRCS_GLOB})
  84. SET(_YFM_DOCS_DIR_DEFAULT_VALUE __dummy_dir__)
  85. }
  86. # tag:docs
  87. macro _DOCS_LIBRARY_EPILOGUE() {
  88. _YFM_DOCS_DIR($_YFM_DOCS_DIR_DEFAULT_VALUE)
  89. _SET_DOCS_BIN_DIR_FLAG($_DOCS_DIR_INTERNAL_NAMESPACE $MODDIR)
  90. }
  91. # tag:docs
  92. ### This module is intended for internal use only. Common parts for submodules of DOCS multimodule
  93. ### should be defined here.
  94. module _DOCS_BASE_UNIT: _DOCS_BARE_UNIT {
  95. .ALIASES=DOCS_DIR=_YFM_DOCS_DIR
  96. .NODE_TYPE=Library
  97. ENABLE(_DOCS_BASE_UNIT)
  98. PEERDIR+=build/platform/yfm
  99. DOCS_CONFIG($_DOCS_YFM_DEFAULT_CONFIG)
  100. }
  101. # tag:internal tag:docs
  102. ### _DOCS_YFM_USE_PLANTUML() # internal
  103. ###
  104. ### This macr sets appropriate dependencies for use of plantuml plugin
  105. macro _DOCS_YFM_USE_PLANTUML() {
  106. when ($DOCSLIB == "yes") {
  107. PEERDIR+=build/platform/java/jdk/jdk21 contrib/java/openjdk-fontconfig
  108. _DOCS_ENV+=$_DOCS_PLANTUML_ENV
  109. _DOCS_EXTRA_TOOLS+=${hide;tool:"contrib/tools/plantuml"}
  110. }
  111. }
  112. # tag:docs
  113. ### @usage: DOCS()
  114. ###
  115. ### Documentation project multimodule.
  116. ###
  117. ### When built directly, via RECURSE, DEPENDS or BUNDLE the output artifact is docs.tar.gz with statically generated site.
  118. ### When PEERDIRed from other DOCS() module behaves like a UNION (supplying own content and dependencies to build target).
  119. ### Peerdirs from modules other than DOCS are not accepted.
  120. ### Most usual macros are not accepted, only used with the macros DOCS_DIR(), DOCS_CONFIG(), DOCS_VARS().
  121. ###
  122. ### @see: [DOCS_DIR()](#macro_DOCS_DIR), [DOCS_CONFIG()](#macro_DOCS_CONFIG), [DOCS_VARS()](#macro_DOCS_VARS).
  123. multimodule DOCS {
  124. module DOCSBOOK: _DOCS_BASE_UNIT {
  125. .CMD=_DOCS_YFM_CMD
  126. .FINAL_TARGET=yes
  127. .PEERDIR_POLICY=as_build_from
  128. .IGNORED=DOCS_DIR DOCS_INCLUDE_SOURCES DOCS_COPY_FILES PEERDIR PYTHON RUN_PROGRAM RUN_PYTHON3 RUN_LUA RUN_JAVA_PROGRAM FROM_SANDBOX SRCS
  129. .PEERDIRSELF=DOCSLIB
  130. ENABLE(DOCSBOOK)
  131. SET(MODULE_TAG DOCSBOOK)
  132. SET(PEERDIR_TAGS DOCSLIB)
  133. _DOCS_YFM_OUTPUT_FORMAT=$_DOCS_YFM_BOOK_OUTPUT_FORMAT
  134. PROCESS_DOCS()
  135. }
  136. module DOCSLIB: _DOCS_BASE_UNIT {
  137. .CMD=_DOCS_YFM_CMD
  138. .PEERDIR_POLICY=as_build_from
  139. .IGNORED=DOCS_DIR DOCS_INCLUDE_SOURCES DOCS_COPY_FILES PEERDIR PYTHON RUN_PROGRAM RUN_PYTHON3 RUN_LUA RUN_JAVA_PROGRAM FROM_SANDBOX SRCS
  140. .PEERDIRSELF=DOCSLIB_INTERNAL
  141. .PROXY=yes
  142. ENABLE(DOCSLIB)
  143. SET(MODULE_TAG DOCSLIB)
  144. SET(PEERDIR_TAGS DOCSLIB_INTERNAL)
  145. REALPRJNAME=preprocessed
  146. _DOCS_YFM_OUTPUT_FORMAT=$_DOCS_YFM_LIB_OUTPUT_FORMAT
  147. PROCESS_DOCS()
  148. }
  149. module DOCSLIB_INTERNAL: DOCS_LIBRARY {
  150. .IGNORED=DOCS_CONFIG
  151. .EPILOGUE=_DOCS_LIBRARY_EPILOGUE
  152. ENABLE(DOCSLIB_INTERNAL)
  153. DISABLE(START_TARGET)
  154. SET(MODULE_TAG DOCSLIB_INTERNAL)
  155. SET(PEERDIR_TAGS DOCSLIB_EXTERNAL DOCS_LIBRARY)
  156. # additional .fake extension make this output suppressed by ya-bin
  157. SET(MODULE_SUFFIX .docslib.fake)
  158. SET(_DOCS_DIR_INTERNAL_NAMESPACE .)
  159. SET(_DOCS_SKIP_NAMESPACE --skip-namespace ${MODDIR}/)
  160. REALPRJNAME=__docs_internal
  161. }
  162. module DOCSLIB_EXTERNAL: DOCS_LIBRARY {
  163. .IGNORED=DOCS_CONFIG
  164. .EPILOGUE=_DOCS_LIBRARY_EPILOGUE
  165. ENABLE(DOCSLIB_EXTERNAL)
  166. DISABLE(START_TARGET)
  167. SET(MODULE_TAG DOCSLIB_EXTERNAL)
  168. SET(PEERDIR_TAGS DOCSLIB_EXTERNAL DOCS_LIBRARY)
  169. REALPRJNAME=__docs_external
  170. }
  171. }
  172. # tag:docs tag:internal
  173. _DOCS_YFM_DEFAULT_CONFIG=$MODDIR/.yfm
  174. # tag:docs
  175. _DOCS_USE_PLANTUML=
  176. ### @usage: USE_PLANTUML()
  177. ###
  178. ### Use PlantUML plug-in for yfm builder to render UML diagrams into documentation
  179. macro USE_PLANTUML() {
  180. ENABLE(_DOCS_USE_PLANTUML)
  181. }
  182. # tag:docs
  183. _DOCS_DIR_VALUE=
  184. _DOCS_BIN_DIR_VALUE=
  185. ### @usage: DOCS_DIR(path)
  186. ###
  187. ### Specify directory with source .md files for DOCS multimodule if it differs from project directory.
  188. ### Path must be Arcadia root relative.
  189. ###
  190. ### @see: [DOCS](#multimodule_DOCS)
  191. macro DOCS_DIR(Dir) {
  192. ENABLE(UNUSED_MACRO)
  193. }
  194. # tag:docs tag:internal
  195. macro _APPEND_DOCS_DIR_FLAG(DIR, NAMESPACE, DYMMY...) {
  196. SET_APPEND(_DOCS_DIR_VALUE --docs-dir $DIR $NAMESPACE)
  197. }
  198. # tag:docs tag:internal
  199. macro _SET_DOCS_BIN_DIR_FLAG(NAMESPACE, DUMMY...) {
  200. SET(_DOCS_BIN_DIR_VALUE --bin-dir $BINDIR $NAMESPACE $AUTO_INPUT)
  201. }
  202. # tag:docs tag:internal
  203. _YFM_DOCS_DIR_DEFAULT_VALUE=$MODDIR
  204. _YFM_DEFAULT_NAMESPACE=
  205. ### @usage: DOCS_DIR(path) # internal
  206. macro _YFM_DOCS_DIR(DIR) {
  207. _APPEND_DOCS_DIR_FLAG($DIR $_DOCS_DIR_INTERNAL_NAMESPACE $DIR)
  208. SET(_VAR_DOCS_DIR_SALT __MODDIR__ $MODDIR __DIR__ $DIR)
  209. SET(_DOCS_DIR_GLOB uniq_docs_dir_${hash:_VAR_DOCS_DIR_SALT})
  210. _LATE_GLOB(${_DOCS_DIR_GLOB} ${ARCADIA_ROOT}/$DIR/**/*)
  211. SET_APPEND(_DOCS_IMPLICIT_SRCS_VALUE \${input;hide:$_DOCS_DIR_GLOB})
  212. # We set the value of var _YFM_DOCS_DIR_DEFAULT_VALUE to some non-existing dir. This value
  213. # will be used in _DOCS_LIBRARY_EPILOGUE calls. In case when this macro _YFM_DOCS_DIR is
  214. # explicitly called in DOCS_LIBRARY module $MODDIR as default DOCS_DIR for DOCS_LIBRARY will
  215. # be ignore.
  216. SET(_YFM_DOCS_DIR_DEFAULT_VALUE __dummy_dir__)
  217. }
  218. # tag:docs
  219. _DOCS_DEFAULT_CONFIG=
  220. _DOCS_CONFIG_VALUE=$_DOCS_DEFAULT_CONFIG
  221. ### @usage: DOCS_CONFIG(path)
  222. ###
  223. ### Specify path to config file for DOCS multimodule if it differs from default path.
  224. ### If used for [MKDOCS](#multimodule_MKDOCS) multimodule the default path is "%%project_directory%%/mkdocs.yml".
  225. ### If used for [DOCS](#multimodule_DOCS) multimodule the default path is "%%project_directory%%/.yfm".
  226. ### Path must be either Arcadia root relative.
  227. ###
  228. ### @see: [DOCS](#multimodule_DOCS)
  229. macro DOCS_CONFIG(File) {
  230. SET(_DOCS_CONFIG_VALUE $File)
  231. }
  232. # tag:docs
  233. _DOCS_VARS_VALUE=
  234. ### @usage: DOCS_VARS(variable1=value1 variable2=value2 ...)
  235. ###
  236. ### Specify a set of default values of template variables for DOCS multimodule.
  237. ### There must be no spaces around "=". Values will be treated as strings.
  238. ###
  239. ### @see: [DOCS](#multimodule_DOCS)
  240. macro DOCS_VARS(Args...) {
  241. SET_APPEND(_DOCS_VARS_VALUE $Args)
  242. }
  243. # tag:docs
  244. _DOCS_INCLUDE_SOURCES_VALUE=
  245. ### @usage: DOCS_INCLUDE_SOURCES(path...)
  246. ###
  247. ### Specify a list of paths to source code files which will be used as text includes in a documentation project.
  248. ### Paths must be Arcadia root relative.
  249. ###
  250. ### @see: [DOCS](#multimodule_DOCS)
  251. macro DOCS_INCLUDE_SOURCES(Args...) {
  252. SET_APPEND(_DOCS_INCLUDE_SOURCES_VALUE $Args)
  253. }