#
#          Copyright Andrey Semashev 2007 - 2015.
# 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)
#

using quickbook ;
using boostbook ;
using doxygen ;
using xsltproc ;

import set ;
import doxygen ;
import xsltproc ;
import notfile ;
import path ;
import project ;

project boost/libs/log/doc ;

path-constant images_location : html ;

# NOTE: At least Doxygen 1.8.2 is needed to generate docs correctly. Older versions don't support C++11 constructs correctly and generate misleading docs.
local doxygen_params =
        <doxygen:param>RECURSIVE=YES
        <doxygen:param>ALPHABETICAL_INDEX=YES
        <doxygen:param>REPEAT_BRIEF=YES
        <doxygen:param>ALWAYS_DETAILED_SEC=YES
        <doxygen:param>BRIEF_MEMBER_DESC=NO
        <doxygen:param>ABBREVIATE_BRIEF=YES
        <doxygen:param>INHERIT_DOCS=YES
        <doxygen:param>HIDE_UNDOC_MEMBERS=YES
        <doxygen:param>HIDE_UNDOC_CLASSES=YES
        <doxygen:param>HIDE_SCOPE_NAMES=YES
        <doxygen:param>EXTRACT_ALL=NO
        <doxygen:param>EXTRACT_PRIVATE=NO
        <doxygen:param>BUILTIN_STL_SUPPORT=YES
        <doxygen:param>ENABLE_PREPROCESSING=YES
        <doxygen:param>MACRO_EXPANSION=YES
        <doxygen:param>TAB_SIZE=4
        <doxygen:param>SOURCE_BROWSER=YES
        <doxygen:param>VERBATIM_HEADERS=NO
#        <doxygen:param>SEARCH_INCLUDES=YES
#        <doxygen:param>"INCLUDE_PATH=../../.."
#        <doxygen:param>EXCLUDE_SYMBOLS="aux aux::*"
        <doxygen:param>"PREDEFINED=BOOST_LOG_DOXYGEN_PASS \\
                        BOOST_LOG_NO_VTABLE= \\
                        BOOST_SYMBOL_VISIBLE= \\
                        BOOST_FORCEINLINE=inline \\
                        BOOST_INLINE_VARIABLE=inline \\
                        BOOST_STATIC_ASSERT(x)= \\
                        BOOST_STATIC_ASSERT_MSG(x,y)= \\
                        BOOST_STATIC_CONSTANT(x,y)=\"static constexpr x y\" \\
                        BOOST_RV_REF(x)=\"x&&\" \\
                        BOOST_NESTED_TEMPLATE=template \\
                        BOOST_CONSTEXPR=constexpr \\
                        BOOST_CXX14_CONSTEXPR=constexpr \\
                        BOOST_CONSTEXPR_OR_CONST=constexpr \\
                        BOOST_NOEXCEPT=noexcept \\
                        BOOST_NOEXCEPT_IF(x)=noexcept(x) \\
                        BOOST_NOEXCEPT_OR_NOTHROW=noexcept \\
                        BOOST_COPY_ASSIGN_REF(x)=\"x const&\" \\
                        BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(x)= \\
                        BOOST_LOG_UNIQUE_IDENTIFIER_NAME(x)=anonymous \\
                        BOOST_LOG_USE_NATIVE_SYSLOG=1 \\
                        BOOST_PARAMETER_KEYWORD(x,y)=\"keyword y;\" \\
                        BOOST_LOG_AUX_VOID_DEFAULT=\"= void\" \\
                        BOOST_LOG_CONSOLE_SINK_FRONTEND_INTERNAL=sinks::synchronous_sink \\
                        BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL=sinks::synchronous_sink \\
                        BOOST_LOG_NAMESPACE=log \\
                        BOOST_LOG_OPEN_NAMESPACE=\"namespace log {\" \\
                        BOOST_LOG_CLOSE_NAMESPACE=\"}\" \\
                        BOOST_DEFAULTED_FUNCTION(x,y)=\"x = default;\" \\
                        BOOST_DELETED_FUNCTION(x)=\"x = delete;\" \\
                        BOOST_EXPLICIT_OPERATOR_BOOL()=\"explicit operator bool() const;\" \\
                        BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()=\"explicit operator bool() const noexcept;\" \\
                        BOOST_LOG_USE_CHAR \\
                        BOOST_LOG_USE_WCHAR_T \\
                        BOOST_LOG_API= \\
                        BOOST_LOG_SETUP_API="
        <xsl:param>boost.doxygen.detailns=aux
#        <xsl:param>boost.doxygen.detail=implementation_
    ;


local top_level_includes =
    [ glob
        ../../../boost/log/*.hpp
    ] ;

local core_includes =
    [ glob
        ../../../boost/log/core/*.hpp
    ] ;

local attributes_includes =
    [ glob
        ../../../boost/log/attributes/*.hpp
    ] ;

local expressions_includes =
    [ glob
        ../../../boost/log/expressions/*.hpp
        ../../../boost/log/expressions/predicates/*.hpp
        ../../../boost/log/expressions/formatters/*.hpp
    ] ;

local sources_includes =
    [ glob
        ../../../boost/log/sources/*.hpp
    ] ;

local sinks_includes =
    [ set.difference
        # Document all these files...
        [ glob
            ../../../boost/log/sinks/*.hpp
        ]
    :
        # ...except these
        [ glob
            ../../../boost/log/sinks/nt6_event_log*.hpp
        ]
    ] ;

local utility_includes =
    [ glob
        ../../../boost/log/utility/*.hpp
        ../../../boost/log/utility/ipc/*.hpp
        ../../../boost/log/utility/setup/*.hpp
        ../../../boost/log/utility/type_dispatch/*.hpp
        ../../../boost/log/utility/functional/*.hpp
        ../../../boost/log/utility/manipulators/*.hpp
    ] ;

local support_includes =
    [ glob
        ../../../boost/log/support/*.hpp
    ] ;


# This rule generates *.qbk files with macros with references to files, classes, etc. from the doxygen resulting *.xml files.
rule gen-references ( target : source : properties * )
{
    DEPENDS target : source ;
    local source-path = [ path.make [ on $(source) return $(LOCATE) ] ] ;
    STYLESHEET on $(target) = [ path.native [ path.join [ path.parent $(source-path) ] gen_references.xsl ] ] ;
    local target-name = $(source:B) ;
    TARGET on $(target) = [ path.native [ path.join $(source-path) $(target-name:S=.qbk) ] ] ;
}
actions gen-references
{
#    echo "*** Executing " $(NAME:E=xsltproc) -o "$(TARGET)" "$(STYLESHEET)" "$(>)"
    $(NAME:E=xsltproc) -o "$(TARGET)" "$(STYLESHEET)" "$(>)"
}


doxygen top_level_reference
    :
        $(top_level_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Top level headers"
        <location>tmp
    ;

notfile top_level_refs : @gen-references : top_level_reference.xml ;

doxygen core_reference
    :
        $(core_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Core components"
        <location>tmp
    ;

notfile core_refs : @gen-references : core_reference.xml ;

doxygen attributes_reference
    :
        $(attributes_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Attributes"
        <location>tmp
    ;

notfile attributes_refs : @gen-references : attributes_reference.xml ;

doxygen expressions_reference
    :
        $(expressions_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Expressions"
        <location>tmp
    ;

notfile expressions_refs : @gen-references : expressions_reference.xml ;

doxygen sources_reference
    :
        $(sources_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Logging sources"
        <location>tmp
    ;

notfile sources_refs : @gen-references : sources_reference.xml ;

doxygen sinks_reference
    :
        $(sinks_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Sinks"
        <location>tmp
    ;

notfile sinks_refs : @gen-references : sinks_reference.xml ;

doxygen utility_reference
    :
        $(utility_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Utilities"
        <location>tmp
    ;

notfile utility_refs : @gen-references : utility_reference.xml ;

doxygen support_reference
    :
        $(support_includes)
    :
        $(doxygen_params)
        <xsl:param>"boost.doxygen.reftitle=Other libraries support layer"
        <location>tmp
    ;

notfile support_refs : @gen-references : support_reference.xml ;


xml log_doc
    :
        log.qbk
    :
        <dependency>top_level_refs
        <dependency>core_refs
        <dependency>attributes_refs
        <dependency>expressions_refs
        <dependency>sources_refs
        <dependency>sinks_refs
        <dependency>utility_refs
        <dependency>support_refs
    ;

boostbook log
    :
        log_doc
    :
        <dependency>html/images/log
        <xsl:param>boost.root=../../../..
        <xsl:param>boost.libraries=../../../libs/libraries.htm
        <xsl:param>nav.layout=none
        <xsl:param>boost.image=Boost
        <xsl:param>navig.graphics=1
        <xsl:param>chunk.section.depth=2
        <xsl:param>boost.compact.function=0
        <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/log/doc/html
        <format>pdf:<xsl:param>img.src.path=$(images_location)/
    ;

install html/images/log : [ glob *.png ] ;

###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : log ;
explicit boostrelease ;
