2 Copyright 2002,2004,2006 Joel de Guzman, Eric Niebler
3 Copyright 2010-2011 Daniel James
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])
10 [chapter Document Structure
12 [id quickbook.syntax.structure]
13 [source-mode teletype]
16 [/TODO: I started to write this in the syntax chapter, but it was too
17 much information, will incorporate into this file.]
19 To avoid breaking old documentation we support using different versions
20 of the language, compatibility is not 100% but we try to avoid
21 problematic changes. This documentation applies to the current version,
24 There is also some mention of the next version `[quickbook 1.6]`. While
25 quickbook allows you to use it now, it isn't recommended as it is
26 currently a work in progress and subject to change.
29 [#quickbook.ref.docinfo]
30 [section:docinfo Document Info]
32 Every document must begin with a Document Info section, which looks something
36 [article The Document Title
39 [id the_document_name]
40 [copyright 2000 2002 2003 Joe Blow, Jane Doe]
41 [authors [Blow, Joe] [Doe, Jane]]
42 [license The document's license]
47 `article` is the document type. There are several possible document types,
48 most of these are based on docbook document elements. These are fully
50 [@http://www.docbook.org/tdg/ DocBook: The Definitive Guide]:
52 * [@http://www.docbook.org/tdg/en/html/book.html book]
53 * [@http://www.docbook.org/tdg/en/html/article.html article]
54 * [@http://www.docbook.org/tdg/en/html/chapter.html chapter]
55 * [@http://www.docbook.org/tdg/en/html/part.html part]
56 * [@http://www.docbook.org/tdg/en/html/appendix.html appendix]
57 * [@http://www.docbook.org/tdg/en/html/preface.html preface]
58 * [@http://www.docbook.org/tdg/en/html/qandadiv.html qandadiv]
59 * [@http://www.docbook.org/tdg/en/html/qandaset.html qandaset]
60 * [@http://www.docbook.org/tdg/en/html/reference.html reference]
61 * [@http://www.docbook.org/tdg/en/html/set.html set]
63 Boostbook also adds another document type [^[link boostbook.defining library]]
64 for documenting software libraries.
66 So the documentation for the 'foo' library might start:
76 [#quickbook.ref.attributes]
77 [section:attributes Document Info Attributes]
79 The document info block has a few different types of attributes.
80 They are all optional.
82 [heading Quickbook specific meta data]
88 The `quickbook` attribute declares the version of quickbook
89 the document is written for.
90 In its absence, version 1.1 is assumed. It's recommended that
91 you use `[quickbook 1.6]` which is the version described here.
95 The quickbook version also makes some changes to the markup
96 that's generated. Most notably, the ids that are automatically
97 for headers and sections are different in later versions. To
98 minimise disruption, you can use the =compatibility-mode=
99 attribute to generate similar markup to the old version:
102 [article Article that was original
103 written in quickbook 1.3
105 [compatibility-mode 1.3]
109 This feature shouldn't be used for new documents, just for
110 porting old documents to the new version.
113 Both the =quickbook= and =compatibility-mode= tags can be used
114 at the start of the file, before the document info block, and
115 also in files that don't have a document info block.
118 [source-mode teletype]
121 The `source-mode` attribute sets the initial __source_mode__. If
122 it is omitted, the default value of =c++= will be used.
124 [heading Boostbook/Docbook root element attributes]
130 `id` specifies the id of the document element. If it isn't specified
131 the id is automatically generated from the title. This id is also
132 used to generate the nested ids.
138 `lang` specifies the document language. This is used by docbook to
139 localize the documentation. Note that Boostbook doesn't have any
140 localization support so if you use it to generate the reference
141 documentation it will be in English regardless.
143 It should be a language code
144 drawn from ISO 639 (perhaps extended with a country code drawn from
151 `dirname` is used to specify the directory name of the library in the
152 repository. This is a boostbook extension so it's only valid for
153 `library` documentation blocks. It's used for some boostbook
154 functionality, but for pure quickbook documentation has no practical
157 [heading Docbook Metadata]
159 =version=, =copyright=, =authors=,
160 =license=, =last-revision= and =bibliod= are optional information.
162 [heading Boostbook Metadata]
164 =purpose= and =category= are boostbook attributes which are only
165 valid for =library= documents. If you use them for other document types,
166 quickbook will warn about them, but still use them, generating invalid markup,
167 that's just ignored by the style sheets.
169 [endsect] [/attributes]
171 [section:nesting Nesting quickbook documents]
173 Docinfo blocks can only appear at the beginning of a quickbook file, so to
174 create a more complicated document you need to use several quickbook files and
175 use the [link quickbook.ref.include include tag] to nest them. For example, say
176 you wish to create a book with an introduction and a chapter, you first create
183 [include introduction.qbk]
184 [include chapter.qbk]
186 [note Structuring a document like this was introduced in quickbook 1.6, so the
187 `[quickbook 1.6]` docinfo field is required.]
189 The appropriate document type for an introduction is `preface`, so
190 the contents of `introduction.qbk` should be something like:
192 [preface Introduction
196 Write the introduction to the book here....
210 [#quickbook.ref.section]
211 [section:section Sections]
213 Quickbook documents are structured using 'sections'. These are used
214 to generate the table of contents, and, when generating html, to
215 split the document into pages. This is optional but a good idea for
216 all but the simplest of documents.
218 A sectioned document might look like:
225 [section First Section]
231 [section Second Section]
238 Sections start with the `section` tag, and end with the `[endsect]` tag.
239 (`[/...]` is a comment, [link quickbook.ref.comments described later]).
241 Sections can be given an optional id:
245 [section:id The Section Title]
248 `id` will be the filename of the generated section.
249 If it is not present, "The Section Title" will be normalized and become the id.
250 Valid characters are =a-Z=, =A-Z=, =0-9= and =_=. All non-valid characters are
251 converted to underscore and all upper-case are converted to lower case.
252 Thus: "The Section Title" will be normalized to "the_section_title".
254 Sections can nest, and that results in a hierarchy in the table of contents.