Skip to content

Commit 70f09ec

Browse files
dynamically generate rst files
1 parent aa0bd7c commit 70f09ec

19 files changed

+20
-2777
lines changed

libc/docs/CMakeLists.txt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
21
if (LLVM_ENABLE_SPHINX)
32
include(AddSphinxTarget)
43
if (SPHINX_FOUND)
54
if (${SPHINX_OUTPUT_HTML})
6-
add_sphinx_target(html libc)
5+
# Similar to clang, we copy our static .rst files from libc/docs/ to the
6+
# $build_dir/libc/docs/. That way, we can have a mix of both static
7+
# (committed) .rst files, and dynamically generated .rst files. We don't
8+
# want the dynamically generated .rst files to pollute the source tree.
9+
add_custom_target(copy-libc-rst-docs
10+
COMMAND "${CMAKE_COMMAND}" -E copy_directory
11+
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
12+
13+
# Change sphinx to build from $build_dir/libc/docs/ rather than
14+
# llvm-project/libc/docs/.
15+
add_sphinx_target(html libc SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
16+
# Depend on the copy target.
17+
add_dependencies(docs-libc-html copy-libc-rst-docs)
718

19+
# Maintain a list of headers for which we dynamically generate html docs
20+
# for via docgen. For more complex docs (such as per arch support, a la
21+
# math.h), those should be omitted and exist statically in
22+
# libc/docs/headers/.
823
list(APPEND docgen_list
924
assert
1025
ctype
@@ -26,9 +41,11 @@ if (SPHINX_FOUND)
2641
)
2742

2843
foreach(stem IN LISTS docgen_list)
44+
# docgen invocation.
2945
add_custom_target(${stem}_rst
3046
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../utils/docgen/docgen.py ${stem}.h >
31-
${CMAKE_CURRENT_SOURCE_DIR}/headers/${stem}.rst)
47+
${CMAKE_CURRENT_BINARY_DIR}/headers/${stem}.rst)
48+
# depend on the docgen invocation.
3249
add_dependencies(docs-libc-html ${stem}_rst)
3350
endforeach()
3451
endif()

libc/docs/headers/assert.rst

Lines changed: 0 additions & 27 deletions
This file was deleted.

libc/docs/headers/ctype.rst

Lines changed: 0 additions & 130 deletions
This file was deleted.

libc/docs/headers/errno.rst

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)