Skip to content

Commit 3722ea4

Browse files
authored
Fix documentation: DeviceProperties display and sidebar navigation (#1444)
* Fix DeviceProperties documentation by using cyclass.rst template DeviceProperties is a Cython cdef class, but was being documented without specifying the cyclass.rst template. This caused Sphinx to use the default class template which uses autoproperty, which doesn't work correctly with Cython extension types. The cyclass.rst template uses autoattribute instead, which properly documents the properties of Cython classes. Fixes #1215 * Enable object entries in table of contents for sidebar navigation Add toc_object_entries=True to all conf.py files to include object descriptions (methods, attributes, etc.) in the table of contents. This is a Sphinx 5.1+ feature that should enable the 'On This Page' sidebar to show class methods and properties. Also set toc_object_entries_show_parents='hide' for cleaner display without redundant parent class names. Partially addresses #1100 * List class members directly without separate sections in autosummary templates Update autosummary templates (class.rst, cyclass.rst, protocol.rst) to list methods and attributes directly under the class without separate section headings. Methods are listed first, followed by attributes. Combined with toc_object_entries=True in conf.py, individual methods and attributes will appear directly in the 'On This Page' sidebar, providing navigation similar to what was available in older versions with the furo theme. Fixes #1100 * Show class prefix in sidebar TOC, plain names in main docs Change toc_object_entries_show_parents from 'hide' to 'domain' so that the sidebar TOC shows class-prefixed names (e.g., Device.allocate()) while the main documentation shows just the method/attribute names. Fixed template indentation to ensure automethod/autoattribute directives are properly nested inside the autoclass block. * Use autoclass :members: option for automatic member documentation * Use section headings for methods/attributes to appear in sidebar TOC * Fix autodoc directives to use fully qualified names * Use autoclass :members: with toc_object_entries for sidebar * Restore original template structure with rubrics This restores the original template formatting where Methods and Attributes are organized under rubric headings (which don't appear in TOC). Note: pydata-sphinx-theme's secondary sidebar only shows document headings, not autodoc entries. Methods/attributes won't appear in the sidebar without using actual section headings, which would add extra headers to the main body. * Configure pydata-sphinx-theme secondary sidebar for autodoc entries - Add secondary_sidebar_items with page-toc and sourcelink - Set show_toc_level: 3 to show more TOC levels by default - Keep toc_object_entries = True for Sphinx to add object entries to TOC This should make autodoc entries appear in the secondary sidebar if Sphinx's toc_object_entries properly populates the page TOC. * Remove sourcelink from secondary sidebar * Apply cyclass.rst template to all Cython cdef classes Public API Cython classes now using cyclass.rst: - Buffer, MemoryResource - Stream, StreamOptions - Event, EventOptions - DeviceMemoryResource, DeviceMemoryResourceOptions - PinnedMemoryResource, PinnedMemoryResourceOptions - ManagedMemoryResource, ManagedMemoryResourceOptions - LaunchConfig Private API Cython classes now using cyclass.rst: - IPCAllocationHandle, IPCBufferDescriptor - DeviceProperties (already was) * Fix template assignments: dataclasses stay under dataclass.rst - Cython dataclasses (StreamOptions, EventOptions, *ResourceOptions) stay under dataclass.rst template - Pure Cython cdef classes (Buffer, Stream, Event, MemoryResource, LaunchConfig) use cyclass.rst template - Classes inheriting from Cython (GraphMemoryResource, LegacyPinnedMemoryResource, VirtualMemoryResource) use cyclass.rst - Restored original ordering * Move LaunchConfig to dataclass template - Device, Graph, GraphBuilder are regular Python classes (use default) - LaunchConfig uses dataclass template per project convention
1 parent f8dddb3 commit 3722ea4

File tree

7 files changed

+59
-11
lines changed

7 files changed

+59
-11
lines changed

cuda_bindings/docs/source/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
# This pattern also affects html_static_path and html_extra_path.
5454
exclude_patterns = []
5555

56+
# Include object entries (methods, attributes, etc.) in the table of contents
57+
# This enables the "On This Page" sidebar to show class methods and properties
58+
# Requires Sphinx 5.1+
59+
toc_object_entries = True
60+
toc_object_entries_show_parents = "domain"
61+
5662
# -- Options for HTML output -------------------------------------------------
5763

5864
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -69,6 +75,10 @@
6975
"version-switcher",
7076
"navbar-nav",
7177
],
78+
# Use custom secondary sidebar that includes autodoc entries
79+
"secondary_sidebar_items": ["page-toc"],
80+
# Show more TOC levels by default
81+
"show_toc_level": 3,
7282
}
7383
if os.environ.get("CI"):
7484
if int(os.environ.get("BUILD_PREVIEW", 0)):

cuda_core/docs/source/_templates/autosummary/cyclass.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77

88
.. autoclass:: {{ objname }}
99

10-
{% block attributes %}
11-
{% if attributes %}
12-
{% for item in attributes %}
13-
.. autoattribute:: {{ item }}
14-
{%- endfor %}
15-
{% endif %}
16-
{% endblock %}
17-
1810
{% block methods %}
1911
{% if methods %}
2012
.. rubric:: {{ _('Methods') }}
@@ -25,3 +17,13 @@
2517

2618
{% endif %}
2719
{% endblock %}
20+
21+
{% block attributes %}
22+
{% if attributes %}
23+
.. rubric:: {{ _('Attributes') }}
24+
25+
{% for item in attributes %}
26+
.. autoattribute:: {{ item }}
27+
{%- endfor %}
28+
{% endif %}
29+
{% endblock %}

cuda_core/docs/source/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ CUDA runtime
2323
Graph
2424
GraphBuilder
2525
launch
26+
27+
:template: autosummary/cyclass.rst
28+
2629
Buffer
2730
Stream
2831
Event

cuda_core/docs/source/api_private.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ CUDA runtime
2222
_memory._virtual_memory_resource.VirtualMemoryGranularityT
2323
_memory._virtual_memory_resource.VirtualMemoryAccessTypeT
2424
_memory._virtual_memory_resource.VirtualMemoryHandleTypeT
25-
_device.DeviceProperties
26-
_memory._ipc.IPCAllocationHandle
27-
_memory._ipc.IPCBufferDescriptor
2825
_module.KernelAttributes
2926
_module.KernelOccupancy
3027
_module.ParamInfo
3128
_module.MaxPotentialBlockSizeOccupancyResult
3229

30+
:template: autosummary/cyclass.rst
31+
32+
_device.DeviceProperties
33+
_memory._ipc.IPCAllocationHandle
34+
_memory._ipc.IPCBufferDescriptor
35+
3336

3437
CUDA protocols
3538
--------------

cuda_core/docs/source/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
# This pattern also affects html_static_path and html_extra_path.
5252
exclude_patterns = []
5353

54+
# Include object entries (methods, attributes, etc.) in the table of contents
55+
# This enables the "On This Page" sidebar to show class methods and properties
56+
# Requires Sphinx 5.1+
57+
toc_object_entries = True
58+
toc_object_entries_show_parents = "domain"
59+
5460
# -- Options for HTML output -------------------------------------------------
5561

5662
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -67,6 +73,10 @@
6773
"version-switcher",
6874
"navbar-nav",
6975
],
76+
# Use custom secondary sidebar that includes autodoc entries
77+
"secondary_sidebar_items": ["page-toc"],
78+
# Show more TOC levels by default
79+
"show_toc_level": 3,
7080
}
7181
if os.environ.get("CI"):
7282
if int(os.environ.get("BUILD_PREVIEW", 0)):

cuda_pathfinder/docs/source/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
# This pattern also affects html_static_path and html_extra_path.
5555
exclude_patterns = []
5656

57+
# Include object entries (methods, attributes, etc.) in the table of contents
58+
# This enables the "On This Page" sidebar to show class methods and properties
59+
# Requires Sphinx 5.1+
60+
toc_object_entries = True
61+
toc_object_entries_show_parents = "domain"
62+
5763
# -- Options for HTML output -------------------------------------------------
5864

5965
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -70,6 +76,10 @@
7076
"version-switcher",
7177
"navbar-nav",
7278
],
79+
# Use custom secondary sidebar that includes autodoc entries
80+
"secondary_sidebar_items": ["page-toc"],
81+
# Show more TOC levels by default
82+
"show_toc_level": 3,
7383
}
7484
if os.environ.get("CI"):
7585
if int(os.environ.get("BUILD_PREVIEW", 0)):

cuda_python/docs/source/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
# This pattern also affects html_static_path and html_extra_path.
4848
exclude_patterns = []
4949

50+
# Include object entries (methods, attributes, etc.) in the table of contents
51+
# This enables the "On This Page" sidebar to show class methods and properties
52+
# Requires Sphinx 5.1+
53+
toc_object_entries = True
54+
toc_object_entries_show_parents = "domain"
55+
5056
# -- Options for HTML output -------------------------------------------------
5157

5258
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -63,6 +69,10 @@
6369
"version-switcher",
6470
"navbar-nav",
6571
],
72+
# Use custom secondary sidebar that includes autodoc entries
73+
"secondary_sidebar_items": ["page-toc"],
74+
# Show more TOC levels by default
75+
"show_toc_level": 3,
6676
}
6777
if os.environ.get("CI"):
6878
if int(os.environ.get("BUILD_PREVIEW", 0)):

0 commit comments

Comments
 (0)