Skip to content

Commit

Permalink
Merge branch 'ershi/add-doctest-to-build-docs' into 'main'
Browse files Browse the repository at this point in the history
Run doctest as part of build_docs.py

See merge request omniverse/warp!952
  • Loading branch information
shi-eric committed Jan 7, 2025
2 parents 3d2b5f9 + a8dcc11 commit 1be5607
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ windows-x86_64 docs:
- python -m pip install -r docs/requirements.txt
- Write-Output "$([char]27)[0Ksection_end:$(GetTime):install_dependencies$([char]13)$([char]27)[0K"
script:
- python build_docs.py
- python build_docs.py --no_doctest
- mv docs/_build/html/ ./public/
after_script:
- echo "View the website at https://$CI_PROJECT_ROOT_NAMESPACE.$CI_PAGES_DOMAIN/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
Expand Down Expand Up @@ -730,7 +730,7 @@ publish wheels to gitlab package registry:
- python -m pip install -r docs/requirements.txt
- echo -e "\\e[0Ksection_end:`date +%s`:install_dependencies\\r\\e[0K"
script:
- python build_docs.py
- python build_docs.py --no_doctest
- mv docs/_build/html/ ./public/

# Merge requests: Build documentation and save as an artifact
Expand Down
21 changes: 21 additions & 0 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.

import argparse
import os
import shutil
import subprocess

from warp.context import export_functions_rst, export_stubs

parser = argparse.ArgumentParser(description="Warp Sphinx Documentation Builder")
# Note argparse.BooleanOptionalAction can be used here when Python 3.9+ becomes the minimum supported version
parser.add_argument("--doctest", action="store_true", help="Also run doctest on code snippets, default enabled")
parser.add_argument("--no_doctest", dest="doctest", action="store_false")
parser.set_defaults(doctest=True)

args = parser.parse_args()

base_path = os.path.dirname(os.path.realpath(__file__))

# generate stubs for autocomplete
Expand All @@ -34,4 +43,16 @@

subprocess.run(command, check=True)

if args.doctest:
print("Running doctest... (skip with --no_doctest)")

output_dir = os.path.join(base_path, "docs", "_build", "doctest")

if os.path.exists(output_dir):
shutil.rmtree(output_dir)

command = ["sphinx-build", "-W", "-b", "doctest", source_dir, output_dir]

subprocess.run(command, check=True)

print("Finished")
1 change: 1 addition & 0 deletions docs/modules/tiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Inside kernels, tile operations are executed cooperatively across each block of
In the following example, we launch a grid of threads where each block is responsible for loading a row of data from a 2D array and computing its sum:

.. testcode::
:skipif: wp.get_cuda_device_count() == 0

TILE_SIZE = wp.constant(256)
TILE_THREADS = 64
Expand Down

0 comments on commit 1be5607

Please sign in to comment.