From 6eb61732bc21b67457baf4988f71cd485b2faa15 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 25 Feb 2020 18:12:41 +0100 Subject: [PATCH] Add Doxygen target. --- CMakeLists.txt | 1 + README.adoc | 1 + lib/CMakeLists.txt | 7 +++++++ lib/cmake/Doxygen.cmake | 43 ++++++++++++++++++++++++++++++++++++++ lib/include/fedipotato.hpp | 12 ++++++----- 5 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 lib/cmake/Doxygen.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 774f64c..aec82b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ option(WITH_TESTS "Compile tests." NO) option(WITH_DEB "Prepare for the building of .deb packages." NO) option(WITH_RPM "Prepare for the building of .rpm packages." NO) option(WITH_CLANG-TIDY "Check sourcecode with clang-tidy while compiling." NO) +option(WITH_DOC "Generate API documentation." NO) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/README.adoc b/README.adoc index f041810..3ba3480 100644 --- a/README.adoc +++ b/README.adoc @@ -98,6 +98,7 @@ cmake --build . -- -j$(nproc --ignore=1) // * `-DWITH_TESTS=YES` if you want to compile the tests. * `-DWITH_CLANG-TIDY=YES` to check the sourcecode with link:{uri-clang-tidy}[clang-tidy] while compiling. +* `-WITH_DOC=YES` to generate the API documentation. * One of: ** `-DWITH_DEB=YES` if you want to be able to generate a deb-package. ** `-DWITH_RPM=YES` if you want to be able to generate an rpm-package. diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 53f8776..68bc78d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -3,3 +3,10 @@ add_subdirectory(include) add_subdirectory(cmake) add_subdirectory(pkg-config) + +if(WITH_DOC) + include(cmake/Doxygen.cmake) + enable_doxygen( + "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${CMAKE_CURRENT_SOURCE_DIR}/src") +endif() diff --git a/lib/cmake/Doxygen.cmake b/lib/cmake/Doxygen.cmake new file mode 100644 index 0000000..ef0c4e7 --- /dev/null +++ b/lib/cmake/Doxygen.cmake @@ -0,0 +1,43 @@ +include(GNUInstallDirs) + +function(enable_doxygen) + find_package(Doxygen REQUIRED dot) + + set(DOXYGEN_RECURSIVE YES) + set(DOXYGEN_STRIP_FROM_INC_PATH "include") + if (WITH_EXAMPLES) + set(DOXYGEN_EXAMPLE_PATH "examples/") + set(DOXYGEN_EXAMPLE_RECURSIVE YES) + endif() + set(DOXYGEN_GENERATE_HTML YES) + set(DOXYGEN_HTML_OUTPUT "doc/html") + set(DOXYGEN_GENERATE_LATEX NO) + set(DOXYGEN_ALLOW_UNICODE_NAMES YES) + set(DOXYGEN_BRIEF_MEMBER_DESC YES) + set(DOXYGEN_REPEAT_BRIEF YES) + set(DOXYGEN_ALWAYS_DETAILED_SEC YES) + set(DOXYGEN_INLINE_INHERITED_MEMB NO) + set(DOXYGEN_INHERIT_DOCS YES) + set(DOXYGEN_SEPARATE_MEMBER_PAGES NO) + set(DOXYGEN_TAB_SIZE 4) + set(DOXYGEN_MARKDOWN_SUPPORT YES) + set(DOXYGEN_AUTOLINK_SUPPORT YES) + set(DOXYGEN_INLINE_SIMPLE_STRUCTS NO) + set(DOXYGEN_QUIET YES) + set(DOXYGEN_WARNINGS YES) + set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) + set(DOXYGEN_BUILTIN_STL_SUPPORT YES) + set(DOXYGEN_VERBATIM_HEADERS YES) + set(DOXYGEN_INLINE_SOURCES YES) + set(DOXYGEN_SEARCHENGINE YES) + set(DOXYGEN_SHOW_FILES YES) + + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc") + + doxygen_add_docs(${PROJECT_NAME}_doxygen "${ARGV}") + # Make sure doxygen is run with every build. + add_custom_target(${PROJECT_NAME}_docs ALL DEPENDS ${PROJECT_NAME}_doxygen) + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html + DESTINATION "${CMAKE_INSTALL_DOCDIR}") +endfunction() diff --git a/lib/include/fedipotato.hpp b/lib/include/fedipotato.hpp index 506cbc9..acbb036 100644 --- a/lib/include/fedipotato.hpp +++ b/lib/include/fedipotato.hpp @@ -19,16 +19,18 @@ #include -/*! - * @brief High-level interface to fediverse accounts and their data. - * - * @since 0.1.0 - */ namespace FediPotato { using std::string_view; +/*! + * @brief High-level interface to fediverse accounts and their data. + * + * @since 0.1.0 + * + * @headerfile fedipotato.hpp FediPotato/fedipotato.hpp + */ class FediPotato { public: