Add CMake project to build documentation
The documentation is compiled from the markdown sources to html using `pandoc`. In order to install `pandoc` run: cabal install pandoc The documentation build is optional and if `pandoc` is not found during cmake project configuration the documentation build is skipped.
This commit is contained in:
Родитель
0944a12502
Коммит
15210207ea
|
@ -24,6 +24,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C ${CMAKE_CFG_INTDIR} --
|
|||
|
||||
add_subdirectory (compiler)
|
||||
add_subdirectory (cpp)
|
||||
add_subdirectory (doc)
|
||||
add_python_subdirectory (python)
|
||||
add_subdirectory (examples)
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ $if(date-meta)$
|
|||
<meta name="date" content="$date-meta$" />
|
||||
$endif$
|
||||
<title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
|
||||
$if(highlighting-css)$
|
||||
<style type="text/css">
|
||||
$if(highlighting-css)$
|
||||
$highlighting-css$
|
||||
$endif$
|
||||
body {
|
||||
line-height: 1.5;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
|
@ -77,7 +78,6 @@ $highlighting-css$
|
|||
}
|
||||
}
|
||||
</style>
|
||||
$endif$
|
||||
$for(css)$
|
||||
<link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>
|
||||
$endfor$
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
include (CMakeParseArguments)
|
||||
include (HaskellUtil)
|
||||
|
||||
#
|
||||
# add_pandoc_markdown (file.md [file2.md ...]
|
||||
# [CODE code]
|
||||
# [OUTPUT_DIR dir]
|
||||
# [OUTPUT_NAME name]
|
||||
# [TEMPLATE template]
|
||||
# [OPTIONS opt [opt2 ...]])
|
||||
#
|
||||
function (add_pandoc_markdown)
|
||||
set (flagArgs)
|
||||
set (oneValueArgs OUTPUT_NAME OUTPUT_DIR CODE TEMPLATE)
|
||||
set (multiValueArgs OPTIONS)
|
||||
cmake_parse_arguments (arg "${flagArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set (options
|
||||
--standalone
|
||||
--smart
|
||||
--data-dir=.pandoc
|
||||
--highlight-style tango
|
||||
${arg_OPTIONS})
|
||||
if (arg_TEMPLATE)
|
||||
list(APPEND options --template="${arg_TEMPLATE}")
|
||||
else()
|
||||
endif()
|
||||
if (arg_CODE)
|
||||
list(APPEND options --indented-code-classes="${arg_CODE}")
|
||||
else()
|
||||
endif()
|
||||
set (inputs "${arg_UNPARSED_ARGUMENTS}")
|
||||
foreach (file ${inputs})
|
||||
get_filename_component (name ${file} NAME_WE)
|
||||
if (arg_OUTPUT_NAME)
|
||||
set (outputName ${arg_OUTPUT_NAME})
|
||||
else()
|
||||
set (outputName ${name})
|
||||
endif()
|
||||
set (output "${CMAKE_CURRENT_BINARY_DIR}/html/${arg_OUTPUT_DIR}/${outputName}.html")
|
||||
list (APPEND sources ${file})
|
||||
list (APPEND outputs ${output})
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND ${Haskell_PANDOC_EXECUTABLE} ${options} --output="${output}" "${file}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS ${file} ${PANDOC_EXECUTABLE})
|
||||
endforeach()
|
||||
add_custom_target ("documentation_${name}"
|
||||
DEPENDS ${outputs}
|
||||
SOURCES ${sources})
|
||||
add_dependencies (documentation "documentation_${name}")
|
||||
endfunction()
|
||||
|
||||
find_haskell_program (pandoc)
|
||||
|
||||
if (Haskell_PANDOC_EXECUTABLE)
|
||||
add_custom_target (documentation)
|
||||
|
||||
add_pandoc_markdown (src/bond_py.md src/bond_cpp.md
|
||||
CODE "cpp,numberLines"
|
||||
OPTIONS --self-contained --table-of-contents
|
||||
OUTPUT_DIR manual)
|
||||
|
||||
add_pandoc_markdown (src/bond_cs.md
|
||||
CODE "cs,numberLines"
|
||||
OPTIONS --self-contained --table-of-contents
|
||||
OUTPUT_DIR manual)
|
||||
|
||||
add_pandoc_markdown (src/reference_index.md
|
||||
CODE "cpp"
|
||||
OPTIONS --self-contained
|
||||
OUTPUT_NAME index
|
||||
OUTPUT_DIR reference)
|
||||
|
||||
add_pandoc_markdown (../readme.md
|
||||
TEMPLATE index.html
|
||||
OUTPUT_NAME index
|
||||
CODE python)
|
||||
|
||||
add_pandoc_markdown (src/why_bond.md
|
||||
TEMPLATE index.html
|
||||
CODE python)
|
||||
endif()
|
||||
|
Загрузка…
Ссылка в новой задаче