Skip to content

Commit

Permalink
Integrate generation back into cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Dec 18, 2023
1 parent e78632a commit 2f14fea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ spack*
# Populated by doc generation
/doc/py_api
/doc/_build
/doc/cpp_api/

# CLion artifacts
.idea/
Expand Down
7 changes: 1 addition & 6 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ find_program(SPHINX_BUILD_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable")

find_program(SPHINX_API_DOC_EXECUTABLE
NAMES sphinx-apidoc
DOC "Path to sphinx-apidoc executable")

include(FindPackageHandleStandardArgs)

# Handle standard arguments to find_package
find_package_handle_standard_args(Sphinx "Failed to find sphinx-executable"
SPHINX_BUILD_EXECUTABLE SPHINX_API_DOC_EXECUTABLE)
find_package_handle_standard_args(Sphinx "Failed to find sphinx executable" SPHINX_BUILD_EXECUTABLE)
39 changes: 5 additions & 34 deletions cmake/podioDoxygen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,19 @@ find_package(Doxygen)
find_package(Sphinx)

if(DOXYGEN_FOUND AND SPHINX_FOUND)
# temporarily override the version for doxy generation (for nightly snapshots)
set(tmp ${podio_VERSION})
if(DOXYVERSION)
set(podio_VERSION ${DOXYVERSION})
endif()
set(SPHINX_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/doc/_build)

set(DOXYGEN_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/doc/_build)
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIRECTORY}) # Doxygen doesn't create this for us

set(DOXYGEN_FILE ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

add_custom_target(doxygen
${DOXYGEN_EXECUTABLE} ${DOXYGEN_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM)

add_custom_target(pybindings_doc
COMMAND
${SPHINX_API_DOC_EXECUTABLE} --force -o ${CMAKE_CURRENT_SOURCE_DIR}/doc/py_api
${CMAKE_SOURCE_DIR}/python ${CMAKE_SOURCE_DIR}/python/podio/test_*.py
COMMENT "Generating python bindigns documentation" VERBATIM
)

set(SPHINX_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sphinx_build)

add_custom_target(Sphinx
add_custom_target(documentation
COMMAND
${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src/:$ENV{LD_LIBRARY_PATH} ROOT_INCLUDE_PATH=${CMAKE_SOURCE_DIR}/include"
${SPHINX_BUILD_EXECUTABLE} -b html
-Dbreathe_projects.PODIO=${DOXYGEN_OUTPUT_DIRECTORY}/xml
${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src/:$ENV{LD_LIBRARY_PATH};ROOT_INCLUDE_PATH=${CMAKE_SOURCE_DIR}/include;"
${SPHINX_BUILD_EXECUTABLE} -M html
${CMAKE_SOURCE_DIR}/doc ${SPHINX_OUTPUT_DIRECTORY}
DEPENDS doxygen pybindings_doc
COMMENT "Building sphinx documentation" VERBATIM
COMMENT "Building documentation" VERBATIM
)

install(DIRECTORY ${SPHINX_OUTPUT_DIRECTORY}/
DESTINATION ${CMAKE_INSTALL_DOCDIR}
OPTIONAL)

# revert version to old value
set(podio_VERSION ${tmp})
unset(tmp)
else()
message(WARNING "Could not generate documentation because either Doxygen or Sphinx could not be found")
endif()
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
"-o",
"py_api",
"../python",
"*/test_*.py", # exclude tests
"podio_version.py", # exclude the convenience version wrapper
"*test_*.py", # exclude tests
]
)

Expand Down
24 changes: 12 additions & 12 deletions include/podio/SIOBlockUserData.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
#include <string>
#include <typeindex>

namespace {

/// helper function to get valid sio block names
template <typename BasicType, typename = podio::EnableIfSupportedUserType<BasicType>>
inline std::string sio_name() {
std::string s = podio::userDataTypeName<BasicType>();
std::replace(s.begin(), s.end(), ' ', '_');
return s;
}
} // namespace

namespace podio {
namespace detail {

/// helper function to get valid sio block names
template <typename BasicType, typename = podio::EnableIfSupportedUserType<BasicType>>
inline std::string sio_name() {
std::string s = podio::userDataTypeName<BasicType>();
std::replace(s.begin(), s.end(), ' ', '_');
return s;
}
} // namespace detail

template <typename BasicType, typename = EnableIfSupportedUserType<BasicType>>
class SIOBlockUserData : public podio::SIOBlock {
public:
SIOBlockUserData() :
SIOBlock(::sio_name<BasicType>(), sio::version::encode_version(UserDataCollection<BasicType>::schemaVersion, 0)) {
SIOBlock(detail::sio_name<BasicType>(),
sio::version::encode_version(UserDataCollection<BasicType>::schemaVersion, 0)) {

podio::SIOBlockFactory::instance().registerBlockForCollection(podio::userDataTypeName<BasicType>(), this);
}
Expand Down

0 comments on commit 2f14fea

Please sign in to comment.