Skip to content

Commit 51b7f58

Browse files
quic-shaksumaquic-seaswara
authored andcommitted
Add support for asciidoc documentation.
This patch adds support to generates HTML documentation from asciidoc source using asciidoc python module. "eld-asciidocs" target is added to build this documentation. ELD_ENABLE_ASCIIDOC flag must be turned ON to enable this target. The asciidoc documentation will also be generated if "eld-docs" is built. An index page is also generated to list all the asciidoc documentation and can be accessed at "<eld-documentation-index-dir>/adoc/index.html". Closes #126 Signed-off-by: Shakti Suman <[email protected]>
1 parent aa4fb10 commit 51b7f58

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
if(ELD_ENABLE_ASCIIDOC)
2+
find_package(Python3 REQUIRED)
3+
endif()
4+
5+
# Convert asciidoc documentation to html
6+
function(build_adoc_to_html adoc_source_dir)
7+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/adoc/)
8+
file(GLOB ADOC_FILES "${adoc_source_dir}/*")
9+
foreach(ADOC_FILE ${ADOC_FILES})
10+
get_filename_component(ADOC_FILE_NAME ${ADOC_FILE} NAME)
11+
add_custom_target(
12+
eld-asciidocs
13+
COMMAND
14+
${Python3_EXECUTABLE} -m asciidoc -o
15+
${CMAKE_CURRENT_BINARY_DIR}/html/adoc/${ADOC_FILE_NAME}.html
16+
${ADOC_FILE}
17+
COMMAND
18+
tree -H "${CMAKE_CURRENT_BINARY_DIR}/html/adoc/" -L 1 -T
19+
"ADOC Documentation"--noreport -I "index.html" -o
20+
${CMAKE_CURRENT_BINARY_DIR}/html/adoc/index.html
21+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/adoc/
22+
DEPENDS ${Python3_EXECUTABLE}
23+
COMMENT
24+
"Generating ASCIIDOC documentation in ${CMAKE_CURRENT_BINARY_DIR}/html/adoc/"
25+
)
26+
endforeach()
27+
endfunction()

docs/userguide/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ if(LLVM_ENABLE_SPHINX)
7373

7474
add_custom_target(eld-docs DEPENDS ${target_name})
7575
endif()
76+
77+
if(ELD_ENABLE_ASCIIDOC)
78+
message(STATUS "ASCIIDOC Documentation Enabled")
79+
# Convert asciidoc to html documentation.
80+
include(${ELD_SOURCE_DIR}/cmake/modules/BuildASCIIDOCTarget.cmake)
81+
build_adoc_to_html(${ELD_SOURCE_DIR}/docs/userguide/documentation/asciidoc/)
82+
83+
# Build asciidocs with eld-docs
84+
if(LLVM_ENABLE_SPHINX)
85+
add_dependencies(eld-docs eld-asciidocs)
86+
endif()
87+
endif()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
= Sample Doc!
2+
3+
This is a sample asciidoc document.
4+
5+
== Section Title
6+
7+
* Sample list
8+

0 commit comments

Comments
 (0)