source:
vbox/trunk/doc/manual/docbook-refentry-to-H-help.xsl
Last change on this file was 99513, checked in by , 13 months ago | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||
File size: 6.4 KB |
Rev | Line | |
---|---|---|
[56192] | 1 | <?xml version="1.0"?> |
2 | <!-- | |
[56344] | 3 | docbook-refentry-to-H-help.xsl: |
4 | XSLT stylesheet for generating command and sub-command | |
5 | constants header for the built-in help. | |
[96300] | 6 | --> |
7 | <!-- | |
[98103] | 8 | Copyright (C) 2006-2023 Oracle and/or its affiliates. |
[56192] | 9 | |
[96407] | 10 | This file is part of VirtualBox base platform packages, as |
11 | available from https://www.virtualbox.org. | |
12 | ||
13 | This program is free software; you can redistribute it and/or | |
14 | modify it under the terms of the GNU General Public License | |
15 | as published by the Free Software Foundation, in version 3 of the | |
16 | License. | |
17 | ||
18 | This program is distributed in the hope that it will be useful, but | |
19 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | General Public License for more details. | |
22 | ||
23 | You should have received a copy of the GNU General Public License | |
24 | along with this program; if not, see <https://www.gnu.org/licenses>. | |
25 | ||
26 | SPDX-License-Identifier: GPL-3.0-only | |
[56192] | 27 | --> |
28 | ||
29 | <xsl:stylesheet | |
30 | version="1.0" | |
31 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
[56208] | 32 | xmlns:str="http://xsltsl.org/string" |
[56192] | 33 | > |
34 | ||
[73276] | 35 | <xsl:import href="string.xsl"/> |
[56208] | 36 | |
37 | <xsl:output method="text" version="1.0" encoding="utf-8" indent="yes"/> | |
[56192] | 38 | <xsl:strip-space elements="*"/> |
39 | ||
[56344] | 40 | <xsl:param name="g_sMode" select="not-specified"/> |
[56192] | 41 | |
[56344] | 42 | |
[56208] | 43 | <!-- Default action, do nothing. --> |
44 | <xsl:template match="node()|@*"/> | |
[56192] | 45 | |
[56208] | 46 | <!-- |
[56344] | 47 | Generate SCOPE enum for a refentry. We convert the |
48 | cmdsynopsisdiv/cmdsynopsis IDs into constants. | |
[56208] | 49 | --> |
50 | <xsl:template match="refentry"> | |
[68860] | 51 | <xsl:variable name="RefEntry" select="."/> |
52 | <xsl:variable name="sRefEntryId" select="@id"/> | |
[56344] | 53 | <xsl:variable name="sBaseNm"> |
[68860] | 54 | <xsl:choose> |
55 | <xsl:when test="contains($sRefEntryId, '-')"> <!-- Multi level command. --> | |
56 | <xsl:call-template name="str:to-upper"> | |
57 | <xsl:with-param name="text" select="translate(substring-after($sRefEntryId, '-'), '-', '_')"/> | |
58 | </xsl:call-template> | |
59 | </xsl:when> | |
60 | <xsl:otherwise> <!-- Simple command. --> | |
61 | <xsl:call-template name="str:to-upper"> | |
62 | <xsl:with-param name="text" select="translate($sRefEntryId, '-', '_')"/> | |
63 | </xsl:call-template> | |
64 | </xsl:otherwise> | |
65 | </xsl:choose> | |
[56344] | 66 | </xsl:variable> |
[56192] | 67 | |
[56344] | 68 | <xsl:choose> |
69 | <!-- Generate subcommand enums and defines --> | |
70 | <xsl:when test="$g_sMode = 'subcmd'"> | |
[68860] | 71 | <!-- Start enum type and start off with the refentry id. --> |
[56231] | 72 | <xsl:text> |
[56344] | 73 | enum |
74 | { | |
75 | #define HELP_SCOPE_</xsl:text> | |
76 | <xsl:value-of select="$sBaseNm"/> | |
77 | <xsl:value-of select="substring(' ',1,56 - string-length($sBaseNm) - 11)"/> | |
[93708] | 78 | <xsl:text> RT_BIT_64(HELP_SCOPE_</xsl:text><xsl:value-of select="$sBaseNm"/><xsl:text>_BIT) |
[56344] | 79 | HELP_SCOPE_</xsl:text><xsl:value-of select="$sBaseNm"/><xsl:text>_BIT = 0</xsl:text> |
[68860] | 80 | |
81 | <!-- Synopsis IDs --> | |
82 | <xsl:for-each select="./refsynopsisdiv/cmdsynopsis[@id != concat('synopsis-', $sRefEntryId)]"> | |
[56344] | 83 | <xsl:variable name="sSubNm"> |
84 | <xsl:text>HELP_SCOPE_</xsl:text> | |
85 | <xsl:call-template name="str:to-upper"> | |
86 | <xsl:with-param name="text" select="translate(substring-after(substring-after(@id, '-'), '-'), '-', '_')"/> | |
87 | </xsl:call-template> | |
88 | </xsl:variable> | |
89 | <xsl:text>, | |
90 | #define </xsl:text> | |
[68860] | 91 | <xsl:value-of select="$sSubNm"/> |
92 | <xsl:value-of select="substring(' ',1,56 - string-length($sSubNm))"/> | |
[93708] | 93 | <xsl:text> RT_BIT_64(</xsl:text><xsl:value-of select="$sSubNm"/><xsl:text>_BIT) |
[68860] | 94 | </xsl:text> |
95 | <xsl:value-of select="$sSubNm"/><xsl:text>_BIT</xsl:text> | |
[56344] | 96 | </xsl:for-each> |
[56231] | 97 | |
[93708] | 98 | <!-- Add scoping info for refsect1 and refsect2 IDs that aren't part of the synopsis. --> |
99 | <xsl:for-each select=".//refsect1[@id] | .//refsect2[@id]"> | |
[68860] | 100 | <xsl:variable name="sThisId" select="@id"/> |
[99513] | 101 | <xsl:if test=" not($RefEntry[@id = $sThisId]) |
102 | and not($RefEntry/refsynopsisdiv/cmdsynopsis[@id = concat('synopsis-', $sThisId)]) | |
103 | and not(contains($sThisId, '-see-also')) | |
104 | and not(contains($sThisId, '-examples')) "> <!-- controlvm is too big, so skip these two --> | |
[68860] | 105 | <xsl:variable name="sSubNm"> |
106 | <xsl:text>HELP_SCOPE_</xsl:text> | |
107 | <xsl:choose> | |
108 | <xsl:when test="contains($sRefEntryId, '-')"> <!-- Multi level command. --> | |
109 | <xsl:call-template name="str:to-upper"> | |
110 | <xsl:with-param name="text" select="translate(substring-after(@id, '-'), '-', '_')"/> | |
111 | </xsl:call-template> | |
112 | </xsl:when> | |
113 | <xsl:otherwise> <!-- Simple command. --> | |
114 | <xsl:call-template name="str:to-upper"> | |
115 | <xsl:with-param name="text" select="translate(@id, '-', '_')"/> | |
116 | </xsl:call-template> | |
117 | </xsl:otherwise> | |
118 | </xsl:choose> | |
119 | </xsl:variable> | |
120 | <xsl:text>, | |
121 | #define </xsl:text> | |
122 | <xsl:value-of select="$sSubNm"/> | |
123 | <xsl:value-of select="substring(' ',1,56 - string-length($sSubNm))"/> | |
[93708] | 124 | <xsl:text> RT_BIT_64(</xsl:text><xsl:value-of select="$sSubNm"/><xsl:text>_BIT) |
[68860] | 125 | </xsl:text> |
126 | <xsl:value-of select="$sSubNm"/><xsl:text>_BIT</xsl:text> | |
127 | </xsl:if> | |
128 | </xsl:for-each> | |
129 | ||
130 | <!-- Done - complete the enum. --> | |
[56344] | 131 | <xsl:text>, |
[68860] | 132 | HELP_SCOPE_</xsl:text><xsl:value-of select="$sBaseNm"/><xsl:text>_END |
[56208] | 133 | }; |
[93708] | 134 | AssertCompile((int)HELP_SCOPE_</xsl:text><xsl:value-of select="$sBaseNm"/><xsl:text>_END >= 1); |
135 | AssertCompile((int)HELP_SCOPE_</xsl:text><xsl:value-of select="$sBaseNm"/><xsl:text>_END < 64); | |
136 | AssertCompile(RT_BIT_64(HELP_SCOPE_</xsl:text><xsl:value-of select="$sBaseNm"/><xsl:text>_END - 1) & RTMSGREFENTRYSTR_SCOPE_MASK); | |
[56208] | 137 | </xsl:text> |
[56231] | 138 | </xsl:when> |
139 | ||
[56344] | 140 | <!-- Generate command enum value. --> |
141 | <xsl:when test="$g_sMode = 'cmd'"> | |
142 | <xsl:text> HELP_CMD_</xsl:text><xsl:value-of select="$sBaseNm"/><xsl:text>, | |
143 | </xsl:text> | |
[56231] | 144 | </xsl:when> |
145 | ||
[56344] | 146 | <!-- Shouldn't happen. --> |
[56231] | 147 | <xsl:otherwise> |
[56344] | 148 | <xsl:message terminate="yes">Bad or missing g_sMode string parameter value.</xsl:message> |
[56231] | 149 | </xsl:otherwise> |
150 | </xsl:choose> | |
151 | </xsl:template> | |
152 | ||
[56192] | 153 | </xsl:stylesheet> |
154 |
Note:
See TracBrowser
for help on using the repository browser.