Skip to content

Commit

Permalink
extract trike module for ///s
Browse files Browse the repository at this point in the history
  • Loading branch information
bkietz committed Oct 30, 2024
1 parent fc3cc46 commit 7701c29
Show file tree
Hide file tree
Showing 10 changed files with 492 additions and 338 deletions.
53 changes: 14 additions & 39 deletions cmake_modules/Maud.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,8 @@ function(_maud_setup_doc)
Python3::Interpreter -m venv --clear "${doc}/venv"
COMMAND
"${doc}/venv/bin/pip" install
"${MAUD_DIR}/maud_sphinx_cmake_adapter"
--editable "${MAUD_DIR}/maud_sphinx_cmake_adapter"
--editable "${_MAUD_SELF_DIR}/trike"
--requirement "${_MAUD_SELF_DIR}/sphinx_requirements.txt"
--isolated
--require-virtualenv
Expand All @@ -1175,41 +1176,6 @@ function(_maud_setup_doc)
string(REPLACE "+" "[+]" ext_regex "${ext_regex}")
string(REPLACE " " "|" ext_regex "${ext_regex}")

glob(_MAUD_HEADERS CONFIGURE_DEPENDS "[.](${ext_regex})$")
set(all_apidoc)
foreach(
file
# We scan every source for doc comments, even though it's
# impossible for a declaration to be public outside a headers
# or interface unit. This allows sphinx access to (for example)
# doc comments in an executable's source, which might be used
# for literate programming.
${_MAUD_HEADERS}
${_MAUD_CXX_SOURCES}
)
_maud_relative_path("${file}" apidoc is_gen)
if(is_gen)
set(apidoc "${doc}/apidoc/rendered/${apidoc}.json")
else()
set(apidoc "${doc}/apidoc/source/${apidoc}.json")
endif()

add_custom_command(
OUTPUT "${apidoc}"
DEPENDS
"${file}"
"${doc}/venv/pip.report.json"
"${_MAUD_SELF_DIR}/maud_apidoc.py"
COMMAND
"${doc}/venv/bin/python3"
"${_MAUD_SELF_DIR}/maud_apidoc.py"
--source="${file}"
--output="${apidoc}"
COMMENT "Scanning ${file}$<$<BOOL:${is_gen}>: (generated)> for apidoc to ${apidoc}"
)
list(APPEND all_apidoc "${apidoc}")
endforeach()

set(all_staged)
foreach(file ${_MAUD_RST})
_maud_relative_path("${file}" staged is_gen)
Expand All @@ -1234,6 +1200,13 @@ function(_maud_setup_doc)

add_custom_target(documentation ALL)

# We run sphinx multithreaded. This can pessimize throughput since ninja
# is probably *also* running `nproc` tasks. If this becomes a problem later,
# there will need to be an option or some other way to mediate between sphinx
# and ninja. In the meantime, ensure that at least sphinx isn't trying to build
# manpages and html at the same time.
set_property(GLOBAL APPEND PROPERTY JOB_POOLS sphinx_build=1)

set(all_build_logs)
foreach(
builder
Expand All @@ -1251,7 +1224,6 @@ function(_maud_setup_doc)
DEPENDS
"${doc}/venv/pip.report.json"
${all_staged}
${all_apidoc}
# FIXME note all of these with Sphinx.env.note_dependency()
# if they aren't already noted.
"${conf_dir}/conf.py"
Expand All @@ -1260,9 +1232,12 @@ function(_maud_setup_doc)
"${SPHINX_BUILD}"
--builder ${builder}
--conf-dir "${conf_dir}"
stage
${builder}
--doctree-dir doctrees
--jobs auto
stage # use stage as source directory
${builder} # provide an independent build directory to each builder
> ${builder}.log
JOB_POOL sphinx_build
COMMAND_EXPAND_LISTS
COMMENT "Building ${builder} with sphinx"
)
Expand Down
238 changes: 0 additions & 238 deletions cmake_modules/maud_apidoc.py

This file was deleted.

3 changes: 3 additions & 0 deletions cmake_modules/trike/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__
*egg-info
build
15 changes: 15 additions & 0 deletions cmake_modules/trike/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "trike"
description = "Simple doc comments for C++"
version = "0.0.1"
dependencies = [
"libclang",
"sphinx >= 8",
]
classifiers = [
"Framework :: Sphinx :: Extension",
]
Loading

0 comments on commit 7701c29

Please sign in to comment.