diff options
Diffstat (limited to 'Utilities/Sphinx')
-rw-r--r-- | Utilities/Sphinx/CMakeLists.txt | 12 | ||||
-rwxr-xr-x | Utilities/Sphinx/create_identifiers.py | 46 | ||||
-rw-r--r-- | Utilities/Sphinx/templates/layout.html | 6 |
3 files changed, 63 insertions, 1 deletions
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 951f7ab..a58604e 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -69,6 +69,8 @@ if(SPHINX_TEXT) list(APPEND doc_formats text) endif() if(SPHINX_QTHELP) + find_package(PythonInterp REQUIRED) + find_program(QCOLLECTIONGENERATOR_EXECUTABLE NAMES qcollectiongenerator DOC "qcollectiongenerator tool" @@ -88,7 +90,15 @@ if(SPHINX_QTHELP) COMMAND ${CMAKE_COMMAND} "-DQTHELP_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/" "-DCMake_VERSION=${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}" -P "${CMAKE_CURRENT_SOURCE_DIR}/fixup_qthelp_names.cmake" - COMMAND qcollectiongenerator ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp + + # Create proper identifiers. Workaround for + # https://bitbucket.org/birkenfeld/sphinx/issue/1491/qthelp-should-generate-identifiers-for + COMMAND "${PYTHON_EXECUTABLE}" + "${CMAKE_CURRENT_SOURCE_DIR}/create_identifiers.py" + "${CMAKE_CURRENT_BINARY_DIR}/qthelp/" + + COMMAND ${QCOLLECTIONGENERATOR_EXECUTABLE} + ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp ) endif() diff --git a/Utilities/Sphinx/create_identifiers.py b/Utilities/Sphinx/create_identifiers.py new file mode 100755 index 0000000..7715e53 --- /dev/null +++ b/Utilities/Sphinx/create_identifiers.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +import sys, os + +if len(sys.argv) != 2: + sys.exit(-1) +name = sys.argv[1] + "/CMake.qhp" + +f = open(name) + +if not f: + sys.exit(-1) + +lines = f.read().splitlines() + +if not lines: + sys.exit(-1) + +newlines = [] + +for line in lines: + + mapping = (("command", "command"), + ("variable", "variable"), + ("target property", "prop_tgt"), + ("test property", "prop_test"), + ("source file property", "prop_sf"), + ("global property", "prop_gbl"), + ("module", "module"), + ("directory property", "prop_dir"), + ("cache property", "prop_cache"), + ("policy", "policy"), + ("installed file property", "prop_inst")) + + for domain_object_string, domain_object_type in mapping: + if "<keyword name=\"" + domain_object_string + "\"" in line: + if not "id=\"" in line: + prefix = "<keyword name=\"" + domain_object_string + "\" " + part1, part2 = line.split(prefix) + head, tail = part2.split("#" + domain_object_type + ":") + domain_object, rest = tail.split("\"") + line = part1 + prefix + "id=\"" + domain_object_type + "/" + domain_object + "\" " + part2 + newlines.append(line + "\n") + +f = open(name, "w") +f.writelines(newlines) diff --git a/Utilities/Sphinx/templates/layout.html b/Utilities/Sphinx/templates/layout.html index 635ace3..1c5728c 100644 --- a/Utilities/Sphinx/templates/layout.html +++ b/Utilities/Sphinx/templates/layout.html @@ -11,3 +11,9 @@ <a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }} </li> {% endblock %} + +{# Put some context in the html title element. Workaround for #} +{# https://bitbucket.org/birkenfeld/sphinx/issue/1492/qthelp-generate-html-title-element-should #} +{% block htmltitle %} + <title>{{ title|striptags|e }} {{ "—"|safe }} {{ docstitle|e }}</title> +{% endblock %} |