Add CMake support for also building Markdown docs in parallel (#49)

This commit is contained in:
Jared Dillard
2025-10-26 20:11:09 -07:00
committed by GitHub
parent b63801bcff
commit e2a80faf04
7 changed files with 120 additions and 12 deletions
+10 -11
View File
@@ -1,15 +1,14 @@
version: 2 version: 2
build: build:
os: "ubuntu-20.04" os: ubuntu-24.04
tools: tools:
python: "3.10" python: "3.13"
commands:
sphinx: - pip install cmake
configuration: docs/source/conf.py - pip install -r docs/requirements.txt
- pip install -e .
python: - cmake --workflow --preset documentation-workflow
install: # Copy built documentation to Read the Docs output directory
- requirements: docs/requirements.txt - mkdir -p $READTHEDOCS_OUTPUT/html
- method: pip - cp -r build/* $READTHEDOCS_OUTPUT/html/
path: .
+8
View File
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(SphinxLLMsTxt VERSION 1.0.0 LANGUAGES NONE)
# Add CMake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Add documentation
add_subdirectory(docs)
+47
View File
@@ -0,0 +1,47 @@
{
"version": 6,
"configurePresets": [
{
"name": "documentation",
"displayName": "Documentation Build",
"description": "Configure project with documentation environment setup",
"binaryDir": "${sourceDir}/build"
}
],
"buildPresets": [
{
"name": "html",
"displayName": "Build HTML Documentation",
"configurePreset": "documentation",
"targets": ["html"]
},
{
"name": "markdown",
"displayName": "Build Markdown Documentation",
"configurePreset": "documentation",
"targets": ["markdown"]
},
{
"name": "docs-parallel",
"displayName": "Build HTML and Markdown in parallel",
"configurePreset": "documentation",
"targets": ["html", "markdown"]
}
],
"workflowPresets": [
{
"name": "documentation-workflow",
"displayName": "Documentation Build Workflow",
"steps": [
{
"type": "configure",
"name": "documentation"
},
{
"type": "build",
"name": "docs-parallel"
}
]
}
]
}
+27
View File
@@ -0,0 +1,27 @@
# SetupSphinx.cmake - Find Sphinx for CI environments
# Function to find Sphinx in the system
function(setup_sphinx_environment)
# Find sphinx-build executable in system
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Sphinx documentation generator"
)
if(NOT SPHINX_EXECUTABLE)
message(FATAL_ERROR "sphinx-build not found. Please install Sphinx.")
endif()
# Get Sphinx version
execute_process(
COMMAND ${SPHINX_EXECUTABLE} --version
OUTPUT_VARIABLE SPHINX_VERSION_OUTPUT
ERROR_VARIABLE SPHINX_VERSION_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Found Sphinx: ${SPHINX_EXECUTABLE}")
message(STATUS "${SPHINX_VERSION_OUTPUT}")
# Export to parent scope
set(SPHINX_EXECUTABLE "${SPHINX_EXECUTABLE}" PARENT_SCOPE)
endfunction()
+24
View File
@@ -0,0 +1,24 @@
# Find Sphinx
include(SetupSphinx)
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 both formats
add_custom_target(docs ALL)
add_dependencies(docs html markdown)
+1
View File
@@ -4,3 +4,4 @@ sphinx-contributors
sphinx sphinx
sphinx-llms-txt sphinx-llms-txt
sphinxext-opengraph sphinxext-opengraph
sphinx-markdown-builder
+2
View File
@@ -48,6 +48,8 @@ test = [
"pytest>=7.0.0", "pytest>=7.0.0",
] ]
[tool.setuptools]
packages = ["sphinx_llms_txt"]
[tool.setuptools.dynamic] [tool.setuptools.dynamic]
version = {attr = "sphinx_llms_txt.__version__"} version = {attr = "sphinx_llms_txt.__version__"}