Use xsltproc to include settings in API documentation

This commit is contained in:
Marcus Weseloh 2020-11-07 21:14:19 +01:00
parent 272cc5edad
commit c5b50455d7
3 changed files with 91 additions and 1 deletions

View file

@ -29,6 +29,19 @@ if ( DOXYGEN_FOUND )
)
endif ( DOXYGEN_FOUND )
find_package ( LibXslt )
if ( LIBXSLT_XSLTPROC_EXECUTABLE )
add_custom_target ( doxygen_settings
${LIBXSLT_XSLTPROC_EXECUTABLE}
--output ${CMAKE_CURRENT_BINARY_DIR}/fluidsettings.txt
${CMAKE_CURRENT_SOURCE_DIR}/doxygen/fluidsettings.xsl
${CMAKE_CURRENT_SOURCE_DIR}/fluidsettings.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(doxygen doxygen_settings)
endif ( LIBXSLT_XSLTPROC_EXECUTABLE )
if ( UNIX )
install ( FILES fluidsynth.1
DESTINATION ${MAN_INSTALL_DIR} )

View file

@ -82,7 +82,7 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = @CMAKE_SOURCE_DIR@/doc/fluidsynth-v20-devdoc.txt @CMAKE_SOURCE_DIR@/include @CMAKE_SOURCE_DIR@/include/fluidsynth @CMAKE_SOURCE_DIR@/src @CMAKE_BINARY_DIR@/include/fluidsynth
INPUT = @CMAKE_SOURCE_DIR@/doc/fluidsynth-v20-devdoc.txt @CMAKE_SOURCE_DIR@/include @CMAKE_SOURCE_DIR@/include/fluidsynth @CMAKE_SOURCE_DIR@/src @CMAKE_BINARY_DIR@/include/fluidsynth @CMAKE_BINARY_DIR@/doc/fluidsettings.txt
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c *.h
RECURSIVE = YES

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes" indent="no"/>
<!-- main template -->
<xsl:template match="/fluidsettings">
/*!
\page FluidSettings FluidSynth Settings
<xsl:apply-templates match="*" mode="PageRef">
<xsl:sort select="@label"/>
</xsl:apply-templates>
<xsl:apply-templates match="*" mode="Page">
<xsl:sort select="@label"/>
</xsl:apply-templates>
*/
</xsl:template>
<!-- Page reference template -->
<xsl:template match="*" mode="PageRef">
- \subpage <xsl:value-of select="concat('settings_', name(.), ' ', @label)"/>
</xsl:template>
<!-- Page template -->
<xsl:template match="*" mode="Page">
\page <xsl:value-of select="concat('settings_', name(.), ' ', @label)"/>
<xsl:apply-templates match="*" mode="Setting">
<xsl:sort select="name(..)" />
</xsl:apply-templates>
</xsl:template>
<!-- Setting template -->
<xsl:template match="*" mode="Setting">
\section <xsl:value-of select="concat('settings_', name(..), '_', translate(name, '.', '_'))" /><xsl:text> </xsl:text><xsl:value-of select="concat(name(..), '.', name)" />
<xsl:text>&#xa;</xsl:text>
\par Type
<xsl:choose>
<xsl:when test="type = 'bool'">Boolean (int)</xsl:when>
<xsl:when test="type = 'int'">Integer (int)</xsl:when>
<xsl:when test="type = 'str'">
<xsl:choose>
<xsl:when test="vals">Selection (str)</xsl:when>
<xsl:otherwise>String (str)</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="type = 'num'">Float (num)</xsl:when>
<xsl:otherwise><xsl:value-of select="type" /></xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="type = 'str' and vals">\par Options
<xsl:value-of select="vals" /></xsl:when>
<xsl:when test="type = 'bool'">\par Values
0, 1</xsl:when>
<xsl:when test="min or max">\par Min - Max
<xsl:value-of select="min" /> - <xsl:value-of select="max" /></xsl:when>
</xsl:choose>
\par Default
\htmlonly
<xsl:copy-of select="def" />
\endhtmlonly
<xsl:if test="deprecated">
\deprecated This setting is deprecated and might be removed in a future version of FluidSynth.
</xsl:if>
\htmlonly
<xsl:copy-of select="desc"/>
\endhtmlonly
</xsl:template>
</xsl:stylesheet>