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