Skip to content

Commit 5a6d944

Browse files
PeterTurcanalandefreitas
authored andcommitted
added all templates
1 parent f75b3ef commit 5a6d944

14 files changed

Lines changed: 819 additions & 37 deletions
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
* New content
2-
xref:intro.adoc[Introduction to becoming a Boost Contributor]
1+
* New Content
2+
* xref:intro.adoc[Introduction to becoming a Boost Contributor]
3+
* Legacy Content
4+
** xref:documentation-structure.adoc[Writing Documentation for Boost - Documentation Structure]
5+
** xref:index-file-template.adoc[Index File Template]
6+
** Templates
7+
*** xref:templates/acknowledgements-template.adoc[Acknowledgments Template]
8+
*** xref:templates/bibliography-template.adoc[Bibliography Template]
9+
*** xref:templates/configuration-template.adoc[Configuration Template]
10+
*** xref:templates/definitions-template.adoc[Definitions Template]
11+
*** xref:templates/faq-template.adoc[FAQ Template]
12+
*** xref:templates/header-template.adoc[Header Template]
13+
*** xref:templates/overview-template.adoc[Overview Template]
14+
*** xref:templates/rationale-template.adoc[Rationale Template]
Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
= Writing Documentation for Boost - Documentation Structure
2+
3+
== [#introduction]#Introduction#
4+
5+
Boost does not require any specific documentation structure. However,
6+
there are some important considerations that influence content and
7+
structure. For example, many Boost libraries wind up being proposed for
8+
inclusion in the C++ Standard, so writing them initially with text
9+
suitable for inclusion in the Standard may be helpful. Also, Boost
10+
library documentation is often accessed via the World Wide Web,
11+
including via search engines, so context is often important for every
12+
page. Finally, Boost libraries should provide additional documentation,
13+
such as introductory, tutorial, example, and rationale content. With
14+
those things in mind, we suggest the following guidelines for Boost
15+
library documentation.
16+
17+
== [#standards-conforming]#Standards Conforming# Documentation
18+
19+
The documentation structure required for the C++ Standard is an
20+
effective way to describe the technical specifications for a library.
21+
Although terse, that format is familiar to many Boost users and is far
22+
more precise than most ad hoc formats. The following description is
23+
based upon §17.3 of the Standard. (Note that while final Standard
24+
proposals must include full standardese wording, which the committee
25+
will not do for you, that level of detail is not expected of Boost
26+
library documentation.)
27+
28+
=== [#elements]#Document elements#
29+
30+
[#footnote1-location]
31+
Each document contains the following elements, as
32+
applicable. link:#footnote1[(1)]:
33+
34+
* link:#summary[Summary]
35+
* link:#requirements[Requirements]
36+
* link:#detailed-specs[Detailed specifications]
37+
* link:#ref-cpp[References to the Standard C++ library]
38+
* link:#ref-c[References to the Standard C library]
39+
40+
==== [#summary]#Summary#
41+
42+
The Summary provides a synopsis of the category, and introduces the
43+
first-level subclauses. Each subclause also provides a summary, listing
44+
the headers specified in the subclause and the library entities provided
45+
in each header.
46+
47+
Paragraphs labeled "Note(s):" or "Example(s):" are informative, other
48+
paragraphs are normative.
49+
50+
The summary and the detailed specifications are presented in the order:
51+
52+
* Macros
53+
* Values
54+
* Types
55+
* Classes
56+
* Functions
57+
* Objects
58+
59+
==== [#requirements]#Requirements#
60+
61+
The library can be extended by a C++ program. Each clause, as
62+
applicable, describes the requirements that such extensions must meet.
63+
Such extensions are generally one of the following:
64+
65+
* Template arguments
66+
* Derived classes
67+
* Containers, iterators, and/or algorithms that meet an interface
68+
convention
69+
70+
Interface convention requirements are stated as generally as possible.
71+
Instead of stating "`class X` has to define a member function
72+
`operator++()`," the interface requires "for any object `x` of
73+
`class X`, `++x` is defined." That is, whether the operator is a member
74+
is unspecified.
75+
76+
Requirements are stated in terms of well-defined expressions, which
77+
define valid terms of the types that satisfy the requirements. For every
78+
set of requirements there is a table that specifies an initial set of
79+
the valid expressions and their semantics. Any generic algorithm that
80+
uses the requirements is described in terms of the valid expressions for
81+
its formal type parameters.
82+
83+
Template argument requirements are sometimes referenced by name.
84+
85+
[#footnote2-location]
86+
In some cases the semantic requirements are presented as C++ code. Such
87+
code is intended as a specification of equivalence of a construct to
88+
another construct, not necessarily as the way the construct must be
89+
implemented.link:#footnote2[(2)]
90+
91+
==== [#detailed-specs]#Detailed specification#
92+
93+
The detailed specifications each contain the following elements:
94+
95+
* Name and brief description
96+
* Synopsis (class definition or function prototype, as appropriate)
97+
* Restrictions on template arguments, if any
98+
* Description of class invariants
99+
* Description of function semantics
100+
101+
[#footnote3-location]
102+
Descriptions of class member functions follow the order (as
103+
appropriate) link:#footnote3[(3)]:
104+
105+
* Constructor(s) and destructor
106+
* Copying and assignment functions
107+
* Comparison functions
108+
* Modifier functions
109+
* Observer functions
110+
* Operators and other non-member functions
111+
112+
[#footnote4-location]
113+
Descriptions of function semantics contain the following
114+
elements (as appropriate) link:#footnote4[(4):]
115+
116+
*link:#requires[Requires:]* the preconditions for calling the function
117+
118+
*link:#effects[Effects:]* the actions performed by the function
119+
120+
*link:#postconditions[Postconditions:]* the observable results
121+
established by the function
122+
123+
*link:#returns[Returns:]* a description of the value(s) returned by the
124+
function
125+
126+
*link:#throws[Throws:]* any exceptions thrown by the function, and the
127+
conditions that would cause the exception
128+
129+
*link:#complexity[Complexity:]* the time and/or space complexity of the
130+
function
131+
132+
*link:#rationale[Rationale:]* the rationale for the function's design or
133+
existence
134+
135+
Complexity requirements specified in the library clauses are upper
136+
bounds, and implementations that provide better complexity guarantees
137+
satisfy the requirements.
138+
139+
==== [#ref-cpp]#References to the C++ Standard library#
140+
141+
==== [#ref-c]#References to the C Standard library#
142+
143+
=== [#other]#Other conventions#
144+
145+
These conventions are for describing implementation-defined types, and
146+
member functions.
147+
148+
==== [#type-descs]#Type descriptions#
149+
150+
The Requirements subclauses may describe names that are used to specify
151+
constraints on template arguments.
152+
153+
== [#more]#More Information#
154+
155+
=== [#function-semantic-explanations]#Function semantic element explanations#
156+
157+
The function semantic element description above is taken directly from the C++ standard, and is quite terse. Here is a
158+
more detailed explanation of each of the elements.
159+
160+
Note the use of the `<code> ... </code>` font tag to distinguish actual
161+
C++ usage from English prose.
162+
163+
==== [#requires]#Requires#
164+
165+
Preconditions for calling the function, typically expressed as
166+
predicates. The most common preconditions are requirements on the value
167+
of arguments, often in the form of C++ expressions. For example,
168+
169+
....
170+
171+
void limit( int * p, int min, int max );
172+
....
173+
174+
*Requires:* `p != 0 && min <= max`
175+
176+
Requirements already enforced by the C++ language rules (such as the
177+
type of arguments) are not repeated in Requires paragraphs.
178+
179+
==== [#effects]#Effects#
180+
181+
The actions performed by the function, described either in prose or in
182+
C++. A description in prose is often less limiting on implementors, but
183+
is often less precise than C++ code.
184+
185+
If an effect is specified in one of the other elements, particularly
186+
_postconditions_, _returns_, or _throws_, it is not also described in
187+
the _effects_ paragraph. Having only a single description ensures that
188+
there is one and only one specification, and thus eliminates the risk of
189+
divergence.
190+
191+
==== [#postconditions]#Postconditions#
192+
193+
The observable results of the function, such as the value of variables.
194+
Postconditions are often expressed as predicates that are true after the
195+
function completes, in the form of C++ expressions. For example:
196+
197+
....
198+
199+
void make_zero_if_negative( int & x );
200+
....
201+
202+
*Postcondition:* `x >= 0`
203+
204+
==== [#returns]#Returns#
205+
206+
The value returned by the function, usually in the form of a C++
207+
expression. For example:
208+
209+
....
210+
int sum( int x, int y );
211+
....
212+
213+
*Returns:* `x + y`
214+
215+
Only specify the return value; the type is already dictated by C++
216+
language rules.
217+
218+
==== [#throws]#Throws#
219+
220+
Specify both the type of exception thrown, and the condition that causes
221+
the exception to be thrown. For example, the `std::basic_string` class
222+
specifies:
223+
224+
....
225+
226+
void resize(size_type n, charT c);
227+
....
228+
229+
*Throws:* `length_error` if `n > max_size()`.
230+
231+
==== [#complexity]#Complexity#
232+
233+
Specifying the time and/or space complexity of a function is often not
234+
desirable because it over-constrains implementors and is hard to specify
235+
correctly. Complexity is thus often best left as a quality of
236+
implementation issue.
237+
238+
A library component, however, can become effectively non-portable if
239+
there is wide variation in performance between conforming
240+
implementations. Containers are a prime example. In these cases it
241+
becomes worthwhile to specify complexity.
242+
243+
Complexity is often specified in generalized
244+
https://web.mit.edu/16.070/www/lecture/big_o.pdf["Big-O" notation].
245+
246+
==== [#rationale]#Rationale#
247+
248+
Specifying the rationale for a function's design or existence can often
249+
give users a lot of insight into why a library is designed the way it
250+
is. More importantly, it can help prevent "fixing" something that wasn't
251+
really broken as the library matures.
252+
253+
[[web]]
254+
== Web Reference Documentation
255+
256+
Boost library documentation is often accessed via the World Web. Using
257+
search engines, a page deep in the reference content could be viewed
258+
without any further context. Therefore, it is helpful to add extra
259+
context, such as the following, to each page:
260+
261+
* Describe the enclosing namespace or use fully scoped identifiers.
262+
* Document required headers for each type or function.
263+
* Link to relevant tutorial information.
264+
* Link to related example code.
265+
* Include the library name.
266+
* Include navigation elements to the beginning of the documentation.
267+
268+
It is also useful to consider the effectiveness of a description in
269+
search engines. Terse or cryptic descriptions are less likely to help
270+
the curious find a relevant function or type.
271+
272+
== [#footnotes]#Footnotes#
273+
274+
[#footnote1]
275+
link:#footnote1-location[(1)] To save space, items that do not apply to
276+
a clause are omitted. For example, if a clause does not specify any
277+
requirements, there will be no "Requirements" subclause.
278+
279+
[#footnote2]
280+
link:#footnote2-location[(2)] Although in some cases the code is
281+
unambiguously the optimum implementation.
282+
283+
[#footnote3]
284+
link:#footnote3-location[(3)] To save space, items that do not apply to
285+
a class are omitted. For example, if a class does not specify any
286+
comparison functions, there will be no "Comparison functions" subclause.
287+
288+
[#footnote4]
289+
link:#footnote4-location[(4)] To save space, items that do not apply to
290+
a function are omitted. For example, if a function does not specify any
291+
precondition, there will be no "Requires" paragraph.
292+
293+
'''''
294+
295+
Revised 04 December, 2006
296+
297+
_Copyright © 2001 mailto:williamkempf@hotmail.com[William E. Kempf]_
298+
299+
_Distributed under the Boost Software License, Version 1.0. (See
300+
http://www.boost.org/LICENSE_1_0.txt)_.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
= \{\{Library}} Index File Template
2+
3+
== Contents
4+
5+
xref:templates/overview-template.adoc[Overview]
6+
7+
=== Reference
8+
9+
xref:templates/header-template.adoc[\{\{header}}]
10+
11+
xref:templates/configuration-template.adoc[Configuration Information]
12+
13+
xref:templates/rationale-template.adoc[Rationale]
14+
15+
xref:templates/definitions-template.adoc[Definitions]
16+
17+
xref:templates/faq-template.adoc[Frequently Asked Questions (FAQs)]
18+
19+
xref:templates/bibliography-template.adoc[Bibliography]
20+
21+
xref:templates/acknowledgements-template.adoc[Acknowledgements]
22+
23+
'''''
24+
25+
Revised 04 December, 2006
26+
27+
_Copyright © 2006 mailto:%7B%7Baddress%7D%7D[\{\{author}}]_
28+
29+
_Distributed under the Boost Software License, Version 1.0. (See
30+
http://www.boost.org/LICENSE_1_0.txt)_.
31+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
= Acknowledgements Template
2+
3+
== \{\{Library}}
4+
5+
=== Acknowledgments
6+
7+
'''''
8+
9+
\{\{text}}
10+
11+
'''''
12+
Revised 04 December, 2006
13+
14+
_Copyright © 2006 mailto:%7B%7Baddress%7D%7D[\{\{author}}]_
15+
16+
_Distributed under the Boost Software License, Version 1.0. (See
17+
http://www.boost.org/LICENSE_1_0.txt)_.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
= Bibliography Template
2+
3+
== \{\{Library}}
4+
5+
=== Bibliography
6+
7+
'''''
8+
9+
\{\{bibliographical information}}
10+
11+
'''''
12+
Revised 04 December, 2006
13+
14+
_Copyright © 2006 mailto:%7B%7Baddress%7D%7D[\{\{author}}]_
15+
16+
_Distributed under the Boost Software License, Version 1.0. (See
17+
http://www.boost.org/LICENSE_1_0.txt)_.

0 commit comments

Comments
 (0)