• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2016-2018 The Khronos Group Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
16
17include ::Asciidoctor
18
19class VulkanInlineMacroBase < Extensions::InlineMacroProcessor
20    use_dsl
21    using_format :short
22end
23
24class NormativeInlineMacroBase < VulkanInlineMacroBase
25    def text
26        'normative'
27    end
28
29    def process parent, target, attributes
30        '<strong class="purple">' + text + '</strong>'
31    end
32end
33
34class LinkInlineMacroBase < VulkanInlineMacroBase
35    def process parent, target, attributes
36      if parent.document.attributes['cross-file-links']
37        return Inline.new(parent, :anchor, target, :type => :link, :target => (target + '.html')).convert
38      else
39        return Inline.new(parent, :anchor, target, :type => :xref, :target => ('#' + target), :attributes => {'fragment' => target, 'refid' => target}).convert
40      end
41    end
42end
43
44class CodeInlineMacroBase < VulkanInlineMacroBase
45    def process parent, target, attributes
46        '<code>' + target + '</code>'
47    end
48end
49
50class StrongInlineMacroBase < VulkanInlineMacroBase
51    def process parent, target, attributes
52        '<code>' + target + '</code>'
53    end
54end
55
56class ParamInlineMacroBase < VulkanInlineMacroBase
57    def process parent, target, attributes
58        '<code>' + target + '</code>'
59    end
60end
61
62class CanInlineMacro < NormativeInlineMacroBase
63    named :can
64    match /can:(\w*)/
65
66    def text
67        'can'
68    end
69end
70
71class CannotInlineMacro < NormativeInlineMacroBase
72    named :cannot
73    match /cannot:(\w*)/
74
75    def text
76        'cannot'
77    end
78end
79
80class MayInlineMacro < NormativeInlineMacroBase
81    named :may
82    match /may:(\w*)/
83
84    def text
85        'may'
86    end
87end
88
89class MustInlineMacro < NormativeInlineMacroBase
90    named :must
91    match /must:(\w*)/
92
93    def text
94        'must'
95    end
96end
97
98class OptionalInlineMacro < NormativeInlineMacroBase
99    named :optional
100    match /optional:(\w*)/
101
102    def text
103        'optional'
104    end
105end
106
107class RequiredInlineMacro < NormativeInlineMacroBase
108    named :required
109    match /required:(\w*)/
110
111    def text
112        'required'
113    end
114end
115
116class ShouldInlineMacro < NormativeInlineMacroBase
117    named :should
118    match /should:(\w*)/
119
120    def text
121        'should'
122    end
123end
124
125class FlinkInlineMacro < LinkInlineMacroBase
126    named :flink
127    match /flink:(\w+)/
128end
129
130class FnameInlineMacro < StrongInlineMacroBase
131    named :fname
132    match /fname:(\w+)/
133end
134
135class FtextInlineMacro < StrongInlineMacroBase
136    named :ftext
137    match /ftext:([\w\*]+)/
138end
139
140class SnameInlineMacro < CodeInlineMacroBase
141    named :sname
142    match /sname:(\w+)/
143end
144
145class SlinkInlineMacro < LinkInlineMacroBase
146    named :slink
147    match /slink:(\w+)/
148end
149
150class StextInlineMacro < CodeInlineMacroBase
151    named :stext
152    match /stext:([\w\*]+)/
153end
154
155class EnameInlineMacro < CodeInlineMacroBase
156    named :ename
157    match /ename:(\w+)/
158end
159
160class ElinkInlineMacro < LinkInlineMacroBase
161    named :elink
162    match /elink:(\w+)/
163end
164
165class EtextInlineMacro < CodeInlineMacroBase
166    named :etext
167    match /etext:([\w\*]+)/
168end
169
170class PnameInlineMacro < ParamInlineMacroBase
171    named :pname
172    match /pname:(\w+(\.\w+)*)/
173end
174
175class PtextInlineMacro < ParamInlineMacroBase
176    named :ptext
177    match /ptext:([\w\*]+(\.[\w\*]+)*)/
178end
179
180class DnameInlineMacro < CodeInlineMacroBase
181    named :dname
182    match /dname:(\w+)/
183end
184
185class DlinkInlineMacro < LinkInlineMacroBase
186    named :dlink
187    match /dlink:(\w+)/
188end
189
190class TnameInlineMacro < CodeInlineMacroBase
191    named :tname
192    match /tname:(\w+)/
193end
194
195class TlinkInlineMacro < LinkInlineMacroBase
196    named :tlink
197    match /tlink:(\w+)/
198end
199
200class BasetypeInlineMacro < CodeInlineMacroBase
201    named :basetype
202    match /basetype:(\w+)/
203end
204
205class CodeInlineMacro < StrongInlineMacroBase
206    named :code
207    match /code:(\w+)/
208end
209
210# The tag: and attr: macros are only used in registry.txt
211
212class TagInlineMacro < StrongInlineMacroBase
213    named :tag
214    match /tag:(\w+)/
215end
216
217class AttrInlineMacro < StrongInlineMacroBase
218    named :attr
219    match /attr:(\w+)/
220end
221
222