diff --git a/.readthedocs.yml b/.readthedocs.yml index eea5bd6..e90e042 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,15 +1,14 @@ version: 2 build: - os: "ubuntu-20.04" + os: ubuntu-24.04 tools: - python: "3.10" - -sphinx: - configuration: docs/source/conf.py - -python: - install: - - requirements: docs/requirements.txt - - method: pip - path: . + python: "3.13" + commands: + - pip install cmake + - pip install -r docs/requirements.txt + - pip install -e . + - 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/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3f5e3c3 --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..8e2f1c3 --- /dev/null +++ b/CMakePresets.json @@ -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" + } + ] + } + ] +} diff --git a/cmake/SetupSphinx.cmake b/cmake/SetupSphinx.cmake new file mode 100644 index 0000000..5bc34fc --- /dev/null +++ b/cmake/SetupSphinx.cmake @@ -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() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 0000000..88bf839 --- /dev/null +++ b/docs/CMakeLists.txt @@ -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) diff --git a/docs/requirements.txt b/docs/requirements.txt index 13194e4..98f1a95 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -4,3 +4,4 @@ sphinx-contributors sphinx sphinx-llms-txt sphinxext-opengraph +sphinx-markdown-builder diff --git a/pyproject.toml b/pyproject.toml index 1d6f1c5..319efdc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,8 @@ test = [ "pytest>=7.0.0", ] +[tool.setuptools] + packages = ["sphinx_llms_txt"] [tool.setuptools.dynamic] version = {attr = "sphinx_llms_txt.__version__"} @@ -88,4 +90,4 @@ filterwarnings = [ "ignore::UserWarning", "ignore::DeprecationWarning", "ignore::PendingDeprecationWarning", -] \ No newline at end of file +]