Files
rocm-systems/projects/amdsmi/docs/conf.py
T

86 řádky
2.5 KiB
Python
Surový Normální zobrazení Historie

2023-05-16 17:14:23 -06:00
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
2024-10-02 14:42:34 -04:00
import re
import sys
from pathlib import Path
2024-11-12 09:43:55 -05:00
sys.path.append(str(Path("_extension").resolve()))
2023-05-16 17:14:23 -06:00
2024-10-02 14:42:34 -04:00
# get version number to print in docs
def get_version_info(filepath):
2024-11-12 09:43:55 -05:00
with open(filepath, "r") as f:
2024-10-02 14:42:34 -04:00
content = f.read()
2023-05-16 17:14:23 -06:00
2024-10-02 14:42:34 -04:00
version_pattern = (
2024-11-12 09:43:55 -05:00
r"^#define\s+AMDSMI_LIB_VERSION_MAJOR\s+(\d+)\s*$|"
r"^#define\s+AMDSMI_LIB_VERSION_MINOR\s+(\d+)\s*$|"
r"^#define\s+AMDSMI_LIB_VERSION_RELEASE\s+(\d+)\s*$"
2024-10-02 14:42:34 -04:00
)
2023-05-16 17:14:23 -06:00
2024-10-02 14:42:34 -04:00
matches = re.findall(version_pattern, content, re.MULTILINE)
if len(matches) == 3:
version_major, version_minor, version_release = [
2024-10-02 14:42:34 -04:00
match for match in matches if any(match)
]
return version_major[0], version_minor[1], version_release[2]
2024-10-02 14:42:34 -04:00
else:
raise ValueError("Couldn't find all VERSION numbers.")
version_major, version_minor, version_release = get_version_info(
2024-11-12 09:43:55 -05:00
"../include/amd_smi/amdsmi.h"
)
version_number = f"{version_major}.{version_minor}.{version_release}"
2024-10-02 14:42:34 -04:00
# project info
project = "AMD SMI"
author = "Advanced Micro Devices, Inc."
2025-01-22 16:06:09 -05:00
copyright = "Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved."
2024-10-02 14:42:34 -04:00
version = version_number
release = version_number
html_theme = "rocm_docs_theme"
html_theme_options = {"flavor": "rocm"}
html_title = f"AMD SMI {version_number} documentation"
suppress_warnings = ["etoc.toctree"]
2023-05-16 17:14:23 -06:00
external_toc_path = "./sphinx/_toc.yml"
2024-10-02 14:42:34 -04:00
external_projects_current_project = "amdsmi"
extensions = ["rocm_docs", "rocm_docs.doxygen", "go_api_ref"]
2023-05-16 17:14:23 -06:00
2024-10-02 14:42:34 -04:00
doxygen_root = "doxygen"
doxysphinx_enabled = True
doxygen_project = {
"name": "AMD SMI C++ API reference",
"path": "doxygen/docBin/xml",
}
def generate_doxyfile(app, _):
doxyfile_in = Path(app.confdir) / doxygen_root / "Doxyfile.in"
doxyfile_out = Path(app.confdir) / doxygen_root / "Doxyfile"
if not doxyfile_in.exists():
from sphinx.errors import ConfigError
raise ConfigError(f"Missing Doxyfile.in at {doxyfile_in}")
with open(doxyfile_in) as f:
content = f.read()
content = content.replace("@PROJECT_NUMBER@", version_number)
with open(doxyfile_out, "w") as f:
f.write(content)
def setup(app):
app.connect("config-inited", generate_doxyfile, priority=100)
return {"parallel_read_safe": True, "parallel_write_safe": True}