# SPDX-License-Identifier: LGPL-2.1-or-later

find_package(Doxygen REQUIRED)

# The documentation is what the public headers say of themselves, with the
# page of its own first, which points to the README. Its name, version and
# brief are those of the project. The guides of `docs/guides/` are pages of
# it, as they are of the reference of the Python package, and the first page
# shows the examples of `examples/cpp/` as they are compiled.
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${CMAKE_CURRENT_SOURCE_DIR}/mainpage.md)
set(DOXYGEN_EXAMPLE_PATH ${PROJECT_SOURCE_DIR}/examples/cpp)
set(DOXYGEN_FILE_PATTERNS *.hpp *.md)
set(DOXYGEN_STRIP_FROM_PATH ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR})
set(DOXYGEN_STRIP_FROM_INC_PATH ${PROJECT_SOURCE_DIR}/include)

# The mark of the logo heads every page, at the height the stylesheet gives
# it, since Doxygen shows it at the size the file has.
set(DOXYGEN_PROJECT_LOGO ${PROJECT_SOURCE_DIR}/docs/logo/isotype/vitrio-mark.svg)
set(DOXYGEN_HTML_EXTRA_STYLESHEET ${CMAKE_CURRENT_SOURCE_DIR}/logo.css)

# A macro between a keyword and the name it declares hides the declaration
# from Doxygen, so those of the library are expanded to nothing.
set(DOXYGEN_MACRO_EXPANSION YES)
set(DOXYGEN_EXPAND_ONLY_PREDEF YES)
set(
	DOXYGEN_PREDEFINED
	VITRIO_API=
	VITRIO_STD_BASE_INTERFACE=
	VITRIO_STD_MEMBER_INTERFACE=
)

# A comment that names a parameter that is not there, or refers to
# something that does not exist, fails the build of the documentation. What
# has no comment does not: the constructors and operators that only copy or
# compare are left without one, and so is what overrides an interface.
set(DOXYGEN_WARN_IF_UNDOCUMENTED NO)
set(DOXYGEN_WARN_AS_ERROR FAIL_ON_WARNINGS)

doxygen_add_docs(
	vitrio-docs
	${CMAKE_CURRENT_SOURCE_DIR}/mainpage.md
	${PROJECT_SOURCE_DIR}/docs/guides
	${PROJECT_SOURCE_DIR}/include
	COMMENT "Generating the documentation of the API"
)
