[macros]

# man macro
#
# Inspired by linkgit macro:
# <https://github.com/git/git/blob/master/Documentation/asciidoc.conf>
#
# Usage: man:command(manpage-section)
(?su)[\\]?(?P<name>man):(?P<target>\S*?)\((?P<attrlist>.*?)\)=

# linkgenoptions macro
#
# Usage: linkgenoptions:(text)
(?su)[\\]?(?P<name>linkgenoptions):\((?P<text>.*?)\)=

# no link option macro
#
# Usage: nloption:--option-name
(?su)[\\]?(?P<name>nloption):(?P<opt>--?[a-zA-Z0-9-]*)=

# lttng(1) general option macro
#
# Usage: genoption:--option-name
(?su)[\\]?(?P<name>genoption):(?P<opt>--?[a-zA-Z0-9-]*)=

# option macro
#
# Usage: option:--option-name
(?su)[\\]?(?P<name>option):(?P<opt>--?[a-zA-Z0-9-]*)=

# not macro
#
# Usage: :not:
:not:=not

# escwc macro
#
# Usage: :escwc:
:escwc:=escwc

# esccomma macro
#
# Usage: :esccomma:
:esccomma:=esccomma

# escbs macro
#
# Usage: :escbs:
:escbs:=escbs

# man macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[man-inlinemacro]
{0%{target}}
{0#<citerefentry>}
{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
{0#</citerefentry>}
endif::backend-docbook[]
endif::doctype-manpage[]

# linkgenoptions macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[linkgenoptions-inlinemacro]
{text}
endif::backend-docbook[]
endif::doctype-manpage[]

# option macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[option-inlinemacro]
<literal>{opt}</literal>
endif::backend-docbook[]
endif::doctype-manpage[]

# no link option macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[nloption-inlinemacro]
<literal>{opt}</literal>
endif::backend-docbook[]
endif::doctype-manpage[]

# lttng(1) general option macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[genoption-inlinemacro]
<literal>{opt}</literal>
endif::backend-docbook[]
endif::doctype-manpage[]

# not macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[not-inlinemacro]
NOT
endif::backend-docbook[]
endif::doctype-manpage[]

# escwc macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[escwc-inlinemacro]
<literal>\e*</literal>
endif::backend-docbook[]
endif::doctype-manpage[]

# esccomma macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[esccomma-inlinemacro]
<literal>\e,</literal>
endif::backend-docbook[]
endif::doctype-manpage[]

# escbs macro expansions
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[escbs-inlinemacro]
<literal>\e</literal>
endif::backend-docbook[]
endif::doctype-manpage[]

# configure XML man page header
ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[header]
template::[header-declarations]
<refentry>
    <refentryinfo>
        <date>{revdate}</date>
    </refentryinfo>
    <refmeta>
        <refentrytitle>{mantitle}</refentrytitle>
        <manvolnum>{manvolnum}</manvolnum>
        <refmiscinfo class="source">LTTng</refmiscinfo>
        <refmiscinfo class="version">{lttng_version}</refmiscinfo>
        <refmiscinfo class="manual">LTTng Manual</refmiscinfo>
    </refmeta>
    <refnamediv>
        <refname>{manname}</refname>
        <refpurpose>{manpurpose}</refpurpose>
    </refnamediv>
endif::backend-docbook[]
endif::doctype-manpage[]
