#
# Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#


project mysql/doc ;

import boostbook ;
import os ;
import path ;
import-search /boost/docca ;
import docca ;


# Note: adding server-specific error codes and collations to the reference
# increases build times a lot without any benefit
local doxygen_exclussions =
    detail
    impl
    mysql_server_errc.hpp
    mariadb_server_errc.hpp
    mysql_collations.hpp
    mariadb_collations.hpp
    src.hpp
;

local include-prefix = [ path.root $(__file__:D) [ path.pwd ] ] ;
include-prefix = [ path.native $(include-prefix:D)/include ] ;

docca.pyreference reference.qbk
    :
        [ glob-tree-ex ../include/boost/mysql : *.hpp : $(doxygen_exclussions) ]
    :
        <doxygen:param>PROJECT_NAME=MySQL
        <doxygen:param>PROJECT_BRIEF="C++ MySQL Client Library"
        <doxygen:param>DISTRIBUTE_GROUP_DOC=YES
        <doxygen:param>ENABLE_PREPROCESSING=YES
        <doxygen:param>MACRO_EXPANSION=YES
        <doxygen:param>EXPAND_ONLY_PREDEF=YES
        <doxygen:param>SEARCH_INCLUDES=NO
        <doxygen:param>STRIP_FROM_PATH=$(include-prefix)
        <doxygen:param>"PREDEFINED=\\
            BOOST_MYSQL_DOXYGEN \\
            __cpp_lib_string_view \\
            __cpp_char8_t \\
            \"BOOST_PFR_ENABLED=1\" \\
            \"BOOST_PFR_CORE_NAME_ENABLED=1\" \\
            \"BOOST_DEPRECATED(a)=\" \\
            \"BOOST_ATTRIBUTE_NODISCARD=[[nodiscard]]\" \\
            \"BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=auto\" \\
            \"BOOST_ASIO_COMPLETION_TOKEN_FOR(sig)=class\" \\
            \"BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ct,sig)=auto\" \\
            \"BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(ex)=\" \\
            \"BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(ex)=\" \\
            \"BOOST_MYSQL_RETURN_TYPE(...)=\" \\
            \"protected=private\" \\
            \"BOOST_CXX14_CONSTEXPR=constexpr\" \\
            \"BOOST_INLINE_CONSTEXPR=inline constexpr\" \\
            \"BOOST_MYSQL_CONSTEVAL=consteval\" \\
            \"BOOST_MYSQL_CXX14\" \\
            \"BOOST_MYSQL_WRITABLE_FIELD_TUPLE=class\" \\
            \"BOOST_MYSQL_FIELD_VIEW_FORWARD_ITERATOR=class\" \\
            \"BOOST_MYSQL_EXECUTION_REQUEST=class\" \\
            \"BOOST_MYSQL_RESULTS_TYPE=class\" \\
            \"BOOST_MYSQL_EXECUTION_STATE_TYPE=class\" \\
            \"BOOST_MYSQL_OUTPUT_STRING=class\" \\
            \"BOOST_MYSQL_FORMATTABLE=class\" \\
            \"BOOST_MYSQL_STATIC_ROW=class\" \\
            \"BOOST_MYSQL_PIPELINE_REQUEST_TYPE=class\" \\
            \"BOOST_MYSQL_PIPELINE_STAGE_TYPE=class\" \\
            \"BOOST_MYSQL_WRITABLE_FIELD=class\" \\
            \"BOOST_MYSQL_DECL=\" \\
            \"BOOST_MYSQL_HAS_LOCAL_TIME=\" \\
            \"BOOST_NO_CXX17_DEDUCTION_GUIDES=\" \\
            "
        <doxygen:param>SKIP_FUNCTION_MACROS=NO
        <doxygen:param>OUTPUT_LANGUAGE=English
        <doxygen:param>ABBREVIATE_BRIEF=
        <doxygen:param>AUTOLINK_SUPPORT=NO
        <doxygen:param>EXTRACT_ALL=NO
        <doxygen:param>EXTRACT_PRIVATE=NO
        <doxygen:param>EXTRACT_LOCAL_CLASSES=NO
        <doxygen:param>HIDE_UNDOC_MEMBERS=YES
        <doxygen:param>HIDE_UNDOC_CLASSES=YES
        <doxygen:param>HIDE_FRIEND_COMPOUNDS=YES
        <doxygen:param>CASE_SENSE_NAMES=YES
        <doxygen:param>SHOW_INCLUDE_FILES=NO
        <doxygen:param>INLINE_INFO=NO
        <doxygen:param>SORT_MEMBER_DOCS=NO
        <doxygen:param>SORT_MEMBERS_CTORS_1ST=YES
        <doxygen:param>SHOW_USED_FILES=NO
        <doxygen:param>SHOW_FILES=NO
        <doxygen:param>SHOW_NAMESPACES=NO
        <doxygen:param>QUIET=YES

        <docca:config>config.json
    ;

install images
    :
        [ glob images/*.png images/*.svg ]
    :
        <location>html/mysql/images
    ;

explicit images ;

xml mysql_doc
    :
        qbk/00_main.qbk
    :
        <dependency>reference.qbk
        <dependency>images
    ;

explicit mysql_doc ;


boostbook mysql
    :
        mysql_doc
    :
        <xsl:param>boost.root=../../../..
        <xsl:param>chapter.autolabel=1
        <xsl:param>chunk.section.depth=8                # Depth to which sections should be chunked
        <xsl:param>chunk.first.sections=1               # Chunk the first top-level section?
        <xsl:param>toc.section.depth=8                  # How deep should recursive sections appear in the TOC?
        <xsl:param>toc.max.depth=8                      # How many levels should be created for each TOC?
        <xsl:param>generate.toc="chapter toc,title section nop reference nop part toc"
        <include>../../../tools/boostbook/dtd
    :
        <dependency>images
    ;

# These are used to inform the build system of the
# means to build the integrated and stand-alone docs.

alias boostdoc ;
explicit boostdoc ;

alias boostrelease : mysql ;
explicit boostrelease ;
