Skip to content

Commit db38fcd

Browse files
authored
Merge pull request #434 from leofang/cpu-doc
Use cpu runner to build docs
2 parents 989e087 + aaecd5f commit db38fcd

File tree

3 files changed

+17
-47
lines changed

3 files changed

+17
-47
lines changed

.github/workflows/build-docs.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,11 @@ jobs:
3737
name: Build docs
3838
# The build stage could fail but we want the CI to keep moving.
3939
if: ${{ github.repository_owner == 'nvidia' && !cancelled() }}
40-
# WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327)
41-
runs-on: linux-amd64-gpu-t4-latest-1
42-
#runs-on: ubuntu-latest
40+
runs-on: ubuntu-latest
4341
defaults:
4442
run:
4543
shell: bash -el {0}
4644
steps:
47-
# WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327)
48-
- name: Ensure GPU is working
49-
run: nvidia-smi
50-
5145
- name: Checkout ${{ github.event.repository.name }}
5246
uses: actions/checkout@v4
5347
with:

cuda_core/docs/source/api.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ CUDA compilation toolchain
4242
CUDA system information
4343
-----------------------
4444

45-
.. autodata:: cuda.core.experimental.system.driver_version
46-
:no-value:
47-
.. autodata:: cuda.core.experimental.system.num_devices
48-
:no-value:
49-
.. autodata:: cuda.core.experimental.system.devices
50-
:no-value:
45+
.. autoproperty:: cuda.core.experimental._system.System.driver_version
46+
.. autoproperty:: cuda.core.experimental._system.System.num_devices
47+
.. autoproperty:: cuda.core.experimental._system.System.devices
5148

5249

5350
.. module:: cuda.core.experimental.utils

cuda_core/docs/source/conf.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
import os
13-
import sys
14-
from unittest.mock import MagicMock
15-
16-
from cuda.core.experimental._system import System
1713

1814
# sys.path.insert(0, os.path.abspath('.'))
1915

@@ -104,49 +100,32 @@
104100
napoleon_google_docstring = False
105101
napoleon_numpy_docstring = True
106102

107-
108-
# Mock the System class and its methods
109-
class MockSystem:
110-
def __init__(self, *args, **kwargs):
111-
pass
112-
113-
driver_version = MagicMock()
114-
driver_version.__doc__ = System.driver_version.__doc__
115-
num_devices = MagicMock()
116-
num_devices.__doc__ = System.num_devices.__doc__
117-
devices = MagicMock()
118-
devices.__doc__ = System.devices.__doc__
119-
120-
121-
sys.modules["cuda.core.experimental._system.System"] = MagicMock(System=MockSystem)
122-
123-
# Add 'cuda.core.experimental.system' to autodoc_mock_imports
124-
autodoc_mock_imports = ["cuda.core.experimental.system"]
125-
126103
section_titles = ["Returns"]
127104

128105

129106
def autodoc_process_docstring(app, what, name, obj, options, lines):
130-
if name.startswith("cuda.core.experimental.system"):
107+
if name.startswith("cuda.core.experimental._system.System"):
108+
name = name.replace("._system.System", ".system")
131109
# patch the docstring (in lines) *in-place*. Should docstrings include section titles other than "Returns",
132110
# this will need to be modified to handle them.
111+
while lines:
112+
lines.pop()
133113
attr = name.split(".")[-1]
134114
from cuda.core.experimental._system import System
135115

136-
lines_new = getattr(System, attr).__doc__.split("\n")
137-
formatted_lines = []
138-
for line in lines_new:
116+
original_lines = getattr(System, attr).__doc__.split("\n")
117+
new_lines = []
118+
new_lines.append(f".. py:data:: {name}")
119+
new_lines.append("")
120+
for line in original_lines:
139121
title = line.strip()
140122
if title in section_titles:
141-
formatted_lines.append(line.replace(title, f".. rubric:: {title}"))
123+
new_lines.append(line.replace(title, f".. rubric:: {title}"))
142124
elif line.strip() == "-" * len(title):
143-
formatted_lines.append(" " * len(title))
125+
new_lines.append(" " * len(title))
144126
else:
145-
formatted_lines.append(line)
146-
n_pops = len(lines)
147-
lines.extend(formatted_lines)
148-
for _ in range(n_pops):
149-
lines.pop(0)
127+
new_lines.append(line)
128+
lines.extend(new_lines)
150129

151130

152131
def setup(app):

0 commit comments

Comments
 (0)