From e3b6521baa4fb73c1d26d714d8938a40df68ab7b Mon Sep 17 00:00:00 2001 From: dota17 Date: Wed, 26 Feb 2020 15:39:27 +0800 Subject: [PATCH] add doc target on cmake --- CMakeLists.txt | 18 ++++++++++++++++++ README.md | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1f6f69..c7b5195 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,6 +317,24 @@ set(JSON_C_SOURCES include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_BINARY_DIR}) +# generate doxygen documentation for json-c API + +find_package(Doxygen) +option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation(requires Doxygen)" ${DOXYGEN_FOUND}) + +if (DOXYGEN_FOUND) + + add_custom_target(doc + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + + # request to configure the file + configure_file(Doxyfile Doxyfile) + +else (DOXYGEN_FOUND) + message("Doxygen need to be installed to generate the doxygen documentation") +endif(DOXYGEN_FOUND) + # XXX for a normal full distribution we'll need to figure out # XXX how to build both shared and static libraries. # Probably leverage that to build a local VALGRIND=1 library for testing too. diff --git a/README.md b/README.md index 766d9e7..b794fcb 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,14 @@ JSONC_TEST_TRACE=1 make test ``` and check the log files again. +To get doxygen documentation + +The libray documentation can be generated directly from the source codes using Doxygen tool: + +```sh +make doc +google-chrome ../doc/html/index.html +``` Linking to `libjson-c` -- 2.40.0