-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconf.py
More file actions
111 lines (92 loc) · 3.95 KB
/
conf.py
File metadata and controls
111 lines (92 loc) · 3.95 KB
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
# SPDX-FileCopyrightText: Copyright (c) <2025> NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
import os
import shutil
import cuda.tile
import cuda.tile._datatype
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'cuTile Python'
copyright = '2025, NVIDIA Corporation'
author = 'NVIDIA Corporation'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon', # for google style support
'sphinx.ext.autosectionlabel', # for automatic section labels
'myst_parser', # for markdown support
]
# Configuration for autosectionlabel extension
autosectionlabel_prefix_document = True # Prefix labels with the document name
autosectionlabel_maxdepth = 4 # Only generate labels for sections and subsections
templates_path = ['_templates']
exclude_patterns = ['references.rst', 'stubs', 'generated/includes']
# Autodoc settings
autodoc_member_order = 'bysource'
autodoc_typehints = 'none'
toc_object_entries = False # Don't include object entries in the TOC
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "nvidia_sphinx_theme"
html_static_path = ["_static"]
html_css_files = ["css/custom.css"]
html_show_sphinx = False
# Configure sidebar depth and content
html_theme_options = {
"navigation_depth": 2,
"show_nav_level": 2,
"show_toc_level": 4
}
# Set up the sidebar to use our custom global TOC
html_sidebars = {
'**': ['globaltoc.html', 'searchbox.html'],
}
# -- Generated content --------------------------------------------------------
# Make sure the generated includes directory exists
generated_includes_dir = os.path.join(os.path.dirname(__file__), 'generated', 'includes')
os.makedirs(generated_includes_dir, exist_ok=True)
# Copy release notes from root
release_notes_src = os.path.join(os.path.dirname(__file__), '..', '..', "CHANGELOG.md")
release_notes_dst = os.path.join(os.path.dirname(__file__), 'generated', "release_notes.md")
shutil.copy(release_notes_src, release_notes_dst)
# List of RST include generation functions to run
rst_generated_includes = [
"dtype_promotion_table",
"numeric_dtypes"
]
# Generate RST include files
for include_name in rst_generated_includes:
function_name = f"_generate_rst_{include_name}"
file_path = os.path.join(generated_includes_dir, f"{include_name}.rst")
content = getattr(cuda.tile._datatype, function_name)()
with open(file_path, 'w') as f:
f.write(content)
# Include substitutions from references.rst in all documents (including docstrings)
with open(os.path.join(os.path.dirname(__file__), 'references.rst'), 'r') as f:
rst_prolog = f.read()
# Don't expand type aliases. See https://github.com/sphinx-doc/sphinx/issues/10785
autodoc_type_aliases = {
'Constant': 'Constant',
'Shape': 'Shape',
}
# Make links to type aliases actually work.
def resolve_type_aliases(app, env, node, contnode):
"""Resolve :class: references to our type aliases as :data: instead."""
if (
node["refdomain"] == "py"
and node["reftype"] == "class"
and node["reftarget"] in autodoc_type_aliases.keys()
):
print("Resolving type alias", node["reftarget"])
return app.env.get_domain("py").resolve_xref(
env, node["refdoc"], app.builder, "data", node["reftarget"], node, contnode
)
def setup(app):
app.connect("missing-reference", resolve_type_aliases)