diff options
author | Gereon Kremer <nafur42@gmail.com> | 2021-05-26 08:10:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-26 06:10:51 +0000 |
commit | 22d05234d9a4a98ad715d6e2d6cb1616592fd2b5 (patch) | |
tree | e87106fa825520c03a8fadc7150f4d06f21d2c10 /docs | |
parent | 8bdef44df0876840a9fb34e7bd820b0eee7c9700 (diff) |
Reduce size of sphinx-gh output (#6601)
This PR reduces the disk size of the docs generated by make sphinx-gh.
Apart from reformatting the cmake source, we now not only remove the _sources folder, but also .doctrees (essentially the sphinx cache) and _static/fonts/ (the fonts that are actually used live in _static/css/fonts).
In combination, this now reduces the disk size from about 20MB (sphinx) to less than 6MB (sphinx-gh).
Furthermore this PR only uploads the generated documentation if it differs from whatever we currently have for master.
This is relevant to make the docs-ci repository smaller (which already has more than 5GB...)
Diffstat (limited to 'docs')
-rw-r--r-- | docs/CMakeLists.txt | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 99c4f3ab3..11c4b8dfd 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -25,34 +25,38 @@ set(SPHINX_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx) configure_file(conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py) -add_custom_target(docs ALL - DEPENDS docs-cpp docs-python gen-options - COMMAND - ${SPHINX_EXECUTABLE} -b html - -c ${CMAKE_CURRENT_BINARY_DIR} - # Tell Breathe where to find the Doxygen output - -Dbreathe_projects.cvc5=${CPP_DOXYGEN_XML_FOLDER} - -Dbreathe_projects.std=${CPP_DOXYGEN_XML_FOLDER} - ${SPHINX_INPUT_DIR} ${SPHINX_OUTPUT_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating Sphinx Api docs") +add_custom_target( + docs ALL + DEPENDS docs-cpp docs-python gen-options + COMMAND + ${SPHINX_EXECUTABLE} -b html -c ${CMAKE_CURRENT_BINARY_DIR} + # Tell Breathe where to find the Doxygen output + -Dbreathe_projects.cvc5=${CPP_DOXYGEN_XML_FOLDER} + -Dbreathe_projects.std=${CPP_DOXYGEN_XML_FOLDER} ${SPHINX_INPUT_DIR} + ${SPHINX_OUTPUT_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating Sphinx Api docs" +) set(SPHINX_GH_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx-gh) -add_custom_target(docs-gh ALL - DEPENDS docs - COMMAND ${CMAKE_COMMAND} -E remove_directory - ${SPHINX_GH_OUTPUT_DIR} - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${SPHINX_OUTPUT_DIR} ${SPHINX_GH_OUTPUT_DIR} - COMMAND ${CMAKE_COMMAND} -E remove_directory - ${SPHINX_GH_OUTPUT_DIR}/_sources - COMMAND ${CMAKE_COMMAND} -E remove - ${SPHINX_GH_OUTPUT_DIR}/objects.inv - COMMAND ${CMAKE_COMMAND} -E rename - ${SPHINX_GH_OUTPUT_DIR}/_static - ${SPHINX_GH_OUTPUT_DIR}/static - COMMAND find ${SPHINX_GH_OUTPUT_DIR} -type f | - xargs sed -i'orig' 's/_static/static/' - COMMAND find ${SPHINX_GH_OUTPUT_DIR} -name '*orig' -delete - COMMENT "Generating GitHub Api docs") - +add_custom_target( + docs-gh ALL + DEPENDS docs + # remove existing sphinx-gh/ directory + COMMAND ${CMAKE_COMMAND} -E remove_directory ${SPHINX_GH_OUTPUT_DIR} + # copy sphinx/ to sphinx-gh/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${SPHINX_OUTPUT_DIR} + ${SPHINX_GH_OUTPUT_DIR} + # remove leftovers from the build + COMMAND ${CMAKE_COMMAND} -E remove_directory ${SPHINX_GH_OUTPUT_DIR}/.doctrees + ${SPHINX_GH_OUTPUT_DIR}/_sources ${SPHINX_GH_OUTPUT_DIR}/_static/fonts + COMMAND ${CMAKE_COMMAND} -E remove ${SPHINX_GH_OUTPUT_DIR}/objects.inv + # rename _static/ to static/ (as jekyll ignores _*/ dirs) + COMMAND ${CMAKE_COMMAND} -E rename ${SPHINX_GH_OUTPUT_DIR}/_static + ${SPHINX_GH_OUTPUT_DIR}/static + COMMAND find ${SPHINX_GH_OUTPUT_DIR} -type f | xargs sed -i'orig' + 's/_static/static/' + COMMAND find ${SPHINX_GH_OUTPUT_DIR} -name '*orig' -delete + # done + COMMENT "Generating GitHub Api docs" +) |