]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/quickbook/doc/1_6.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / tools / quickbook / doc / 1_6.qbk
CommitLineData
7c673cae
FG
1[/
2 Copyright 2002,2004,2006 Joel de Guzman, Eric Niebler
3 Copyright 2010-2013 Daniel James
4
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8]
9
10[section:1_6 Quickbook 1.6]
11
12Upgrading a document from an earlier version of quickbook shouldn't be too
13hard. The first thing to do is update the version in the docinfo block.
14For example, if you were updating the Xpressive documentation, the existing
15docinfo block looks like:
16
17 [library Boost.Xpressive
18 [quickbook 1.3]
19 ...
20 ]
21
22Change this to:
23
24 [library Boost.Xpressive
25 [quickbook 1.6]
26 [compatibility-mode 1.3]
27 ...
28 ]
29
30The =compatibility-mode= tag ensures that automatically generated links
31won't change. It might turn out that it isn't required, but in Xpressive's
32case if it isn't included it will break a lot of links.
33
34Then try building it. You might need to fix some stray square brackets. The
35new version has a stricter parser which will have an error for brackets
36which don't pair up. They might be there by mistake, in which case they
37should probably be deleted, or if they're intentional escaped. For example,
38to write out the half-open range \[a,b), use: `\[a,b)`.
39
40Next, you might need to reconsider how templates and macros are defined.
41If you `include` a file to use its templates, you'll now need to `import` it
42instead as templates are now scoped by included files. Also, if you define
43templates and macros in your main quickbook file, you might want to put them
44into a separate file and `import` that, which allows the main documentation
45files to concentrate on the structure and contents of the document, making them
46easier to read.
47
48Now that headings can have ids, it can be a good idea to add ids to existing
49headings. This means that the headings will have more predictable ids which
50don't change when the text of the heading changes. In order to preserve
51links you can use the existing generated id as the heading.
52
53[section:docinfo Includes with docinfo]
54
55In quickbook 1.5 if you include a file which starts with a docinfo block, it's
56ignored and the file is expanded in place. In quickbook 1.6 it's treated as a
57document nested in the current position. So if it has an 'article' docinfo block,
58boostbook 'article' tags are used.
59
60It also mostly generates the same markup as if the file was converted separately -
61so for example, the same ids are generated, the document is processed using the
62language version specified in the docinfo block. If no language is specified it
63uses the default (1.1) not the version of the document that included it. This
64might seem surprising, but is requried so that quickbook will convert it the same
65way as if it was converted separately.
66
67So for the most part, includes with a docinfo are like an `xinclude`, apart from
68a couple of differences. Templates and macros defined in the parent document are
69used in the included document, and the id generator rewrites ids that clash
70between multiple documents.
71
72If an included document doesn't have a docinfo block, it's just included as
73before.
74
75[endsect] [/docinfo]
76
77[section:doc_info_macros Macros in docinfo block]
78
79You can now expand macros in text fields in the docinfo block. In the top
80docinfo block only the predefined macros are available, but in nested documents
81macros defined in the parent document are also available.
82
83There's a small bug here - this leaks into older versions for the `license`
84and `purpose` fields, but since only the predefined macros are available, it's
85unlikely to break any existing documents. So I'd rather not complicate the code
86further by fixing that.
87
88[endsect]
89
90[section:scope Scoping templates and macros]
91
92A long standing quickbook bug is that macros are scoped by file, but templates
93aren't. So you can define templates in a separate file and include them, but not
94macros. This has been fixed so that templates defined in one file won't 'leak'
95into another.
96
97But this means there's no way to define templates in a separate file - a useful
98feature. To do this the `import` element has been adapted to also support
99quickbook files. If a quickbook file is imported, the templates and macros
100defined in it are added to the current scope, but nothing else contained in that
101file is used. This could be used to create template and macro library files.
102This matches the existing semantics of importing code snippets.
103
104When importing templates, they're bound to the language version of the file
105they were defined in. This means that if you import them into a file with
106a different version it won't change the way they're interpreted. Although,
107as we'll see [link compatibility later], the generated boostbook is slightly
108different.
109
110[endsect] [/scope]
111
112[section:include Including C++ and python files]
113
114As `import` now supports quickbook files, `include` also supports source files.
115It includes any quickbook contained in comments outside of code snippets.
116Code snippets in the file are available to be expanded within the file but
117are scoped to the file. In exactly the same manner as when templates and macros
118are scoped in an included quickbook file.
119
120[endsect] [/include]
121
122[section:ids Id Generation]
123
124Id generation in quickbook 1.5 is a bit buggy, but that can't be fixed without a
125version switch as it will break existing documents. For example in quickbook 1.5
126when you include a quickbook file, it stops using the explicit id from the
127documentation info and generates a new id from the document title to use instead.
128
129The id generator in quickbook 1.6 has been improved in some other ways to. When
130generating ids from section titles, table titles etc. it always uses the
131quickbook source rather than the generated boostbook to generate the id. It then
132cleans up the id slightly, trimming leading and trailing underscores and replacing
133multiple underscores with a single underscore. Then if the newly generated part
134of the id is longer than 32 characters it truncates it.
135
136While the new id generator generally creates better ids, it's more likely to
137generate duplicates so quickbook needs to handle duplicates better. When there
138are multiple identical ids, quickbook chooses one to use based on a priority
139list - anchors are preferred, then explicit document and section ids, then other
140explicit ids, followed by the generated ids. Then any other explicit ids in the
141document have numbers added to avoid duplicates - first the explicit ids in the
142order they appear and then the generated ids. A generated id which accidentally
143clashes with an explicit id should never change the explicit id.
144
145Older language versions still generate the same ids they always have, with the
146exception of duplicate ids which are handled using the new mechanism - this
147is not a breaking change since duplicate ids can't be linked to.
148
149[endsect] [/ids]
150
151[#compatibility]
152[section:compatibility Compatibility Mode]
153
154As mentioned before, changing the id generator will break links in documents
155written using an old language version. So to ease the transition a
156'compatibility mode' is used, this just requires an extra attribute in the
157docinfo, for example if you're converting a 1.5 document to 1.6:
158
159 [article Document
160 [quickbook 1.6]
161 [compatibility-mode 1.5]
162 ]
163
164This means the document will be parsed as 1.6, using all the new features, but
165ids (and possibly other markup) will generated as they were for a 1.5 document.
166
167Compatibility mode is also implicitly used when generating templates written
168in a different language version to the current document. So the template is
169parsed in the version it was written for, but generates boostbook that's
170compatible with the current document.
171
172[endsect] [/compatibility]
173
174[section:version Version info outside of document info block]
175
176Can now use `quickbook` and `compatibility-mode` tags at the beginning of the
177file. Either before or without a document info block. This is useful for
178files just containing templates, which don't really need a document info
179block.
180
181If you don't specify `compatibility-mode`, the behaviour depends on whether or
182not you have a docinfo block. If you do it uses the file's quickbook version,
183if you don't it inherits the parent's compatibility mode even if you specify
184a quickbook version. This is the right thing to do - mixing compatibility modes
185within documents is problematic. It might actually be a mistake to allow them
186to specified outside docinfo blocks.
187
188This change is also backdated to older versions. So when including from an
189older version, the included file's version can be set (older versions
190ignore document info in included files).
191
192[endsect]
193
194[section:heading_ids Explicit Heading Ids]
195
196Headings can now be given explicit ids:
197
198 [heading:id A heading with an explicit id]
199
200[endsect] [/heading_ids]
201
202[section:escapes Punctuation changes]
203
204In 1.6, quickbook is more consistent about how it parses punctuation.
205Escapes are now supported in links, anchors, table titles, image
206attributes etc. The flip side of this is that quickbook is now stricter
207about unescaped brackets. They can still be used, but need to match up,
208otherwise there's an error.
209
210Since quickbook now matches up square brackets it will fix some
211mis-parses. For example `[*[bold]]` used to parse as [*\[bold]\] - note
212that the closing square bracket isn't bold, now it parses as
213[*\[bold\]]. In this case it's just a subtle visual difference, but it
214could cause odd problems, for example when nested in a table cell.
215
216[endsect] [/escapes]
217
218[section:table Table Titles]
219
220Table titles are now parsed as phrases, so some markup is allowd:
221
222 [table [*bold title]]
223
224Which is an empty table with a bold title. The title is no longer ended
225by a newline, but by either a closing square bracket, or two opening
226square brackets - which you get at the start of the table cells, so
227this now works:
228
229 [table Simple[[heading 1][heading 2]][[cell 1][cell 2]]]
230
231[endsect] [/table]
232
233[section:xmlbase XML base]
234
235A problem when using `xi:include` tags in escaped boostbook is that you
236typically don't know which directory the boostbook file will be in, so
237it's impossible to use relative links. This can be fixed by adding an
238`xml:base` attribute to the document tag. To do this use the new
239`xmlbase` attribute in your document's docinfo block. For example to
240make escaped `xi:include`s be relative to the directory of the file:
241
242 [library Library documentation
243 [quickbook 1.6]
244 [xmlbase .]
245 ]
246
247Any paths in `xinclude` elements will be rewritten accordingly. Note that
248most documents won't need this, and probably shouldn't use it. Only use it
249if you're totally sure that you will need it.
250
251[endsect] [/xmlbase]
252
253[section:template_parser Improved template parser]
254
255There's a new parser for template declarations and parameters which does
256a better job of understanding escaped and bracketed text. Unfortunately
257it does not understand element names so there are some cases where it
258could go wrong. For example:
259
260 [template doesnt_work[]
261 [ordered_list
262 [`code phrase`]
263 ]
264 ]
265
266In this case it will think the `[\`` is a template call and give a parse
267error. To work around this put an escaped space before the code phrase:
268
269 [template works[]
270 [ordered_list
271 [\ `code phrase`]
272 ]
273 ]
274
275[endsect]
276
277[section:elements New Elements]
278
279New elements added in quickbook 1.6:
280
281* [link quickbook.ref.block `block`]
282* [link quickbook.ref.list_tags `ordered_list` and `itemized_list`]
283* [link quickbook.ref.role `role`]
284
285[endsect] [/ elements]
286
287[endsect] [/ Quickbok 1.6]