|
37 | 37 | "sphinx.ext.todo",
|
38 | 38 | "sphinx.ext.viewcode",
|
39 | 39 | "sphinxcontrib.programoutput",
|
40 |
| - # "sphinxcontrib.googleanalytics", |
| 40 | + "sphinxcontrib.googleanalytics", |
41 | 41 | "sphinx_design",
|
42 | 42 | ]
|
43 | 43 |
|
| 44 | +googleanalytics_id = 'G-7TCKS5BHYE' |
| 45 | +googleanalytics_enabled = True |
| 46 | + |
| 47 | +todo_include_todos = True |
| 48 | +use_doxyrest = "@DPCTL_ENABLE_DOXYREST@" |
| 49 | + |
| 50 | +if use_doxyrest == "ON": |
| 51 | + # Specify the path to Doxyrest extensions for Sphinx: |
| 52 | + import os |
| 53 | + import sys |
| 54 | + |
| 55 | + sys.path.insert( |
| 56 | + 1, |
| 57 | + os.path.abspath("@DOXYREST_SPHINX_DIR@"), |
| 58 | + ) |
| 59 | + extensions += ["doxyrest", "cpplexer"] |
| 60 | + # A workaround to fix issues leftover in the doxyrest generated |
| 61 | + # rst files. |
| 62 | + import fileinput |
| 63 | + |
| 64 | + with fileinput.FileInput( |
| 65 | + "@DOXYREST_OUTPUT_DIR@/global.rst", inplace=True |
| 66 | + ) as file: |
| 67 | + for line in file: |
| 68 | + print(line.replace("typedefDPCTL_C_EXTERN_C_BEGIN", ""), end="") |
| 69 | + |
| 70 | + |
44 | 71 | templates_path = ["_templates"]
|
45 | 72 | exclude_patterns = []
|
46 | 73 |
|
|
82 | 109 | "numba_dpex": ("https://intelpython.github.io/numba-dpex/latest/", None),
|
83 | 110 | "cython": ("https://docs.cython.org/en/latest/", None),
|
84 | 111 | }
|
| 112 | + |
| 113 | +# When the cmake DPCTL_USE_MULTIVERSION_TEMPLATE flag is set we generate |
| 114 | +# links in the sidebar to the documentation for older versions of dpctl. |
| 115 | +# Note that this option does not actually generate the documentation for |
| 116 | +# older versions, it only adds links in the sidebar to earlier versions of |
| 117 | +# the documentation. All earlier versions of the documentation should be |
| 118 | +# generated and pushed to the gh-pages branch manually, after which the |
| 119 | +# doc_versions.txt should be updated. |
| 120 | + |
| 121 | +generate_multiversion = "@DPCTL_USE_MULTIVERSION_TEMPLATE@" |
| 122 | + |
| 123 | +if generate_multiversion == "ON": |
| 124 | + try: |
| 125 | + html_context |
| 126 | + except NameError: |
| 127 | + html_context = dict() |
| 128 | + html_context["display_lower_left"] = True |
| 129 | + templates_path = ["_templates"] |
| 130 | + html_context["current_version"] = version |
| 131 | + html_context["version"] = version |
| 132 | + |
| 133 | + # POPULATE LINKS TO OTHER VERSIONS |
| 134 | + html_context["versions"] = list() |
| 135 | + |
| 136 | + # Populate the list of documented versions from the doc_versions.tx |
| 137 | + versions = [] |
| 138 | + with open("doc_versions.txt", "r") as doc_versions: |
| 139 | + while True: |
| 140 | + version = doc_versions.readline().strip() |
| 141 | + if not version: |
| 142 | + break |
| 143 | + elif len(version): |
| 144 | + versions.append(version) |
| 145 | + |
| 146 | + # FIXME: Remove this hard coding |
| 147 | + DOC_SITE_NAME = "https://intelpython.github.io/dpctl/" |
| 148 | + |
| 149 | + for version in versions: |
| 150 | + html_context["versions"].append( |
| 151 | + (version, DOC_SITE_NAME + version + "/index.html") |
| 152 | + ) |
0 commit comments