Imported Upstream version 1.57.0
[platform/upstream/boost.git] / tools / quickbook / test / templates-1_6.quickbook
1 [article Template 1.6
2     [quickbook 1.6]
3 ]
4
5 [section Templates]
6
7 [/-------------------------------- nullary arg ]
8
9 [template foo0 nullary_arg]
10
11 [foo0]
12
13 [/-------------------------------- unary arg, phrase syle ]
14
15 [template foo1[bar] foo [bar]]
16
17 [foo1 baz]
18
19 [/-------------------------------- unary arg, block syle ]
20
21 [template foo2[bar]
22 foo [bar]
23 ]
24
25 [foo2 baz]
26
27 [template foo3[bar]
28 This is a complete paragraph. [bar] [bar] [bar] [bar] [bar]
29 [bar] [bar] [bar] [bar].... blah blah blah......
30 ]
31
32 [foo3 kalamazoo]
33
34 [/-------------------------------- unary arg, using punctuation ]
35
36 [template ![bar] '''<hey>'''[bar]'''</hey>''']
37
38 [!baz]
39
40 [/-------------------------------- recursive templates ]
41
42 [template foo4[bar]
43 [foo3 [bar]]
44 ]
45
46 [foo3 madagascar]
47
48 [template foo5[x] zoom [x]]
49 [template foo6[x] [x] zoom]
50
51 [foo6[foo5 peanut]]
52
53 [template kinda_weird[x y] [x] [y]]
54
55 [kinda_weird exactly..xanadu]
56
57
58 [/-------------------------------- space delimitted args ]
59
60 [template simple1[a b] [a][b]]
61
62 [simple1 w x]
63
64 [template simple2[a b c d] [a][b][c][d]]
65
66 [simple2 w x y z][simple2 w x y z trail]
67
68 [/-------------------------------- John's templates ]
69
70 [template code[x]
71     int main()
72     {
73         std::cout << ``[x]`` << std::endl;
74     }
75 ]
76
77 [code "Hello\, World"]
78
79 [template alpha '''&alpha;''']
80 [template pow[a b] [a]'''<superscript>'''[b]'''</superscript>''' ]
81 [template super[text]'''<superscript>'''[text]'''</superscript>''' ]
82
83 [pow x 2]
84
85 [pow [alpha] 2]
86
87 x[super 2]
88
89 [/-------------------------------- Some more ]
90
91 [template banana got a banana?]
92 [template plantation[bananarama] [bananarama]]
93
94 [plantation [banana]]
95
96 [/-------------------------------- Not a bug (there was a syntax error here) ]
97
98 [template join1[a b] [b][a]]
99 [template join2[a b] [a][b]]
100 [template test[x] [join1 [join2 0 [x]]...0]]
101 [test 0]
102
103 [/-------------------------------- Mismatched template ]
104
105 [template foo 1]
106 [fool]
107
108 [template blah 10]
109
110 [endsect]
111
112 [section Empty Templates]
113
114 [template empty1]
115 [template empty2 ]
116 [template empty3 [/comment]]
117 [template empty4 [/comment]
118
119 ]
120 [template empty5
121 ]
122 [template empty6
123
124 ]
125 [template empty7
126 [/comment]
127 ]
128 [template empty8
129
130 [/comment]
131 ]
132 [template empty_arg1[x]]
133 [template empty_arg2[x y]]
134
135 [empty1]
136 [empty2]
137 [empty3]
138 [empty4]
139 [empty5]
140 [empty6]
141 [empty7]
142 [empty8]
143 [empty_arg1 1]
144 [empty_arg2 1 2]
145
146 [endsect]
147
148 [/----------------------------------- Nested templates ]
149
150 [section Nested Templates]
151
152 [template block_foo[content]
153
154 Start block template.
155
156 [content]
157
158 End block template.
159 ]
160
161 [template phrase_foo[content] Start phrase template. [content] End phrase template.]
162
163 Pre [block_foo [block_foo Hello!]] Post
164
165 Pre [block_foo [phrase_foo Hello!]] Post
166
167 Pre [phrase_foo [block_foo Hello!]] Post
168
169 Pre [phrase_foo [phrase_foo Hello!]] Post
170
171 [endsect]
172
173 [/----------------------------------- Block Markup ]
174
175 [section Block Markup]
176
177 [template list
178 * a
179 * b]
180
181 [template horizontal
182 ----]
183
184 [template codeblock
185     int main() {}]
186
187 [template paragraphs
188 Paragraphs 1
189
190 Paragraphs 2
191 ]
192
193 [list][horizontal][codeblock][paragraphs]
194
195 * [list]
196 * [horizontal]
197 * [codeblock]
198 * [paragraphs]
199
200 [endsect]
201
202 [/----------------------------------- 1.5+ use static scoping ]
203
204 [section Static Scoping]
205
206 [template x static scoping]
207 [template static_test1[] [x]]
208 [template static_test2[x] [static_test1]]
209 [static_test2 dynamic scoping]
210
211 [/ This should be '[a]' because [a] isn't matched. ]
212 [template test1[] [a]]
213 [template test2[a] [test1]]
214 [test2 1]
215
216 [/ In 1.5 template arguments are scoped at the point they are defined]
217
218 [template y new]
219 [template static_test3[a y] [a]]
220 [static_test3 [y] old]
221
222 [/ From https://svn.boost.org/trac/boost/ticket/2034 ]
223
224 [template same[x] [x]]
225 [template echo[a b] [a] [b]]
226 [template echo_twice[x] [echo [same [x]]..[same [x]]]]
227 [echo_twice foo]
228
229 [endsect]
230
231 [/----------------------------------- 1.5+ template arguments ]
232
233 [section Template Arguments]
234
235 [template binary[x y] {[x]-[y]}]
236 [binary 1..2]     [/ {1-2} ]
237 [binary 1 2]      [/ {1-2} ]
238 [binary 1..2 3 4] [/ {1-2 3 4} ]
239 [binary 1 2..3 4] [/ {1 2-3 4} ]
240 [binary 1 2 3..4] [/ {1 2 3-4} ]
241 [binary 1.\.2..3] [/ {1..2-3} ]
242 [binary 1.\.2 3]  [/ {1..2-3} ]
243
244 [binary [binary 1 2..3]..4] [/ { {1 2-3}-4} ]
245 [binary [binary 1 2..3] 4] [/ { {1 2-3}-4} ]
246 [binary [binary 1 2 3]..4] [/ { {1-2 3}-4} ]
247
248 [binary \[1 2\] 3] [/ {[1-2] 3} ]
249 [binary \[1..2\] 3] [/ {[1-2] 3} ]
250 [binary \[1 2] [/ {(1-2} ]
251
252 [template ternary[x y z] {[x]-[y]-[z]}]
253 [ternary 1..2..3]  [/ {1-2-3} ]
254 [ternary 1 2 3]    [/ {1-2-3} ]
255
256 [endsect]
257
258 [/----------------------------------- Block and phrases ]
259
260 [section Block and phrase templates]
261
262 [template phrase_template[] Some *text*]
263 [template block_template[]
264
265 A <emphasis>paragraph</emphasis>.
266 ]
267
268 [phrase_template]
269 [block_template]
270 [`phrase_template]
271 [`block_template]
272
273 [/ Trailing newline shouldn't be included]
274
275 [template named_index[type title]
276 '''<index type="'''[type]'''"><title>'''[title]'''</title></index>'''
277 ]
278
279 [named_index things Things]
280
281 [endsect]
282
283 [/-------------------------------- Skipping template body ]
284
285 [section:template_body Skipping the template body correctly]
286
287 [template args1[x] [`x]]
288 [template args2[]
289 [ordered_list [``code``]]
290 ]
291 [/ Due to a bug in the template parser need to stop the parser
292    thinking that the code is an escaped template. ]
293 [template args3[]
294 [ordered_list [\ `code`]]
295 ]
296
297 [args1 <emphasis>Argument</emphasis>]
298 [args2]
299 [args3]
300
301 [endsect]
302
303 [/----------------------------------- Escaped templates ]
304
305 [section Escaped templates]
306
307 [template raw_markup <thingbob>Not real boostbook</thingbob>]
308 [template escaped1 [x] [`x]]
309
310 [`raw_markup]
311 [escaped1 <thingbob>More fake boostbook</thingbob>]
312
313 [endsect]