VirtualBox

Changeset 56482 in vbox


Ignore:
Timestamp:
Jun 17, 2015 3:19:48 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101099
Message:

Made docbook-refentry-to-manual-sect1.xsl produce valid docbook xml but with a few hints that can be used for nice manpage-like formatting.

Location:
trunk/doc/manual
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/Makefile.kmk

    r56471 r56482  
    755755                       -e 's|\$$TARGETPATH|$(@D)|g' --output $@ $<
    756756
     757 # Manual formatcfg dependencies.
     758 $(foreach lang,$(VBOX_MANUAL_LANGUAGES), $(VBOX_PATH_MANUAL_OUTBASE)/$(lang)/docbook-htmlhelp-formatcfg.xsl): \
     759        $(VBOX_PATH_MANUAL_SRC)/common-formatcfg.xsl \
     760        $(VBOX_PATH_MANUAL_SRC)/common-html-formatcfg.xsl
     761
    757762 # Prepare the XSL file for our title page, htmlhelp variant.
    758763 $(foreach f,$(VBOX_MANUAL_LANGUAGES),$(VBOX_PATH_MANUAL_OUTBASE)/$f/titlepage-htmlhelp.xsl): \
     
    805810#
    806811##########################################################################################
     812
     813# Manual formatcfg dependencies.
     814$(VBOX_PATH_MANUAL_OUTBASE)/en_US/docbook-html-one-page-formatcfg.xsl \
     815$(VBOX_PATH_MANUAL_OUTBASE)/en_US/docbook-html-chunks-formatcfg.xsl: \
     816        $(VBOX_PATH_MANUAL_SRC)/common-formatcfg.xsl \
     817        $(VBOX_PATH_MANUAL_SRC)/common-html-formatcfg.xsl
    807818
    808819# intermediate step to do some variable replacement in the XSL configuration
  • trunk/doc/manual/common-formatcfg.xsl

    r31972 r56482  
    5656</xsl:attribute-set>
    5757
     58
     59<!--
     60  refentry related layout tweaks.
     61
     62  Note! While we could save us all this work by using refsect1..3 and
     63        refsynopsisdiv docbook-refentry-to-manual-sect1.xsl, we'd like to have
     64        a valid XML document and thus do do some extra markup using the role
     65        and condition attributes.  We catch some of it here.  But the XSLT
     66        for specific targets (html, latex, etc) have a few more tweaks
     67        related to this.
     68
     69        The @role has only one special trick 'not-in-toc' that excludes sections
     70        like 'Synopsis' and 'Description' from the TOCs.
     71
     72        The @condition records the original refentry element name, i.e. it will
     73        have values like refentry, refsynopsisdiv, refsect1, refsect2 and refsect3.
     74  -->
     75
     76<!-- This removes the not-in-toc bits from the toc. -->
     77<xsl:template match="sect2[@role = 'not-in-toc']"      mode="toc" />
     78<xsl:template match="sect3[@role = 'not-in-toc']"      mode="toc" />
     79<xsl:template match="sect4[@role = 'not-in-toc']"      mode="toc" />
     80<xsl:template match="sect5[@role = 'not-in-toc']"      mode="toc" />
     81<xsl:template match="section[@role = 'not-in-toc']"    mode="toc" />
     82<xsl:template match="simplesect[@role = 'not-in-toc']" mode="toc" />
     83
     84<!-- This removes unnecessary <dd><dl> stuff caused by the above. -->
     85<xsl:template match="sect1[sect2/@role = 'not-in-toc']" mode="toc">
     86  <xsl:param name="toc-context" select="."/>
     87  <xsl:call-template name="subtoc">
     88    <xsl:with-param name="toc-context" select="$toc-context"/>
     89    <xsl:with-param name="nodes" select="sect2[@role != 'not-in-toc'] | bridgehead[$bridgehead.in.toc != 0]"/>
     90  </xsl:call-template>
     91</xsl:template>
     92
     93<xsl:template match="sect2[sect3/@role = 'not-in-toc']" mode="toc">
     94  <xsl:param name="toc-context" select="."/>
     95  <xsl:call-template name="subtoc">
     96    <xsl:with-param name="toc-context" select="$toc-context"/>
     97    <xsl:with-param name="nodes" select="sect3[@role != 'not-in-toc'] | bridgehead[$bridgehead.in.toc != 0]"/>
     98  </xsl:call-template>
     99</xsl:template>
     100
     101<!-- This make the refsect* and refsynopsisdiv unnumbered like the default refentry rendering. -->
     102<xsl:template match="sect2[@condition = 'refsynopsisdiv']
     103                   | sect2[starts-with(@condition, 'refsect')]
     104                   | sect3[starts-with(@condition, 'refsect')]
     105                   | sect4[starts-with(@condition, 'refsect')]
     106                   | sect5[starts-with(@condition, 'refsect')]
     107                   | section[starts-with(@condition, 'refsect')]
     108                   | simplesect[starts-with(@condition, 'refsect')]"
     109  mode="object.title.template"
     110  >
     111    <xsl:call-template name="gentext.template">
     112      <xsl:with-param name="context" select="'title-unnumbered'"/>
     113      <xsl:with-param name="name">
     114        <xsl:call-template name="xpath.location"/>
     115      </xsl:with-param>
     116    </xsl:call-template>
     117</xsl:template>
     118
     119
    58120</xsl:stylesheet>
  • trunk/doc/manual/docbook-refentry-to-manual-sect1.xsl

    r56466 r56482  
    5151<!-- rename refentry to sect1 -->
    5252<xsl:template match="refentry">
    53   <sect1>
     53  <xsl:element name="sect1">
     54    <xsl:attribute name="condition">refentry</xsl:attribute>
    5455    <xsl:apply-templates select="node()|@*"/>
    55   </sect1>
     56  </xsl:element>
    5657</xsl:template>
    57 
    58 <!-- TODO: refsect1 -> sect2 or something... -->
    5958
    6059<!-- Remove refentryinfo, keeping the title element. -->
     
    6766<!-- Morph refnamediv into a brief description. -->
    6867<xsl:template match="refnamediv">
    69   <para>
     68  <xsl:element name="para">
    7069    <xsl:call-template name="capitalize">
    7170      <xsl:with-param name="text" select="normalize-space(./refpurpose)"/>
    7271    </xsl:call-template>
    7372    <xsl:text>.</xsl:text>
    74   </para>
     73  </xsl:element>
    7574</xsl:template>
     75
     76<!-- Morph the refsynopsisdiv part into a synopsis section. -->
     77<xsl:template match="refsynopsisdiv">
     78  <xsl:if test="name(*[1]) != 'cmdsynopsis'"><xsl:message terminate="yes">Expected refsynopsisdiv to start with cmdsynopsis</xsl:message></xsl:if>
     79  <xsl:if test="title"><xsl:message terminate="yes">No title element supported in refsynopsisdiv</xsl:message></xsl:if>
     80
     81  <xsl:element name="sect2">
     82    <xsl:attribute name="role">not-in-toc</xsl:attribute>
     83    <xsl:attribute name="condition">refsynopsisdiv</xsl:attribute>
     84    <xsl:element name="title">
     85    <xsl:text>Synopsis</xsl:text>
     86    </xsl:element>
     87    <xsl:apply-templates />
     88  </xsl:element>
     89
     90</xsl:template>
     91
     92<!-- refsect1 -> sect2 -->
     93<xsl:template match="refsect1">
     94  <xsl:if test="not(title)"><xsl:message terminate="yes">refsect1 requires title</xsl:message></xsl:if>
     95  <xsl:element name="sect2">
     96    <xsl:attribute name="role">not-in-toc</xsl:attribute>
     97    <xsl:attribute name="condition">refsect1</xsl:attribute>
     98    <xsl:apply-templates />
     99  </xsl:element>
     100</xsl:template>
     101
     102<!-- refsect2 -> sect3 -->
     103<xsl:template match="refsect2">
     104  <xsl:if test="not(title)"><xsl:message terminate="yes">refsect2 requires title</xsl:message></xsl:if>
     105  <xsl:element name="sect3">
     106    <xsl:attribute name="role">not-in-toc</xsl:attribute>
     107    <xsl:attribute name="condition">refsect2</xsl:attribute>
     108    <xsl:apply-templates />
     109  </xsl:element>
     110</xsl:template>
     111
     112<!-- refsect3 -> sect4 -->
     113<xsl:template match="refsect3">
     114  <xsl:if test="not(title)"><xsl:message terminate="yes">refsect3 requires title</xsl:message></xsl:if>
     115  <xsl:element name="sect4">
     116    <xsl:attribute name="role">not-in-toc</xsl:attribute>
     117    <xsl:attribute name="condition">refsect3</xsl:attribute>
     118    <xsl:apply-templates />
     119  </xsl:element>
     120</xsl:template>
     121
    76122
    77123<!-- Remove refmeta. -->
  • trunk/doc/manual/docbook2latex.xsl

    r56469 r56482  
    329329        </xsl:call-template>
    330330      </xsl:when>
    331       <xsl:when test="parent::sect2[@condition='no-toc'] or parent::refsect1 or (parent::section and count(ancestor::section) = 2)">
     331      <xsl:when test="parent::sect2[@role='not-in-toc'] or parent::refsect1 or (parent::section and count(ancestor::section) = 2)">
    332332        <xsl:call-template name="title-wrapper">
    333333          <xsl:with-param name="texcmd">\subsection*</xsl:with-param>
     
    339339        </xsl:call-template>
    340340      </xsl:when>
    341       <xsl:when test="parent::sect3[@condition='no-toc'] or parent::refsect2 or (parent::section and count(ancestor::section) = 3)">
     341      <xsl:when test="parent::sect3[@role='not-in-toc'] or parent::refsect2 or (parent::section and count(ancestor::section) = 3)">
    342342        <xsl:call-template name="title-wrapper">
    343343          <xsl:with-param name="texcmd">\subsubsection*</xsl:with-param>
     
    349349        </xsl:call-template>
    350350      </xsl:when>
    351       <xsl:when test="parent::sect4[@condition='no-toc'] or parent::refsect3 or (parent::section and count(ancestor::section) = 4)">
     351      <xsl:when test="parent::sect4[@role='not-in-toc'] or parent::refsect3 or (parent::section and count(ancestor::section) = 4)">
    352352        <xsl:call-template name="title-wrapper">
    353353          <xsl:with-param name="texcmd">\paragraph*</xsl:with-param>
     
    359359        </xsl:call-template>
    360360      </xsl:when>
    361       <xsl:when test="parent::sect5[@condition='no-toc'] or parent::refsect4 or (parent::section and count(ancestor::section) = 5)">
     361      <xsl:when test="parent::sect5[@role='not-in-toc'] or parent::refsect4 or (parent::section and count(ancestor::section) = 5)">
    362362        <xsl:call-template name="title-wrapper">
    363363          <xsl:with-param name="texcmd">\subparagraph*</xsl:with-param>
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette