From dc9f16d4544ccd9cf56e552869861d63b815b597 Mon Sep 17 00:00:00 2001 From: Jared Dillard Date: Mon, 1 Dec 2025 13:51:26 -0800 Subject: [PATCH] Add singlerst builder --- .readthedocs.yml | 5 +++- CMakePresets.json | 8 ++++- .../{SetupSphinx.cmake => SphinxUtils.cmake} | 13 +++++++- docs/CMakeLists.txt | 30 ++++--------------- docs/requirements.txt | 2 +- docs/source/conf.py | 1 + 6 files changed, 31 insertions(+), 28 deletions(-) rename cmake/{SetupSphinx.cmake => SphinxUtils.cmake} (54%) diff --git a/.readthedocs.yml b/.readthedocs.yml index e90e042..2725cfa 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -11,4 +11,7 @@ build: - cmake --workflow --preset documentation-workflow # Copy built documentation to Read the Docs output directory - mkdir -p $READTHEDOCS_OUTPUT/html - - cp -r build/* $READTHEDOCS_OUTPUT/html/ + - cp -r build/html/* $READTHEDOCS_OUTPUT/html/ + - cp -r build/markdown/* $READTHEDOCS_OUTPUT/html/ + - cp -r build/rst/* $READTHEDOCS_OUTPUT/html/ + - cp build/singlerst/index.rst $READTHEDOCS_OUTPUT/html/llms-full.txt diff --git a/CMakePresets.json b/CMakePresets.json index 1336542..678b631 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -27,11 +27,17 @@ "configurePreset": "documentation", "targets": ["rst"] }, + { + "name": "singlerst", + "displayName": "Build Single reStructuredText Documentation", + "configurePreset": "documentation", + "targets": ["singlerst"] + }, { "name": "docs-parallel", "displayName": "Build HTML and Markdown in parallel", "configurePreset": "documentation", - "targets": ["html", "markdown", "rst"] + "targets": ["html", "markdown", "rst", "singlerst"] } ], "workflowPresets": [ diff --git a/cmake/SetupSphinx.cmake b/cmake/SphinxUtils.cmake similarity index 54% rename from cmake/SetupSphinx.cmake rename to cmake/SphinxUtils.cmake index 4ec7466..2277f66 100644 --- a/cmake/SetupSphinx.cmake +++ b/cmake/SphinxUtils.cmake @@ -1,4 +1,7 @@ -# SetupSphinx.cmake - Find Sphinx for CI environments +# Sphinx related utilities + +set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/source) +set(SPHINX_BUILD ${CMAKE_BINARY_DIR}) # Function to find Sphinx in the system function(setup_sphinx_environment) @@ -15,3 +18,11 @@ function(setup_sphinx_environment) # Export to parent scope set(SPHINX_EXECUTABLE "${SPHINX_EXECUTABLE}" PARENT_SCOPE) endfunction() + +# Function to add a Sphinx builder target +function(add_sphinx_builder builder_name) + add_custom_target(${builder_name} + COMMAND ${SPHINX_EXECUTABLE} -b ${builder_name} ${SPHINX_SOURCE} ${SPHINX_BUILD}/${builder_name} + VERBATIM + ) +endfunction() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index fbb1baa..c61163b 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,27 +1,9 @@ # Find Sphinx -include(SetupSphinx) +include(SphinxUtils) setup_sphinx_environment() -set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/source) -set(SPHINX_BUILD ${CMAKE_BINARY_DIR}) - -# Build HTML documentation -add_custom_target(html - COMMAND ${SPHINX_EXECUTABLE} -b html ${SPHINX_SOURCE} ${SPHINX_BUILD} - COMMENT "Building HTML documentation" - VERBATIM -) - -# Build markdown documentation -add_custom_target(markdown - COMMAND ${SPHINX_EXECUTABLE} -b markdown ${SPHINX_SOURCE} ${SPHINX_BUILD} - COMMENT "Building Markdown documentation" - VERBATIM -) - -# Build reStructuredText documentation -add_custom_target(rst - COMMAND ${SPHINX_EXECUTABLE} -b rst ${SPHINX_SOURCE} ${SPHINX_BUILD} - COMMENT "Building reStructuredText documentation" - VERBATIM -) +# Add builder targets +add_sphinx_builder(html) +add_sphinx_builder(markdown) +add_sphinx_builder(rst) +add_sphinx_builder(singlerst) diff --git a/docs/requirements.txt b/docs/requirements.txt index 6f7cb11..301821b 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -5,4 +5,4 @@ sphinx sphinx-llms-txt sphinxext-opengraph sphinx-markdown-builder -sphinxcontrib-restbuilder +sphinxcontrib-restbuilder @ git+https://github.com/jdillard/restbuilder.git@feature/singlerst-builder diff --git a/docs/source/conf.py b/docs/source/conf.py index b9f9dfb..38505e0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,6 +17,7 @@ copyright = "Jared Dillard" author = "Jared Dillard" llms_txt_uri_template = "{base_url}{docname}.md" +llms_txt_full_file = False llms_txt_code_files = ["+:../../sphinx_llms_txt/*.py"] llms_txt_summary = """ A Sphinx extension that generates a summary llms.txt file,written in Markdown,