Skip to content

Commit b1663dc

Browse files
committed
[Offload] Add Sphinx HTML documentation target
Introduces the `docs-offload-html` target when CMake is configured with `LLVM_ENABLE_SPHINX=ON` and `SPHINX_OUTPUT_HTML=ON`. Utilized `offload-tblgen -gen-spen` to generate Offload API specification docs.
1 parent ef4e5ec commit b1663dc

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

offload/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
2323
return()
2424
endif()
2525

26+
set(OFFLOAD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
27+
2628
if(OPENMP_STANDALONE_BUILD)
2729
set(OFFLOAD_LIBDIR_SUFFIX "" CACHE STRING
2830
"Suffix of lib installation directory, e.g. 64 => lib64")
@@ -371,6 +373,7 @@ add_subdirectory(tools/offload-tblgen)
371373
add_subdirectory(plugins-nextgen)
372374
add_subdirectory(DeviceRTL)
373375
add_subdirectory(tools)
376+
add_subdirectory(docs)
374377

375378
# Build target agnostic offloading library.
376379
add_subdirectory(libomptarget)

offload/docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
offload-api.rst

offload/docs/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
if(LLVM_ENABLE_SPHINX)
2+
include(AddSphinxTarget)
3+
if(SPHINX_FOUND AND SPHINX_OUTPUT_HTML)
4+
# Generate offload-api.rst from OffloadAPI.td
5+
set(LLVM_TARGET_DEFINITIONS
6+
${OFFLOAD_SOURCE_DIR}/liboffload/API/OffloadAPI.td)
7+
tablegen(OFFLOAD source/offload-api.rst -gen-spec
8+
EXTRA_INCLUDES ${OFFLOAD_SOURCE_DIR}/liboffload/API)
9+
add_public_tablegen_target(OffloadDocsGenerate)
10+
11+
# Due to Sphinx only allowing a single source direcotry and the fact we
12+
# only generate a single file, copy offload-api.rst to the source directory
13+
# to be included in the generated documentation. A .gitignore file ensures
14+
# offload-api.rst will not be added to the repository.
15+
add_custom_target(OffloadDocsCopy
16+
COMMAND ${CMAKE_COMMAND} -E copy
17+
${CMAKE_CURRENT_BINARY_DIR}/source/offload-api.rst
18+
${CMAKE_CURRENT_SOURCE_DIR}/offload-api.rst)
19+
20+
# Generate the HTML documentation, invoked wt the docs-offload-html target.
21+
add_sphinx_target(html offload
22+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
23+
add_dependencies(docs-offload-html OffloadDocsGenerate OffloadDocsCopy)
24+
endif()
25+
endif()

offload/docs/conf.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = "Offload"
10+
copyright = "2025, LLVM project"
11+
author = "LLVM project"
12+
13+
# -- General configuration ---------------------------------------------------
14+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
15+
16+
extensions = []
17+
18+
templates_path = ["_templates"]
19+
exclude_patterns = []
20+
21+
# -- C domain configuration --------------------------------------------------
22+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#c-config
23+
24+
c_maximum_signature_line_length = 60
25+
26+
# -- Options for HTML output -------------------------------------------------
27+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
28+
29+
html_theme = "llvm-theme"
30+
html_theme_path = ["_themes"]
31+
html_static_path = ["_static"]
32+
html_favicon = "_static/favicon.ico"

offload/docs/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. Offload documentation master file, created by
2+
sphinx-quickstart on Fri Jul 4 14:59:13 2025.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to Offload's documentation!
7+
===================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
offload-api
14+
15+
16+
Indices and tables
17+
==================
18+
19+
* :ref:`genindex`
20+
* :ref:`modindex`
21+
* :ref:`search`

0 commit comments

Comments
 (0)