#
# Copyright (c) 2023-2024 Ivica Siladic, Bruno Iljazovic, Korina Simicevic
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
#

project async_mqtt5/doc ;

import os ;
local BOOST_ROOT = [ os.environ DevRoot ] ;

using boostbook
  : $(BOOST_ROOT)3rdParty/boost-doc/boostbook/docbook-xsl-1.79.1
  : $(BOOST_ROOT)3rdParty/boost-doc/boostbook/docbook-dtd-4.2
  : $(BOOST_ROOT)3rdParty/boost-doc/boostbook
;

using xsltproc ;
using doxygen ;

# we shall use os.platform to correctly map quickbook executable
# echo [ os.platform ] ;

if [ os.name ] = MACOSX
{
	using quickbook : $(BOOST_ROOT)build/macos-arm64-release/bin/quickbook ;
}
else if [ os.name ] = LINUX
{
	using quickbook : $(BOOST_ROOT)build/linux-native-x64-release/bin/quickbook ;
}

import boostbook ;

make xml/index.xml
	:
		reference.dox
		
		# additional dependencies
		../include/async_mqtt5/error.hpp
		../include/async_mqtt5/logger.hpp
		../include/async_mqtt5/reason_codes.hpp
		../include/async_mqtt5/types.hpp
		../include/async_mqtt5/mqtt_client.hpp
	:
		@call-doxygen
	;

# combine.xslt is generated after using doxygen but bjam is unaware of it
make xml/combine.xslt
	:
		xml/index.xml
	:
		@null-action
	;

make xml/all.xml
	:
		xml/combine.xslt
		xml/index.xml
	:
		@call-xsltproc
	;

make reference.qbk
	:
		reference.xsl
		xml/all.xml
	:
		@call-xsltproc
	;

# We have to make a copy of reference.qbk and put it
# in a place where the static .qbk files can find it
install qbk/reference : reference.qbk ;


actions null-action 
{
	# the action is used with "make" rule to make bjam aware that a file exists
}

actions call-doxygen 
{
	doxygen $(2)
}

actions call-xsltproc
{
	xsltproc $(2) > $(1)
}

install stylesheets
	:
		$(BOOST_ROOT)3rdParty/boost-doc/style/boostbook.css
	:
		<location>html/
	;

explicit stylesheets ;

install callouts
	:
		[ glob $(BOOST_ROOT)3rdParty/boost-doc/style/images/callouts/*.png ]
	:
		<location>html/images/callouts
	;

explicit callout ;

install images
	:
		[ glob $(BOOST_ROOT)3rdParty/boost-doc/style/images/*.png ]
	:
		<location>html/images
	;

explicit images ;

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

explicit async_mqtt5_doc ;

boostbook async_mqtt5
	:
		async_mqtt5_doc
	:
		<xsl:param>"boost.root=https://www.boost.org/doc/libs/1_82_0"
		<xsl:param>boost.graphics.root=images/
		<xsl:param>nav.layout=none
		<xsl:param>chapter.autolabel=1
		<xsl:param>chunk.section.depth=8
		<xsl:param>chunk.first.sections=1
		<xsl:param>toc.max.depth=2
		<xsl:param>generate.toc="chapter toc,title section nop reference nop part toc"
		<xsl:param>html.stylesheet=boostbook.css
	:
		<dependency>stylesheets
		<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 : async_mqtt5 ;
explicit boostrelease ;
