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