diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index d0801870d..1a5473387 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -37,17 +37,11 @@ jobs: name: Build docs # The build stage could fail but we want the CI to keep moving. if: ${{ github.repository_owner == 'nvidia' && !cancelled() }} - # WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327) - runs-on: linux-amd64-gpu-t4-latest-1 - #runs-on: ubuntu-latest + runs-on: ubuntu-latest defaults: run: shell: bash -el {0} steps: - # WAR: Building the doc currently requires a GPU (NVIDIA/cuda-python#326,327) - - name: Ensure GPU is working - run: nvidia-smi - - name: Checkout ${{ github.event.repository.name }} uses: actions/checkout@v4 with: diff --git a/cuda_core/docs/source/api.rst b/cuda_core/docs/source/api.rst index 5239174f4..f5ee30c1a 100644 --- a/cuda_core/docs/source/api.rst +++ b/cuda_core/docs/source/api.rst @@ -42,12 +42,9 @@ CUDA compilation toolchain CUDA system information ----------------------- -.. autodata:: cuda.core.experimental.system.driver_version - :no-value: -.. autodata:: cuda.core.experimental.system.num_devices - :no-value: -.. autodata:: cuda.core.experimental.system.devices - :no-value: +.. autoproperty:: cuda.core.experimental._system.System.driver_version +.. autoproperty:: cuda.core.experimental._system.System.num_devices +.. autoproperty:: cuda.core.experimental._system.System.devices .. module:: cuda.core.experimental.utils diff --git a/cuda_core/docs/source/conf.py b/cuda_core/docs/source/conf.py index 7c42cd7d0..9e0972e03 100644 --- a/cuda_core/docs/source/conf.py +++ b/cuda_core/docs/source/conf.py @@ -10,10 +10,6 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. import os -import sys -from unittest.mock import MagicMock - -from cuda.core.experimental._system import System # sys.path.insert(0, os.path.abspath('.')) @@ -104,49 +100,32 @@ napoleon_google_docstring = False napoleon_numpy_docstring = True - -# Mock the System class and its methods -class MockSystem: - def __init__(self, *args, **kwargs): - pass - - driver_version = MagicMock() - driver_version.__doc__ = System.driver_version.__doc__ - num_devices = MagicMock() - num_devices.__doc__ = System.num_devices.__doc__ - devices = MagicMock() - devices.__doc__ = System.devices.__doc__ - - -sys.modules["cuda.core.experimental._system.System"] = MagicMock(System=MockSystem) - -# Add 'cuda.core.experimental.system' to autodoc_mock_imports -autodoc_mock_imports = ["cuda.core.experimental.system"] - section_titles = ["Returns"] def autodoc_process_docstring(app, what, name, obj, options, lines): - if name.startswith("cuda.core.experimental.system"): + if name.startswith("cuda.core.experimental._system.System"): + name = name.replace("._system.System", ".system") # patch the docstring (in lines) *in-place*. Should docstrings include section titles other than "Returns", # this will need to be modified to handle them. + while lines: + lines.pop() attr = name.split(".")[-1] from cuda.core.experimental._system import System - lines_new = getattr(System, attr).__doc__.split("\n") - formatted_lines = [] - for line in lines_new: + original_lines = getattr(System, attr).__doc__.split("\n") + new_lines = [] + new_lines.append(f".. py:data:: {name}") + new_lines.append("") + for line in original_lines: title = line.strip() if title in section_titles: - formatted_lines.append(line.replace(title, f".. rubric:: {title}")) + new_lines.append(line.replace(title, f".. rubric:: {title}")) elif line.strip() == "-" * len(title): - formatted_lines.append(" " * len(title)) + new_lines.append(" " * len(title)) else: - formatted_lines.append(line) - n_pops = len(lines) - lines.extend(formatted_lines) - for _ in range(n_pops): - lines.pop(0) + new_lines.append(line) + lines.extend(new_lines) def setup(app):