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
|
# This file is part of the pgRouting project.
# Copyright (c) 2013-2026 pgRouting developers
# License: GPL-2 See https://github.com/pgRouting/pgrouting/blob/main/LICENSE
# Relevant changes from 3.8 to 4.0
# WITH-DOC is not used anymore
# * The HTML documentation is build by default
# * The translated languages (en, es, zh_Hans) HTML documentation is build by default
# Documentation is not build when
# * Sphinx is not found
# * When all Sphinx formats are OFF
# * When all languages are OFF
# Output is on build/doc/_build/<format> directory
#---------------------------------------------
# Checking for prerequisites
#---------------------------------------------
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Sphinx Documentation Builder (sphinx-doc.org)"
)
if (NOT SPHINX_EXECUTABLE)
message(WARNING "Sphinx not found.
Building without user's documentation")
return()
endif()
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
option(BUILD_HTML "Set ON|OFF (default=OFF) to build Documentation library tree as HTML" ON)
option(BUILD_PDF "Set ON|OFF (default=OFF) to build Documentation library tree as PDF" OFF)
option(BUILD_LOCALE "Set ON|OFF (default=OFF) to build the locale files" OFF)
option(BUILD_LINKCHECK "Set ON|OFF (default=OFF) to build Documentation library tree as LINKCHECK page" OFF)
# not quite sure how these look
option(BUILD_LATEX "Set ON|OFF (default=OFF) to build Documentation library tree as PDF" OFF)
option(BUILD_SINGLEHTML "Set ON|OFF (default=OFF) to build Documentation library tree as SINGLE HTML" OFF)
option(BUILD_MAN "Set ON|OFF (default=OFF) to build Documentation library tree as MAN page" OFF)
option(BUILD_EPUB "Set ON|OFF (default=OFF) to build Documentation library tree as EPUB page" OFF)
option(BUILD_DUMMY "Set ON|OFF (default=OFF) for debugging purposes" OFF)
# get the ON options of the Sphinx formats
foreach(opt BUILD_HTML BUILD_LATEX BUILD_MAN BUILD_SINGLEHTML BUILD_EPUB BUILD_DUMMY BUILD_LINKCHECK BUILD_LOCALE)
if (${${opt}} OR WITH_ALL_DOC)
string(TOLOWER ${opt} val)
string(REPLACE "build_" "" val ${val})
list(APPEND PROJECT_DOC_TARGETS ${val})
endif()
endforeach()
if("${PROJECT_DOC_TARGETS}" STREQUAL "")
message(WARNING "No documentation targets found
Building without documentation")
return()
endif()
add_custom_target(doc ALL COMMENT "Building documentation with Sphinx")
#---------------------------------------------
# LANGUAGES SETTINGS
#---------------------------------------------
list(APPEND PROJECT_LANGUAGES_TRANSLATED "EN" "ES" "SV" "ZH_HANS")
list(APPEND PROJECT_LANGUAGES "de" "en" "es" "ja" "ko" "sv" "zh_Hans")
foreach(lang ${PROJECT_LANGUAGES})
string(TOUPPER ${lang} val)
if ("${val}" IN_LIST PROJECT_LANGUAGES_TRANSLATED)
option(${val} "Set ON|OFF (default=ON) build ${lang} Documentation" ON)
else()
option(${val} "Set ON|OFF (default=OFF) build ${lang} Documentation" OFF)
endif()
endforeach()
#---------------------------------------------
# Catching the language options to be build
#---------------------------------------------
foreach(lang ${PROJECT_LANGUAGES})
string(TOUPPER ${lang} opt)
if (${opt})
list(APPEND PROJECT_BUILD_LANGUAGES ${lang})
endif()
endforeach()
if("${PROJECT_BUILD_LANGUAGES}" STREQUAL "")
message(WARNING "No documentation languages found
Building without documentation")
return()
endif()
message(STATUS "PROJECT_BUILD_LANGUAGES = ${PROJECT_BUILD_LANGUAGES}")
#---------------------------------------------
# Kind of "looks"
#---------------------------------------------
if (DOC_USE_BOOTSTRAP)
set(SPHINX_INCLUDE "import sphinx_bootstrap_theme")
set(SPHINX_THEME "bootstrap")
set(SPHINX_THEME_DIR "sphinx_bootstrap_theme.get_html_theme_path()")
set(SPHINX_THEME_OPTIONS "
'navbar_class': \"navbar\",
'source_link_position': \"nav\",
'bootstrap_version': \"2\",
")
# Modify
# https://github.com/ryan-roemer/sphinx-bootstrap-theme/blob/master/sphinx_bootstrap_theme/bootstrap/layout.html#L67
# adding the call to get the history of the file
set(THEME_HISTORY "
{%- block content %}
{{ navBar() }}
<div class=\"container\">
<div class=\"row\">
{%- block sidebar1 %}{{ bsidebar() }}{% endblock %}
<div class=\"body {{ bs_span_prefix }}{{ bs_content_width }} content\" role=\"main\">
<script> document.write(get_history('{{ pagename }}','{{ language }}')); </script>
{% block body %}{% endblock %}
</div>
{% block sidebar2 %} {# possible location for sidebar #} {% endblock %}
</div>
</div>
{%- endblock %}
")
else()
set(SPHINX_INCLUDE "")
set(SPHINX_THEME "haiku")
set(SPHINX_THEME_DIR "['']")
set(SPHINX_THEME_OPTIONS "")
set(THEME_HISTORY "")
endif()
# configured documentation tools and intermediate build results
set(PGR_DOCUMENTATION_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")
set(PGR_DOCUMENTATION_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "PGR_DOCUMENTATION_BUILD_DIR = ${PGR_DOCUMENTATION_BUILD_DIR}")
message(STATUS "PGR_DOCUMENTATION_SOURCE_DIR = ${PGR_DOCUMENTATION_SOURCE_DIR}")
#---------------------------------------------
# Adding documentation directories
#---------------------------------------------
foreach (subdir ${PROJECT_DOC_DIRECTORIES} "src")
add_subdirectory("${subdir}")
if (EXISTS "${CMAKE_SOURCE_DIR}/docqueries/${subdir}")
add_subdirectory("${CMAKE_SOURCE_DIR}/docqueries/${subdir}" "docqueries/${subdir}")
endif()
endforeach()
add_subdirectory("images")
configure_file("../tools/testers/sampledata.pg" "${PGR_DOCUMENTATION_SOURCE_DIR}/sampledata/sampledata.sql")
add_subdirectory("_static")
add_subdirectory("_templates")
configure_file("conf.py.in" "${PGR_DOCUMENTATION_SOURCE_DIR}/conf.py" @ONLY)
foreach (format ${PROJECT_DOC_TARGETS})
message(STATUS "format=${format}")
if ("${format}" STREQUAL "locale")
find_program(SPHINX_INTL_EXECUTABLE
NAMES sphinx-intl
DOC "Sphinx Documentation Builder (sphinx-doc.org)"
)
if (SPHINX_INTL_EXECUTABLE)
add_custom_target(locale
COMMAND ${SPHINX_EXECUTABLE}
-b gettext
-c "${PGR_DOCUMENTATION_SOURCE_DIR}"
"${PGR_DOCUMENTATION_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/locale/pot"
COMMAND ${SPHINX_INTL_EXECUTABLE} update
-d ${CMAKE_SOURCE_DIR}/locale
-l en > locale_changes.txt
COMMENT "Generating POT and PO files"
SOURCES ${PROJECT_DOC_FILES})
else()
message(WARNING "sphinx-intl not found.
Not building the pot and po locale files")
endif()
else()
add_custom_target("${format}"
COMMENT "Building ${format} documentation with Sphinx")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/forward.html"
"${PGR_DOCUMENTATION_BUILD_DIR}/${format}/index.html")
foreach (lang ${PROJECT_BUILD_LANGUAGES})
add_custom_target(
"${format}-${lang}"
COMMAND ${SPHINX_EXECUTABLE}
-c ${CMAKE_CURRENT_BINARY_DIR}
-d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
-b ${format}
-D language='${lang}'
${sphinx_flags}
"${PGR_DOCUMENTATION_SOURCE_DIR}"
"${PGR_DOCUMENTATION_BUILD_DIR}/${format}/${lang}"
COMMENT "Generating ${format}/${lang} documentation"
SOURCES ${PROJECT_DOC_FILES} ${PROJECT_IMG_FILES}
DEPENDS ${PROJECT_DOC_FILES} ${PROJECT_IMG_FILES}
)
add_dependencies(${format} "${format}-${lang}")
endforeach()
add_dependencies(doc "${format}")
endif()
endforeach()
|