From 3fd363b1ee8e14a8f0ea3e219f4bcd6a311672a5 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 01/94] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r33417] From 1ee700353e64628aa70fcad06a8e78f451489f6c Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Thu, 20 Jul 2006 14:06:13 +0000 Subject: [PATCH 02/94] manual merge from trunk: fixed typos reported in http://bugs.debian.org/378016 [SVN r34637] --- doc/quickbook.qbk | 2 +- doc/quickbook.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 4b52b44..82d007e 100755 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -297,7 +297,7 @@ syntax highlighted. [blurb __note__ Note that we simply enclose the code with the tick: [^'''"`"'''], not the -single quote: `"'"`. Note too that [^'''`some code`'''] is prefered over +single quote: `"'"`. Note too that [^'''`some code`'''] is preferred over [^'''[^some code]''']. ] diff --git a/doc/quickbook.xml b/doc/quickbook.xml index cbdd011..c280993 100755 --- a/doc/quickbook.xml +++ b/doc/quickbook.xml @@ -399,7 +399,7 @@ the true business precept.] Note that we simply enclose the code with the tick: "`", not the single quote: "'". Note too that `some - code` is prefered over [^some code]. + code` is preferred over [^some code]. From c3137cbd75147f2de623c9eec5d20722faa7eba9 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Thu, 20 Jul 2006 14:09:10 +0000 Subject: [PATCH 03/94] manual merge from trunk: fixed typos reported in http://bugs.debian.org/378016 (NOTE: the html code is quite in bad shape, but I'm not sure whether it is automatically generated; it that case fixing the typo here is probably useless but doesn't hurt either) [SVN r34638] --- doc/html/quickbook/syntax/phrase.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/html/quickbook/syntax/phrase.html b/doc/html/quickbook/syntax/phrase.html index cba438a..1ac502a 100644 --- a/doc/html/quickbook/syntax/phrase.html +++ b/doc/html/quickbook/syntax/phrase.html @@ -300,7 +300,7 @@ This*Isn't*Bold (no bold) , not the single quote: "'". Note too that `some code` - is prefered over + is preferred over [^some code] . From a8b36d9411a4031968ea61ced2e3df3c877dd92d Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Thu, 20 Jul 2006 14:13:43 +0000 Subject: [PATCH 04/94] manual merge from trunk: fixed typos reported in http://bugs.debian.org/378016 [SVN r34639] --- test/quickbook-manual.gold | 2 +- test/quickbook-manual.quickbook | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold index 5bb8e9c..33aa108 100644 --- a/test/quickbook-manual.gold +++ b/test/quickbook-manual.gold @@ -444,7 +444,7 @@ the true business precept.] , not the single quote: "'". Note too that `some code` - is prefered over + is preferred over [^some code] . diff --git a/test/quickbook-manual.quickbook b/test/quickbook-manual.quickbook index 4b52b44..82d007e 100644 --- a/test/quickbook-manual.quickbook +++ b/test/quickbook-manual.quickbook @@ -297,7 +297,7 @@ syntax highlighted. [blurb __note__ Note that we simply enclose the code with the tick: [^'''"`"'''], not the -single quote: `"'"`. Note too that [^'''`some code`'''] is prefered over +single quote: `"'"`. Note too that [^'''`some code`'''] is preferred over [^'''[^some code]''']. ] From e6cf85eaa090cf9d0307e119d1c68661b634210c Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 27 Aug 2006 05:28:49 +0000 Subject: [PATCH 05/94] One of the examples linked to the old quickbook grammar reference - which has been removed, so change it to link to something that exists. [SVN r34968] --- doc/quickbook.qbk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 82d007e..c5228ef 100755 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -793,18 +793,18 @@ syntax highlighted according to the current __source_mode__: Macros that are already defined are expanded in source code. Example: [pre''' -[def __syntax_highlight__ [@quickbook/highlight.html syntax_highlight]] -[def __quickbook__ [@index.html quickbook]] +[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] +[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] - using __quickbook__::__syntax_highlight__; + using __boost__::__array__; '''] Generates: -[def __syntax_highlight__ [@quickbook/highlight.html syntax_highlight]] -[def __quickbook__ [@index.html quickbook]] +[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] +[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] - using __quickbook__::__syntax_highlight__; + using __boost__::__array__; [endsect] [section:escape_back Escaping Back To QuickBook] From ceff940e1579a286fbbf277f6e45e66691cb5048 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 27 Aug 2006 05:30:05 +0000 Subject: [PATCH 06/94] Add missing image files for quickbook documentation. [SVN r34969] --- doc/html/images/caution.png | Bin 0 -> 1249 bytes doc/html/images/important.png | Bin 0 -> 721 bytes doc/html/images/warning.png | Bin 0 -> 1240 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 doc/html/images/caution.png create mode 100644 doc/html/images/important.png create mode 100644 doc/html/images/warning.png diff --git a/doc/html/images/caution.png b/doc/html/images/caution.png new file mode 100644 index 0000000000000000000000000000000000000000..221af138769c3d1766ed40afccafea9d12abc4e7 GIT binary patch literal 1249 zcmeAS@N?&q;$mQ6;PUiv31VPikN{y0W(Ed^>nqQmVqjoq2=EDUWnf_7;9w9CV33et zP*h|vG-PmcVu*@jNKR(R&SoesW~i=aXlY?+X({gMVd&{8?&;~7GKFEvl;SBx0c6VXuV3qY?U|{&@>Eakt zajSIF?Y<@lo;K-^2i7HtoLP6uGkK?D!0m*jivR4Ji=ABGhAxkP{@$NGV?T?H{JAfZ z2?CeZ8y*_|US3|n*LUX$=T}Cy@M$OJN|jit7MDI$+gz@5z~j}+6YGDZao+eh`NW^5 z>6<2)S}u52cEGCPcuX9Z8>=;Y!t+%g?2o?M4G{L59Ymv_Ak^1jNwrA+f&UeJt#1?x+e+^=15MsSm4-_dt3`R9iv z$%rfpnN_vj<@o}>joZr}JDh)OJEbUK*T3n@m!?RUew{wQv8=zUn%(bpj`j3JEincL z2Imsjh?3y^w370~qErS44P{Nw+{E-$-^BFHnqQmVqjo+65tc!D!{-XARr(iA)%?M zX=!Qc0vrO9j8X0KgaeeWK_wQCah?kV28XL#?P<@4tp z@82`Le=qR=Kg0k39RL3dJb$kF{JG)#_lE!fD;_%*b?sWvxpT$Wt|ec)mi_*{)AQ%a z&!1Pfw6yf}^h}vDW$DtEwQGBpE}gP;>72cLTlVgqvvldwwQHBIUAuPc)~$Q@?mc$w z*tv7(u3fu!@7}%V&!4}4|Ni^;@Bjb*Uwi5BJq88_#w2fd7w7Z~TuBTJjN+ayjv*Dd zawl;IA2Q%MZtVKeaO%PXS5A802?!CHGPTo9eeTxZ|Lz}O*B|))+y2+Flj7wwg-&>H zbXv-;w#%(aL+q*9gZm$gB*cDwNZ!TR!=gX&;+EDJX1{xfGZt@{t)=kDsNnHV+g7WU zEML6derG6~D#~Whv|;ML{~Qa6MqSb3zM{Ri`S7w^Mu+1g%id`HKPa-~#nc>;vNd%*>D*D<#G?C) zCx2m$j6OUe(OQzz_UBvuZ~0zFW(X)QNo)AWFgH18eNgThP=awTag8Vm&QB{TPb^Ah zaL`cJ^vq36PxVbq&rHr%Fwry8vrw?K)HkruH!xI4F3Kz}sdUJ#EH24R)=MqcODQeL z&nwYO&d;5=OK}GS1A`XWxXkpt#FEmYREA{Z)Z}Etv}995W78DFR7+D!GfUG{Q!~pH aBST|DBcmd|%nu9<3=E#GelF{r5}E)QN=y0x literal 0 HcmV?d00001 diff --git a/doc/html/images/warning.png b/doc/html/images/warning.png new file mode 100644 index 0000000000000000000000000000000000000000..23bc02a4b28e0be91def15d2ab89fd8744789d6c GIT binary patch literal 1240 zcmeAS@N?&q;$mQ6;PUiv31VPikN{y0W(Ed^>nqQmVqjoq2=EDUguHo3`;F7 zmwI_EZE0CLWy;c}OV=_mtTi-TJ7vmN28OMgnp=B%w$7Qeb?MTrTet3IVA#8M?cS|h zk1;SD6A(BiA#v>3v2zRz=L7`KNl2X2)V#*Pa7|P5+O=!<7#Qx|yZ4-d;klyX^XJds zGcdg8;CTQ3{dWe2@87@wXJGh03PwYKN+D2S{dfuk0|R4{x4R2N2dk_H0|UbgPZ!6K zid(spYV(^61dhF*;(O=Wk(bMuP5H!IRrgF)&E>lPzj*DNs({IH{}CW;3+UFvb*i@I-I?gR9u{n7B*t=AguM-cZaxE-5@E}9(L*#Fnw>$_`T-}ks+ zllM|~rIOr~k12h5MQt-@+ihAJ>T>9>ci#Q%XzNS6?G0G-6!*_zE@WU}a4vC;C<)F_ zD=AMbN@Z}+P}cO!O-xVqO-#>B&Q>tdGt#qAu(Z@Su+TR!R7ft$EH0^Z$gM0c$xPNu zE!ImZEy&L+(M!(How!SJ2Ll6x7TCDV^t{B9(xOy`WD}z#^Aw{LQ!|sq#3WM-3kyp_ zOLI$e1LHIUqa+hkf5H2c85kJ&K)M1F(^DCYOe%~_v< Date: Sun, 27 Aug 2006 05:30:44 +0000 Subject: [PATCH 07/94] Regenerate quickbook documentation. [SVN r34970] --- doc/html/index.html | 8 +- doc/html/quickbook/change_log.html | 10 +- doc/html/quickbook/intro.html | 8 +- doc/html/quickbook/ref.html | 176 ++++++++++++------------ doc/html/quickbook/syntax.html | 4 +- doc/html/quickbook/syntax/block.html | 120 ++++++++-------- doc/html/quickbook/syntax/comments.html | 4 +- doc/html/quickbook/syntax/phrase.html | 150 ++++++++++---------- 8 files changed, 240 insertions(+), 240 deletions(-) diff --git a/doc/html/index.html b/doc/html/index.html index 4d6ebcb..59c84fb 100755 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -3,7 +3,7 @@ Quickbook 1.3 - + @@ -31,7 +31,7 @@
-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

@@ -54,8 +54,8 @@
- - +

Last revised: February 03, 2006 at 09:21:02 GMT

+

Last revised: August 27, 2006 at 05:24:19 GMT


diff --git a/doc/html/quickbook/change_log.html b/doc/html/quickbook/change_log.html index 18b9f8b..a1abad9 100644 --- a/doc/html/quickbook/change_log.html +++ b/doc/html/quickbook/change_log.html @@ -3,7 +3,7 @@ Change Log - + @@ -26,7 +26,7 @@

Change Log

- + Version 1.3

    @@ -65,7 +65,7 @@
  • Fully qualified section and headers. Subsection names are concatenated to - the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name + the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name
  • Better &nbsp; and whitespace handling in code snippets. @@ -90,11 +90,11 @@ Post-processor bug fix for escaped XML code that it does not recognize.
  • - Replaceable, with the [~ replacement] syntax. + Replaceable, with the [~replacement] syntax.
- +
Copyright © 2002, 2004 Joel de Guzman, Eric Niebler
diff --git a/doc/html/quickbook/intro.html b/doc/html/quickbook/intro.html index 0ffcdd0..0f2297d 100644 --- a/doc/html/quickbook/intro.html +++ b/doc/html/quickbook/intro.html @@ -3,7 +3,7 @@ Introduction - + @@ -26,8 +26,8 @@

Introduction

- Why program by hand in five days what - you can spend five years of your life automating?
+ Why program by hand in five days what + you can spend five years of your life automating?

-- Terrence Parr, author ANTLR/PCCTS

@@ -81,7 +81,7 @@ - +
Copyright © 2002, 2004 Joel de Guzman, Eric Niebler
diff --git a/doc/html/quickbook/ref.html b/doc/html/quickbook/ref.html index 9f49e22..1ddf783 100755 --- a/doc/html/quickbook/ref.html +++ b/doc/html/quickbook/ref.html @@ -3,7 +3,7 @@ Quick Reference - + @@ -26,7 +26,7 @@ Quick Reference

- + Syntax Compendium

@@ -43,16 +43,16 @@ - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -260,15 +260,15 @@ - + - + @@ -280,106 +280,106 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - +
comment + [/ some comment] - Comments
italics + ['italics] or /italics/ - Font Styles and formatting @@ -60,10 +60,10 @@
bold +bold [*bold] or *bold* - Font Styles and formatting @@ -72,9 +72,9 @@
underline + [_underline] or _underline_ - Font Styles and formatting @@ -82,10 +82,10 @@
teletype +teletype [^teletype] or =teletype= - Font Styles and formatting @@ -94,9 +94,9 @@
strikethrough + [-strikethrough] - Font Styles and formatting @@ -105,151 +105,151 @@
- + replaceable - + + [~replaceable] - Replaceble
source mode -[c++] or [python] +[c++] or [python] Source Mode
inline code + `int main();` - Inline code
code block + ``int main();`` - Code
code escape + ``from c++ to QuickBook`` - Escaping Back To QuickBook
line break + [br] or \n - line-break
anchor + [#anchor] - Anchors
link + [@http://www.boost.org Boost] - Links
anchor link + [link section.anchor Link text] - Anchor links
refentry link + [link xml.refentry Link text] - refentry links
function link + [funcref fully::qualified::function_name Link text] - function, class, member, enum or header links
class link + [classref fully::qualified::class_name Link text] - function, class, member, enum or header links
member link + [memberref fully::qualified::member_name Link text] - function, class, member, enum or header links
enum link + [enumref fully::qualified::enum_name Link text] - function, class, member, enum or header links
header link + [headerref path/to/header.hpp Link text] - function, class, member, enum or header links
escape'''escaped text (no processing/formatting)''''''escaped text (no processing/formatting)''' Escape
single char escape\c\c Single char escape
images + [$image.jpg] - Images
begin section + [section The Section Title] - Section
end section + [endsect] - Section
ordered list# one
# two
# - three
# one
# two
# + three
Ordered lists
unordered list* one
* two
- * three
* one
* two
+ * three
Unordered lists
preformatted + [pre preformatted] - Preformatted
block quote + [:sometext...] - Blockquote
heading 1 + [h1 Heading 1] - Heading
heading 2 + [h2 Heading 2] - Heading
heading 3 + [h3 Heading 3] - Heading
heading 4 + [h4 Heading 4] - Heading
heading 5 + [h5 Heading 5] - Heading
heading 6 + [h6 Heading 6] - Heading
macro + [def macro_identifier some text] - Macros
blurb + [blurb advertisement or note...] - Blurbs
admonition + [warning Warning text...] - Admonitions
table[table Title
[[a][b][c]]
- [[a][b][c]]
]
[table Title
[[a][b][c]]
+ [[a][b][c]]
]
Tables
variablelist[variablelist Title
- [[a][b]]
[[a][b]]
]
[variablelist Title
+ [[a][b]]
[[a][b]]
]
Variable Lists
include + [include someother.qbk] - Include
- +
Copyright © 2002, 2004 Joel de Guzman, Eric Niebler
diff --git a/doc/html/quickbook/syntax.html b/doc/html/quickbook/syntax.html index 33779d6..2c923fb 100755 --- a/doc/html/quickbook/syntax.html +++ b/doc/html/quickbook/syntax.html @@ -3,7 +3,7 @@ Syntax Summary - + @@ -46,7 +46,7 @@ past a single block.

- +
Copyright © 2002, 2004 Joel de Guzman, Eric Niebler
diff --git a/doc/html/quickbook/syntax/block.html b/doc/html/quickbook/syntax/block.html index b68f326..43ced7f 100644 --- a/doc/html/quickbook/syntax/block.html +++ b/doc/html/quickbook/syntax/block.html @@ -3,7 +3,7 @@ Block Level Elements - + @@ -107,16 +107,16 @@ for. In its absence, version 1.1 is assumed.

- version, id, dirname, - copyright, purpose, category, - authors, license, last-revision - and source-mode are optional information. + version, id, dirname, + copyright, purpose, category, + authors, license, last-revision + and source-mode are optional information.

- source-type is a lowercase string setting the initial + source-type is a lowercase string setting the initial Source Mode. - If the source-mode field is omitted, a default value - of c++ will be used. + If the source-mode field is omitted, a default value + of c++ will be used.

@@ -130,8 +130,8 @@

where id is optional. id will be the filename of the generated section. If it is not present, "The Section Title" - will be normalized and become the id. Valid characters are a-Z, - A-Z, 0-9 and _. + will be normalized and become the id. Valid characters are a-Z, + A-Z, 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower case. Thus: "The Section Title" will be normalized to "the_section_title". @@ -457,16 +457,16 @@

Macros that are already defined are expanded in source code. Example:

-
[def __syntax_highlight__ [@quickbook/highlight.html syntax_highlight]]
-[def __quickbook__ [@index.html quickbook]]
+
[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]]
+[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]]
 
-    using __quickbook__::__syntax_highlight__;
+    using __boost__::__array__;
 

Generates:

-using quickbook::syntax_highlight;
+using boost::array;
 
@@ -502,7 +502,7 @@ Preformatted

Sometimes, you don't want some preformatted text to be parsed as C++. In - such cases, use the [pre ... ] markup block. + such cases, use the [pre ... ] markup block.

[pre
 
@@ -519,16 +519,16 @@
           level markup, pre (and Code) are the only ones that allow multiple newlines.
           The markup above will generate:
         

-
Some preformatted text                    Some preformatted text
+
Some preformatted text                    Some preformatted text
 
-    Some preformatted text            Some preformatted text
+    Some preformatted text            Some preformatted text
 
-        Some preformatted text    Some preformatted text
+        Some preformatted text    Some preformatted text
 
 

Notice that unlike Code, phrase markup such as font style is still permitted - inside pre blocks. + inside pre blocks.

@@ -552,54 +552,54 @@

generates DocBook admonitions:

-
+
-
[Note] Note

+

This is a note

-
+
-
[Tip] Tip

+

This is a tip

-
+
-
[Important] Important

+

This is important

-
+
-
[Caution] Caution

+

This is a caution

-
+
-
[Warning] Warning

+

This is a warning

These are the only admonitions supported by DocBook. - So, for example [information This is some information] + So, for example [information This is some information] is unlikely to produce the desired effect.

@@ -614,36 +614,36 @@ [h6 Heading 6]

- + Heading 1

- + Heading 2

- + Heading 3

- + Heading 4

- + Heading 5
- + Heading 6

Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized - names with name="section_id.normalized_header_text" - (i.e. valid characters are a-z, A-Z, - 0-9 and _. All non-valid characters + names with name="section_id.normalized_header_text" + (i.e. valid characters are a-z, A-Z, + 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower-case. - For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). + For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). You can use:

[link section_id.normalized_header_text The link text]
@@ -678,19 +678,19 @@ sf_logo
 
  tip It's a good idea to use macro identifiers that
                 are distinguishable. For instance, in this document, macro identifiers
-                have two leading and trailing underscores (e.g. 
+                have two leading and trailing underscores (e.g. 
 __spirit__
-                ). The reason is to avoid unwanted macro replacement.
+                ). The reason is to avoid unwanted macro replacement.
 
 

- Links (URLS) and images are good candidates for macros. 1) + Links (URLS) and images are good candidates for macros. 1) They tend to change a lot. It is a good idea to place all links and images - in one place near the top to make it easy to make changes. 2) - The syntax is not pretty. It's easier to read and write, e.g. + in one place near the top to make it easy to make changes. 2) + The syntax is not pretty. It's easier to read and write, e.g. __spirit__ - than + than [@http://spirit.sourceforge.net Spirit] - . + .

Some more examples: @@ -722,7 +722,7 @@ __spirit__

- + Predefined Macros

@@ -742,21 +742,21 @@ __spirit__ __DATE__ - + - + - +
Today's date2006-Feb-032006-Aug-27
__TIME__ The current time05:21:02 PM06:24:19 AM
__FILENAME__ Quickbook source filenameC:\dev\boost\tools\quickbook\doc\quickbook.qbk/home/daniel/src/boost-1.34/tools/quickbook/doc/quickbook.qbk
@@ -777,8 +777,8 @@ __FILENAME__

-
smiley An eye catching advertisement - or note...

Spirit +
smiley An eye catching advertisement + or note...

Spirit is an object-oriented recursive-descent parser generator framework implemented using template meta-programming techniques. Expression templates allow us to approximate the syntax of Extended Backus-Normal @@ -800,7 +800,7 @@ __FILENAME__

- + A Simple Table

@@ -835,7 +835,7 @@ __FILENAME__

The table title is optional. The first row of the table is automatically - treated as the table header; that is, it is wrapped in <thead>...</thead> + treated as the table header; that is, it is wrapped in <thead>...</thead> XML tags. Note that unlike the original QuickDoc, the columns are nested in [ cells... ]. The syntax is free-format and allows big cells to be formatted nicely. Example: @@ -862,7 +862,7 @@ __FILENAME__

- + Table with fat cells

@@ -911,7 +911,7 @@ __FILENAME__

- + Table with code

@@ -1003,7 +1003,7 @@ __FILENAME__ of two sections having the same name. Since QuickBook generates an anchor for each section based on the section name, it is possible to end up with two identically named anchors, leading to link ambiguities. To resolve - these ambiguities, the [include] directive lets you + these ambiguities, the [include] directive lets you specify a document id to use for the included file. You can use it like this:

@@ -1013,11 +1013,11 @@ __FILENAME__ When using this form, all auto-generated anchors will use "someid" as a unique prefix. So for instance, if there is a section in someother.qbk named "Intro", the named anchor for that section will be "someid.intro", - and you can link to it with [link someid.intro The Intro]. + and you can link to it with [link someid.intro The Intro].

-
+
Copyright © 2002, 2004 Joel de Guzman, Eric Niebler
diff --git a/doc/html/quickbook/syntax/comments.html b/doc/html/quickbook/syntax/comments.html index da8fdcf..3d72e73 100644 --- a/doc/html/quickbook/syntax/comments.html +++ b/doc/html/quickbook/syntax/comments.html @@ -3,7 +3,7 @@ Comments - + @@ -31,7 +31,7 @@
[/ comment (no output generated) ]
 
- +
Copyright © 2002, 2004 Joel de Guzman, Eric Niebler
diff --git a/doc/html/quickbook/syntax/phrase.html b/doc/html/quickbook/syntax/phrase.html index 1ac502a..638468e 100644 --- a/doc/html/quickbook/syntax/phrase.html +++ b/doc/html/quickbook/syntax/phrase.html @@ -3,7 +3,7 @@ Phrase Level Elements - + @@ -53,7 +53,7 @@ will generate:

- italic, bold, underline, teletype, strikethrough + italic, bold, underline, teletype, strikethrough

Like all non-terminal phrase level elements, this can of course be nested: @@ -64,7 +64,7 @@ will generate:

- bold-italic + bold-italic

@@ -80,9 +80,9 @@ This will generate:

- + replacement - +

@@ -129,7 +129,7 @@ the true business precept.] will generate:

- italic, bold, underline, teletype + italic, bold, underline, teletype

Unlike QuickBook's standard formatting scheme, the rules for simpler alternatives @@ -164,7 +164,7 @@ the true business precept.]

- + More Formatting Samples

@@ -178,92 +178,92 @@ the true business precept.] - - + + - - + + - + - + - - + - + - + - + - - + - + - + +This is bold. - + - - + +
+ *Bold* - BoldBold
+ *Is bold* - Is boldIs bold
+ * Not bold* *Not bold * * Not bold * - * Not bold* *Not bold * * Not bold *
+ This*Isn't*Bold (no bold) - This*Isn't*Bold (no bold)
+ (*Bold Inside*) (parenthesis not bold) - (Bold Inside) + (Bold Inside) (parenthesis not bold)
+ *(Bold Outside)* (parenthesis bold) - -(Bold Outside) +(Bold Outside) (parenthesis bold)
+ 3*4*5 = 60 (no bold) - 3*4*5 = 60 (no bold)
+ 3 * 4 * 5 = 60 (no bold) - 3 * 4 * 5 = 60 (no bold)
+ 3 *4* 5 = 60 (4 is bold) - 3 4 5 = + 3 4 5 = 60 (4 is bold)
+ *This is bold* this is not *but this is* - -This is bold - this is not but this is +This is bold + this is not but this is
+ *This is bold*. - -This is bold.
+ *B*. (bold B) - -B. (bold +B. (bold B)
+ ['*Bold-Italic*] - Bold-ItalicBold-Italic
@@ -290,19 +290,19 @@ This*Isn't*Bold (no bold) will generate:

- This text has inlined code int main() { return 0; } in it. The code will be syntax highlighted. + This text has inlined code int main() { return 0; } in it. The code will be syntax highlighted.

+ .
note Note that we simply enclose the code with the - tick: + tick: "`" - , not the single quote: "'". - Note too that + , not the single quote: "'". + Note too that `some code` - is preferred over + is preferred over [^some code] - .
@@ -361,8 +361,8 @@ This*Isn't*Bold (no bold) section.

- To change the source mode, use the [source-mode] markup, - where source-mode is one of the supported modes. For + To change the source mode, use the [source-mode] markup, + where source-mode is one of the supported modes. For example, this:

Python's [python] `import` is rather like C++'s [c++] `#include`. A
@@ -373,14 +373,14 @@ C++ comment `// looks like this` whereas a Python comment [python]
           will generate:
         

- Python's import is rather - like C++'s #include. - A C++ comment // looks like this - whereas a Python comment #looks like this. + Python's import is rather + like C++'s #include. + A C++ comment // looks like this + whereas a Python comment #looks like this.

- + Supported Source Modes

@@ -395,11 +395,11 @@ C++ comment `// looks like this` whereas a Python comment [python] - + - +
C++[c++][c++]
Python[python][python]
@@ -416,7 +416,7 @@ C++ comment `// looks like this` whereas a Python comment [python]
- +
note Note that \n is now preferred over [br].
note Note that \n is now preferred over [br].
@@ -426,10 +426,10 @@ C++ comment `// looks like this` whereas a Python comment [python]

A named anchor is a hook that can be referenced by a link elsewhere in - the document. You can then reference an anchor with + the document. You can then reference an anchor with [link named_anchor Some link text] - . See Anchor + . See Anchor links, Section and Heading.

@@ -443,7 +443,7 @@ Some link text] will generate:

- this is boost's + this is boost's website....

@@ -486,8 +486,8 @@ Some link text]

[link xml.refentry The link text]
 

- This gets converted into <link linkend="xml.refentry">The - link text</link>. + This gets converted into <link linkend="xml.refentry">The + link text</link>.

Like URLs, the link text is optional. If this is not present, the link @@ -496,7 +496,7 @@ Some link text]

[link xml.refentry]
 

- This gets converted into <link linkend="xml.refentry">xml.refentry</link>. + This gets converted into <link linkend="xml.refentry">xml.refentry</link>.

@@ -542,7 +542,7 @@ escape (no processing/formatting)

-This is direct XML markup +This is direct XML markup

@@ -557,13 +557,13 @@ escape (no processing/formatting)

The backslash may be used to escape a single punctuation character. The punctuation immediately after the backslash is passed without any processing. - This is useful when we need to escape QuickBook punctuations such as [ and ]. - For example, how do you escape the triple quote? Simple: \'\'\' + This is useful when we need to escape QuickBook punctuations such as [ and ]. + For example, how do you escape the triple quote? Simple: \'\'\'

- \n - has a special meaning. It is used to generate line breaks. Note that \n is - now preferred over [br]. + \n + has a special meaning. It is used to generate line breaks. Note that \n is + now preferred over [br].

@@ -577,25 +577,25 @@ escape (no processing/formatting) Footnotes

As of version 1.3, QuickBook supports footnotes. Just put the text of the - footnote in a [footnote] block, and the text will be put at the + footnote in a [footnote] block, and the text will be put at the bottom of the current page. For example, this:

[footnote A sample footnote]
 

will generate this - [1] + [1] .



-

[1] +

[1] A sample footnote

-
+
Copyright © 2002, 2004 Joel de Guzman, Eric Niebler
From 5fe3f4d52f3ff2fbc55ac6bbf38f40a399e40c3d Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Thu, 16 Nov 2006 02:59:16 +0000 Subject: [PATCH 08/94] fixed the images [SVN r36049] --- doc/html/images/caution.png | Bin 1249 -> 1250 bytes doc/html/images/important.png | Bin 721 -> 722 bytes doc/html/images/warning.png | Bin 1240 -> 1241 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/html/images/caution.png b/doc/html/images/caution.png index 221af138769c3d1766ed40afccafea9d12abc4e7..5b7809ca4a9c8d778087522e5ce04b6e90099595 100644 GIT binary patch delta 28 jcmaFJ`G}LJGr-TCmrII^fq{W{BlmJ Date: Sun, 31 Dec 2006 03:53:52 +0000 Subject: [PATCH 09/94] Copyright notices [SVN r36543] --- doc/Jamfile.v2 | 10 ++++++++++ doc/html/quickbook/change_log.html | 11 +++++++++++ doc/html/quickbook/intro.html | 11 +++++++++++ doc/html/quickbook/ref.html | 11 +++++++++++ doc/html/quickbook/syntax.html | 11 +++++++++++ doc/html/quickbook/syntax/block.html | 11 +++++++++++ doc/html/quickbook/syntax/comments.html | 11 +++++++++++ doc/html/quickbook/syntax/phrase.html | 11 +++++++++++ index.html | 11 +++++++++++ 9 files changed, 98 insertions(+) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index e4deae0..9f6858a 100755 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -1,3 +1,13 @@ +#============================================================================== +# Copyright (c) 2002 2004 Joel de Guzman +# Copyright (c) 2004 Eric Niebler +# http://spirit.sourceforge.net/ +# +# Use, modification and distribution is subject to the Boost Software +# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +#============================================================================== + project boost/quickbook/doc ; import boostbook : boostbook ; diff --git a/doc/html/quickbook/change_log.html b/doc/html/quickbook/change_log.html index a1abad9..cbe06a8 100644 --- a/doc/html/quickbook/change_log.html +++ b/doc/html/quickbook/change_log.html @@ -1,5 +1,16 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Change Log diff --git a/doc/html/quickbook/intro.html b/doc/html/quickbook/intro.html index 0f2297d..296d8fa 100644 --- a/doc/html/quickbook/intro.html +++ b/doc/html/quickbook/intro.html @@ -1,5 +1,16 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Introduction diff --git a/doc/html/quickbook/ref.html b/doc/html/quickbook/ref.html index 1ddf783..72b1c00 100755 --- a/doc/html/quickbook/ref.html +++ b/doc/html/quickbook/ref.html @@ -1,5 +1,16 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Quick Reference diff --git a/doc/html/quickbook/syntax.html b/doc/html/quickbook/syntax.html index 2c923fb..6484db9 100755 --- a/doc/html/quickbook/syntax.html +++ b/doc/html/quickbook/syntax.html @@ -1,5 +1,16 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Syntax Summary diff --git a/doc/html/quickbook/syntax/block.html b/doc/html/quickbook/syntax/block.html index 43ced7f..9037305 100644 --- a/doc/html/quickbook/syntax/block.html +++ b/doc/html/quickbook/syntax/block.html @@ -1,5 +1,16 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Block Level Elements diff --git a/doc/html/quickbook/syntax/comments.html b/doc/html/quickbook/syntax/comments.html index 3d72e73..f8b0bf7 100644 --- a/doc/html/quickbook/syntax/comments.html +++ b/doc/html/quickbook/syntax/comments.html @@ -1,5 +1,16 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Comments diff --git a/doc/html/quickbook/syntax/phrase.html b/doc/html/quickbook/syntax/phrase.html index 638468e..6b31dfd 100644 --- a/doc/html/quickbook/syntax/phrase.html +++ b/doc/html/quickbook/syntax/phrase.html @@ -1,5 +1,16 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Phrase Level Elements diff --git a/index.html b/index.html index b6ce29b..a06710f 100755 --- a/index.html +++ b/index.html @@ -2,6 +2,17 @@ + + <-- + Copyright (c) 2002 2004 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + --> + Automatic redirection failed, click this From 446df4e509932e491d6733805a4f34405d5e30eb Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 24 Jul 2007 19:28:14 +0000 Subject: [PATCH 10/94] This commit was manufactured by cvs2svn to create tag 'Version_1_34_1'. [SVN r38286] From 7e558d5fbda52eea6bd2309f06e0ecf49f8ba004 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 5 Oct 2007 14:25:06 +0000 Subject: [PATCH 11/94] Starting point for releases [SVN r39706] From c52714a0cfc20a027cd453f549b9ebd61db09cfe Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 23 Nov 2007 17:03:14 +0000 Subject: [PATCH 12/94] config, detail, filesystem, system, tools, at 41278. [SVN r41316] --- detail/utils.cpp | 1 + test/import.gold | 80 ++++++++-------- test/import.quickbook | 12 +-- test/templates.gold | 140 ++++++++++++++-------------- test/templates.quickbook | 192 +++++++++++++++++++-------------------- test/xinclude.gold | 18 ++-- test/xinclude.quickbook | 8 +- 7 files changed, 226 insertions(+), 225 deletions(-) diff --git a/detail/utils.cpp b/detail/utils.cpp index 96ba96d..093a10a 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include diff --git a/test/import.gold b/test/import.gold index b033458..87988a6 100644 --- a/test/import.gold +++ b/test/import.gold @@ -1,40 +1,40 @@ - - -
- - - Import - - - This is the foo function. - - - This description can have paragraphs... - - - - lists - - - etc. - - - - And any quickbook block markup. - - - - -std::string foo() -{ - // return 'em, foo man! - return "foo"; -} - - - - - - -
+ + +
+ + + Import + + + This is the foo function. + + + This description can have paragraphs... + + + + lists + + + etc. + + + + And any quickbook block markup. + + + + +std::string foo() +{ + // return 'em, foo man! + return "foo"; +} + + + + + + +
diff --git a/test/import.quickbook b/test/import.quickbook index 88bf400..9bd5f24 100644 --- a/test/import.quickbook +++ b/test/import.quickbook @@ -1,6 +1,6 @@ -[article Import] - -[import stub.cpp] - -[foo] - +[article Import] + +[import stub.cpp] + +[foo] + diff --git a/test/templates.gold b/test/templates.gold index 58ecb94..d6323ba 100644 --- a/test/templates.gold +++ b/test/templates.gold @@ -1,70 +1,70 @@ - - -
- - - Templates -
- <link linkend="templates.templates">Templates</link> - - nullary_arg - - - foo baz - - - - foo baz - - - - - This is a complete paragraph. kalamazoo kalamazoo kalamazoo kalamazoo kalamazoo - kalamazoo kalamazoo kalamazoo kalamazoo.... blah blah blah...... - - - - baz - - - - This is a complete paragraph. madagascar madagascar madagascar madagascar - madagascar madagascar madagascar madagascar madagascar.... blah blah blah...... - - - - zoom peanut zoom - - - exactly xanadu - - - wx - - - wxyz wxyz trail - - - - -int main() -{ - std::cout << "Hello, World" << std::endl; -} - - - - x2 - - - α2 - - - x2 - - - got a banana? - -
-
+ + +
+ + + Templates +
+ <link linkend="templates.templates">Templates</link> + + nullary_arg + + + foo baz + + + + foo baz + + + + + This is a complete paragraph. kalamazoo kalamazoo kalamazoo kalamazoo kalamazoo + kalamazoo kalamazoo kalamazoo kalamazoo.... blah blah blah...... + + + + baz + + + + This is a complete paragraph. madagascar madagascar madagascar madagascar + madagascar madagascar madagascar madagascar madagascar.... blah blah blah...... + + + + zoom peanut zoom + + + exactly xanadu + + + wx + + + wxyz wxyz trail + + + + +int main() +{ + std::cout << "Hello, World" << std::endl; +} + + + + x2 + + + α2 + + + x2 + + + got a banana? + +
+
diff --git a/test/templates.quickbook b/test/templates.quickbook index b0f7bf9..6683f11 100644 --- a/test/templates.quickbook +++ b/test/templates.quickbook @@ -1,96 +1,96 @@ -[article Templates - [quickbook 1.3] -] - -[section Templates] - -[/-------------------------------- nullary arg ] - -[template foo0 nullary_arg] - -[foo0] - -[/-------------------------------- unary arg, phrase syle ] - -[template foo1[bar] foo [bar]] - -[foo1 baz] - -[/-------------------------------- unary arg, block syle ] - -[template foo2[bar] -foo [bar] -] - -[foo2 baz] - -[template foo3[bar] -This is a complete paragraph. [bar] [bar] [bar] [bar] [bar] -[bar] [bar] [bar] [bar].... blah blah blah...... -] - -[foo3 kalamazoo] - -[/-------------------------------- unary arg, using punctuation ] - -[template ![bar] ''''''[bar]''''''] - -[!baz] - -[/-------------------------------- recursive templates ] - -[template foo4[bar] -[foo3 [bar]] -] - -[foo3 madagascar] - -[template foo5[x] zoom [x]] -[template foo6[x] [x] zoom] - -[foo6[foo5 peanut]] - -[template kinda_weird[x y] [x] [y]] - -[kinda_weird exactly..xanadu] - - -[/-------------------------------- space delimitted args ] - -[template simple1[a b] [a][b]] - -[simple1 w x] - -[template simple2[a b c d] [a][b][c][d]] - -[simple2 w x y z][simple2 w x y z trail] - -[/-------------------------------- John's templates ] - -[template code[x] - int main() - { - std::cout << ``[x]`` << std::endl; - } -] - -[code "Hello\, World"] - -[template alpha '''α'''] -[template pow[a b] [a]''''''[b]'''''' ] -[template super[text]''''''[text]'''''' ] - -[pow x 2] - -[pow [alpha] 2] - -x[super 2] - -[/-------------------------------- Some more ] - -[template banana got a banana?] -[template plantation[bananarama] [bananarama]] - -[plantation [banana]] - -[endsect] +[article Templates + [quickbook 1.3] +] + +[section Templates] + +[/-------------------------------- nullary arg ] + +[template foo0 nullary_arg] + +[foo0] + +[/-------------------------------- unary arg, phrase syle ] + +[template foo1[bar] foo [bar]] + +[foo1 baz] + +[/-------------------------------- unary arg, block syle ] + +[template foo2[bar] +foo [bar] +] + +[foo2 baz] + +[template foo3[bar] +This is a complete paragraph. [bar] [bar] [bar] [bar] [bar] +[bar] [bar] [bar] [bar].... blah blah blah...... +] + +[foo3 kalamazoo] + +[/-------------------------------- unary arg, using punctuation ] + +[template ![bar] ''''''[bar]''''''] + +[!baz] + +[/-------------------------------- recursive templates ] + +[template foo4[bar] +[foo3 [bar]] +] + +[foo3 madagascar] + +[template foo5[x] zoom [x]] +[template foo6[x] [x] zoom] + +[foo6[foo5 peanut]] + +[template kinda_weird[x y] [x] [y]] + +[kinda_weird exactly..xanadu] + + +[/-------------------------------- space delimitted args ] + +[template simple1[a b] [a][b]] + +[simple1 w x] + +[template simple2[a b c d] [a][b][c][d]] + +[simple2 w x y z][simple2 w x y z trail] + +[/-------------------------------- John's templates ] + +[template code[x] + int main() + { + std::cout << ``[x]`` << std::endl; + } +] + +[code "Hello\, World"] + +[template alpha '''α'''] +[template pow[a b] [a]''''''[b]'''''' ] +[template super[text]''''''[text]'''''' ] + +[pow x 2] + +[pow [alpha] 2] + +x[super 2] + +[/-------------------------------- Some more ] + +[template banana got a banana?] +[template plantation[bananarama] [bananarama]] + +[plantation [banana]] + +[endsect] diff --git a/test/xinclude.gold b/test/xinclude.gold index d7c502e..55a1f50 100644 --- a/test/xinclude.gold +++ b/test/xinclude.gold @@ -1,9 +1,9 @@ - - -
- - - Include - -
+ + +
+ + + Include + +
diff --git a/test/xinclude.quickbook b/test/xinclude.quickbook index e2a455e..9d1fb3e 100644 --- a/test/xinclude.quickbook +++ b/test/xinclude.quickbook @@ -1,4 +1,4 @@ -[article Include] - -[xinclude stub.xml] - +[article Include] + +[xinclude stub.xml] + From 7ab93b31c4c74add1e8e72ef6b2845c4ac3f5141 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 15 Mar 2008 19:35:51 +0000 Subject: [PATCH 13/94] Merge latest quickbook from trunk to release. [SVN r43639] --- detail/actions.cpp | 30 +++++++++++++++++++----------- detail/actions.hpp | 12 ++++++++++++ detail/actions_class.cpp | 3 +-- detail/actions_class.hpp | 4 ++-- doc_info.hpp | 9 +++++---- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/detail/actions.cpp b/detail/actions.cpp index 4fc9937..9e3abe1 100644 --- a/detail/actions.cpp +++ b/detail/actions.cpp @@ -1096,6 +1096,21 @@ namespace quickbook << " \n"; } + void xml_copyright::operator()(std::pair, std::string> const& copyright) const + { + out << "\n" << " \n"; + + for_each( + copyright.first.begin() + , copyright.first.end() + , xml_year(out)); + + out << " " << copyright.second << "\n" + << " \n" + << "\n" + ; + } + void xml_year::operator()(std::string const &year) const { out << " " << year << "\n"; @@ -1170,19 +1185,12 @@ namespace quickbook out << " \n"; } - if (!actions.doc_copyright_holder.empty()) + if (!actions.doc_copyrights.empty()) { - out << "\n" << " \n"; - for_each( - actions.doc_copyright_years.begin() - , actions.doc_copyright_years.end() - , xml_year(out)); - - out << " " << actions.doc_copyright_holder << "\n" - << " \n" - << "\n" - ; + actions.doc_copyrights.begin() + , actions.doc_copyrights.end() + , xml_copyright(out)); } if (qbk_version_n < 103) diff --git a/detail/actions.hpp b/detail/actions.hpp index 88bcb8b..036f137 100755 --- a/detail/actions.hpp +++ b/detail/actions.hpp @@ -743,6 +743,18 @@ namespace quickbook collector& out; }; + struct xml_copyright + { + // Handles xml copyright + + xml_copyright(collector& out) + : out(out) {} + + void operator()(std::pair, std::string> const ©right) const; + + collector& out; + }; + void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo = false); void post(collector& out, quickbook::actions& actions, bool ignore_docinfo = false); diff --git a/detail/actions_class.cpp b/detail/actions_class.cpp index 25e2d0f..17d675f 100644 --- a/detail/actions_class.cpp +++ b/detail/actions_class.cpp @@ -24,8 +24,7 @@ namespace quickbook , doc_version() , doc_id() , doc_dirname() - , doc_copyright_years() - , doc_copyright_holder() + , doc_copyrights() , doc_purpose() , doc_category() , doc_authors() diff --git a/detail/actions_class.hpp b/detail/actions_class.hpp index 27e5fe1..5fc3a25 100644 --- a/detail/actions_class.hpp +++ b/detail/actions_class.hpp @@ -28,6 +28,7 @@ namespace quickbook typedef std::vector string_list; typedef std::vector > author_list; + typedef std::vector > copyright_list; typedef std::pair mark_type; static int const max_template_depth = 100; @@ -37,8 +38,7 @@ namespace quickbook std::string doc_version; std::string doc_id; std::string doc_dirname; - string_list doc_copyright_years; - std::string doc_copyright_holder; + copyright_list doc_copyrights; std::string doc_purpose; std::string doc_category; author_list doc_authors; diff --git a/doc_info.hpp b/doc_info.hpp index 5c4ace2..874daf8 100755 --- a/doc_info.hpp +++ b/doc_info.hpp @@ -66,7 +66,7 @@ namespace quickbook doc_version | doc_id | doc_dirname - | doc_copyright + | doc_copyright [push_back_a(actions.doc_copyrights, copyright)] | doc_purpose [actions.extract_doc_purpose] | doc_category | doc_authors @@ -103,12 +103,12 @@ namespace quickbook ; doc_copyright = - "copyright" >> hard_space - >> +( repeat_p(4)[digit_p] [push_back_a(actions.doc_copyright_years)] + "copyright" >> hard_space [clear_a(copyright.first)] + >> +( repeat_p(4)[digit_p] [push_back_a(copyright.first)] >> space ) >> space - >> (*(anychar_p - ']')) [assign_a(actions.doc_copyright_holder)] + >> (*(anychar_p - ']')) [assign_a(copyright.second)] ; doc_purpose = @@ -178,6 +178,7 @@ namespace quickbook bool unused; std::pair name; + std::pair, std::string> copyright; rule doc_info, doc_title, doc_version, doc_id, doc_dirname, doc_copyright, doc_purpose,doc_category, doc_authors, doc_author, comment, space, hard_space, doc_license, From 3e6e6219b4649aac1251b55effa4764f533f54ad Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 16 Mar 2008 11:38:32 +0000 Subject: [PATCH 14/94] Rebuild a lot of documentation. [SVN r43650] --- doc/html/index.html | 14 +- doc/html/quickbook/change_log.html | 51 +-- doc/html/quickbook/editors.html | 24 +- doc/html/quickbook/editors/kde_support.html | 119 ++--- doc/html/quickbook/editors/scite.html | 31 +- doc/html/quickbook/faq.html | 35 +- doc/html/quickbook/install.html | 21 +- doc/html/quickbook/install/linux.html | 45 +- doc/html/quickbook/install/macosx.html | 53 +-- doc/html/quickbook/install/windows.html | 57 +-- doc/html/quickbook/intro.html | 19 +- doc/html/quickbook/ref.html | 226 +++++----- doc/html/quickbook/syntax.html | 15 +- doc/html/quickbook/syntax/block.html | 455 ++++++++++---------- doc/html/quickbook/syntax/comments.html | 17 +- doc/html/quickbook/syntax/phrase.html | 277 ++++++------ 16 files changed, 755 insertions(+), 704 deletions(-) diff --git a/doc/html/index.html b/doc/html/index.html index 28598c8..8a453f9 100755 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -3,17 +3,17 @@ Quickbook 1.4 - + - + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -34,7 +34,7 @@
-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

@@ -70,7 +70,7 @@
- +

Last revised: November 14, 2007 at 10:19:55 GMT

Last revised: March 15, 2008 at 14:07:42 GMT


diff --git a/doc/html/quickbook/change_log.html b/doc/html/quickbook/change_log.html index 719620c..e96ffaa 100644 --- a/doc/html/quickbook/change_log.html +++ b/doc/html/quickbook/change_log.html @@ -1,21 +1,21 @@ - Change Log +Change Log - + - - + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,11 +24,12 @@
+

+ + Version 1.3 +

  • Quickbook file inclusion [include]. @@ -65,7 +66,7 @@
  • Fully qualified section and headers. Subsection names are concatenated to - the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name + the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name
  • Better &nbsp; and whitespace handling in code snippets. @@ -93,10 +94,10 @@ Replaceable, with the [~replacement] syntax.
-

- - Version 1.4 -

+

+ + Version 1.4 +

  • Generic Headers @@ -115,7 +116,7 @@
  • Allow escape of spaces. The escaped space is removed from the output. Syntax: - \ . + \ .
  • Nested comments are now allowed. @@ -124,7 +125,7 @@ Quickbook blocks can nest inside comments.
  • -Import facility. +Import facility.
  • Callouts on imported code @@ -133,21 +134,21 @@ Simple markups can now span a whole block.
  • -Blurbs, Admonitions - and table cells (see Tables) +Blurbs, Admonitions + and table cells (see Tables) may now contain paragraphs.
  • -\n - and [br] are now deprecated. +\n + and [br] are now deprecated.
  • -Conditional Generation. +Conditional Generation. Ala C++ #ifdef.
  • Searching of included and imported files in an extensible search path with - --include-path (-I) option. + --include-path (-I) option.
diff --git a/doc/html/quickbook/editors.html b/doc/html/quickbook/editors.html index 66016af..fcf828c 100644 --- a/doc/html/quickbook/editors.html +++ b/doc/html/quickbook/editors.html @@ -1,21 +1,21 @@ - Editor Support +Editor Support - + - - + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Scintilla Text Editor
KDE Support
@@ -34,11 +35,14 @@ The following sections list the settings for some editors which can help make editing quickbook files a bit easier.

-
diff --git a/doc/html/quickbook/editors/kde_support.html b/doc/html/quickbook/editors/kde_support.html index 8d9b336..740a8df 100644 --- a/doc/html/quickbook/editors/kde_support.html +++ b/doc/html/quickbook/editors/kde_support.html @@ -3,19 +3,19 @@ KDE Support - + - - - + + +
- + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,11 +24,12 @@ +
+ + boost::hs::quickbook +

boost::hs::quickbook is a syntax highlighting designed to work with Katepart. It can be used in KWrite, Kate, Konqueror and KDevelop, and supports all @@ -48,11 +49,11 @@

- html generated from this .qbk file + html generated from this .qbk file

-

Table 7. Code examples

- +

Table 7. Code examples

+
@@ -84,8 +85,8 @@ -

- for(int k=0; - k<10; k++) v+=k; + for(int k=0; + k<10; k++) v+=k;

@@ -102,12 +103,12 @@

- { int + { int k; while( k < 10 ) - { v+=k; k++ } } + { v+=k; k++ } }

@@ -124,10 +125,10 @@

- while( + while( true ) { v+=1; - } + }

@@ -137,34 +138,34 @@
+
-

- - Code Folding +

+ + Code Folding -
+

boost::hs goes far beyond simple coloring. One useful thing you can get the editor to do is to mark regions. They appear in a small grey line and each region can be folded or unfolded independently.

-

- - Auto +

+ + Auto Comment / Uncomment -
+

Another important feature is the possibility to auto-comment or uncomment some piece of code (Tools - Comment). Commented regions can be uncommented simple calling the uncomment command while being in it.

-

- - Styles reference +

+ + Styles reference -
+
@@ -192,7 +193,7 @@

- plain text + plain text

@@ -209,7 +210,7 @@

- formatted text + formatted text

@@ -226,7 +227,7 @@

- structure + structure

@@ -244,7 +245,7 @@

- macros + macros

@@ -262,7 +263,7 @@

- templates + templates

@@ -279,7 +280,7 @@

- anchors + anchors

@@ -296,7 +297,7 @@

- comments + comments

@@ -313,7 +314,7 @@

- tables + tables

@@ -330,7 +331,7 @@

- variable lists + variable lists

@@ -347,7 +348,7 @@

- c++ code + c++ code

@@ -364,7 +365,7 @@

- paths + paths

@@ -381,7 +382,7 @@

- IDE specific + IDE specific

@@ -397,10 +398,10 @@
-

- - About boost::hs -

+
+ + About boost::hs +

boost.hs.logo

@@ -414,15 +415,15 @@ [Note] Note -

+

boost::hs::cpp support QuickBook code import comments style!

-

- - Installing +

+ + Installing boost::hs -
+

There exist an ongoing effort to push boost::hs upstream to the KatePart project. In a few months KDE may have native Quickbook support! For the moment @@ -436,13 +437,13 @@ [Note] Note -

- A copy of boost::hs::quickbook and boost::hs::cpp is available in boost/tools/quickbook/extra/katepart. +

+ A copy of boost::hs::quickbook and boost::hs::cpp is available in boost/tools/quickbook/extra/katepart.

- In order to install it you must copy the content in the folder katepart/syntax/ to the appropriate katepart syntax - folder in your machine. In general this folder will be in /usr/share/apps/katepart/syntax. + In order to install it you must copy the content in the folder katepart/syntax/ to the appropriate katepart syntax + folder in your machine. In general this folder will be in /usr/share/apps/katepart/syntax. A bash script named install.sh is included that copy the files to this folder.

diff --git a/doc/html/quickbook/editors/scite.html b/doc/html/quickbook/editors/scite.html index 23f990a..e533b40 100644 --- a/doc/html/quickbook/editors/scite.html +++ b/doc/html/quickbook/editors/scite.html @@ -1,21 +1,21 @@ - Scintilla Text Editor +Scintilla Text Editor - + - - + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@

@@ -38,9 +39,12 @@ The Scintilla Text Editor (SciTE) is a free source code editor for Win32 and X. It uses the SCIntilla source code editing component.

-

You can use the following settings to highlight quickbook tags when editing quickbook files. @@ -57,9 +61,12 @@ comment.box.start.props=[/ comment.box.middle.props= comment.box.end.props=]

- diff --git a/doc/html/quickbook/faq.html b/doc/html/quickbook/faq.html index 5ff7ea9..6773e68 100644 --- a/doc/html/quickbook/faq.html +++ b/doc/html/quickbook/faq.html @@ -1,21 +1,21 @@ - Frequently Asked Questions +Frequently Asked Questions - + - +
- + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,12 +24,13 @@ +

+ + Can I use QuickBook for non-Boost documentation? -

+

QuickBook can be used for non-Boost documentation with a little extra work.

@@ -60,18 +61,18 @@ boostbook standalone : my_doc : - <xsl:param>boost.image.srcimages/my_project_logo.png - <xsl:param>boost.image.alt"\"My Project\"" + <xsl:param>boost.image.srcimages/my_project_logo.png + <xsl:param>boost.image.alt"\"My Project\"" <xsl:param>boost.image.w=100 <xsl:param>boost.image.h=50 <xsl:param>nav.layout=none ;
-

- - Is +

+ + Is there an easy way to convert BoostBook docs to QuickBook? -

+

There's a stylesheet that allows Boostbook generated HTML to be viewed as quickbook source, see http://svn.boost.org/trac/boost/wiki/QuickbookSourceStylesheetProject, diff --git a/doc/html/quickbook/install.html b/doc/html/quickbook/install.html index d58045e..ade87e9 100644 --- a/doc/html/quickbook/install.html +++ b/doc/html/quickbook/install.html @@ -1,21 +1,21 @@ - Installation and configuration +Installation and configuration - + - - + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More


@@ -24,7 +24,8 @@
Mac OS X
Windows 2000, XP, 2003, Vista
@@ -37,8 +38,8 @@

Before continuing, it is very important that you keep this in mind: if you try to build some documents and the process breaks due to misconfiguration, - be absolutely sure to delete any bin - and bin.v2 directories generated by the build before + be absolutely sure to delete any bin + and bin.v2 directories generated by the build before trying again. Otherwise your configuration fixes will not take any effect.

diff --git a/doc/html/quickbook/install/linux.html b/doc/html/quickbook/install/linux.html index afbfeed..683296a 100644 --- a/doc/html/quickbook/install/linux.html +++ b/doc/html/quickbook/install/linux.html @@ -1,21 +1,21 @@ - Debian, Ubuntu +Debian, Ubuntu - + - - - + + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,29 +24,30 @@

The following instructions apply to Debian and its derivatives. They are based on a Ubuntu Edgy install but should work on other Debian based systems.

- First install the bjam, - xsltproc, docbook-xsl and - docbook-xml packages. For example, using apt-get: + First install the bjam, + xsltproc, docbook-xsl and + docbook-xml packages. For example, using apt-get:

 sudo apt-get install xsltproc docbook-xsl docbook-xml
 

If you're planning on building boost's documentation, you'll also need to - install the doxygen package + install the doxygen package as well.

Next, we need to configure Boost Build to compile BoostBook files. Add the - following to your user-config.jam file, which should be in your home + following to your user-config.jam file, which should be in your home directory. If you don't have one, create a file containing this text. For - more information on setting up user-config.jam, see + more information on setting up user-config.jam, see the Boost Build documentation.

@@ -67,19 +68,19 @@

  1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook).
  2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
  3. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) - to a safe place. The traditional location is /usr/local/bin. + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) + to a safe place. The traditional location is /usr/local/bin.
  4. - Add the following to your user-config.jam + Add the following to your user-config.jam file, using the full path of the quickbook executable:
diff --git a/doc/html/quickbook/install/macosx.html b/doc/html/quickbook/install/macosx.html index e7ff6af..168c3ca 100644 --- a/doc/html/quickbook/install/macosx.html +++ b/doc/html/quickbook/install/macosx.html @@ -1,21 +1,21 @@ - Mac OS X +Mac OS X - + - - - + + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@

@@ -44,13 +45,13 @@

The text below assumes you want to install all the necessary utilities in a system-wide location, allowing any user in the machine to have access to - them. Therefore, all files will be put in the /usr/local + them. Therefore, all files will be put in the /usr/local hierarchy. If you do not want this, you can choose any other prefix such - as ~/Applications + as ~/Applications for a single-user installation.

- Mac OS X comes with xsltproc + Mac OS X comes with xsltproc and all related libraries preinstalled, so you do not need to take any extra steps to set them up. It is probable that future versions will include them too, but these instructions may not apply to older versions. @@ -61,16 +62,16 @@

  1. Download Docbook - XML 4.2 and unpack it inside /usr/local/share/xml/docbook/4.2. + XML 4.2 and unpack it inside /usr/local/share/xml/docbook/4.2.
  2. Download the latest Docbook - XSL version and unpack it. Put the results in /usr/local/share/xsl/docbook, thus effectively removing the + XSL version and unpack it. Put the results in /usr/local/share/xsl/docbook, thus effectively removing the version number from the directory name (for simplicity).
  3. - Add the following to your user-config.jam - file, which should live in your home directory (/Users/<your_username>). + Add the following to your user-config.jam + file, which should live in your home directory (/Users/<your_username>). You must already have it somewhere or otherwise you could not be building Boost (i.e. missing tools configuration).
  4. @@ -90,20 +91,20 @@

    1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook).
    2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
    3. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) to a safe place. Following our previous example, you can install it into: - /usr/local/bin. + /usr/local/bin.
    4. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
    @@ -119,14 +120,14 @@
    1. Go to the downloads - section and get the disk image (dmg + section and get the disk image (dmg file) for Mac OS X.
    2. - Open the disk image and drag the Doxygen application to your Applications folder to install it. + Open the disk image and drag the Doxygen application to your Applications folder to install it.
    3. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
    diff --git a/doc/html/quickbook/install/windows.html b/doc/html/quickbook/install/windows.html index 34133fe..aca71f1 100644 --- a/doc/html/quickbook/install/windows.html +++ b/doc/html/quickbook/install/windows.html @@ -1,21 +1,21 @@ - Windows 2000, XP, 2003, Vista +Windows 2000, XP, 2003, Vista - + - - - + + + - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

    @@ -24,7 +24,8 @@

@@ -44,39 +45,39 @@

  1. - First of all you need to have a copy of xsltproc + First of all you need to have a copy of xsltproc for Windows. There are many ways to get this tool, but to keep things simple, use the binary packages made by Igor Zlatkovic. At the very least, you need to download the following - packages: iconv, zlib, libxml2 - and libxslt. + packages: iconv, zlib, libxml2 + and libxslt.
  2. Unpack all these packages in the same directory so that you get unique - bin, include - and lib directories within - the hierarchy. These instructions use C:\Users\example\Documents\boost\xml + bin, include + and lib directories within + the hierarchy. These instructions use C:\Users\example\Documents\boost\xml as the root for all files.
  3. - From the command line, go to the bin - directory and launch xsltproc.exe + From the command line, go to the bin + directory and launch xsltproc.exe to ensure it works. You should get usage information on screen.
  4. Download Docbook XML 4.2 and unpack it in the same directory used above. That is: - C:\Users\example\Documents\boost\xml\docbook-xml. + C:\Users\example\Documents\boost\xml\docbook-xml.
  5. Download the latest Docbook XSL version and unpack it, again in the same directory used before. To make things easier, rename the directory created during the extraction - to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. + to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl.
  6. - Add the following to your user-config.jam - file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). + Add the following to your user-config.jam + file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). You must already have it somewhere or otherwise you could not be building Boost (i.e. missing tools configuration).
  7. @@ -97,20 +98,20 @@

    1. - Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). + Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook).
    2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
    3. - Copy the resulting quickbook.exe - binary (located under the BOOST_ROOT\bin.v2 hierarchy) + Copy the resulting quickbook.exe + binary (located under the BOOST_ROOT\bin.v2 hierarchy) to a safe place. Following our previous example, you can install it into: - C:\Users\example\Documents\boost\xml\bin. + C:\Users\example\Documents\boost\xml\bin.
    4. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
    diff --git a/doc/html/quickbook/intro.html b/doc/html/quickbook/intro.html index acc0670..1c0ee4d 100644 --- a/doc/html/quickbook/intro.html +++ b/doc/html/quickbook/intro.html @@ -1,21 +1,21 @@ - Introduction +Introduction - + - + - + - - + +
    Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

    @@ -24,13 +24,14 @@

- Why program by hand in five days - what you can spend five years of your life automating? + Why program by hand in five days + what you can spend five years of your life automating?

diff --git a/doc/html/quickbook/ref.html b/doc/html/quickbook/ref.html index e419a88..c4f782c 100755 --- a/doc/html/quickbook/ref.html +++ b/doc/html/quickbook/ref.html @@ -1,20 +1,20 @@ - Quick Reference +Quick Reference - + - + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -23,12 +23,13 @@

-

Table 8. Syntax Compendium

- +

Table 8. Syntax Compendium

+
@@ -60,12 +61,12 @@ @@ -77,13 +78,13 @@ @@ -91,18 +92,18 @@ @@ -115,13 +116,13 @@ @@ -129,18 +130,18 @@ @@ -153,13 +154,13 @@ @@ -167,19 +168,19 @@ @@ -191,12 +192,12 @@ @@ -208,12 +209,12 @@ @@ -225,12 +226,12 @@ @@ -242,13 +243,12 @@ @@ -260,13 +260,13 @@ @@ -278,12 +278,12 @@ @@ -295,12 +295,12 @@ @@ -312,12 +312,12 @@ @@ -329,12 +329,12 @@ @@ -346,12 +346,12 @@ @@ -364,12 +364,12 @@ @@ -382,12 +382,12 @@ @@ -400,12 +400,12 @@ @@ -418,12 +418,12 @@ @@ -436,12 +436,12 @@ @@ -454,12 +454,12 @@ @@ -472,12 +472,12 @@ @@ -489,13 +489,12 @@ @@ -508,12 +507,12 @@ @@ -525,12 +524,12 @@ @@ -542,12 +541,12 @@ @@ -565,7 +564,7 @@ @@ -588,8 +587,7 @@ @@ -612,8 +610,7 @@ @@ -631,7 +628,7 @@ @@ -643,12 +640,12 @@ @@ -660,12 +657,12 @@ @@ -677,12 +674,12 @@ @@ -694,12 +691,12 @@ @@ -711,12 +708,12 @@ @@ -728,12 +725,12 @@ @@ -745,12 +742,12 @@ @@ -762,12 +759,12 @@ @@ -779,12 +776,12 @@ @@ -796,12 +793,12 @@ @@ -813,12 +810,12 @@ @@ -830,12 +827,12 @@ @@ -859,7 +856,7 @@ @@ -883,7 +880,7 @@ @@ -895,12 +892,12 @@ @@ -912,18 +909,19 @@ -

- [/ some comment] + [/ some comment]

- Comments + Comments

- ['italics] or /italics/ + ['italics] or /italics/

- Font Styles - and Simple + Font Styles + and Simple formatting

- bold + bold

- [*bold] or *bold* + [*bold] or *bold*

- Font Styles - and Simple + Font Styles + and Simple formatting

- [_underline] or _underline_ + [_underline] or _underline_

- Font Styles - and Simple + Font Styles + and Simple formatting

- teletype + teletype

- [^teletype] or =teletype= + [^teletype] or =teletype=

- Font Styles - and Simple + Font Styles + and Simple formatting

- [-strikethrough] + [-strikethrough]

- Font Styles - and Simple + Font Styles + and Simple formatting

- + replaceable - +

- [~replaceable] + [~replaceable]

- Replaceble + Replaceble

- [c++] or [python] + [c++] or [python]

- Source Mode + Source Mode

- `int main();` + `int main();`

- Inline code + Inline code

- ``int main();`` + ``int main();``

- Code + Code

- ``from c++ to QuickBook`` + ``from c++ to QuickBook``

- Escaping Back To QuickBook + Escaping Back To QuickBook

- [br] or \n + [br] or \n

- line-break - DEPRECATED + line-break + DEPRECATED

- [#anchor] + [#anchor]

- Anchors + Anchors

- [@http://www.boost.org Boost] + [@http://www.boost.org Boost]

- Links + Links

- [link section.anchor Link text] + [link section.anchor Link text]

- Anchor links + Anchor links

- [link xml.refentry Link text] + [link xml.refentry Link text]

- refentry links + refentry links

- [funcref fully::qualified::function_name Link text] + [funcref fully::qualified::function_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [classref fully::qualified::class_name Link text] + [classref fully::qualified::class_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [memberref fully::qualified::member_name Link text] + [memberref fully::qualified::member_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [enumref fully::qualified::enum_name Link text] + [enumref fully::qualified::enum_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [macroref MACRO_NAME Link text] + [macroref MACRO_NAME Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [conceptref ConceptName Link text] + [conceptref ConceptName Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [headerref path/to/header.hpp Link text] + [headerref path/to/header.hpp Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- '''escaped text (no processing/formatting)''' + '''escaped text (no processing/formatting)'''

- Escape + Escape

- \c + \c

- Single char + Single char escape

- [$image.jpg] + [$image.jpg]

- Images + Images

- [section The Section Title] + [section The Section Title]

- Section + Section

- [endsect] + [endsect]

- Section + Section

- Paragraphs + Paragraphs

- Ordered lists + Ordered lists

- Unordered + Unordered lists

- Code + Code

- [pre preformatted] + [pre preformatted]

- Preformatted + Preformatted

- [:sometext...] + [:sometext...]

- Blockquote + Blockquote

- [h1 Heading 1] + [h1 Heading 1]

- Heading + Heading

- [h2 Heading 2] + [h2 Heading 2]

- Heading + Heading

- [h3 Heading 3] + [h3 Heading 3]

- Heading + Heading

- [h4 Heading 4] + [h4 Heading 4]

- Heading + Heading

- [h5 Heading 5] + [h5 Heading 5]

- Heading + Heading

- [h6 Heading 6] + [h6 Heading 6]

- Heading + Heading

- [def macro_identifier some text] + [def macro_identifier some text]

- Macros + Macros

- [template[a b] [a] body [b]] + [template[a b] [a] body [b]]

- Templates + Templates

- [blurb advertisement or note...] + [blurb advertisement or note...]

- Blurbs + Blurbs

- [warning Warning text...] + [warning Warning text...]

- Admonitions + Admonitions

- Tables + Tables

- Variable Lists + Variable Lists

- [include someother.qbk] + [include someother.qbk]

- Include + Include

- [? symbol phrase] + [? symbol phrase]

- Conditional Generation + Conditional Generation

+
+
diff --git a/doc/html/quickbook/syntax.html b/doc/html/quickbook/syntax.html index 612eb9c..a197e9e 100755 --- a/doc/html/quickbook/syntax.html +++ b/doc/html/quickbook/syntax.html @@ -1,21 +1,21 @@ - Syntax Summary +Syntax Summary - + - +
- + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Comments
Phrase Level Elements
diff --git a/doc/html/quickbook/syntax/block.html b/doc/html/quickbook/syntax/block.html index 3cad929..04adec5 100644 --- a/doc/html/quickbook/syntax/block.html +++ b/doc/html/quickbook/syntax/block.html @@ -1,21 +1,21 @@ - Block Level Elements +Block Level Elements - + - - - + + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Document
Section
@@ -51,7 +52,8 @@

Every document must begin with a Document Info section, which should look like this: @@ -112,21 +114,22 @@ for. In its absence, version 1.1 is assumed.

- version, id, dirname, - copyright, purpose, category, - authors, license, last-revision - and source-mode are optional information. + version, id, dirname, + copyright, purpose, category, + authors, license, last-revision + and source-mode are optional information.

- source-type is a lowercase string setting the initial - Source Mode. - If the source-mode field is omitted, a default value - of c++ will be used. + source-type is a lowercase string setting the initial + Source Mode. + If the source-mode field is omitted, a default value + of c++ will be used.

Starting a new section is accomplished with:

@@ -135,8 +138,8 @@

where id is optional. id will be the filename of the generated section. If it is not present, "The Section Title" - will be normalized and become the id. Valid characters are a-Z, - A-Z, 0-9 and _. + will be normalized and become the id. Valid characters are a-Z, + A-Z, 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower case. Thus: "The Section Title" will be normalized to "the_section_title". @@ -152,7 +155,8 @@

You can include another XML file with:

@@ -165,7 +169,8 @@

Paragraphs start left-flushed and are terminated by two or more newlines. No markup is needed for paragraphs. QuickBook automatically detects paragraphs @@ -179,7 +184,8 @@

Ordered lists
@@ -193,9 +199,9 @@
# One
 # Two
 # Three
@@ -217,9 +223,9 @@
 
 
 

List hierarchies are supported. Example:

@@ -280,9 +286,9 @@

Long lines will be wrapped appropriately. Example:

@@ -311,9 +317,9 @@
* First
 * Second
 * Third
@@ -335,7 +341,8 @@
 
 
 

Mixed lists (ordered and unordered) are supported. Example:

@@ -446,10 +453,11 @@
+Code +

Preformatted code starts with a space or a tab. The code will be syntax - highlighted according to the current Source + highlighted according to the current Source Mode:

@@ -493,9 +501,9 @@

Inside code, code blocks and inline code, QuickBook does not allow any markup to avoid conflicts with the target syntax (e.g. c++). In case you @@ -523,10 +531,11 @@

Sometimes, you don't want some preformatted text to be parsed as C++. In - such cases, use the [pre ... ] markup block. + such cases, use the [pre ... ] markup block.

[pre
 
@@ -543,21 +552,22 @@
           level markup, pre (and Code) are the only ones that allow multiple newlines.
           The markup above will generate:
         

-
Some preformatted text                    Some preformatted text
+
Some preformatted text                    Some preformatted text
 
-    Some preformatted text            Some preformatted text
+    Some preformatted text            Some preformatted text
 
-        Some preformatted text    Some preformatted text
+        Some preformatted text    Some preformatted text
 
 

Notice that unlike Code, phrase markup such as font style is still permitted - inside pre blocks. + inside pre blocks.

[:sometext...]
 
@@ -572,7 +582,8 @@
[note This is a note]
 [tip This is a tip]
 [important This is important]
@@ -587,7 +598,7 @@
 [Note]
 Note
 
-

+

This is a note

@@ -596,7 +607,7 @@ [Tip] Tip -

+

This is a tip

@@ -605,7 +616,7 @@ [Important] Important -

+

This is important

@@ -614,7 +625,7 @@ [Caution] Caution -

+

This is a caution

@@ -623,19 +634,20 @@ [Warning] Warning -

+

This is a warning

These are the only admonitions supported by DocBook. - So, for example [information This is some information] + So, for example [information This is some information] is unlikely to produce the desired effect.

[h1 Heading 1]
 [h2 Heading 2]
 [h3 Heading 3]
@@ -643,50 +655,51 @@
 [h5 Heading 5]
 [h6 Heading 6]
 
-

- - Heading 1 -

-

- - Heading 2 +

+ + Heading 1

-

- - Heading 3 +

+ + Heading 2

-

- - Heading 4 +

+ + Heading 3

-
- - Heading 5 +
+ + Heading 4
+
+ + Heading 5 +
- - Heading 6 + + Heading 6

Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized - names with name="section_id.normalized_header_text" - (i.e. valid characters are a-z, A-Z, - 0-9 and _. All non-valid characters + names with name="section_id.normalized_header_text" + (i.e. valid characters are a-z, A-Z, + 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower-case. - For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). + For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). You can use:

[link section_id.normalized_header_text The link text]
 

- to link to them. See Anchor - links and Section + to link to them. See Anchor + links and Section for more info.

In cases when you don't want to care about the heading level (1 to 6), you can use the Generic Heading: @@ -733,7 +746,8 @@

[def macro_identifier some text]
 

@@ -757,19 +771,19 @@ sf_logo [Tip] Tip -

+

It's a good idea to use macro identifiers that are distinguishable. For instance, in this document, macro identifiers have two leading and trailing - underscores (e.g. __spirit__). The reason is to avoid unwanted + underscores (e.g. __spirit__). The reason is to avoid unwanted macro replacement.

- Links (URLS) and images are good candidates for macros. 1) + Links (URLS) and images are good candidates for macros. 1) They tend to change a lot. It is a good idea to place all links and images - in one place near the top to make it easy to make changes. 2) - The syntax is not pretty. It's easier to read and write, e.g. __spirit__ - than [@http://spirit.sourceforge.net Spirit]. + in one place near the top to make it easy to make changes. 2) + The syntax is not pretty. It's easier to read and write, e.g. __spirit__ + than [@http://spirit.sourceforge.net Spirit].

Some more examples: @@ -778,8 +792,8 @@ sf_logo [def __spirit__ [@http://spirit.sourceforge.net Spirit]]

- (See Images and - Links) + (See Images and + Links)

Invoking these macros: @@ -795,15 +809,15 @@ sf_logo

Quickbook has some predefined macros that you can already use.

-

Table 3. Predefined Macros

- +

Table 3. Predefined Macros

+
@@ -840,7 +854,7 @@ sf_logo @@ -857,7 +871,7 @@ sf_logo @@ -874,17 +888,19 @@ sf_logo -

- 2007-Nov-14 + 2008-Mar-15

- 06:19:55 PM + 02:07:42 PM

- C:\dev\boost\tools\quickbook\doc\quickbook.qbk + /home/daniel/boost/branches/release/tools/quickbook/doc/quickbook.qbk

+
+

Templates provide a more versatile text substitution mechanism. Templates come in handy when you need to create parameterizable, multi-line, boilerplate @@ -902,11 +918,11 @@ Hi, my name is [name]. I am [age] years old. I am a [what]. ]

-
- - Template +
+ + Template Identifier -
+

Template identifiers can either consist of:

@@ -920,11 +936,11 @@ Hi, my name is [name]. I am [age] years old. I am a [what]. A single character punctuation (a non-alphanumeric printable character) -
- - Formal +
+ + Formal Template Arguments -
+

Template formal arguments are identifiers consisting of an initial alphabetic character or the underscore, followed by zero or more alphanumeric characters @@ -932,19 +948,19 @@ Hi, my name is [name]. I am [age] years old. I am a [what].

A template formal argument temporarily hides a template of the same name - at the point where the template - is expanded. Note that the body of the person - template above refers to name age - and what as [name] [age] - and [what]. name age - and what are actually templates that exist in the duration + at the point where the template + is expanded. Note that the body of the person + template above refers to name age + and what as [name] [age] + and [what]. name age + and what are actually templates that exist in the duration of the template call.

-
- - Template +
+ + Template Body -
+

The template body can be just about any QuickBook block or phrase. There are actually two forms. Templates may be phrase or block level. Phrase @@ -965,11 +981,11 @@ replacement text... Phrase templates are typically expanded as part of phrases. Like macros, block level elements are not allowed in phrase templates.

-
- - Template +
+ + Template Expansion -
+

You expand a template this way:

@@ -1002,7 +1018,7 @@ replacement text... [Caution] Caution -

+

A word of caution: Templates are recursive. A template can call another template or even itself, directly or indirectly. There are no control structures in QuickBook (yet) so this will always mean infinite recursion. @@ -1012,15 +1028,15 @@ replacement text...

Each actual argument can be a word, a text fragment or just about any - QuickBook phrase. Arguments - are separated by the double dot ".." and terminated + QuickBook phrase. Arguments + are separated by the double dot ".." and terminated by the close parenthesis.

-
- - Nullary +
+ + Nullary Templates -
+

Nullary templates look and act like simple macros. Example:

@@ -1035,14 +1051,14 @@ replacement text... We have:

- Some squiggles...αβ + Some squiggles...αβ

The difference with macros are

  • - The explicit template + The explicit template expansion syntax. This is an advantage because, now, we don't have to use obscure naming conventions like double underscores (e.g. __alpha__) to avoid unwanted macro replacement. @@ -1055,7 +1071,7 @@ replacement text...

- The empty brackets after the template identifier (alpha[]) + The empty brackets after the template identifier (alpha[]) indicates no arguments. If the template body does not look like a template argument list, we can elide the empty brackets. Example:

@@ -1071,15 +1087,15 @@ for the journey to old age.]]] We have:

- Here's a quote from Aristotle: Education - is the best provision for the journey to old age.. + Here's a quote from Aristotle: Education + is the best provision for the journey to old age..

The disadvantage is that you can't avoid the space between the template - identifier, aristotle_quote, + identifier, aristotle_quote, and the template body "Aristotle...". This space will be part of the template body. If that space is unwanted, use empty brackets or - use the space escape: "\ ". + use the space escape: "\ ". Example:

[template tag\ _tag]
@@ -1093,26 +1109,26 @@ for the journey to old age.]]]
           We have:
         

- struct x_tag; + struct x_tag;

You have a couple of ways to do it. I personally prefer the explicit empty brackets, though.

-
- - Simple +
+ + Simple Arguments -
+

- As mentioned, arguments are separated by the double dot "..". + As mentioned, arguments are separated by the double dot "..". If there are less arguments passed than expected, QuickBook attempts to break the last argument into two or more arguments following this logic:

  • - Break the last argument into two, at the first space found ('', - '\n', \t' or '\r'). + Break the last argument into two, at the first space found ('', + '\n', \t' or '\r').
  • Repeat until there are enough arguments or if there are no more spaces @@ -1133,8 +1149,8 @@ for the journey to old age.]]]

    "w x y z" is initially treated as a single argument because we - didn't supply any ".." separators. However, - since simple expects 4 arguments, "w x y z" + didn't supply any ".." separators. However, + since simple expects 4 arguments, "w x y z" is broken down iteratively (applying the logic above) until we have "w", "x", "y" and "z".

    @@ -1155,8 +1171,8 @@ for the journey to old age.]]]

    It should be obvious now that for simple arguments with no spaces, we can - get by without separating the arguments with ".." - separators. It is possible to combine ".." + get by without separating the arguments with ".." + separators. It is possible to combine ".." separators with the argument passing simplification presented above. Example:

    [simple what do you think ..m a n?]
    @@ -1167,17 +1183,17 @@ for the journey to old age.]]]
     

    what do you think man?

    -
    - - Punctuation +
    + + Punctuation Templates -
    +

    With templates, one of our objectives is to allow us to rewrite QuickBook in QuickBook (as a qbk library). For that to happen, we need to accommodate single character punctuation templates which are fairly common in QuickBook. You might have noticed that single character punctuations are allowed as - template + template identifiers. Example:

    [template ![bar] <hey>[bar]</hey>]
    @@ -1195,7 +1211,8 @@ for the journey to old age.]]]
     
[blurb :-) [*An eye catching advertisement or note...]
 
     __spirit__ is an object-oriented recursive-descent parser generator framework
@@ -1208,9 +1225,10 @@ for the journey to old age.]]]
           will generate this:
         

[table A Simple Table
     [[Heading 1] [Heading 2] [Heading 3]]
     [[R0-C0]     [R0-C1]     [R0-C2]]
@@ -1244,8 +1263,8 @@ for the journey to old age.]]]
           will generate:
         

-

Table 4. A Simple Table

- +

Table 4. A Simple Table

+
@@ -1321,11 +1340,11 @@ for the journey to old age.]]] -
+
-

+

The table title is optional. The first row of the table is automatically - treated as the table header; that is, it is wrapped in <thead>...</thead> + treated as the table header; that is, it is wrapped in <thead>...</thead> XML tags. Note that unlike the original QuickDoc, the columns are nested in [ cells... ]. The syntax is free-format and allows big cells to be formatted nicely. Example: @@ -1355,8 +1374,8 @@ for the journey to old age.]]] and thus:

-

Table 5. Table with fat cells

- +

Table 5. Table with fat cells

+
@@ -1408,9 +1427,9 @@ for the journey to old age.]]] -
+
-

+

Here's how to have preformatted blocks of code in a table cell:

[table Table with code
@@ -1430,8 +1449,8 @@ for the journey to old age.]]]
 ]
 
-

Table 6. Table with code

- +

Table 6. Table with code

+
@@ -1471,12 +1490,14 @@ for the journey to old age.]]]

-
+
+
[variablelist A Variable List
     [[term 1] [The definition of term 1]]
     [[term 2] [The definition of term 2]]
@@ -1521,7 +1542,8 @@ for the journey to old age.]]]
 
 
 

You can include one QuickBook file from another. The syntax is simply:

@@ -1541,7 +1563,7 @@ for the journey to old age.]]]

- The [include] directive lets you specify a document + The [include] directive lets you specify a document id to use for the included file. When this id is not explicitly specified, the id defaults to the filename ("someother", in the example above). You can specify the id like this: @@ -1552,12 +1574,13 @@ for the journey to old age.]]] All auto-generated anchors will use the document id as a unique prefix. So for instance, if there is a top section in someother.qbk named "Intro", the named anchor for that section will be "someid.intro", and - you can link to it with [link someid.intro The Intro]. + you can link to it with [link someid.intro The Intro].

When documenting code, you'd surely need to present code from actual source files. While it is possible to copy some code and paste them in your QuickBook @@ -1569,10 +1592,10 @@ for the journey to old age.]]]

QuickBook's import facility provides a nice solution.

-
- - Example -
+
+ + Example +

You can effortlessly import code snippets from source code into your QuickBook. The following illustrates how this is done: @@ -1589,8 +1612,8 @@ for the journey to old age.]]]

collects specially marked-up code snippets from stub.cpp and places them in your QuickBook file as virtual templates. Each of the - specially marked-up code snippets has a name (e.g. foo - and bar in the example + specially marked-up code snippets has a name (e.g. foo + and bar in the example above). This shall be the template identifier for that particular code snippet. The second and third line above does the actual template expansion:

@@ -1603,7 +1626,7 @@ for the journey to old age.]]]

- This is the foo + This is the foo function.

@@ -1643,7 +1666,7 @@ for the journey to old age.]]]

- This is the bar + This is the bar function

@@ -1666,11 +1689,11 @@ for the journey to old age.]]]

-
- - Code +
+ + Code Snippet Markup -
+

Note how the code snippets in stub.cpp get marked up. We use distinguishable comments following the form: @@ -1682,16 +1705,16 @@ for the journey to old age.]]]

The first comment line above initiates a named code-snippet. This prefix - will not be visible in quickbook. The entire code-snippet in between //[id and //] + will not be visible in quickbook. The entire code-snippet in between //[id and //] will be inserted as a template in quickbook with name id. - The comment //] ends a code-snippet + The comment //] ends a code-snippet This too will not be visible in quickbook.

-
- - Special +
+ + Special Comments -
+

Special comments of the form:

@@ -1735,10 +1758,10 @@ for the journey to old age.]]] can be used to inhibit code from passing through to quickbook. All text between the delimeters will simply be ignored.

-
- - Callouts -
+
+ + Callouts +

Special comments of the form:

@@ -1757,9 +1780,9 @@ for the journey to old age.]]]

-std::string foo_bar() 1
+std::string foo_bar() 1
 {
-    return "foo-bar"; 2
+    return "foo-bar"; 2
 }
 

@@ -1770,14 +1793,12 @@ for the journey to old age.]]]

- + - +
-1

1

The Mythical FooBar. See Foobar for details

-2

2

return 'em, foo-bar man!

@@ -1821,20 +1842,20 @@ for the journey to old age.]]] { public: - 1x() : n(0) + 1x() : n(0) { } - 2~x() + 2~x() { } - 3int get() const + 3int get() const { return n; } - 4void set(int n_) + 4void set(int n_) { n = n_; } @@ -1848,25 +1869,21 @@ for the journey to old age.]]]

- + - + - - + - - +
-1

1

Constructor

-2

2

Destructor

-3

Get the n +

3

Get the n member variable

-4

Set the n +

4

Set the n member variable

diff --git a/doc/html/quickbook/syntax/comments.html b/doc/html/quickbook/syntax/comments.html index d7a0569..2af6687 100644 --- a/doc/html/quickbook/syntax/comments.html +++ b/doc/html/quickbook/syntax/comments.html @@ -3,19 +3,19 @@ Comments - + - - - + + + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@

Can be placed anywhere.

diff --git a/doc/html/quickbook/syntax/phrase.html b/doc/html/quickbook/syntax/phrase.html index d52a077..0950c83 100644 --- a/doc/html/quickbook/syntax/phrase.html +++ b/doc/html/quickbook/syntax/phrase.html @@ -1,21 +1,21 @@ - Phrase Level Elements +Phrase Level Elements - + - + - + - + - - + +
Boost C++ LibrariesHomeHome LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Font Styles
Replaceable
@@ -48,14 +49,15 @@
['italic], [*bold], [_underline], [^teletype], [-strikethrough]
 

will generate:

- italic, bold, underline, teletype, strikethrough + italic, bold, underline, teletype, strikethrough

Like all non-terminal phrase level elements, this can of course be nested: @@ -66,12 +68,13 @@ will generate:

- bold-italic + bold-italic

When you want content that may or must be replaced by the user, use the syntax: @@ -82,14 +85,15 @@ This will generate:

- + replacement - +

["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein
 

@@ -120,7 +124,8 @@ the true business precept.]

Simple markup for formatting text, common in many applications, is now supported: @@ -131,12 +136,12 @@ the true business precept.] will generate:

- italic, bold, underline, teletype + italic, bold, underline, teletype

Unlike QuickBook's standard formatting scheme, the rules for simpler alternatives are much stricter - [1] + [1] .

    @@ -166,14 +171,13 @@ the true business precept.]
  • A line starting with the star will be interpreted as an unordered list. - See Unordered + See Unordered lists.
-

Table 1. More Formatting Samples

- +

Table 1. More Formatting Samples

+
@@ -194,31 +198,31 @@ the true business precept.] -

- *Bold* + *Bold*

- Bold + Bold

- *Is bold* + *Is bold*

- Is bold + Is bold

- * Not bold* *Not bold * * Not bold * + * Not bold* *Not bold * * Not bold *

@@ -230,7 +234,7 @@ the true business precept.]

- This*Isn't*Bold (no bold) + This*Isn't*Bold (no bold)

@@ -242,31 +246,31 @@ the true business precept.]

- (*Bold Inside*) (parenthesis not bold) + (*Bold Inside*) (parenthesis not bold)

- (Bold Inside) (parenthesis not bold) + (Bold Inside) (parenthesis not bold)

- *(Bold Outside)* (parenthesis bold) + *(Bold Outside)* (parenthesis bold)

- (Bold Outside) (parenthesis bold) + (Bold Outside) (parenthesis bold)

- 3*4*5 = 60 (no bold) + 3*4*5 = 60 (no bold)

@@ -278,7 +282,7 @@ the true business precept.]

- 3 * 4 * 5 = 60 (no bold) + 3 * 4 * 5 = 60 (no bold)

@@ -290,79 +294,79 @@ the true business precept.]

- 3 *4* 5 = 60 (4 is bold) + 3 *4* 5 = 60 (4 is bold)

- 3 4 5 = 60 (4 is bold) + 3 4 5 = 60 (4 is bold)

- *This is bold* this is not *but this is* + *This is bold* this is not *but this is*

- This is bold this is not but this is + This is bold this is not but this is

- *This is bold*. + *This is bold*.

- This is bold. + This is bold.

- *B*. (bold B) + *B*. (bold B)

- B. (bold B) + B. (bold B)

- ['*Bold-Italic*] + ['*Bold-Italic*]

- Bold-Italic + Bold-Italic

- *side-by*/-side/ + *side-by*/-side/

- side-by-side + side-by-side

+
-

+

As mentioned, simple markups cannot go past a single block. The text from "have" to "full" in the following paragraph will be rendered as bold: @@ -373,8 +377,8 @@ One for the master, one for the dame, And one for the little boy who lives down the lane.

- Baa baa black sheep, have you any wool? Yes sir, - yes sir, three bags full! One for the master, one for the dame, + Baa baa black sheep, have you any wool? Yes sir, + yes sir, three bags full! One for the master, one for the dame, And one for the little boy who lives down the lane.

@@ -393,7 +397,8 @@ And one for the little boy who lives down the lane.

Inlining code in paragraphs is quite common when writing C++ documentation. We provide a very simple markup for this. For example, this: @@ -404,7 +409,7 @@ And one for the little boy who lives down the lane. will generate:

- This text has inlined code int main() { return 0; } + This text has inlined code int main() { return 0; } in it. The code will be syntax highlighted.

@@ -412,24 +417,23 @@ And one for the little boy who lives down the lane. -
[Note] Note

- We simply enclose the code with the tick: "`", not the - single quote: "'". - Note too that `some code` is preferred over [^some code]. +

+ We simply enclose the code with the tick: "`", not the + single quote: "'". + Note too that `some code` is preferred over [^some code].

- Preformatted code simply starts with a space or a tab (See Code). + Preformatted code simply starts with a space or a tab (See Code). However, such a simple syntax cannot be used as phrase elements in lists - (See Ordered - lists and Unordered - lists), tables (See Tables), + (See Ordered + lists and Unordered + lists), tables (See Tables), etc. Inline code (see above) can. The problem is, inline code does not allow formatting with newlines, spaces, and tabs. These are lost.

@@ -468,17 +472,18 @@ And one for the little boy who lives down the lane.

If a document contains more than one type of source code then the source mode may be changed dynamically as the document is processed. All QuickBook documents are initially in C++ mode by default, though an alternative initial - value may be set in the Document + value may be set in the Document section.

- To change the source mode, use the [source-mode] markup, - where source-mode is one of the supported modes. For + To change the source mode, use the [source-mode] markup, + where source-mode is one of the supported modes. For example, this:

Python's [python] `import` is rather like C++'s [c++] `#include`. A
@@ -489,14 +494,14 @@ C++ comment `// looks like this` whereas a Python comment [python]
           will generate:
         

- Python's import is rather - like C++'s #include. - A C++ comment // looks like this - whereas a Python comment #looks like this. + Python's import is rather + like C++'s #include. + A C++ comment // looks like this + whereas a Python comment #looks like this.

-

Table 2. Supported Source Modes

- +

Table 2. Supported Source Modes

+
@@ -522,7 +527,7 @@ C++ comment `// looks like this` whereas a Python comment [python] @@ -534,26 +539,27 @@ C++ comment `// looks like this` whereas a Python comment [python] -

- [c++] + [c++]

- [python] + [python]

+
-
+
-
[Note] Note

+

The source mode strings are lowercase.

[br]
 
@@ -561,37 +567,39 @@ C++ comment `// looks like this` whereas a Python comment [python] -
[Warning] Warning

- [br] is now deprecated. Blurbs, - Admonitions - and table cells (see Tables) +

+ [br] is now deprecated. Blurbs, + Admonitions + and table cells (see Tables) may now contain paragraphs.

[#named_anchor]
 

A named anchor is a hook that can be referenced by a link elsewhere in - the document. You can then reference an anchor with [link named_anchor -Some link text]. - See Anchor links, - Section and Heading. + the document. You can then reference an anchor with [link named_anchor +Some link text]. + See Anchor links, + Section and Heading.

[@http://www.boost.org this is [*boost's] website....]
 

will generate:

- this is boost's + this is boost's website....

@@ -613,29 +621,31 @@ Some link text].

You can link within a document using:

[link section_id.normalized_header_text The link text]
 

- See sections Section - and Heading for + See sections Section + and Heading for more info.

In addition, you can link internally to an XML refentry like:

[link xml.refentry The link text]
 

- This gets converted into <link linkend="xml.refentry">The - link text</link>. + This gets converted into <link linkend="xml.refentry">The + link text</link>.

Like URLs, the link text is optional. If this is not present, the link @@ -644,12 +654,13 @@ Some link text].

[link xml.refentry]
 

- This gets converted into <link linkend="xml.refentry">xml.refentry</link>. + This gets converted into <link linkend="xml.refentry">xml.refentry</link>.

If you want to link to a function, class, member, enum, concept or header in the reference section, you can use: @@ -675,7 +686,8 @@ Some link text].

The escape mark-up is used when we don't want to do any processing.

@@ -692,31 +704,31 @@ escape (no processing/formatting) '''

- This is direct XML markup + This is direct XML markup

-
[Important] Important

+

Be careful when using the escape. The text must conform to BoostBook/DocBook syntax.

The backslash may be used to escape a single punctuation character. The punctuation immediately after the backslash is passed without any processing. - This is useful when we need to escape QuickBook punctuations such as [ and ]. - For example, how do you escape the triple quote? Simple: \'\'\' + This is useful when we need to escape QuickBook punctuations such as [ and ]. + For example, how do you escape the triple quote? Simple: \'\'\'

- \n + \n has a special meaning. It is used to generate line breaks.

@@ -724,28 +736,30 @@ escape (no processing/formatting) -
[Warning] Warning

- \n - and [br] are now deprecated. Blurbs, - Admonitions - and table cells (see Tables) +

+ \n + and [br] are now deprecated. Blurbs, + Admonitions + and table cells (see Tables) may now contain paragraphs.

- The escaped space: \ also + The escaped space: \ also has a special meaning. The escaped space is removed from the output.

[$image.jpg]
 
Macro Expansion
@@ -754,45 +768,46 @@ escape (no processing/formatting)

As of version 1.3, QuickBook supports footnotes. Just put the text of the - footnote in a [footnote] block, and the text will be put at the + footnote in a [footnote] block, and the text will be put at the bottom of the current page. For example, this:

[footnote A sample footnote]
 

will generate this - [2] + [2] .

__a_macro_identifier__
 

- See Macros for details. + See Macros for details.

[a_template_identifier]
 

- See Templates + See Templates for details.

- Like C++ #ifdef, you can generate + Like C++ #ifdef, you can generate phrases depending on the presence of a macro. Example:

[? __to_be__ To be or not to be]
@@ -814,22 +829,22 @@ escape (no processing/formatting)
         

Yes! - [3] + [3]



-

[1] +

[1] Thanks to David Barrett, author of Qwiki, for sharing these samples and teaching me these obscure formatting rules. I wasn't sure at all if Spirit, being more or less a formal EBNF parser, can handle the context sensitivity and ambiguity.

-

[2] +

[2] A sample footnote

-

[3] +

[3] Conditional Generation makes quickbook turing complete.

From 39ae9b0c14e82437f93ad18b574ea4f3d3e615be Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Tue, 15 Jul 2008 15:05:07 +0000 Subject: [PATCH 15/94] merge from trunk [SVN r47445] --- detail/actions.cpp | 85 +- doc/html/index.html | 8 +- doc/html/quickbook/change_log.html | 45 +- doc/html/quickbook/editors.html | 18 +- doc/html/quickbook/editors/kde_support.html | 113 +- doc/html/quickbook/editors/scite.html | 25 +- doc/html/quickbook/faq.html | 29 +- doc/html/quickbook/install.html | 15 +- doc/html/quickbook/install/linux.html | 39 +- doc/html/quickbook/install/macosx.html | 47 +- doc/html/quickbook/install/windows.html | 51 +- doc/html/quickbook/intro.html | 13 +- doc/html/quickbook/ref.html | 220 +- doc/html/quickbook/syntax.html | 9 +- doc/html/quickbook/syntax/block.html | 449 +- doc/html/quickbook/syntax/comments.html | 11 +- doc/html/quickbook/syntax/phrase.html | 271 +- test/code-block-1.gold | 3 +- test/code-block-2.gold | 3 +- test/import.gold | 6 +- test/quickbook-manual.gold | 5074 +++++++++---------- test/templates.gold | 3 +- test/templates.quickbook | 7 + 23 files changed, 3251 insertions(+), 3293 deletions(-) mode change 100755 => 100644 doc/html/index.html mode change 100755 => 100644 doc/html/quickbook/ref.html mode change 100755 => 100644 doc/html/quickbook/syntax.html diff --git a/detail/actions.cpp b/detail/actions.cpp index 9e3abe1..ffe59ca 100644 --- a/detail/actions.cpp +++ b/detail/actions.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "./actions.hpp" #include "./utils.hpp" @@ -324,7 +325,11 @@ namespace quickbook temp.swap(str); phrase.swap(save); - out << "\n"; + // + // We must not place a \n after the tag + // otherwise PDF output starts code blocks with a blank line: + // + out << ""; out << str; out << "\n"; } @@ -376,9 +381,73 @@ namespace quickbook { fs::path const img_path(std::string(first, last)); + std::string attr_text; + if(fs::extension(img_path) == ".svg") + { + // + // SVG's need special handling: + // + // 1) We must set the "format" attribute, otherwise + // HTML generation produces code that will not display + // the image at all. + // 2) We need to set the "contentwidth" and "contentdepth" + // attributes, otherwise the image will be displayed inside + // a tiny box with scrollbars (Firefox), or else cropped to + // fit in a tiny box (IE7). + // + attr_text = " format=\"SVG\""; + // + // Image paths are relative to the html subdirectory: + // + fs::path img; + if(img_path.root_path().empty()) + img = "html" / img_path; // relative path + else + img = img_path; // absolute path + // + // Now load the SVG file: + // + std::string svg_text; + fs::ifstream fs(img); + char c; + while(fs.get(c) && fs.good()) + svg_text.push_back(c); + // + // Extract the svg header from the file: + // + std::string::size_type a, b; + a = svg_text.find("', a); + svg_text = (a == std::string::npos) ? "" : svg_text.substr(a, b - a); + // + // Now locate the "width" and "height" attributes + // and borrow their values: + // + a = svg_text.find("width"); + a = svg_text.find('=', a); + a = svg_text.find('\"', a); + b = svg_text.find('\"', a + 1); + if(a != std::string::npos) + { + attr_text.append(" contentwidth="); + attr_text.append(svg_text.begin() + a, svg_text.begin() + b + 1); + } + a = svg_text.find("height"); + a = svg_text.find('=', a); + a = svg_text.find('\"', a); + b = svg_text.find('\"', a + 1); + if(a != std::string::npos) + { + attr_text.append(" contentdepth="); + attr_text.append(svg_text.begin() + a, svg_text.begin() + b + 1); + } + } + phrase << ""; - phrase << ""; @@ -615,7 +684,11 @@ namespace quickbook { boost::spirit::file_position const pos = first.get_position(); detail::outerr(pos.file,pos.line) - << "Expanding template" << std::endl; + << "Expanding template:" << template_info[0] << std::endl + << "------------------begin------------------" << std::endl + << body + << "------------------end--------------------" << std::endl + << std::endl; actions.pop(); // restore the actions' states --actions.template_depth; return; @@ -992,7 +1065,7 @@ namespace quickbook fs::path include_search(fs::path const & current, std::string const & name) { fs::path path(name,fs::native); - + // If the path is relative, try and resolve it. if (!path.is_complete()) { @@ -1001,7 +1074,7 @@ namespace quickbook { return current / path; } - + // Search in each of the include path locations. BOOST_FOREACH(std::string const & p, include_path) { @@ -1013,7 +1086,7 @@ namespace quickbook } } } - + return path; } } diff --git a/doc/html/index.html b/doc/html/index.html old mode 100755 new mode 100644 index 8a453f9..71527c9 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -3,9 +3,9 @@ Quickbook 1.4 - + - + @@ -34,7 +34,7 @@
-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

@@ -70,7 +70,7 @@
- +

Last revised: March 15, 2008 at 14:07:42 GMT

Last revised: May 21, 2008 at 03:54:31 GMT


diff --git a/doc/html/quickbook/change_log.html b/doc/html/quickbook/change_log.html index e96ffaa..41c81cc 100644 --- a/doc/html/quickbook/change_log.html +++ b/doc/html/quickbook/change_log.html @@ -1,13 +1,13 @@ -Change Log + Change Log - + - - + + @@ -24,12 +24,11 @@ +

+ + Version 1.3 +

  • Quickbook file inclusion [include]. @@ -66,7 +65,7 @@
  • Fully qualified section and headers. Subsection names are concatenated to - the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name + the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name
  • Better &nbsp; and whitespace handling in code snippets. @@ -94,10 +93,10 @@ Replaceable, with the [~replacement] syntax.
-

- - Version 1.4 -

+

+ + Version 1.4 +

  • Generic Headers @@ -116,7 +115,7 @@
  • Allow escape of spaces. The escaped space is removed from the output. Syntax: - \ . + \ .
  • Nested comments are now allowed. @@ -125,7 +124,7 @@ Quickbook blocks can nest inside comments.
  • -Import facility. +Import facility.
  • Callouts on imported code @@ -134,21 +133,21 @@ Simple markups can now span a whole block.
  • -Blurbs, Admonitions - and table cells (see Tables) +Blurbs, Admonitions + and table cells (see Tables) may now contain paragraphs.
  • -\n - and [br] are now deprecated. +\n + and [br] are now deprecated.
  • -Conditional Generation. +Conditional Generation. Ala C++ #ifdef.
  • Searching of included and imported files in an extensible search path with - --include-path (-I) option. + --include-path (-I) option.
diff --git a/doc/html/quickbook/editors.html b/doc/html/quickbook/editors.html index fcf828c..2900de5 100644 --- a/doc/html/quickbook/editors.html +++ b/doc/html/quickbook/editors.html @@ -1,13 +1,13 @@ -Editor Support + Editor Support - + - - + +
@@ -24,8 +24,7 @@
Scintilla Text Editor
KDE Support
@@ -35,14 +34,11 @@ The following sections list the settings for some editors which can help make editing quickbook files a bit easier.

-
diff --git a/doc/html/quickbook/editors/kde_support.html b/doc/html/quickbook/editors/kde_support.html index 740a8df..d772752 100644 --- a/doc/html/quickbook/editors/kde_support.html +++ b/doc/html/quickbook/editors/kde_support.html @@ -3,11 +3,11 @@ KDE Support - + - - - + + +
@@ -24,12 +24,11 @@ +

+ + boost::hs::quickbook +

boost::hs::quickbook is a syntax highlighting designed to work with Katepart. It can be used in KWrite, Kate, Konqueror and KDevelop, and supports all @@ -49,11 +48,11 @@

- html generated from this .qbk file + html generated from this .qbk file

-

Table 7. Code examples

-
+

Table 7. Code examples

+
@@ -85,8 +84,8 @@ -

- for(int k=0; - k<10; k++) v+=k; + for(int k=0; + k<10; k++) v+=k;

@@ -103,12 +102,12 @@

- { int + { int k; while( k < 10 ) - { v+=k; k++ } } + { v+=k; k++ } }

@@ -125,10 +124,10 @@

- while( + while( true ) { v+=1; - } + }

@@ -138,34 +137,34 @@
+
-
- - Code Folding +

+ + Code Folding -

+

boost::hs goes far beyond simple coloring. One useful thing you can get the editor to do is to mark regions. They appear in a small grey line and each region can be folded or unfolded independently.

-
- - Auto +

+ + Auto Comment / Uncomment -

+

Another important feature is the possibility to auto-comment or uncomment some piece of code (Tools - Comment). Commented regions can be uncommented simple calling the uncomment command while being in it.

-
- - Styles reference +

+ + Styles reference -

+
@@ -193,7 +192,7 @@

- plain text + plain text

@@ -210,7 +209,7 @@

- formatted text + formatted text

@@ -227,7 +226,7 @@

- structure + structure

@@ -245,7 +244,7 @@

- macros + macros

@@ -263,7 +262,7 @@

- templates + templates

@@ -280,7 +279,7 @@

- anchors + anchors

@@ -297,7 +296,7 @@

- comments + comments

@@ -314,7 +313,7 @@

- tables + tables

@@ -331,7 +330,7 @@

- variable lists + variable lists

@@ -348,7 +347,7 @@

- c++ code + c++ code

@@ -365,7 +364,7 @@

- paths + paths

@@ -382,7 +381,7 @@

- IDE specific + IDE specific

@@ -398,10 +397,10 @@
-
- - About boost::hs -
+

+ + About boost::hs +

boost.hs.logo

@@ -415,15 +414,15 @@ [Note] Note -

+

boost::hs::cpp support QuickBook code import comments style!

-
- - Installing +

+ + Installing boost::hs -

+

There exist an ongoing effort to push boost::hs upstream to the KatePart project. In a few months KDE may have native Quickbook support! For the moment @@ -437,13 +436,13 @@ [Note] Note -

- A copy of boost::hs::quickbook and boost::hs::cpp is available in boost/tools/quickbook/extra/katepart. +

+ A copy of boost::hs::quickbook and boost::hs::cpp is available in boost/tools/quickbook/extra/katepart.

- In order to install it you must copy the content in the folder katepart/syntax/ to the appropriate katepart syntax - folder in your machine. In general this folder will be in /usr/share/apps/katepart/syntax. + In order to install it you must copy the content in the folder katepart/syntax/ to the appropriate katepart syntax + folder in your machine. In general this folder will be in /usr/share/apps/katepart/syntax. A bash script named install.sh is included that copy the files to this folder.

diff --git a/doc/html/quickbook/editors/scite.html b/doc/html/quickbook/editors/scite.html index e533b40..3c6698d 100644 --- a/doc/html/quickbook/editors/scite.html +++ b/doc/html/quickbook/editors/scite.html @@ -1,12 +1,12 @@ -Scintilla Text Editor + Scintilla Text Editor - + - - + + @@ -24,8 +24,7 @@

@@ -39,12 +38,9 @@ The Scintilla Text Editor (SciTE) is a free source code editor for Win32 and X. It uses the SCIntilla source code editing component.

-

You can use the following settings to highlight quickbook tags when editing quickbook files. @@ -61,12 +57,9 @@ comment.box.start.props=[/ comment.box.middle.props= comment.box.end.props=]

- diff --git a/doc/html/quickbook/faq.html b/doc/html/quickbook/faq.html index 6773e68..36a2094 100644 --- a/doc/html/quickbook/faq.html +++ b/doc/html/quickbook/faq.html @@ -1,13 +1,13 @@ -Frequently Asked Questions + Frequently Asked Questions - + - +
@@ -24,13 +24,12 @@ +

+ + Can I use QuickBook for non-Boost documentation? -

+

QuickBook can be used for non-Boost documentation with a little extra work.

@@ -61,18 +60,18 @@ boostbook standalone : my_doc : - <xsl:param>boost.image.srcimages/my_project_logo.png - <xsl:param>boost.image.alt"\"My Project\"" + <xsl:param>boost.image.srcimages/my_project_logo.png + <xsl:param>boost.image.alt"\"My Project\"" <xsl:param>boost.image.w=100 <xsl:param>boost.image.h=50 <xsl:param>nav.layout=none ; -

- - Is +

+ + Is there an easy way to convert BoostBook docs to QuickBook? -

+

There's a stylesheet that allows Boostbook generated HTML to be viewed as quickbook source, see http://svn.boost.org/trac/boost/wiki/QuickbookSourceStylesheetProject, diff --git a/doc/html/quickbook/install.html b/doc/html/quickbook/install.html index ade87e9..7b33e1f 100644 --- a/doc/html/quickbook/install.html +++ b/doc/html/quickbook/install.html @@ -1,13 +1,13 @@ -Installation and configuration + Installation and configuration - + - - + +

@@ -24,8 +24,7 @@
Mac OS X
Windows 2000, XP, 2003, Vista
@@ -38,8 +37,8 @@

Before continuing, it is very important that you keep this in mind: if you try to build some documents and the process breaks due to misconfiguration, - be absolutely sure to delete any bin - and bin.v2 directories generated by the build before + be absolutely sure to delete any bin + and bin.v2 directories generated by the build before trying again. Otherwise your configuration fixes will not take any effect.

diff --git a/doc/html/quickbook/install/linux.html b/doc/html/quickbook/install/linux.html index 683296a..c6b7253 100644 --- a/doc/html/quickbook/install/linux.html +++ b/doc/html/quickbook/install/linux.html @@ -1,13 +1,13 @@ -Debian, Ubuntu + Debian, Ubuntu - + - - - + + +
@@ -24,30 +24,29 @@

The following instructions apply to Debian and its derivatives. They are based on a Ubuntu Edgy install but should work on other Debian based systems.

- First install the bjam, - xsltproc, docbook-xsl and - docbook-xml packages. For example, using apt-get: + First install the bjam, + xsltproc, docbook-xsl and + docbook-xml packages. For example, using apt-get:

 sudo apt-get install xsltproc docbook-xsl docbook-xml
 

If you're planning on building boost's documentation, you'll also need to - install the doxygen package + install the doxygen package as well.

Next, we need to configure Boost Build to compile BoostBook files. Add the - following to your user-config.jam file, which should be in your home + following to your user-config.jam file, which should be in your home directory. If you don't have one, create a file containing this text. For - more information on setting up user-config.jam, see + more information on setting up user-config.jam, see the Boost Build documentation.

@@ -68,19 +67,19 @@

  1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook).
  2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
  3. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) - to a safe place. The traditional location is /usr/local/bin. + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) + to a safe place. The traditional location is /usr/local/bin.
  4. - Add the following to your user-config.jam + Add the following to your user-config.jam file, using the full path of the quickbook executable:
diff --git a/doc/html/quickbook/install/macosx.html b/doc/html/quickbook/install/macosx.html index 168c3ca..e664184 100644 --- a/doc/html/quickbook/install/macosx.html +++ b/doc/html/quickbook/install/macosx.html @@ -1,13 +1,13 @@ -Mac OS X + Mac OS X - + - - - + + +
@@ -24,8 +24,7 @@

@@ -45,13 +44,13 @@

The text below assumes you want to install all the necessary utilities in a system-wide location, allowing any user in the machine to have access to - them. Therefore, all files will be put in the /usr/local + them. Therefore, all files will be put in the /usr/local hierarchy. If you do not want this, you can choose any other prefix such - as ~/Applications + as ~/Applications for a single-user installation.

- Mac OS X comes with xsltproc + Mac OS X comes with xsltproc and all related libraries preinstalled, so you do not need to take any extra steps to set them up. It is probable that future versions will include them too, but these instructions may not apply to older versions. @@ -62,16 +61,16 @@

  1. Download Docbook - XML 4.2 and unpack it inside /usr/local/share/xml/docbook/4.2. + XML 4.2 and unpack it inside /usr/local/share/xml/docbook/4.2.
  2. Download the latest Docbook - XSL version and unpack it. Put the results in /usr/local/share/xsl/docbook, thus effectively removing the + XSL version and unpack it. Put the results in /usr/local/share/xsl/docbook, thus effectively removing the version number from the directory name (for simplicity).
  3. - Add the following to your user-config.jam - file, which should live in your home directory (/Users/<your_username>). + Add the following to your user-config.jam + file, which should live in your home directory (/Users/<your_username>). You must already have it somewhere or otherwise you could not be building Boost (i.e. missing tools configuration).
  4. @@ -91,20 +90,20 @@

    1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook).
    2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
    3. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) to a safe place. Following our previous example, you can install it into: - /usr/local/bin. + /usr/local/bin.
    4. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
    @@ -120,14 +119,14 @@
    1. Go to the downloads - section and get the disk image (dmg + section and get the disk image (dmg file) for Mac OS X.
    2. - Open the disk image and drag the Doxygen application to your Applications folder to install it. + Open the disk image and drag the Doxygen application to your Applications folder to install it.
    3. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
    diff --git a/doc/html/quickbook/install/windows.html b/doc/html/quickbook/install/windows.html index aca71f1..605c89b 100644 --- a/doc/html/quickbook/install/windows.html +++ b/doc/html/quickbook/install/windows.html @@ -1,13 +1,13 @@ -Windows 2000, XP, 2003, Vista + Windows 2000, XP, 2003, Vista - + - - - + + +
@@ -24,8 +24,7 @@

@@ -45,39 +44,39 @@

  1. - First of all you need to have a copy of xsltproc + First of all you need to have a copy of xsltproc for Windows. There are many ways to get this tool, but to keep things simple, use the binary packages made by Igor Zlatkovic. At the very least, you need to download the following - packages: iconv, zlib, libxml2 - and libxslt. + packages: iconv, zlib, libxml2 + and libxslt.
  2. Unpack all these packages in the same directory so that you get unique - bin, include - and lib directories within - the hierarchy. These instructions use C:\Users\example\Documents\boost\xml + bin, include + and lib directories within + the hierarchy. These instructions use C:\Users\example\Documents\boost\xml as the root for all files.
  3. - From the command line, go to the bin - directory and launch xsltproc.exe + From the command line, go to the bin + directory and launch xsltproc.exe to ensure it works. You should get usage information on screen.
  4. Download Docbook XML 4.2 and unpack it in the same directory used above. That is: - C:\Users\example\Documents\boost\xml\docbook-xml. + C:\Users\example\Documents\boost\xml\docbook-xml.
  5. Download the latest Docbook XSL version and unpack it, again in the same directory used before. To make things easier, rename the directory created during the extraction - to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. + to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl.
  6. - Add the following to your user-config.jam - file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). + Add the following to your user-config.jam + file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). You must already have it somewhere or otherwise you could not be building Boost (i.e. missing tools configuration).
  7. @@ -98,20 +97,20 @@

    1. - Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). + Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook).
    2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
    3. - Copy the resulting quickbook.exe - binary (located under the BOOST_ROOT\bin.v2 hierarchy) + Copy the resulting quickbook.exe + binary (located under the BOOST_ROOT\bin.v2 hierarchy) to a safe place. Following our previous example, you can install it into: - C:\Users\example\Documents\boost\xml\bin. + C:\Users\example\Documents\boost\xml\bin.
    4. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
    diff --git a/doc/html/quickbook/intro.html b/doc/html/quickbook/intro.html index 1c0ee4d..9a2a57c 100644 --- a/doc/html/quickbook/intro.html +++ b/doc/html/quickbook/intro.html @@ -1,13 +1,13 @@ -Introduction + Introduction - + - +
@@ -24,14 +24,13 @@

- Why program by hand in five days - what you can spend five years of your life automating? + Why program by hand in five days + what you can spend five years of your life automating?

diff --git a/doc/html/quickbook/ref.html b/doc/html/quickbook/ref.html old mode 100755 new mode 100644 index c4f782c..c12acbc --- a/doc/html/quickbook/ref.html +++ b/doc/html/quickbook/ref.html @@ -1,12 +1,12 @@ -Quick Reference + Quick Reference - + - +
@@ -23,13 +23,12 @@

-

Table 8. Syntax Compendium

-
+

Table 8. Syntax Compendium

+
@@ -61,12 +60,12 @@ @@ -78,13 +77,13 @@ @@ -92,18 +91,18 @@ @@ -116,13 +115,13 @@ @@ -130,18 +129,18 @@ @@ -154,13 +153,13 @@ @@ -168,19 +167,19 @@ @@ -192,12 +191,12 @@ @@ -209,12 +208,12 @@ @@ -226,12 +225,12 @@ @@ -243,12 +242,13 @@ @@ -260,13 +260,13 @@ @@ -278,12 +278,12 @@ @@ -295,12 +295,12 @@ @@ -312,12 +312,12 @@ @@ -329,12 +329,12 @@ @@ -346,12 +346,12 @@ @@ -364,12 +364,12 @@ @@ -382,12 +382,12 @@ @@ -400,12 +400,12 @@ @@ -418,12 +418,12 @@ @@ -436,12 +436,12 @@ @@ -454,12 +454,12 @@ @@ -472,12 +472,12 @@ @@ -489,12 +489,13 @@ @@ -507,12 +508,12 @@ @@ -524,12 +525,12 @@ @@ -541,12 +542,12 @@ @@ -564,7 +565,7 @@ @@ -587,7 +588,8 @@ @@ -610,7 +612,8 @@ @@ -628,7 +631,7 @@ @@ -640,12 +643,12 @@ @@ -657,12 +660,12 @@ @@ -674,12 +677,12 @@ @@ -691,12 +694,12 @@ @@ -708,12 +711,12 @@ @@ -725,12 +728,12 @@ @@ -742,12 +745,12 @@ @@ -759,12 +762,12 @@ @@ -776,12 +779,12 @@ @@ -793,12 +796,12 @@ @@ -810,12 +813,12 @@ @@ -827,12 +830,12 @@ @@ -856,7 +859,7 @@ @@ -880,7 +883,7 @@ @@ -892,12 +895,12 @@ @@ -909,19 +912,18 @@ -

- [/ some comment] + [/ some comment]

- Comments + Comments

- ['italics] or /italics/ + ['italics] or /italics/

- Font Styles - and Simple + Font Styles + and Simple formatting

- bold + bold

- [*bold] or *bold* + [*bold] or *bold*

- Font Styles - and Simple + Font Styles + and Simple formatting

- [_underline] or _underline_ + [_underline] or _underline_

- Font Styles - and Simple + Font Styles + and Simple formatting

- teletype + teletype

- [^teletype] or =teletype= + [^teletype] or =teletype=

- Font Styles - and Simple + Font Styles + and Simple formatting

- [-strikethrough] + [-strikethrough]

- Font Styles - and Simple + Font Styles + and Simple formatting

- + replaceable - +

- [~replaceable] + [~replaceable]

- Replaceble + Replaceble

- [c++] or [python] + [c++] or [python]

- Source Mode + Source Mode

- `int main();` + `int main();`

- Inline code + Inline code

- ``int main();`` + ``int main();``

- Code + Code

- ``from c++ to QuickBook`` + ``from c++ to QuickBook``

- Escaping Back To QuickBook + Escaping Back To QuickBook

- [br] or \n + [br] or \n

- line-break - DEPRECATED + line-break + DEPRECATED

- [#anchor] + [#anchor]

- Anchors + Anchors

- [@http://www.boost.org Boost] + [@http://www.boost.org Boost]

- Links + Links

- [link section.anchor Link text] + [link section.anchor Link text]

- Anchor links + Anchor links

- [link xml.refentry Link text] + [link xml.refentry Link text]

- refentry links + refentry links

- [funcref fully::qualified::function_name Link text] + [funcref fully::qualified::function_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [classref fully::qualified::class_name Link text] + [classref fully::qualified::class_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [memberref fully::qualified::member_name Link text] + [memberref fully::qualified::member_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [enumref fully::qualified::enum_name Link text] + [enumref fully::qualified::enum_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [macroref MACRO_NAME Link text] + [macroref MACRO_NAME Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [conceptref ConceptName Link text] + [conceptref ConceptName Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [headerref path/to/header.hpp Link text] + [headerref path/to/header.hpp Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- '''escaped text (no processing/formatting)''' + '''escaped text (no processing/formatting)'''

- Escape + Escape

- \c + \c

- Single char + Single char escape

- [$image.jpg] + [$image.jpg]

- Images + Images

- [section The Section Title] + [section The Section Title]

- Section + Section

- [endsect] + [endsect]

- Section + Section

- Paragraphs + Paragraphs

- Ordered lists + Ordered lists

- Unordered + Unordered lists

- Code + Code

- [pre preformatted] + [pre preformatted]

- Preformatted + Preformatted

- [:sometext...] + [:sometext...]

- Blockquote + Blockquote

- [h1 Heading 1] + [h1 Heading 1]

- Heading + Heading

- [h2 Heading 2] + [h2 Heading 2]

- Heading + Heading

- [h3 Heading 3] + [h3 Heading 3]

- Heading + Heading

- [h4 Heading 4] + [h4 Heading 4]

- Heading + Heading

- [h5 Heading 5] + [h5 Heading 5]

- Heading + Heading

- [h6 Heading 6] + [h6 Heading 6]

- Heading + Heading

- [def macro_identifier some text] + [def macro_identifier some text]

- Macros + Macros

- [template[a b] [a] body [b]] + [template[a b] [a] body [b]]

- Templates + Templates

- [blurb advertisement or note...] + [blurb advertisement or note...]

- Blurbs + Blurbs

- [warning Warning text...] + [warning Warning text...]

- Admonitions + Admonitions

- Tables + Tables

- Variable Lists + Variable Lists

- [include someother.qbk] + [include someother.qbk]

- Include + Include

- [? symbol phrase] + [? symbol phrase]

- Conditional Generation + Conditional Generation

+ -
diff --git a/doc/html/quickbook/syntax.html b/doc/html/quickbook/syntax.html old mode 100755 new mode 100644 index a197e9e..7fc2a0d --- a/doc/html/quickbook/syntax.html +++ b/doc/html/quickbook/syntax.html @@ -1,12 +1,12 @@ -Syntax Summary + Syntax Summary - + - + @@ -24,8 +24,7 @@
Comments
Phrase Level Elements
diff --git a/doc/html/quickbook/syntax/block.html b/doc/html/quickbook/syntax/block.html index 04adec5..d5e2474 100644 --- a/doc/html/quickbook/syntax/block.html +++ b/doc/html/quickbook/syntax/block.html @@ -1,13 +1,13 @@ -Block Level Elements + Block Level Elements - + - - - + + +
@@ -24,8 +24,7 @@
Document
Section
@@ -52,8 +51,7 @@

Every document must begin with a Document Info section, which should look like this: @@ -114,22 +112,21 @@ for. In its absence, version 1.1 is assumed.

- version, id, dirname, - copyright, purpose, category, - authors, license, last-revision - and source-mode are optional information. + version, id, dirname, + copyright, purpose, category, + authors, license, last-revision + and source-mode are optional information.

- source-type is a lowercase string setting the initial - Source Mode. - If the source-mode field is omitted, a default value - of c++ will be used. + source-type is a lowercase string setting the initial + Source Mode. + If the source-mode field is omitted, a default value + of c++ will be used.

Starting a new section is accomplished with:

@@ -138,8 +135,8 @@

where id is optional. id will be the filename of the generated section. If it is not present, "The Section Title" - will be normalized and become the id. Valid characters are a-Z, - A-Z, 0-9 and _. + will be normalized and become the id. Valid characters are a-Z, + A-Z, 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower case. Thus: "The Section Title" will be normalized to "the_section_title". @@ -155,8 +152,7 @@

You can include another XML file with:

@@ -169,8 +165,7 @@

Paragraphs start left-flushed and are terminated by two or more newlines. No markup is needed for paragraphs. QuickBook automatically detects paragraphs @@ -184,8 +179,7 @@

Ordered lists
@@ -199,9 +193,9 @@
# One
 # Two
 # Three
@@ -223,9 +217,9 @@
 
 
 

List hierarchies are supported. Example:

@@ -286,9 +280,9 @@

Long lines will be wrapped appropriately. Example:

@@ -317,9 +311,9 @@
* First
 * Second
 * Third
@@ -341,8 +335,7 @@
 
 
 

Mixed lists (ordered and unordered) are supported. Example:

@@ -453,11 +446,10 @@

-Code -

+Code

Preformatted code starts with a space or a tab. The code will be syntax - highlighted according to the current Source + highlighted according to the current Source Mode:

@@ -501,9 +493,9 @@

Inside code, code blocks and inline code, QuickBook does not allow any markup to avoid conflicts with the target syntax (e.g. c++). In case you @@ -531,11 +523,10 @@

Sometimes, you don't want some preformatted text to be parsed as C++. In - such cases, use the [pre ... ] markup block. + such cases, use the [pre ... ] markup block.

[pre
 
@@ -552,22 +543,21 @@
           level markup, pre (and Code) are the only ones that allow multiple newlines.
           The markup above will generate:
         

-
Some preformatted text                    Some preformatted text
+
Some preformatted text                    Some preformatted text
 
-    Some preformatted text            Some preformatted text
+    Some preformatted text            Some preformatted text
 
-        Some preformatted text    Some preformatted text
+        Some preformatted text    Some preformatted text
 
 

Notice that unlike Code, phrase markup such as font style is still permitted - inside pre blocks. + inside pre blocks.

[:sometext...]
 
@@ -582,8 +572,7 @@
[note This is a note]
 [tip This is a tip]
 [important This is important]
@@ -598,7 +587,7 @@
 
-
[Note] Note

+

This is a note

@@ -607,7 +596,7 @@ [Tip] Tip -

+

This is a tip

@@ -616,7 +605,7 @@ [Important] Important -

+

This is important

@@ -625,7 +614,7 @@ [Caution] Caution -

+

This is a caution

@@ -634,20 +623,19 @@ [Warning] Warning -

+

This is a warning

These are the only admonitions supported by DocBook. - So, for example [information This is some information] + So, for example [information This is some information] is unlikely to produce the desired effect.

[h1 Heading 1]
 [h2 Heading 2]
 [h3 Heading 3]
@@ -655,51 +643,50 @@
 [h5 Heading 5]
 [h6 Heading 6]
 
-

- - Heading 1 +

+ + Heading 1 +

+

+ + Heading 2

-

- - Heading 2 +

+ + Heading 3

-

- - Heading 3 +

+ + Heading 4

-
- - Heading 4 +
+ + Heading 5
-
- - Heading 5 -
- - Heading 6 + + Heading 6

Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized - names with name="section_id.normalized_header_text" - (i.e. valid characters are a-z, A-Z, - 0-9 and _. All non-valid characters + names with name="section_id.normalized_header_text" + (i.e. valid characters are a-z, A-Z, + 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower-case. - For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). + For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). You can use:

[link section_id.normalized_header_text The link text]
 

- to link to them. See Anchor - links and Section + to link to them. See Anchor + links and Section for more info.

In cases when you don't want to care about the heading level (1 to 6), you can use the Generic Heading: @@ -746,8 +733,7 @@

[def macro_identifier some text]
 

@@ -771,19 +757,19 @@ sf_logo [Tip] Tip -

+

It's a good idea to use macro identifiers that are distinguishable. For instance, in this document, macro identifiers have two leading and trailing - underscores (e.g. __spirit__). The reason is to avoid unwanted + underscores (e.g. __spirit__). The reason is to avoid unwanted macro replacement.

- Links (URLS) and images are good candidates for macros. 1) + Links (URLS) and images are good candidates for macros. 1) They tend to change a lot. It is a good idea to place all links and images - in one place near the top to make it easy to make changes. 2) - The syntax is not pretty. It's easier to read and write, e.g. __spirit__ - than [@http://spirit.sourceforge.net Spirit]. + in one place near the top to make it easy to make changes. 2) + The syntax is not pretty. It's easier to read and write, e.g. __spirit__ + than [@http://spirit.sourceforge.net Spirit].

Some more examples: @@ -792,8 +778,8 @@ sf_logo [def __spirit__ [@http://spirit.sourceforge.net Spirit]]

- (See Images and - Links) + (See Images and + Links)

Invoking these macros: @@ -809,15 +795,15 @@ sf_logo

Quickbook has some predefined macros that you can already use.

-

Table 3. Predefined Macros

-
+

Table 3. Predefined Macros

+
@@ -854,7 +840,7 @@ sf_logo @@ -871,7 +857,7 @@ sf_logo @@ -888,19 +874,17 @@ sf_logo -

- 2008-Mar-15 + 2008-May-21

- 02:07:42 PM + 11:54:31 AM

- /home/daniel/boost/branches/release/tools/quickbook/doc/quickbook.qbk + C:\dev\boost\tools\quickbook\doc\quickbook.qbk

+
-

Templates provide a more versatile text substitution mechanism. Templates come in handy when you need to create parameterizable, multi-line, boilerplate @@ -918,11 +902,11 @@ Hi, my name is [name]. I am [age] years old. I am a [what]. ]

-
- - Template +
+ + Template Identifier -
+

Template identifiers can either consist of:

@@ -936,11 +920,11 @@ Hi, my name is [name]. I am [age] years old. I am a [what]. A single character punctuation (a non-alphanumeric printable character) -
- - Formal +
+ + Formal Template Arguments -
+

Template formal arguments are identifiers consisting of an initial alphabetic character or the underscore, followed by zero or more alphanumeric characters @@ -948,19 +932,19 @@ Hi, my name is [name]. I am [age] years old. I am a [what].

A template formal argument temporarily hides a template of the same name - at the point where the template - is expanded. Note that the body of the person - template above refers to name age - and what as [name] [age] - and [what]. name age - and what are actually templates that exist in the duration + at the point where the template + is expanded. Note that the body of the person + template above refers to name age + and what as [name] [age] + and [what]. name age + and what are actually templates that exist in the duration of the template call.

-
- - Template +
+ + Template Body -
+

The template body can be just about any QuickBook block or phrase. There are actually two forms. Templates may be phrase or block level. Phrase @@ -981,11 +965,11 @@ replacement text... Phrase templates are typically expanded as part of phrases. Like macros, block level elements are not allowed in phrase templates.

-
- - Template +
+ + Template Expansion -
+

You expand a template this way:

@@ -1018,7 +1002,7 @@ replacement text... [Caution] Caution -

+

A word of caution: Templates are recursive. A template can call another template or even itself, directly or indirectly. There are no control structures in QuickBook (yet) so this will always mean infinite recursion. @@ -1028,15 +1012,15 @@ replacement text...

Each actual argument can be a word, a text fragment or just about any - QuickBook phrase. Arguments - are separated by the double dot ".." and terminated + QuickBook phrase. Arguments + are separated by the double dot ".." and terminated by the close parenthesis.

-
- - Nullary +
+ + Nullary Templates -
+

Nullary templates look and act like simple macros. Example:

@@ -1051,14 +1035,14 @@ replacement text... We have:

- Some squiggles...αβ + Some squiggles...αβ

The difference with macros are

  • - The explicit template + The explicit template expansion syntax. This is an advantage because, now, we don't have to use obscure naming conventions like double underscores (e.g. __alpha__) to avoid unwanted macro replacement. @@ -1071,7 +1055,7 @@ replacement text...

- The empty brackets after the template identifier (alpha[]) + The empty brackets after the template identifier (alpha[]) indicates no arguments. If the template body does not look like a template argument list, we can elide the empty brackets. Example:

@@ -1087,15 +1071,15 @@ for the journey to old age.]]] We have:

- Here's a quote from Aristotle: Education - is the best provision for the journey to old age.. + Here's a quote from Aristotle: Education + is the best provision for the journey to old age..

The disadvantage is that you can't avoid the space between the template - identifier, aristotle_quote, + identifier, aristotle_quote, and the template body "Aristotle...". This space will be part of the template body. If that space is unwanted, use empty brackets or - use the space escape: "\ ". + use the space escape: "\ ". Example:

[template tag\ _tag]
@@ -1109,26 +1093,26 @@ for the journey to old age.]]]
           We have:
         

- struct x_tag; + struct x_tag;

You have a couple of ways to do it. I personally prefer the explicit empty brackets, though.

-
- - Simple +
+ + Simple Arguments -
+

- As mentioned, arguments are separated by the double dot "..". + As mentioned, arguments are separated by the double dot "..". If there are less arguments passed than expected, QuickBook attempts to break the last argument into two or more arguments following this logic:

  • - Break the last argument into two, at the first space found ('', - '\n', \t' or '\r'). + Break the last argument into two, at the first space found ('', + '\n', \t' or '\r').
  • Repeat until there are enough arguments or if there are no more spaces @@ -1149,8 +1133,8 @@ for the journey to old age.]]]

    "w x y z" is initially treated as a single argument because we - didn't supply any ".." separators. However, - since simple expects 4 arguments, "w x y z" + didn't supply any ".." separators. However, + since simple expects 4 arguments, "w x y z" is broken down iteratively (applying the logic above) until we have "w", "x", "y" and "z".

    @@ -1171,8 +1155,8 @@ for the journey to old age.]]]

    It should be obvious now that for simple arguments with no spaces, we can - get by without separating the arguments with ".." - separators. It is possible to combine ".." + get by without separating the arguments with ".." + separators. It is possible to combine ".." separators with the argument passing simplification presented above. Example:

    [simple what do you think ..m a n?]
    @@ -1183,17 +1167,17 @@ for the journey to old age.]]]
     

    what do you think man?

    -
    - - Punctuation +
    + + Punctuation Templates -
    +

    With templates, one of our objectives is to allow us to rewrite QuickBook in QuickBook (as a qbk library). For that to happen, we need to accommodate single character punctuation templates which are fairly common in QuickBook. You might have noticed that single character punctuations are allowed as - template + template identifiers. Example:

    [template ![bar] <hey>[bar]</hey>]
    @@ -1211,8 +1195,7 @@ for the journey to old age.]]]
     
[blurb :-) [*An eye catching advertisement or note...]
 
     __spirit__ is an object-oriented recursive-descent parser generator framework
@@ -1225,10 +1208,9 @@ for the journey to old age.]]]
           will generate this:
         

[table A Simple Table
     [[Heading 1] [Heading 2] [Heading 3]]
     [[R0-C0]     [R0-C1]     [R0-C2]]
@@ -1263,8 +1244,8 @@ for the journey to old age.]]]
           will generate:
         

-

Table 4. A Simple Table

-
+

Table 4. A Simple Table

+
@@ -1340,11 +1321,11 @@ for the journey to old age.]]] -
+
-

+

The table title is optional. The first row of the table is automatically - treated as the table header; that is, it is wrapped in <thead>...</thead> + treated as the table header; that is, it is wrapped in <thead>...</thead> XML tags. Note that unlike the original QuickDoc, the columns are nested in [ cells... ]. The syntax is free-format and allows big cells to be formatted nicely. Example: @@ -1374,8 +1355,8 @@ for the journey to old age.]]] and thus:

-

Table 5. Table with fat cells

-
+

Table 5. Table with fat cells

+
@@ -1427,9 +1408,9 @@ for the journey to old age.]]] -
+
-

+

Here's how to have preformatted blocks of code in a table cell:

[table Table with code
@@ -1449,8 +1430,8 @@ for the journey to old age.]]]
 ]
 
-

Table 6. Table with code

-
+

Table 6. Table with code

+
@@ -1490,14 +1471,12 @@ for the journey to old age.]]]

-
+
-
[variablelist A Variable List
     [[term 1] [The definition of term 1]]
     [[term 2] [The definition of term 2]]
@@ -1542,8 +1521,7 @@ for the journey to old age.]]]
 
 
 

You can include one QuickBook file from another. The syntax is simply:

@@ -1563,7 +1541,7 @@ for the journey to old age.]]]

- The [include] directive lets you specify a document + The [include] directive lets you specify a document id to use for the included file. When this id is not explicitly specified, the id defaults to the filename ("someother", in the example above). You can specify the id like this: @@ -1574,13 +1552,12 @@ for the journey to old age.]]] All auto-generated anchors will use the document id as a unique prefix. So for instance, if there is a top section in someother.qbk named "Intro", the named anchor for that section will be "someid.intro", and - you can link to it with [link someid.intro The Intro]. + you can link to it with [link someid.intro The Intro].

When documenting code, you'd surely need to present code from actual source files. While it is possible to copy some code and paste them in your QuickBook @@ -1592,10 +1569,10 @@ for the journey to old age.]]]

QuickBook's import facility provides a nice solution.

-
- - Example -
+
+ + Example +

You can effortlessly import code snippets from source code into your QuickBook. The following illustrates how this is done: @@ -1612,8 +1589,8 @@ for the journey to old age.]]]

collects specially marked-up code snippets from stub.cpp and places them in your QuickBook file as virtual templates. Each of the - specially marked-up code snippets has a name (e.g. foo - and bar in the example + specially marked-up code snippets has a name (e.g. foo + and bar in the example above). This shall be the template identifier for that particular code snippet. The second and third line above does the actual template expansion:

@@ -1626,7 +1603,7 @@ for the journey to old age.]]]

- This is the foo + This is the foo function.

@@ -1666,7 +1643,7 @@ for the journey to old age.]]]

- This is the bar + This is the bar function

@@ -1689,11 +1666,11 @@ for the journey to old age.]]]

-
- - Code +
+ + Code Snippet Markup -
+

Note how the code snippets in stub.cpp get marked up. We use distinguishable comments following the form: @@ -1705,16 +1682,16 @@ for the journey to old age.]]]

The first comment line above initiates a named code-snippet. This prefix - will not be visible in quickbook. The entire code-snippet in between //[id and //] + will not be visible in quickbook. The entire code-snippet in between //[id and //] will be inserted as a template in quickbook with name id. - The comment //] ends a code-snippet + The comment //] ends a code-snippet This too will not be visible in quickbook.

-
- - Special +
+ + Special Comments -
+

Special comments of the form:

@@ -1758,10 +1735,10 @@ for the journey to old age.]]] can be used to inhibit code from passing through to quickbook. All text between the delimeters will simply be ignored.

-
- - Callouts -
+
+ + Callouts +

Special comments of the form:

@@ -1780,9 +1757,9 @@ for the journey to old age.]]]

-std::string foo_bar() 1
+std::string foo_bar() 1
 {
-    return "foo-bar"; 2
+    return "foo-bar"; 2
 }
 

@@ -1793,12 +1770,14 @@ for the journey to old age.]]]

- + - +

1

+1

The Mythical FooBar. See Foobar for details

2

+2

return 'em, foo-bar man!

@@ -1842,20 +1821,20 @@ for the journey to old age.]]] { public: - 1x() : n(0) + 1x() : n(0) { } - 2~x() + 2~x() { } - 3int get() const + 3int get() const { return n; } - 4void set(int n_) + 4void set(int n_) { n = n_; } @@ -1869,21 +1848,25 @@ for the journey to old age.]]]

- + - + - - + - - +

1

+1

Constructor

2

+2

Destructor

3

Get the n +

+3

Get the n member variable

4

Set the n +

+4

Set the n member variable

diff --git a/doc/html/quickbook/syntax/comments.html b/doc/html/quickbook/syntax/comments.html index 2af6687..880a2ab 100644 --- a/doc/html/quickbook/syntax/comments.html +++ b/doc/html/quickbook/syntax/comments.html @@ -3,11 +3,11 @@ Comments - + - - - + + + @@ -24,8 +24,7 @@

Can be placed anywhere.

diff --git a/doc/html/quickbook/syntax/phrase.html b/doc/html/quickbook/syntax/phrase.html index 0950c83..6a4a156 100644 --- a/doc/html/quickbook/syntax/phrase.html +++ b/doc/html/quickbook/syntax/phrase.html @@ -1,13 +1,13 @@ -Phrase Level Elements + Phrase Level Elements - + - + - +
@@ -24,8 +24,7 @@
Font Styles
Replaceable
@@ -49,15 +48,14 @@
['italic], [*bold], [_underline], [^teletype], [-strikethrough]
 

will generate:

- italic, bold, underline, teletype, strikethrough + italic, bold, underline, teletype, strikethrough

Like all non-terminal phrase level elements, this can of course be nested: @@ -68,13 +66,12 @@ will generate:

- bold-italic + bold-italic

When you want content that may or must be replaced by the user, use the syntax: @@ -85,15 +82,14 @@ This will generate:

- + replacement - +

["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein
 

@@ -124,8 +120,7 @@ the true business precept.]

Simple markup for formatting text, common in many applications, is now supported: @@ -136,12 +131,12 @@ the true business precept.] will generate:

- italic, bold, underline, teletype + italic, bold, underline, teletype

Unlike QuickBook's standard formatting scheme, the rules for simpler alternatives are much stricter - [1] + [1] .

    @@ -171,13 +166,14 @@ the true business precept.]
  • A line starting with the star will be interpreted as an unordered list. - See Unordered + See Unordered lists.
-

Table 1. More Formatting Samples

-
+

Table 1. More Formatting Samples

+
@@ -198,31 +194,31 @@ the true business precept.] -

- *Bold* + *Bold*

- Bold + Bold

- *Is bold* + *Is bold*

- Is bold + Is bold

- * Not bold* *Not bold * * Not bold * + * Not bold* *Not bold * * Not bold *

@@ -234,7 +230,7 @@ the true business precept.]

- This*Isn't*Bold (no bold) + This*Isn't*Bold (no bold)

@@ -246,31 +242,31 @@ the true business precept.]

- (*Bold Inside*) (parenthesis not bold) + (*Bold Inside*) (parenthesis not bold)

- (Bold Inside) (parenthesis not bold) + (Bold Inside) (parenthesis not bold)

- *(Bold Outside)* (parenthesis bold) + *(Bold Outside)* (parenthesis bold)

- (Bold Outside) (parenthesis bold) + (Bold Outside) (parenthesis bold)

- 3*4*5 = 60 (no bold) + 3*4*5 = 60 (no bold)

@@ -282,7 +278,7 @@ the true business precept.]

- 3 * 4 * 5 = 60 (no bold) + 3 * 4 * 5 = 60 (no bold)

@@ -294,79 +290,79 @@ the true business precept.]

- 3 *4* 5 = 60 (4 is bold) + 3 *4* 5 = 60 (4 is bold)

- 3 4 5 = 60 (4 is bold) + 3 4 5 = 60 (4 is bold)

- *This is bold* this is not *but this is* + *This is bold* this is not *but this is*

- This is bold this is not but this is + This is bold this is not but this is

- *This is bold*. + *This is bold*.

- This is bold. + This is bold.

- *B*. (bold B) + *B*. (bold B)

- B. (bold B) + B. (bold B)

- ['*Bold-Italic*] + ['*Bold-Italic*]

- Bold-Italic + Bold-Italic

- *side-by*/-side/ + *side-by*/-side/

- side-by-side + side-by-side

+ -

+

As mentioned, simple markups cannot go past a single block. The text from "have" to "full" in the following paragraph will be rendered as bold: @@ -377,8 +373,8 @@ One for the master, one for the dame, And one for the little boy who lives down the lane.

- Baa baa black sheep, have you any wool? Yes sir, - yes sir, three bags full! One for the master, one for the dame, + Baa baa black sheep, have you any wool? Yes sir, + yes sir, three bags full! One for the master, one for the dame, And one for the little boy who lives down the lane.

@@ -397,8 +393,7 @@ And one for the little boy who lives down the lane.

Inlining code in paragraphs is quite common when writing C++ documentation. We provide a very simple markup for this. For example, this: @@ -409,7 +404,7 @@ And one for the little boy who lives down the lane. will generate:

- This text has inlined code int main() { return 0; } + This text has inlined code int main() { return 0; } in it. The code will be syntax highlighted.

@@ -417,23 +412,24 @@ And one for the little boy who lives down the lane. -
[Note] Note

- We simply enclose the code with the tick: "`", not the - single quote: "'". - Note too that `some code` is preferred over [^some code]. +

+ We simply enclose the code with the tick: "`", not the + single quote: "'". + Note too that `some code` is preferred over [^some code].

- Preformatted code simply starts with a space or a tab (See Code). + Preformatted code simply starts with a space or a tab (See Code). However, such a simple syntax cannot be used as phrase elements in lists - (See Ordered - lists and Unordered - lists), tables (See Tables), + (See Ordered + lists and Unordered + lists), tables (See Tables), etc. Inline code (see above) can. The problem is, inline code does not allow formatting with newlines, spaces, and tabs. These are lost.

@@ -472,18 +468,17 @@ And one for the little boy who lives down the lane.

If a document contains more than one type of source code then the source mode may be changed dynamically as the document is processed. All QuickBook documents are initially in C++ mode by default, though an alternative initial - value may be set in the Document + value may be set in the Document section.

- To change the source mode, use the [source-mode] markup, - where source-mode is one of the supported modes. For + To change the source mode, use the [source-mode] markup, + where source-mode is one of the supported modes. For example, this:

Python's [python] `import` is rather like C++'s [c++] `#include`. A
@@ -494,14 +489,14 @@ C++ comment `// looks like this` whereas a Python comment [python]
           will generate:
         

- Python's import is rather - like C++'s #include. - A C++ comment // looks like this - whereas a Python comment #looks like this. + Python's import is rather + like C++'s #include. + A C++ comment // looks like this + whereas a Python comment #looks like this.

-

Table 2. Supported Source Modes

-
+

Table 2. Supported Source Modes

+
@@ -527,7 +522,7 @@ C++ comment `// looks like this` whereas a Python comment [python] @@ -539,27 +534,26 @@ C++ comment `// looks like this` whereas a Python comment [python] -

- [c++] + [c++]

- [python] + [python]

+
-
+
-
[Note] Note

+

The source mode strings are lowercase.

[br]
 
@@ -567,39 +561,37 @@ C++ comment `// looks like this` whereas a Python comment [python] -
[Warning] Warning

- [br] is now deprecated. Blurbs, - Admonitions - and table cells (see Tables) +

+ [br] is now deprecated. Blurbs, + Admonitions + and table cells (see Tables) may now contain paragraphs.

[#named_anchor]
 

A named anchor is a hook that can be referenced by a link elsewhere in - the document. You can then reference an anchor with [link named_anchor -Some link text]. - See Anchor links, - Section and Heading. + the document. You can then reference an anchor with [link named_anchor +Some link text]. + See Anchor links, + Section and Heading.

[@http://www.boost.org this is [*boost's] website....]
 

will generate:

- this is boost's + this is boost's website....

@@ -621,31 +613,29 @@ Some link text].

You can link within a document using:

[link section_id.normalized_header_text The link text]
 

- See sections Section - and Heading for + See sections Section + and Heading for more info.

In addition, you can link internally to an XML refentry like:

[link xml.refentry The link text]
 

- This gets converted into <link linkend="xml.refentry">The - link text</link>. + This gets converted into <link linkend="xml.refentry">The + link text</link>.

Like URLs, the link text is optional. If this is not present, the link @@ -654,13 +644,12 @@ Some link text].

[link xml.refentry]
 

- This gets converted into <link linkend="xml.refentry">xml.refentry</link>. + This gets converted into <link linkend="xml.refentry">xml.refentry</link>.

If you want to link to a function, class, member, enum, concept or header in the reference section, you can use: @@ -686,8 +675,7 @@ Some link text].

The escape mark-up is used when we don't want to do any processing.

@@ -704,31 +692,31 @@ escape (no processing/formatting) '''

- This is direct XML markup + This is direct XML markup

-
[Important] Important

+

Be careful when using the escape. The text must conform to BoostBook/DocBook syntax.

The backslash may be used to escape a single punctuation character. The punctuation immediately after the backslash is passed without any processing. - This is useful when we need to escape QuickBook punctuations such as [ and ]. - For example, how do you escape the triple quote? Simple: \'\'\' + This is useful when we need to escape QuickBook punctuations such as [ and ]. + For example, how do you escape the triple quote? Simple: \'\'\'

- \n + \n has a special meaning. It is used to generate line breaks.

@@ -736,30 +724,28 @@ escape (no processing/formatting) -
[Warning] Warning

- \n - and [br] are now deprecated. Blurbs, - Admonitions - and table cells (see Tables) +

+ \n + and [br] are now deprecated. Blurbs, + Admonitions + and table cells (see Tables) may now contain paragraphs.

- The escaped space: \ also + The escaped space: \ also has a special meaning. The escaped space is removed from the output.

[$image.jpg]
 
Macro Expansion
@@ -768,46 +754,45 @@ escape (no processing/formatting)

As of version 1.3, QuickBook supports footnotes. Just put the text of the - footnote in a [footnote] block, and the text will be put at the + footnote in a [footnote] block, and the text will be put at the bottom of the current page. For example, this:

[footnote A sample footnote]
 

will generate this - [2] + [2] .

__a_macro_identifier__
 

- See Macros for details. + See Macros for details.

[a_template_identifier]
 

- See Templates + See Templates for details.

- Like C++ #ifdef, you can generate + Like C++ #ifdef, you can generate phrases depending on the presence of a macro. Example:

[? __to_be__ To be or not to be]
@@ -829,22 +814,22 @@ escape (no processing/formatting)
         

Yes! - [3] + [3]



-

[1] +

[1] Thanks to David Barrett, author of Qwiki, for sharing these samples and teaching me these obscure formatting rules. I wasn't sure at all if Spirit, being more or less a formal EBNF parser, can handle the context sensitivity and ambiguity.

-

[2] +

[2] A sample footnote

-

[3] +

[3] Conditional Generation makes quickbook turing complete.

diff --git a/test/code-block-1.gold b/test/code-block-1.gold index 6db940a..7cd06b3 100644 --- a/test/code-block-1.gold +++ b/test/code-block-1.gold @@ -11,8 +11,7 @@ A code block with proper indentation ;-) - -#include <iostream> +#include <iostream> int main() { diff --git a/test/code-block-2.gold b/test/code-block-2.gold index aa3facf..7b87673 100644 --- a/test/code-block-2.gold +++ b/test/code-block-2.gold @@ -12,8 +12,7 @@ - -#include <iostream> +#include <iostream> int main() { diff --git a/test/import.gold b/test/import.gold index 87988a6..358a559 100644 --- a/test/import.gold +++ b/test/import.gold @@ -25,16 +25,12 @@ - -std::string foo() +std::string foo() { // return 'em, foo man! return "foo"; } - - - diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold index 7c3cb4c..0b8c0b7 100644 --- a/test/quickbook-manual.gold +++ b/test/quickbook-manual.gold @@ -129,8 +129,7 @@ Better (intuitive) paragraph termination. Some markups may terminate a paragraph. Example: - -[section x] +[section x] blah... [endsect] @@ -647,8 +646,7 @@ And one for the little boy who lives down the lane. - -#include <iostream> +#include <iostream> int main() { @@ -740,105 +738,103 @@ C++ comment `// looks like this` whereas a Python comment [python] - - [br] is now deprecated. Blurbs, - Admonitions - and table cells (see Tables) - may now contain paragraphs. - - - -
- <link linkend="quickbook.syntax.phrase.anchors">Anchors</link> - + [br] is now deprecated. Blurbs, + Admonitions + and table cells (see Tables) + may now contain paragraphs. + + +
+
+ <link linkend="quickbook.syntax.phrase.anchors">Anchors</link> + [#named_anchor] - - A named anchor is a hook that can be referenced by a link elsewhere in - the document. You can then reference an anchor with [link named_anchor + + A named anchor is a hook that can be referenced by a link elsewhere in + the document. You can then reference an anchor with [link named_anchor Some link text]. - See Anchor links, - Section and Heading. - -
- + - + - + - + -
- <link linkend="quickbook.syntax.phrase.escape">Escape</link> - - The escape mark-up is used when we don't want to do any processing. - - + + would have "boost::bar::baz" as the link text. + +
+
+ <link linkend="quickbook.syntax.phrase.escape">Escape</link> + + The escape mark-up is used when we don't want to do any processing. + + ''' escape (no processing/formatting) ''' - - Escaping allows us to pass XML markup to BoostBook - or DocBook. For example: - - + + Escaping allows us to pass XML markup to BoostBook + or DocBook. For example: + + ''' <emphasis role="bold">This is direct XML markup</emphasis> ''' + + This is direct XML markup + + - This is direct XML markup - - - - Be careful when using the escape. The text must conform to BoostBook/DocBook syntax. - - -
-
- <link linkend="quickbook.syntax.phrase.single_char_escape">Single - char escape</link> - - The backslash may be used to escape a single punctuation character. The - punctuation immediately after the backslash is passed without any processing. - This is useful when we need to escape QuickBook punctuations such as - [ and ]. - For example, how do you escape the triple quote? Simple: \'\'\' + Be careful when using the escape. The text must conform to BoostBook/DocBook syntax. + +
+
+ <link linkend="quickbook.syntax.phrase.single_char_escape">Single + char escape</link> + + The backslash may be used to escape a single punctuation character. The + punctuation immediately after the backslash is passed without any processing. + This is useful when we need to escape QuickBook punctuations such as [ and ]. + For example, how do you escape the triple quote? Simple: \'\'\' + + + \n + has a special meaning. It is used to generate line breaks. + + \n - has a special meaning. It is used to generate line breaks. + and [br] are now deprecated. Blurbs, + Admonitions + and table cells (see Tables) + may now contain paragraphs. - - - - \n - and [br] are now deprecated. Blurbs, - Admonitions - and table cells (see Tables) - may now contain paragraphs. - - - - The escaped space: \ - also has a special meaning. The escaped space is removed from the output. - -
-
- <link linkend="quickbook.syntax.phrase.images">Images</link> - + + + The escaped space: \ also + has a special meaning. The escaped space is removed from the output. + +
+
+ <link linkend="quickbook.syntax.phrase.images">Images</link> + [$image.jpg] -
-
- <link linkend="quickbook.syntax.phrase.footnotes">Footnotes</link> - - As of version 1.3, QuickBook supports footnotes. Just put the text - of the footnote in a [footnote] - block, and the text will be put at the bottom of the current page. - For example, this: - - +
+
+ <link linkend="quickbook.syntax.phrase.footnotes">Footnotes</link> + + As of version 1.3, QuickBook supports footnotes. Just put the text of the + footnote in a [footnote] block, and the text will be put at the + bottom of the current page. For example, this: + + [footnote A sample footnote] + + will generate this + - will generate this - - - A sample footnote - - - . + A sample footnote -
- <link linkend="quickbook.syntax.phrase.footnotes.macro_expansion">Macro - Expansion</link> + + . + +
+ <link linkend="quickbook.syntax.phrase.footnotes.macro_expansion">Macro + Expansion</link> __a_macro_identifier__ - - See Macros for - details. - -
-
- <link linkend="quickbook.syntax.phrase.footnotes.template_expansion">Template - Expansion</link> + + See Macros for details. + +
+
+ <link linkend="quickbook.syntax.phrase.footnotes.template_expansion">Template + Expansion</link> [a_template_identifier] - - See Templates - for details. - -
-
+ + See Templates + for details. +
-
- <link linkend="quickbook.syntax.block"> Block Level Elements</link> -
- <link linkend="quickbook.syntax.block.document">Document</link> - - Every document must begin with a Document Info section, which should - look like this: - - +
+
+
+ <link linkend="quickbook.syntax.block"> Block Level Elements</link> +
+ <link linkend="quickbook.syntax.block.document">Document</link> + + Every document must begin with a Document Info section, which should look + like this: + + [document-type The Document Title [quickbook 1.3] [version 1.0] @@ -989,143 +982,142 @@ escape (no processing/formatting) [source-mode source-type] ] - - Where document-type is one of: - - - - book - - - article - - - library - - - chapter - - - part - - - appendix - - - preface - - - qandadiv - - - qandaset - - - reference - - - set - - - - quickbook 1.3 declares the version of quickbook the document is written - for. In its absence, version 1.1 is assumed. - - - version, id, dirname, - copyright, purpose, category, - authors, license, last-revision - and source-mode are optional information. - - - source-type is a lowercase string setting the initial - Source Mode. - If the source-mode field is omitted, a default value - of c++ will be used. - -
-
- <link linkend="quickbook.syntax.block.section">Section</link> - - Starting a new section is accomplished with: - - + + Where document-type is one of: + + + + book + + + article + + + library + + + chapter + + + part + + + appendix + + + preface + + + qandadiv + + + qandaset + + + reference + + + set + + + + quickbook 1.3 declares the version of quickbook the document is written + for. In its absence, version 1.1 is assumed. + + + version, id, dirname, + copyright, purpose, category, + authors, license, last-revision + and source-mode are optional information. + + + source-type is a lowercase string setting the initial + Source Mode. + If the source-mode field is omitted, a default value + of c++ will be used. + +
+
+ <link linkend="quickbook.syntax.block.section">Section</link> + + Starting a new section is accomplished with: + + [section:id The Section Title] - - where id is optional. id will be the filename - of the generated section. If it is not present, "The Section Title" - will be normalized and become the id. Valid characters are a-Z, - A-Z, 0-9 and _. - All non-valid characters are converted to underscore and all upper-case - are converted to lower case. Thus: "The Section Title" will - be normalized to "the_section_title". - - - End a section with: - - + + where id is optional. id will be the filename of the + generated section. If it is not present, "The Section Title" + will be normalized and become the id. Valid characters are a-Z, + A-Z, 0-9 and _. + All non-valid characters are converted to underscore and all upper-case + are converted to lower case. Thus: "The Section Title" will be + normalized to "the_section_title". + + + End a section with: + + [endsect] - - Sections can nest, and that results in a hierarchy in the table of - contents. - -
-
- <link linkend="quickbook.syntax.block.xinclude">xinclude</link> - - You can include another XML file with: - - + + Sections can nest, and that results in a hierarchy in the table of contents. + +
+
+ <link linkend="quickbook.syntax.block.xinclude">xinclude</link> + + You can include another XML file with: + + [xinclude file.xml] - - This is useful when file.xml has been generated by Doxygen and contains - your reference section. - -
-
- <link linkend="quickbook.syntax.block.paragraphs">Paragraphs</link> - - Paragraphs start left-flushed and are terminated by two or more newlines. - No markup is needed for paragraphs. QuickBook automatically detects - paragraphs from the context. Block markups [section, endsect, h1, h2, - h3, h4, h5, h6, blurb, (block-quote) ':', pre, def, table and include - ] may also terminate a paragraph. - -
-
- <link linkend="quickbook.syntax.block.lists">Lists</link> -
- <link linkend="quickbook.syntax.block.lists.ordered_lists">Ordered - lists</link> + + This is useful when file.xml has been generated by Doxygen and contains + your reference section. + +
+
+ <link linkend="quickbook.syntax.block.paragraphs">Paragraphs</link> + + Paragraphs start left-flushed and are terminated by two or more newlines. + No markup is needed for paragraphs. QuickBook automatically detects paragraphs + from the context. Block markups [section, endsect, h1, h2, h3, h4, h5, + h6, blurb, (block-quote) ':', pre, def, table and include ] may also terminate + a paragraph. + +
+
+ <link linkend="quickbook.syntax.block.lists">Lists</link> +
+ <link linkend="quickbook.syntax.block.lists.ordered_lists">Ordered + lists</link> # One # Two # Three - - will generate: - - - - One - - - Two - - - Three - - -
-
- <link linkend="quickbook.syntax.block.lists.list_hierarchies">List - Hierarchies</link> - - List hierarchies are supported. Example: - - + + will generate: + + + + One + + + Two + + + Three + + +
+
+ <link linkend="quickbook.syntax.block.lists.list_hierarchies">List + Hierarchies</link> + + List hierarchies are supported. Example: + + # One # Two # Three @@ -1138,58 +1130,58 @@ escape (no processing/formatting) # Four.a.ii # Five - - will generate: - + + will generate: + + + + One + + + Two + + + Three - One + Three.a - Two + Three.b - Three - - - Three.a - - - Three.b - - - Three.c - - - - - Fourth - - - Four.a - - - Four.a.i - - - Four.a.ii - - - - - - - Five + Three.c -
-
- <link linkend="quickbook.syntax.block.lists.long_list_lines">Long - List Lines</link> - - Long lines will be wrapped appropriately. Example: - - + + + Fourth + + + Four.a + + + Four.a.i + + + Four.a.ii + + + + + + + Five + + +
+
+ <link linkend="quickbook.syntax.block.lists.long_list_lines">Long + List Lines</link> + + Long lines will be wrapped appropriately. Example: + + # A short item. # A very long item. A very long item. A very long item. A very long item. A very long item. A very long item. @@ -1198,51 +1190,49 @@ escape (no processing/formatting) A very long item. A very long item. A very long item. # A short item. - - - A short item. - - - A very long item. A very long item. A very long item. A very long - item. A very long item. A very long item. A very long item. A very - long item. A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. A very long - item. - - - A short item. - - -
-
- <link linkend="quickbook.syntax.block.lists.unordered_lists">Unordered - lists</link> + + + A short item. + + + A very long item. A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + + + A short item. + + +
+
+ <link linkend="quickbook.syntax.block.lists.unordered_lists">Unordered + lists</link> * First * Second * Third - - will generate: - - - - First - - - Second - - - Third - - -
-
- <link linkend="quickbook.syntax.block.lists.mixed_lists">Mixed - lists</link> - - Mixed lists (ordered and unordered) are supported. Example: - - + + will generate: + + + + First + + + Second + + + Third + + +
+
+ <link linkend="quickbook.syntax.block.lists.mixed_lists">Mixed lists</link> + + Mixed lists (ordered and unordered) are supported. Example: + + # One # Two # Three @@ -1251,38 +1241,38 @@ escape (no processing/formatting) * Three.c # Four - - will generate: - - + + will generate: + + + + One + + + Two + + + Three + - One + Three.a - Two + Three.b - Three - - - Three.a - - - Three.b - - - Three.c - - + Three.c - - Four - - - - And... - - + + + + Four + + + + And... + + # 1 * 1.a # 1.a.1 @@ -1296,71 +1286,70 @@ escape (no processing/formatting) * 2.b.2.a * 2.b.2.b - - will generate: - - + + will generate: + + + + 1 + - 1 - + 1.a + - 1.a - - - 1.a.1 - - - 1.a.2 - - + 1.a.1 - 1.b + 1.a.2 - + - 2 - - - 2.a - - - 2.b - - - 2.b.1 - - - 2.b.2 - - - 2.b.2.a - - - 2.b.2.b - - - - - - + 1.b - -
-
-
- <link linkend="quickbook.syntax.block.code">Code</link> - - Preformatted code starts with a space or a tab. The code will be syntax - highlighted according to the current Source - Mode: - - - - - -#include <iostream> + + + + 2 + + + 2.a + + + 2.b + + + 2.b.1 + + + 2.b.2 + + + 2.b.2.a + + + 2.b.2.b + + + + + + + + +
+
+
+ <link linkend="quickbook.syntax.block.code">Code</link> + + Preformatted code starts with a space or a tab. The code will be syntax + highlighted according to the current Source + Mode: + + + + +#include <iostream> int main() { @@ -1369,73 +1358,70 @@ escape (no processing/formatting) return 0; } - - - - -import cgi + + + +import cgi def cookForHtml(text): '''"Cooks" the input text for HTML.''' return cgi.escape(text) - - - - Macros that are already defined are expanded in source code. Example: - - + + + + Macros that are already defined are expanded in source code. Example: + + [def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] [def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] using __boost__::__array__; - - Generates: - - - -using boost::array; + + Generates: + + +using boost::array; -
-
- <link linkend="quickbook.syntax.block.escape_back"> Escaping Back - To QuickBook</link> - - Inside code, code blocks and inline code, QuickBook does not allow - any markup to avoid conflicts with the target syntax (e.g. c++). In - case you need to switch back to QuickBook markup inside code, you can - do so using a language specific escape-back delimiter. - In C++ and Python, the delimiter is the double tick (back-quote): "``" - and "``". Example: - - +
+
+ <link linkend="quickbook.syntax.block.escape_back"> Escaping Back + To QuickBook</link> + + Inside code, code blocks and inline code, QuickBook does not allow any + markup to avoid conflicts with the target syntax (e.g. c++). In case you + need to switch back to QuickBook markup inside code, you can do so using + a language specific escape-back delimiter. In C++ + and Python, the delimiter is the double tick (back-quote): "``" + and "``". Example: + + void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() { } - - Will generate: - - - -void foo() + + Will generate: + + +void foo() { } - - When escaping from code to QuickBook, only phrase level markups are - allowed. Block level markups like lists, tables etc. are not allowed. - -
-
- <link linkend="quickbook.syntax.block.preformatted">Preformatted</link> - - Sometimes, you don't want some preformatted text to be parsed as C++. - In such cases, use the [pre ... ] markup block. - - + + When escaping from code to QuickBook, only phrase level markups are allowed. + Block level markups like lists, tables etc. are not allowed. + +
+
+ <link linkend="quickbook.syntax.block.preformatted">Preformatted</link> + + Sometimes, you don't want some preformatted text to be parsed as C++. In + such cases, use the [pre ... ] markup block. + + [pre Some *preformatted* text Some *preformatted* text @@ -1446,12 +1432,12 @@ escape (no processing/formatting) ] - - Spaces, tabs and newlines are rendered as-is. Unlike all quickbook - block level markup, pre (and Code) are the only ones that allow multiple - newlines. The markup above will generate: - - + + Spaces, tabs and newlines are rendered as-is. Unlike all quickbook block + level markup, pre (and Code) are the only ones that allow multiple newlines. + The markup above will generate: + + Some preformatted text Some preformatted text Some preformatted text Some preformatted text @@ -1459,71 +1445,70 @@ escape (no processing/formatting) Some preformatted text Some preformatted text - - Notice that unlike Code, phrase markup such as font style is still - permitted inside pre blocks. - -
-
- <link linkend="quickbook.syntax.block.blockquote">Blockquote</link> - + + Notice that unlike Code, phrase markup such as font style is still permitted + inside pre blocks. + +
+
+ <link linkend="quickbook.syntax.block.blockquote">Blockquote</link> + [:sometext...] -
- - - Indents the paragraph. This applies to one paragraph only. - - -
-
-
- <link linkend="quickbook.syntax.block.admonitions">Admonitions</link> - +
+ + + Indents the paragraph. This applies to one paragraph only. + + +
+
+
+ <link linkend="quickbook.syntax.block.admonitions">Admonitions</link> + [note This is a note] [tip This is a tip] [important This is important] [caution This is a caution] [warning This is a warning] - - generates DocBook admonitions: - - - - This is a note - - - - - This is a tip - - - - - This is important - - - - - This is a caution - - - - - - This is a warning - - - - These are the only admonitions supported by DocBook. - So, for example [information This is some information] - is unlikely to produce the desired effect. - -
-
- <link linkend="quickbook.syntax.block.headings">Headings</link> - + + generates DocBook admonitions: + + + + This is a note + + + + + This is a tip + + + + + This is important + + + + + This is a caution + + + + + This is a warning + + + + These are the only admonitions supported by DocBook. + So, for example [information This is some information] + is unlikely to produce the desired effect. + +
+
+ <link linkend="quickbook.syntax.block.headings">Headings</link> + [h1 Heading 1] [h2 Heading 2] [h3 Heading 3] @@ -1531,577 +1516,564 @@ escape (no processing/formatting) [h5 Heading 5] [h6 Heading 6] - - - Heading - 1 - - - - Heading - 2 - - - - Heading - 3 - - - - Heading - 4 - - - - Heading - 5 - - - - Heading - 6 - - - Headings 1-3 [h1 h2 and h3] will automatically have anchors with - normalized names with name="section_id.normalized_header_text" - (i.e. valid characters are a-z, A-Z, - 0-9 and _. All non-valid characters - are converted to underscore and all upper-case are converted to lower-case. - For example: Heading 1 in section Section 2 will be normalized to - section_2.heading_1). You can use: - - + + + Heading 1 + + + + Heading 2 + + + + Heading 3 + + + + Heading 4 + + + + Heading 5 + + + + Heading 6 + + + Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized + names with name="section_id.normalized_header_text" + (i.e. valid characters are a-z, A-Z, + 0-9 and _. All non-valid characters + are converted to underscore and all upper-case are converted to lower-case. + For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). + You can use: + + [link section_id.normalized_header_text The link text] - - to link to them. See Anchor - links and Section - for more info. - -
-
- <link linkend="quickbook.syntax.block.generic_heading">Generic - Heading</link> - - In cases when you don't want to care about the heading level (1 to - 6), you can use the Generic Heading: - - + + to link to them. See Anchor + links and Section + for more info. + +
+
+ <link linkend="quickbook.syntax.block.generic_heading">Generic Heading</link> + + In cases when you don't want to care about the heading level (1 to 6), + you can use the Generic Heading: + + [heading Heading] - - The Generic Heading assumes the level, plus - one, of the innermost section where it is placed. For example, if - it is placed in the outermost section, then, it assumes h2. - - - Headings are often used as an alternative to sections. It is used - particularly if you do not want to start a new section. In many cases, - however, headings in a particular section is just flat. Example: - - + + The Generic Heading assumes the level, plus one, of + the innermost section where it is placed. For example, if it is placed + in the outermost section, then, it assumes h2. + + + Headings are often used as an alternative to sections. It is used particularly + if you do not want to start a new section. In many cases, however, headings + in a particular section is just flat. Example: + + [section A] [h2 X] [h2 Y] [h2 Z] [endsect] - - Here we use h2 assuming that section A is the outermost level. If - it is placed in an inner level, you'll have to use h3, h4, etc. depending - on where the section is. In general, it is the section level plus - one. It is rather tedious, however, to scan the section level everytime. - If you rewrite the example above as shown below, this will be automatic: - - + + Here we use h2 assuming that section A is the outermost level. If it is + placed in an inner level, you'll have to use h3, h4, etc. depending on + where the section is. In general, it is the section level plus one. It + is rather tedious, however, to scan the section level everytime. If you + rewrite the example above as shown below, this will be automatic: + + [section A] [heading X] [heading Y] [heading Z] [endsect] - - They work well regardless where you place them. You can rearrange - sections at will without any extra work to ensure correct heading - levels. In fact, with section and heading, - you have all you need. h1..h6 - becomes redundant. h1..h6 - might be deprecated in the future. - -
-
- <link linkend="quickbook.syntax.block.macros">Macros</link> - + + They work well regardless where you place them. You can rearrange sections + at will without any extra work to ensure correct heading levels. In fact, + with section and heading, you + have all you need. h1..h6 becomes + redundant. h1..h6 might be deprecated + in the future. + +
+
+ <link linkend="quickbook.syntax.block.macros">Macros</link> + [def macro_identifier some text] - - When a macro is defined, the identifier replaces the text anywhere - in the file, in paragraphs, in markups, etc. macro_identifier is - a string of non- white space characters except ']'. A macro may not - follow an alphabetic character or the underscore. The replacement - text can be any phrase (even marked up). Example: - - + + When a macro is defined, the identifier replaces the text anywhere in the + file, in paragraphs, in markups, etc. macro_identifier is a string of non- + white space characters except ']'. A macro may not follow an alphabetic + character or the underscore. The replacement text can be any phrase (even + marked up). Example: + + [def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] sf_logo - - Now everywhere the sf_logo is placed, the picture will be inlined. - - - - - sflogo - - - - - - It's a good idea to use macro identifiers that are distinguishable. - For instance, in this document, macro identifiers have two leading - and trailing underscores (e.g. __spirit__). The reason - is to avoid unwanted macro replacement. - - - - Links (URLS) and images are good candidates for macros. 1) They tend to change a lot. It is a good - idea to place all links and images in one place near the top to make - it easy to make changes. 2) The - syntax is not pretty. It's easier to read and write, e.g. __spirit__ - than [@http://spirit.sourceforge.net Spirit]. - - - Some more examples: - - + + Now everywhere the sf_logo is placed, the picture will be inlined. + + + + + sflogo + + + + + + It's a good idea to use macro identifiers that are distinguishable. For + instance, in this document, macro identifiers have two leading and trailing + underscores (e.g. __spirit__). The reason is to avoid unwanted + macro replacement. + + + + Links (URLS) and images are good candidates for macros. 1) + They tend to change a lot. It is a good idea to place all links and images + in one place near the top to make it easy to make changes. 2) + The syntax is not pretty. It's easier to read and write, e.g. __spirit__ + than [@http://spirit.sourceforge.net Spirit]. + + + Some more examples: + + [def :-) [$theme/smiley.png]] [def __spirit__ [@http://spirit.sourceforge.net Spirit]] - - (See Images - and Links) - - - Invoking these macros: - - + + (See Images and + Links) + + + Invoking these macros: + + Hi __spirit__ :-) + + will generate this: + + + Hi Spirit + + smiley + + + +
+
+ <link linkend="quickbook.syntax.block.predefined_macros">Predefined + Macros</link> + + Quickbook has some predefined macros that you can already use. + + Predefined Macros + + + + - will generate this: + Macro + - Hi Spirit - - smiley - - + Meaning - -
- <link linkend="quickbook.syntax.block.predefined_macros">Predefined - Macros</link> + - Quickbook has some predefined macros that you can already use. + Example -
Predefined Macros - - - - - - Macro - - - - Meaning - - - - Example - - - - - - - - - __DATE__ - - - - Today's date - - - - 2000-Dec-20 - - - - - - - __TIME__ - - - - The current time - - - - 12:00:00 PM - - - - - - - __FILENAME__ - - - - Quickbook source filename - - - - NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE - - - - - -
-
-
- <link linkend="quickbook.syntax.block.templates">Templates</link> + + + + + + - Templates provide a more versatile text substitution mechanism. Templates - come in handy when you need to create parameterizable, multi-line, - boilerplate text that you specify once and expand many times. Templates - accept one or more arguments. These arguments act like place-holders - for text replacement. Unlike simple macros, which are limited to - phrase level markup, templates can contain block level markup (e.g. - paragraphs, code blocks and tables). + __DATE__ + - Example template: + Today's date - + + + 2000-Dec-20 + + + + + + + __TIME__ + + + + The current time + + + + 12:00:00 PM + + + + + + + __FILENAME__ + + + + Quickbook source filename + + + + NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE + + + + + + +
+
+ <link linkend="quickbook.syntax.block.templates">Templates</link> + + Templates provide a more versatile text substitution mechanism. Templates + come in handy when you need to create parameterizable, multi-line, boilerplate + text that you specify once and expand many times. Templates accept one + or more arguments. These arguments act like place-holders for text replacement. + Unlike simple macros, which are limited to phrase level markup, templates + can contain block level markup (e.g. paragraphs, code blocks and tables). + + + Example template: + + [template person[name age what] Hi, my name is [name]. I am [age] years old. I am a [what]. ] - - - Template - Identifier - - - Template identifiers can either consist of: - - - - An initial alphabetic character or the underscore, followed by - zero or more alphanumeric characters or the underscore. This is - similar to your typical C/C++ identifier. - - - A single character punctuation (a non-alphanumeric printable character) - - - - - Formal - Template Arguments - - - Template formal arguments are identifiers consisting of an initial - alphabetic character or the underscore, followed by zero or more - alphanumeric characters or the underscore. This is similar to your - typical C/C++ identifier. - - - A template formal argument temporarily hides a template of the same - name at the point where the template - is expanded. Note that the body of the person - template above refers to name age - and what as [name] [age] - and [what]. name age - and what are actually templates that exist in - the duration of the template call. - - - - Template - Body - - - The template body can be just about any QuickBook block or phrase. - There are actually two forms. Templates may be phrase or block level. - Phrase templates are of the form: - - + + + Template + Identifier + + + Template identifiers can either consist of: + + + + An initial alphabetic character or the underscore, followed by zero or + more alphanumeric characters or the underscore. This is similar to your + typical C/C++ identifier. + + + A single character punctuation (a non-alphanumeric printable character) + + + + + Formal + Template Arguments + + + Template formal arguments are identifiers consisting of an initial alphabetic + character or the underscore, followed by zero or more alphanumeric characters + or the underscore. This is similar to your typical C/C++ identifier. + + + A template formal argument temporarily hides a template of the same name + at the point where the template + is expanded. Note that the body of the person + template above refers to name age + and what as [name] [age] + and [what]. name age + and what are actually templates that exist in the duration + of the template call. + + + + Template + Body + + + The template body can be just about any QuickBook block or phrase. There + are actually two forms. Templates may be phrase or block level. Phrase + templates are of the form: + + [template sample[arg1 arg2...argN] replacement text... ] - - Block templates are of the form: - - + + Block templates are of the form: + + [template sample[arg1 arg2...argN] replacement text... ] - - The basic rule is as follows: if a newline immediately follows the - argument list, then it is a block template, otherwise, it is a phrase - template. Phrase templates are typically expanded as part of phrases. - Like macros, block level elements are not allowed in phrase templates. - - - - Template - Expansion - - - You expand a template this way: - - + + The basic rule is as follows: if a newline immediately follows the argument + list, then it is a block template, otherwise, it is a phrase template. + Phrase templates are typically expanded as part of phrases. Like macros, + block level elements are not allowed in phrase templates. + + + + Template + Expansion + + + You expand a template this way: + + [template_identifier arg1..arg2..arg3] - - At template expansion, you supply the actual arguments. The template - will be expanded with your supplied arguments. Example: - - + + At template expansion, you supply the actual arguments. The template will + be expanded with your supplied arguments. Example: + + [person James Bond..39..Spy] [person Santa Clause..87..Big Red Fatso] - - Which will expand to: - - - - Hi, my name is James Bond. I am 39 years old. I am a Spy. - - - Hi, my name is Santa Clause. I am 87 years old. I am a Big Red - Fatso. - - - - - A word of caution: Templates are recursive. A template can call - another template or even itself, directly or indirectly. There - are no control structures in QuickBook (yet) so this will always - mean infinite recursion. QuickBook can detect this situation and - report an error if recursion exceeds a certain limit. - - - - Each actual argument can be a word, a text fragment or just about - any QuickBook phrase. - Arguments are separated by the double dot ".." - and terminated by the close parenthesis. - - - - Nullary - Templates - - - Nullary templates look and act like simple macros. Example: - - + + Which will expand to: + + + + Hi, my name is James Bond. I am 39 years old. I am a Spy. + + + Hi, my name is Santa Clause. I am 87 years old. I am a Big Red Fatso. + + + + + A word of caution: Templates are recursive. A template can call another + template or even itself, directly or indirectly. There are no control + structures in QuickBook (yet) so this will always mean infinite recursion. + QuickBook can detect this situation and report an error if recursion + exceeds a certain limit. + + + + Each actual argument can be a word, a text fragment or just about any + QuickBook phrase. Arguments + are separated by the double dot ".." and terminated + by the close parenthesis. + + + + Nullary + Templates + + + Nullary templates look and act like simple macros. Example: + + [template alpha[]'''&#945;'''] [template beta[]'''&#946;'''] - - Expanding: - - + + Expanding: + + Some squigles...[*[alpha][beta]] - - We have: - - - Some squiggles...αβ - - - The difference with macros are - - - - The explicit template - expansion syntax. This is an advantage because, now, we - don't have to use obscure naming conventions like double underscores - (e.g. __alpha__) to avoid unwanted macro replacement. - - - The template is expanded at the point where it is invoked. A macro - is expanded immediately at its point of declaration. This is subtle - and can cause a slight difference in behavior especially if you - refer to other macros and templates in the body. - - - - The empty brackets after the template identifier (alpha[]) - indicates no arguments. If the template body does not look like a - template argument list, we can elide the empty brackets. Example: - - + + We have: + + + Some squiggles...αβ + + + The difference with macros are + + + + The explicit template + expansion syntax. This is an advantage because, now, we don't + have to use obscure naming conventions like double underscores (e.g. + __alpha__) to avoid unwanted macro replacement. + + + The template is expanded at the point where it is invoked. A macro is + expanded immediately at its point of declaration. This is subtle and + can cause a slight difference in behavior especially if you refer to + other macros and templates in the body. + + + + The empty brackets after the template identifier (alpha[]) + indicates no arguments. If the template body does not look like a template + argument list, we can elide the empty brackets. Example: + + [template aristotle_quote Aristotle: [*['Education is the best provision for the journey to old age.]]] - - Expanding: - - + + Expanding: + + Here's a quote from [aristotle_quote]. - - We have: - - - Here's a quote from Aristotle: Education - is the best provision for the journey to old age.. - - - The disadvantage is that you can't avoid the space between the template - identifier, aristotle_quote, - and the template body "Aristotle...". This space will be - part of the template body. If that space is unwanted, use empty brackets - or use the space escape: "\ - ". Example: - - + + We have: + + + Here's a quote from Aristotle: Education + is the best provision for the journey to old age.. + + + The disadvantage is that you can't avoid the space between the template + identifier, aristotle_quote, + and the template body "Aristotle...". This space will be part + of the template body. If that space is unwanted, use empty brackets or + use the space escape: "\ ". + Example: + + [template tag\ _tag] - - Then expanding: - - + + Then expanding: + + `struct` x[tag]; - - We have: - - - struct x_tag; - - - You have a couple of ways to do it. I personally prefer the explicit - empty brackets, though. - - - - Simple - Arguments - - - As mentioned, arguments are separated by the double dot "..". - If there are less arguments passed than expected, QuickBook attempts - to break the last argument into two or more arguments following this - logic: - - - - Break the last argument into two, at the first space found ('', - '\n', \t' or '\r'). - - - Repeat until there are enough arguments or if there are no more - spaces found (in which case, an error is reported). - - - - For example: - - + + We have: + + + struct x_tag; + + + You have a couple of ways to do it. I personally prefer the explicit empty + brackets, though. + + + + Simple + Arguments + + + As mentioned, arguments are separated by the double dot "..". + If there are less arguments passed than expected, QuickBook attempts to + break the last argument into two or more arguments following this logic: + + + + Break the last argument into two, at the first space found ('', + '\n', \t' or '\r'). + + + Repeat until there are enough arguments or if there are no more spaces + found (in which case, an error is reported). + + + + For example: + + [template simple[a b c d] [a][b][c][d]] [simple w x y z] - - will produce: - - - wxyz - - - "w x y z" is initially treated as a single argument because - we didn't supply any ".." separators. - However, since simple expects 4 arguments, "w - x y z" is broken down iteratively (applying the logic above) - until we have "w", "x", "y" and "z". - - - QuickBook only tries to get the arguments it needs. For example: - - + + will produce: + + + wxyz + + + "w x y z" is initially treated as a single argument because we + didn't supply any ".." separators. However, + since simple expects 4 arguments, "w x y z" + is broken down iteratively (applying the logic above) until we have "w", + "x", "y" and "z". + + + QuickBook only tries to get the arguments it needs. For example: + + [simple w x y z trail] - - will produce: - - - wxyz trail - - - The arguments being: "w", "x", "y" - and "z trail". - - - It should be obvious now that for simple arguments with no spaces, - we can get by without separating the arguments with ".." - separators. It is possible to combine ".." - separators with the argument passing simplification presented above. - Example: - - + + will produce: + + + wxyz trail + + + The arguments being: "w", "x", "y" and "z + trail". + + + It should be obvious now that for simple arguments with no spaces, we can + get by without separating the arguments with ".." + separators. It is possible to combine ".." + separators with the argument passing simplification presented above. Example: + + [simple what do you think ..m a n?] - - will produce: - - - what do you think man? - - - - Punctuation - Templates - - - With templates, one of our objectives is to allow us to rewrite QuickBook - in QuickBook (as a qbk library). For that to happen, we need to accommodate - single character punctuation templates which are fairly common in - QuickBook. You might have noticed that single character punctuations - are allowed as template - identifiers. Example: - - + + will produce: + + + what do you think man? + + + + Punctuation + Templates + + + With templates, one of our objectives is to allow us to rewrite QuickBook + in QuickBook (as a qbk library). For that to happen, we need to accommodate + single character punctuation templates which are fairly common in QuickBook. + You might have noticed that single character punctuations are allowed as + template + identifiers. Example: + + [template ![bar] <hey>[bar]</hey>] - - Now, expanding this: - - + + Now, expanding this: + + [!baz] - - We will have: - - + + We will have: + + <hey>baz</hey> -
-
- <link linkend="quickbook.syntax.block.blurbs">Blurbs</link> - +
+
+ <link linkend="quickbook.syntax.block.blurbs">Blurbs</link> + [blurb :-) [*An eye catching advertisement or note...] __spirit__ is an object-oriented recursive-descent parser generator framework @@ -2110,35 +2082,35 @@ for the journey to old age.]]] completely in C++. ] - - will generate this: - - - - - - smiley - - An eye catching advertisement - or note... - - - Spirit is an object-oriented - recursive-descent parser generator framework implemented using template - meta-programming techniques. Expression templates allow us to approximate - the syntax of Extended Backus-Normal Form (EBNF) completely in C++. - - - - - Prefer admonitions - wherever appropriate. - - -
-
- <link linkend="quickbook.syntax.block.tables">Tables</link> - + + will generate this: + + + + + + smiley + + An eye catching advertisement + or note... + + + Spirit is an object-oriented + recursive-descent parser generator framework implemented using template + meta-programming techniques. Expression templates allow us to approximate + the syntax of Extended Backus-Normal Form (EBNF) completely in C++. + + + + + Prefer admonitions + wherever appropriate. + + +
+
+ <link linkend="quickbook.syntax.block.tables">Tables</link> + [table A Simple Table [[Heading 1] [Heading 2] [Heading 3]] [[R0-C0] [R0-C1] [R0-C2]] @@ -2146,85 +2118,85 @@ for the journey to old age.]]] [[R2-C0] [R2-C1] [R2-C2]] ] + + will generate: + + A Simple Table + + + + - will generate: + Heading 1 -
A Simple Table - - - - - - Heading 1 - - - - Heading 2 - - - - Heading 3 - - - - - - - - - R0-C0 - - - - R0-C1 - - - - R0-C2 - - - - - - - R2-C0 - - - - R2-C1 - - - - R2-C2 - - - - - - - R3-C0 - - - - R3-C1 - - - - R3-C2 - - - - - -
+ - The table title is optional. The first row of the table is automatically - treated as the table header; that is, it is wrapped in <thead>...</thead> - XML tags. Note that unlike the original QuickDoc, the columns are - nested in [ cells... ]. The syntax is free-format and allows big - cells to be formatted nicely. Example: + Heading 2 - + + + Heading 3 + + + + + + + + + R0-C0 + + + + R0-C1 + + + + R0-C2 + + + + + + + R2-C0 + + + + R2-C1 + + + + R2-C2 + + + + + + + R3-C0 + + + + R3-C1 + + + + R3-C2 + + + + + + + + The table title is optional. The first row of the table is automatically + treated as the table header; that is, it is wrapped in <thead>...</thead> + XML tags. Note that unlike the original QuickDoc, the columns are nested + in [ cells... ]. The syntax is free-format and allows big cells to be formatted + nicely. Example: + + [table Table with fat cells [[Heading 1] [Heading 2]] [ @@ -2246,63 +2218,63 @@ for the journey to old age.]]] ] ] + + and thus: + + Table with fat cells + + + + - and thus: + Heading 1 -
Table with fat cells - - - - - - Heading 1 - - - - Heading 2 - - - - - - - - - Row 0, Col 0: a small cell - - - - Row 0, Col 1: a big fat cell with paragraphs - - - Boost provides free peer-reviewed portable C++ source libraries. - - - We emphasize libraries that work well with the C++ Standard - Library. Boost libraries are intended to be widely useful, - and usable across a broad spectrum of applications. The Boost - license encourages both commercial and non-commercial use. - - - - - - - Row 1, Col 0: a small cell - - - - Row 1, Col 1: a small cell - - - - - -
+ - Here's how to have preformatted blocks of code in a table cell: + Heading 2 - + + + + + + + + Row 0, Col 0: a small cell + + + + Row 0, Col 1: a big fat cell with paragraphs + + + Boost provides free peer-reviewed portable C++ source libraries. + + + We emphasize libraries that work well with the C++ Standard Library. + Boost libraries are intended to be widely useful, and usable across + a broad spectrum of applications. The Boost license encourages both + commercial and non-commercial use. + + + + + + + Row 1, Col 0: a small cell + + + + Row 1, Col 1: a small cell + + + + + + + + Here's how to have preformatted blocks of code in a table cell: + + [table Table with code [[Comment] [Code]] [ @@ -2319,32 +2291,31 @@ for the journey to old age.]]] ] ] - Table with code - - - - - - Comment - - - - Code - - - - - - - - - My first program - - - - - -#include <iostream> +
Table with code + + + + + + Comment + + + + Code + + + + + + + + + My first program + + + + +#include <iostream> int main() { @@ -2352,381 +2323,361 @@ for the journey to old age.]]] return 0; } - - - - - -
-
-
- <link linkend="quickbook.syntax.block.variable_lists">Variable - Lists</link> + + + + + + +
+
+ <link linkend="quickbook.syntax.block.variable_lists">Variable Lists</link> + [variablelist A Variable List [[term 1] [The definition of term 1]] [[term 2] [The definition of term 2]] [[term 3] [The definition of term 3]] ] - - will generate: - - - A Variable List term 1 - - - The definition of term 1 - - - term 2 - - - The definition of term 2 - - - term 3 - - - The definition of term 3 - - - - - - The rules for variable lists are the same as for tables, except that - only 2 "columns" are allowed. The first column contains - the terms, and the second column contains the definitions. Those - familiar with HTML will recognize this as a "definition list". - -
-
- <link linkend="quickbook.syntax.block.include">Include</link> - - You can include one QuickBook file from another. The syntax is simply: - - + + will generate: + + + A Variable List term 1 + + + The definition of term 1 + + + term 2 + + + The definition of term 2 + + + term 3 + + + The definition of term 3 + + + + + + The rules for variable lists are the same as for tables, except that only + 2 "columns" are allowed. The first column contains the terms, + and the second column contains the definitions. Those familiar with HTML + will recognize this as a "definition list". + +
+
+ <link linkend="quickbook.syntax.block.include">Include</link> + + You can include one QuickBook file from another. The syntax is simply: + + [include someother.qbk] - - The included file will be processed as if it had been cut and pasted - into the current document, with the following exceptions: - - - - The __FILENAME__ predefined macro will reflect the name of the file currently - being processed. - - - Any macros defined in the included file are scoped to that file. - - - - The [include] directive lets you specify a document - id to use for the included file. When this id is not explicitly specified, - the id defaults to the filename ("someother", in the example - above). You can specify the id like this: - - + + The included file will be processed as if it had been cut and pasted into + the current document, with the following exceptions: + + + + The __FILENAME__ predefined macro will reflect the name of the file currently being + processed. + + + Any macros defined in the included file are scoped to that file. + + + + The [include] directive lets you specify a document + id to use for the included file. When this id is not explicitly specified, + the id defaults to the filename ("someother", in the example + above). You can specify the id like this: + + [include:someid someother.qbk] - - All auto-generated anchors will use the document id as a unique prefix. - So for instance, if there is a top section in someother.qbk named - "Intro", the named anchor for that section will be "someid.intro", - and you can link to it with [link someid.intro The Intro]. - -
-
- <link linkend="quickbook.syntax.block.import">Import</link> - - When documenting code, you'd surely need to present code from actual - source files. While it is possible to copy some code and paste them - in your QuickBook file, doing so is error prone and the extracted - code in the documentation tends to get out of sync with the actual - code as the code evolves. The problem, as always, is that once documentation - is written, the tendency is for the docs to languish in the archives - without maintenance. - - - QuickBook's import facility provides a nice solution. - - - - Example - - - You can effortlessly import code snippets from source code into your - QuickBook. The following illustrates how this is done: - - + + All auto-generated anchors will use the document id as a unique prefix. + So for instance, if there is a top section in someother.qbk named "Intro", + the named anchor for that section will be "someid.intro", and + you can link to it with [link someid.intro The Intro]. + +
+
+ <link linkend="quickbook.syntax.block.import">Import</link> + + When documenting code, you'd surely need to present code from actual source + files. While it is possible to copy some code and paste them in your QuickBook + file, doing so is error prone and the extracted code in the documentation + tends to get out of sync with the actual code as the code evolves. The + problem, as always, is that once documentation is written, the tendency + is for the docs to languish in the archives without maintenance. + + + QuickBook's import facility provides a nice solution. + + + + Example + + + You can effortlessly import code snippets from source code into your QuickBook. + The following illustrates how this is done: + + [import ../test/stub.cpp] [foo] [bar] - - The first line: - - + + The first line: + + [import ../test/stub.cpp] - - collects specially marked-up code snippets from stub.cpp - and places them in your QuickBook file as virtual templates. Each - of the specially marked-up code snippets has a name (e.g. foo and bar - in the example above). This shall be the template identifier for - that particular code snippet. The second and third line above does - the actual template expansion: - - + + collects specially marked-up code snippets from stub.cpp + and places them in your QuickBook file as virtual templates. Each of the + specially marked-up code snippets has a name (e.g. foo + and bar in the example + above). This shall be the template identifier for that particular code + snippet. The second and third line above does the actual template expansion: + + [foo] [bar] - - And the result is: - - - - This is the foo - function. - - - This description can have paragraphs... - - - - lists - - - etc. - - - - And any quickbook block markup. - - - - -std::string foo() + + And the result is: + + + + This is the foo + function. + + + This description can have paragraphs... + + + + lists + + + etc. + + + + And any quickbook block markup. + + + +std::string foo() { // return 'em, foo man! return "foo"; } - - - - - - This is the bar - function - - - - -std::string bar() + + + This is the bar + function + + + +std::string bar() { // return 'em, bar man! return "bar"; } - - - Some trailing text here - - - - - Code - Snippet Markup - - - Note how the code snippets in stub.cpp - get marked up. We use distinguishable comments following the form: - - - -//[id + + + Some trailing text here + + + + + Code + Snippet Markup + + + Note how the code snippets in stub.cpp + get marked up. We use distinguishable comments following the form: + + +//[id some code here //] - - The first comment line above initiates a named code-snippet. This - prefix will not be visible in quickbook. The entire code-snippet - in between //[id and - //] will be inserted - as a template in quickbook with name id. - The comment //] ends - a code-snippet This too will not be visible in quickbook. - - - - Special - Comments - - - Special comments of the form: - - - -//` some [*quickbook] markup here + + The first comment line above initiates a named code-snippet. This prefix + will not be visible in quickbook. The entire code-snippet in between //[id and //] + will be inserted as a template in quickbook with name id. + The comment //] ends a code-snippet + This too will not be visible in quickbook. + + + + Special + Comments + + + Special comments of the form: + + +//` some [*quickbook] markup here - - and: - - - -/*` some [*quickbook] markup here */ + + and: + + +/*` some [*quickbook] markup here */ - - will be parsed by QuickBook. This can contain quickbook blocks - (e.g. sections, paragraphs, tables, etc). In the first case, the - initial slash-slash, tick and white-space shall be ignored. In the - second, the initial slash-star-tick and the final star-slash shall - be ignored. - - - - Callouts - - - Special comments of the form: - - - -/*< some [*quickbook] markup here >*/ + + will be parsed by QuickBook. This can contain quickbook blocks + (e.g. sections, paragraphs, tables, etc). In the first case, the initial + slash-slash, tick and white-space shall be ignored. In the second, the + initial slash-star-tick and the final star-slash shall be ignored. + + + + Callouts + + + Special comments of the form: + + +/*< some [*quickbook] markup here >*/ - - will be regarded as callouts. These will be collected, numbered and - rendered as a "callout bug" (a small icon with a number). - After the whole snippet is parsed, the callout list is generated. - See Callouts - for details. Example: - - - - - -std::string foo_bar() + + will be regarded as callouts. These will be collected, numbered and rendered + as a "callout bug" (a small icon with a number). After the whole + snippet is parsed, the callout list is generated. See Callouts + for details. Example: + + + + +std::string foo_bar() { return "foo-bar"; } - - - The Mythical FooBar. See Foobar - for details return 'em, foo-bar man! - - - - Checkout stub.cpp to see - the actual code. - -
-
- -
- <link linkend="quickbook.install"> Installation and configuration</link> - - This section provides some guidelines on how to install and configure - BoostBook and Quickbook under several operating systems. - Before continuing, it is very important that you keep this in mind: if - you try to build some documents and the process breaks due to misconfiguration, - be absolutely sure to delete any bin - and bin.v2 directories generated by the build - before trying again. Otherwise your configuration fixes will not take - any effect. + The Mythical FooBar. See Foobar + for details return 'em, foo-bar man! -
- <link linkend="quickbook.install.windows"> Windows 2000, XP, 2003, - Vista</link> - - -
- - - Section contributed by Julio M. Merino Vidal - - -
- - The following instructions apply to any Windows system based on Windows - 2000, including Windows XP, Windows 2003 Server and Windows Vista. - The paths shown below are taken from a Windows Vista machine; you will - need to adjust them to match your system in case you are running an - older version. - - - - First of all you need to have a copy of xsltproc - for Windows. There are many ways to get this tool, but to keep things - simple, use the binary - packages made by Igor Zlatkovic. At the very least, you need - to download the following packages: iconv, - zlib, libxml2 and libxslt. - - - Unpack all these packages in the same directory so that you get unique - bin, include and lib - directories within the hierarchy. These instructions use C:\Users\example\Documents\boost\xml as the root for all files. - - - From the command line, go to the bin - directory and launch xsltproc.exe - to ensure it works. You should get usage information on screen. - - - Download Docbook - XML 4.2 and unpack it in the same directory used above. That - is: C:\Users\example\Documents\boost\xml\docbook-xml. - - - Download the latest Docbook - XSL version and unpack it, again in the same directory used - before. To make things easier, rename the directory created during - the extraction to docbook-xsl - (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. - - - Add the following to your user-config.jam - file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). - You must already have it somewhere or otherwise you could not be - building Boost (i.e. missing tools configuration). - - - - -using xsltproc + + + Checkout stub.cpp to see the actual + code. + +
+
+ +
+ <link linkend="quickbook.install"> Installation and configuration</link> + + This section provides some guidelines on how to install and configure BoostBook + and Quickbook under several operating systems. + + + Before continuing, it is very important that you keep this in mind: if you + try to build some documents and the process breaks due to misconfiguration, + be absolutely sure to delete any bin + and bin.v2 directories generated by the build before + trying again. Otherwise your configuration fixes will not take any effect. + +
+ <link linkend="quickbook.install.windows"> Windows 2000, XP, 2003, Vista</link> + + +
+ + + Section contributed by Julio M. Merino Vidal + + +
+ + The following instructions apply to any Windows system based on Windows 2000, + including Windows XP, Windows 2003 Server and Windows Vista. The paths shown + below are taken from a Windows Vista machine; you will need to adjust them + to match your system in case you are running an older version. + + + + First of all you need to have a copy of xsltproc + for Windows. There are many ways to get this tool, but to keep things simple, + use the binary packages + made by Igor Zlatkovic. At the very least, you need to download the following + packages: iconv, zlib, libxml2 + and libxslt. + + + Unpack all these packages in the same directory so that you get unique + bin, include + and lib directories within + the hierarchy. These instructions use C:\Users\example\Documents\boost\xml + as the root for all files. + + + From the command line, go to the bin + directory and launch xsltproc.exe + to ensure it works. You should get usage information on screen. + + + Download Docbook + XML 4.2 and unpack it in the same directory used above. That is: + C:\Users\example\Documents\boost\xml\docbook-xml. + + + Download the latest Docbook + XSL version and unpack it, again in the same directory used before. + To make things easier, rename the directory created during the extraction + to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. + + + Add the following to your user-config.jam + file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). + You must already have it somewhere or otherwise you could not be building + Boost (i.e. missing tools configuration). + + + +using xsltproc : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe" ; @@ -2735,90 +2686,84 @@ for the journey to old age.]]] : "C:/Users/example/Documents/boost/xml/docbook-xml" ; - - The above steps are enough to get a functional BoostBook setup. Quickbook - will be automatically built when needed. If you want to avoid these - rebuilds: - - - - Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). - - - Build the utility by issuing bjam - --v2. - - - Copy the resulting quickbook.exe - binary (located under the BOOST_ROOT\bin.v2 - hierarchy) to a safe place. Following our previous example, you can - install it into: C:\Users\example\Documents\boost\xml\bin. - - - Add the following to your user-config.jam - file: - - - - -using quickbook + + The above steps are enough to get a functional BoostBook setup. Quickbook + will be automatically built when needed. If you want to avoid these rebuilds: + + + + Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). + + + Build the utility by issuing bjam + --v2. + + + Copy the resulting quickbook.exe + binary (located under the BOOST_ROOT\bin.v2 hierarchy) + to a safe place. Following our previous example, you can install it into: + C:\Users\example\Documents\boost\xml\bin. + + + Add the following to your user-config.jam + file: + + + +using quickbook : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe" ; -
-
- <link linkend="quickbook.install.linux"> Debian, Ubuntu</link> - - The following instructions apply to Debian and its derivatives. They - are based on a Ubuntu Edgy install but should work on other Debian - based systems. - - - First install the bjam, - xsltproc, docbook-xsl and docbook-xml - packages. For example, using apt-get: - - - -sudo apt-get install xsltprc docbook-xsl docbook-xml +
+
+ <link linkend="quickbook.install.linux"> Debian, Ubuntu</link> + + The following instructions apply to Debian and its derivatives. They are + based on a Ubuntu Edgy install but should work on other Debian based systems. + + + First install the bjam, + xsltproc, docbook-xsl and + docbook-xml packages. For example, using apt-get: + + +sudo apt-get install xsltprc docbook-xsl docbook-xml - - If you're planning on building boost's documentation, you'll also need - to install the doxygen - package as well. - - - Next, we need to configure Boost Build to compile BoostBook files. - Add the following to your user-config.jam - file, which should be in your home directory. If you don't have one, - create a file containing this text. For more information on setting - up user-config.jam, see the Boost - Build documentation. - - - -using xsltproc ; + + If you're planning on building boost's documentation, you'll also need to + install the doxygen package + as well. + + + Next, we need to configure Boost Build to compile BoostBook files. Add the + following to your user-config.jam file, which should be in your home + directory. If you don't have one, create a file containing this text. For + more information on setting up user-config.jam, see + the Boost + Build documentation. + + +using xsltproc ; using boostbook : /usr/share/xml/docbook/stylesheet/nwalsh @@ -2828,91 +2773,89 @@ for the journey to old age.]]] # Remove this line if you're not using doxygen using doxygen ; - - The above steps are enough to get a functional BoostBook setup. Quickbook - will be automatically built when needed. If you want to avoid these - rebuilds: - - - - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). - - - Build the utility by issuing bjam - --v2. - - - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 - hierarchy) to a safe place. The traditional location is /usr/local/bin. - - - Add the following to your user-config.jam - file, using the full path of the quickbook executable: - - - - -using quickbook + + The above steps are enough to get a functional BoostBook setup. Quickbook + will be automatically built when needed. If you want to avoid these rebuilds: + + + + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + + + Build the utility by issuing bjam + --v2. + + + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) + to a safe place. The traditional location is /usr/local/bin. + + + Add the following to your user-config.jam + file, using the full path of the quickbook executable: + + + +using quickbook : /usr/local/bin/quickbook ; -
-
-
- <link linkend="quickbook.editors"> Editor Support</link> +
+ +
+ <link linkend="quickbook.editors"> Editor Support</link> + + Editing quickbook files is usually done with text editors both simple and powerful. + The following sections list the settings for some editors which can help make + editing quickbook files a bit easier. + + + + + + note + + You may submit your settings, tips, and suggestions to + the authors, or through the docs + Boost Docs mailing list. + + +
+ <link linkend="quickbook.editors.scite"> Scintilla Text Editor</link> +
+ - Editing quickbook files is usually done with text editors both simple - and powerful. The following sections list the settings for some editors - which can help make editing quickbook files a bit easier. + Section contributed by Dean Michael Berris - - - - - note - - You may submit your settings, tips, and suggestions - to the authors, or through the docs - Boost Docs mailing list. - - -
- <link linkend="quickbook.editors.scite"> Scintilla Text Editor</link> -
- - - Section contributed by Dean Michael Berris - - -
- - The Scintilla Text Editor (SciTE) is a free source code editor for - Win32 and X. It uses the SCIntilla source code editing component. - - - - - - tip - - SciTE can be downloaded from http://www.scintilla.org/SciTE.html - - - - You can use the following settings to highlight quickbook tags when - editing quickbook files. - - + +
+ + The Scintilla Text Editor (SciTE) is a free source code editor for Win32 + and X. It uses the SCIntilla source code editing component. + + + + + + tip + + SciTE can be downloaded from http://www.scintilla.org/SciTE.html + + + + You can use the following settings to highlight quickbook tags when editing + quickbook files. + + qbk=*.qbk lexer.*.qbk=props use.tabs.$(qbk)=0 @@ -2925,47 +2868,45 @@ comment.box.start.props=[/ comment.box.middle.props= comment.box.end.props=] - - - - - note - - Thanks to Rene Rivera for the above SciTE settings. - - -
-
-
- <link linkend="quickbook.faq"> Frequently Asked Questions</link> - - - Can - I use QuickBook for non-Boost documentation? - - - QuickBook can be used for non-Boost documentation with a little extra - work. - -
- - - Faq contributed by Michael Marcin - - -
- - When building HTML documentation with BoostBook a Boost C++ Libraries - header is added to the files. When using QuickBook to document projects - outside of Boost this is not desirable. This behavior can be overridden - at the BoostBook level by specifying some XSLT options. When using Boost - Build version 2 (BBv2) this can be achieved by adding parameters to the - BoostBook target declaration. - - - For example: - - + + + + + note + + Thanks to Rene Rivera for the above SciTE settings. + + +
+ +
+ <link linkend="quickbook.faq"> Frequently Asked Questions</link> + + + Can + I use QuickBook for non-Boost documentation? + + + QuickBook can be used for non-Boost documentation with a little extra work. + +
+ + + Faq contributed by Michael Marcin + + +
+ + When building HTML documentation with BoostBook a Boost C++ Libraries header + is added to the files. When using QuickBook to document projects outside of + Boost this is not desirable. This behavior can be overridden at the BoostBook + level by specifying some XSLT options. When using Boost Build version 2 (BBv2) + this can be achieved by adding parameters to the BoostBook target declaration. + + + For example: + + using quickbook ; xml my_doc : my_doc.qbk ; @@ -2981,785 +2922,780 @@ boostbook standalone <xsl:param>nav.layout=none ; -
-
- <link linkend="quickbook.ref"> Quick Reference</link> +
+
+ <link linkend="quickbook.ref"> Quick Reference</link> + + [cpp] + + Syntax Compendium + + + + - [cpp] + To do this... -
Syntax Compendium - - - - - - To do this... - - - - Use this... - - - - See this... - - - - - - - - - comment - - - - [/ some comment] - - - - Comments - - - - - - - italics - - - - ['italics] or /italics/ - - - - Font Styles - and Simple - formatting - - - - - - - bold - - - - [*bold] or *bold* - - - - Font Styles - and Simple - formatting - - - - - - - underline - - - - [_underline] or _underline_ - - - - Font Styles - and Simple - formatting - - - - - - - teletype - - - - [^teletype] or =teletype= - - - - Font Styles - and Simple - formatting - - - - - - - strikethrough - - - - [-strikethrough] - - - - Font Styles - and Simple - formatting - - - - - - - - replaceable - - - - - [~replaceable] - - - - Replaceble - - - - - - - source mode - - - - [c++] or [python] - - - - Source Mode - - - - - - - inline code - - - - `int main();` - - - - Inline code - - - - - - - code block - - - - ``int main();`` - - - - Code - - - - - - - code escape - - - - ``from c++ to QuickBook`` - - - - Escaping Back - To QuickBook - - - - - - - line break - - - - [br] or \n - - - - line-break - DEPRECATED - - - - - - - anchor - - - - [#anchor] - - - - Anchors - - - - - - - link - - - - [@http://www.boost.org Boost] - - - - Links - - - - - - - anchor link - - - - [link section.anchor Link text] - - - - Anchor links - - - - - - - refentry link - - - - [link xml.refentry Link text] - - - - refentry - links - - - - - - - function link - - - - [funcref fully::qualified::function_name Link text] - - - - function, class, - member, enum, macro, concept or header links - - - - - - - class link - - - - [classref fully::qualified::class_name Link text] - - - - function, class, - member, enum, macro, concept or header links - - - - - - - member link - - - - [memberref fully::qualified::member_name Link text] - - - - function, class, - member, enum, macro, concept or header links - - - - - - - enum link - - - - [enumref fully::qualified::enum_name Link text] - - - - function, class, - member, enum, macro, concept or header links - - - - - - - macro link - - - - [macroref MACRO_NAME Link text] - - - - function, class, - member, enum, macro, concept or header links - - - - - - - concept link - - - - [conceptref ConceptName Link text] - - - - function, class, - member, enum, macro, concept or header links - - - - - - - header link - - - - [headerref path/to/header.hpp Link text] - - - - function, class, - member, enum, macro, concept or header links - - - - - - - escape - - - - '''escaped text (no processing/formatting)''' - - - - Escape - - - - - - - single char escape - - - - \c - - - - Single - char escape - - - - - - - images - - - - [$image.jpg] - - - - Images - - - - - - - begin section - - - - [section The Section Title] - - - - Section - - - - - - - end section - - - - [endsect] - - - - Section - - - - - - - paragraph - - - - No markup. Paragraphs start left-flushed and are terminated by - two or more newlines. - - - - Paragraphs - - - - - - - ordered list - - - - + + + Use this... + + + + See this... + + + + + + + + + comment + + + + [/ some comment] + + + + Comments + + + + + + + italics + + + + ['italics] or /italics/ + + + + Font Styles + and Simple + formatting + + + + + + + bold + + + + [*bold] or *bold* + + + + Font Styles + and Simple + formatting + + + + + + + underline + + + + [_underline] or _underline_ + + + + Font Styles + and Simple + formatting + + + + + + + teletype + + + + [^teletype] or =teletype= + + + + Font Styles + and Simple + formatting + + + + + + + strikethrough + + + + [-strikethrough] + + + + Font Styles + and Simple + formatting + + + + + + + + replaceable + + + + + [~replaceable] + + + + Replaceble + + + + + + + source mode + + + + [c++] or [python] + + + + Source Mode + + + + + + + inline code + + + + `int main();` + + + + Inline code + + + + + + + code block + + + + ``int main();`` + + + + Code + + + + + + + code escape + + + + ``from c++ to QuickBook`` + + + + Escaping Back To QuickBook + + + + + + + line break + + + + [br] or \n + + + + line-break + DEPRECATED + + + + + + + anchor + + + + [#anchor] + + + + Anchors + + + + + + + link + + + + [@http://www.boost.org Boost] + + + + Links + + + + + + + anchor link + + + + [link section.anchor Link text] + + + + Anchor links + + + + + + + refentry link + + + + [link xml.refentry Link text] + + + + refentry links + + + + + + + function link + + + + [funcref fully::qualified::function_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + class link + + + + [classref fully::qualified::class_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + member link + + + + [memberref fully::qualified::member_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + enum link + + + + [enumref fully::qualified::enum_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + macro link + + + + [macroref MACRO_NAME Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + concept link + + + + [conceptref ConceptName Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + header link + + + + [headerref path/to/header.hpp Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + escape + + + + '''escaped text (no processing/formatting)''' + + + + Escape + + + + + + + single char escape + + + + \c + + + + Single char + escape + + + + + + + images + + + + [$image.jpg] + + + + Images + + + + + + + begin section + + + + [section The Section Title] + + + + Section + + + + + + + end section + + + + [endsect] + + + + Section + + + + + + + paragraph + + + + No markup. Paragraphs start left-flushed and are terminated by two or + more newlines. + + + + Paragraphs + + + + + + + ordered list + + + + # one # two # three - - - - Ordered - lists - - - - - - - unordered list - - - - + + + + Ordered lists + + + + + + + unordered list + + + + * one * two * three - - - - Unordered - lists - - - - - - - code - - - - No markup. Preformatted code starts with a space or a tab. - - - - Code - - - - - - - preformatted - - - - [pre preformatted] - - - - Preformatted - - - - - - - block quote - - - - [:sometext...] - - - - Blockquote - - - - - - - heading 1 - - - - [h1 Heading 1] - - - - Heading - - - - - - - heading 2 - - - - [h2 Heading 2] - - - - Heading - - - - - - - heading 3 - - - - [h3 Heading 3] - - - - Heading - - - - - - - heading 4 - - - - [h4 Heading 4] - - - - Heading - - - - - - - heading 5 - - - - [h5 Heading 5] - - - - Heading - - - - - - - heading 6 - - - - [h6 Heading 6] - - - - Heading - - - - - - - macro - - - - [def macro_identifier some text] - - - - Macros - - - - - - - template - - - - [template[a b] [a] body [b]] - - - - Templates - - - - - - - blurb - - - - [blurb advertisement or note...] - - - - Blurbs - - - - - - - admonition - - - - [warning Warning text...] - - - - Admonitions - - - - - - - table - - - - + + + + Unordered + lists + + + + + + + code + + + + No markup. Preformatted code starts with a space or a tab. + + + + Code + + + + + + + preformatted + + + + [pre preformatted] + + + + Preformatted + + + + + + + block quote + + + + [:sometext...] + + + + Blockquote + + + + + + + heading 1 + + + + [h1 Heading 1] + + + + Heading + + + + + + + heading 2 + + + + [h2 Heading 2] + + + + Heading + + + + + + + heading 3 + + + + [h3 Heading 3] + + + + Heading + + + + + + + heading 4 + + + + [h4 Heading 4] + + + + Heading + + + + + + + heading 5 + + + + [h5 Heading 5] + + + + Heading + + + + + + + heading 6 + + + + [h6 Heading 6] + + + + Heading + + + + + + + macro + + + + [def macro_identifier some text] + + + + Macros + + + + + + + template + + + + [template[a b] [a] body [b]] + + + + Templates + + + + + + + blurb + + + + [blurb advertisement or note...] + + + + Blurbs + + + + + + + admonition + + + + [warning Warning text...] + + + + Admonitions + + + + + + + table + + + + [table Title [[a][b][c]] [[a][b][c]] ] - - - - Tables - - - - - - - variablelist - - - - + + + + Tables + + + + + + + variablelist + + + + [variablelist Title [[a][b]] [[a][b]] ] - - - - Variable - Lists - - - - - - - include - - - - [include someother.qbk] - - - - Include - - - - - -
-
- - \ No newline at end of file +
+ + + Variable Lists + + + + + + + include + + + + [include someother.qbk] + + + + Include + + + + + + + + diff --git a/test/templates.gold b/test/templates.gold index d6323ba..3488d99 100644 --- a/test/templates.gold +++ b/test/templates.gold @@ -47,8 +47,7 @@ - -int main() +int main() { std::cout << "Hello, World" << std::endl; } diff --git a/test/templates.quickbook b/test/templates.quickbook index 6683f11..538a5b0 100644 --- a/test/templates.quickbook +++ b/test/templates.quickbook @@ -93,4 +93,11 @@ x[super 2] [plantation [banana]] +[/-------------------------------- Bugs! ] + +[template join1[a b] [b][a]] +[template join2[a b] [a][b]] +[template test[x] [join1 [join2 0 [x]] 0]] +[test 0] + [endsect] From ec0c61a8f0fe5ac299325ff10ae22f0a73dbd27f Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 18 Aug 2008 21:46:32 +0000 Subject: [PATCH 16/94] Merged revisions 47861-47862,47873 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r47861 | eric_niebler | 2008-07-28 22:38:59 -0700 (Mon, 28 Jul 2008) | 1 line add globalname for linking to the documentation for a global object ........ r47862 | eric_niebler | 2008-07-28 22:52:35 -0700 (Mon, 28 Jul 2008) | 1 line add globalref tag for linking to the reference section for a global object ........ r47873 | eric_niebler | 2008-07-29 14:59:36 -0700 (Tue, 29 Jul 2008) | 1 line add new globalname entity to DTD ........ [SVN r48202] --- detail/actions_class.cpp | 2 + detail/actions_class.hpp | 2 + detail/markups.hpp | 2 + doc/html/index.html | 12 +- doc/html/quickbook/change_log.html | 52 +- doc/html/quickbook/editors.html | 22 +- doc/html/quickbook/editors/kde_support.html | 117 ++--- doc/html/quickbook/editors/scite.html | 29 +- doc/html/quickbook/faq.html | 33 +- doc/html/quickbook/install.html | 19 +- doc/html/quickbook/install/linux.html | 52 +- doc/html/quickbook/install/macosx.html | 60 ++- doc/html/quickbook/install/windows.html | 61 ++- doc/html/quickbook/intro.html | 17 +- doc/html/quickbook/ref.html | 242 +++++----- doc/html/quickbook/syntax.html | 13 +- doc/html/quickbook/syntax/block.html | 505 ++++++++++---------- doc/html/quickbook/syntax/comments.html | 15 +- doc/html/quickbook/syntax/phrase.html | 287 +++++------ doc/quickbook.qbk | 9 +- phrase.hpp | 14 +- 21 files changed, 813 insertions(+), 752 deletions(-) mode change 100755 => 100644 doc/quickbook.qbk diff --git a/detail/actions_class.cpp b/detail/actions_class.cpp index 17d675f..d5f6bf2 100644 --- a/detail/actions_class.cpp +++ b/detail/actions_class.cpp @@ -113,6 +113,8 @@ namespace quickbook , headerref_post(phrase, headerref_post_) , conceptref_pre(phrase, conceptref_pre_) , conceptref_post(phrase, conceptref_post_) + , globalref_pre(phrase, globalref_pre_) + , globalref_post(phrase, globalref_post_) , bold_pre(phrase, bold_pre_) , bold_post(phrase, bold_post_) diff --git a/detail/actions_class.hpp b/detail/actions_class.hpp index 5fc3a25..332d581 100644 --- a/detail/actions_class.hpp +++ b/detail/actions_class.hpp @@ -136,6 +136,8 @@ namespace quickbook markup_action headerref_post; link_action conceptref_pre; markup_action conceptref_post; + link_action globalref_pre; + markup_action globalref_post; markup_action bold_pre; markup_action bold_post; diff --git a/detail/markups.hpp b/detail/markups.hpp index 0038948..5e80805 100644 --- a/detail/markups.hpp +++ b/detail/markups.hpp @@ -90,6 +90,8 @@ namespace quickbook { namespace /*unnamed*/ const char* headerref_post_ = ""; const char* conceptref_pre_ = " Quickbook 1.4 - + - + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -34,7 +34,7 @@
-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

@@ -70,7 +70,7 @@
- +

Last revised: May 21, 2008 at 03:54:31 GMT

Last revised: July 29, 2008 at 05:49:54 GMT


diff --git a/doc/html/quickbook/change_log.html b/doc/html/quickbook/change_log.html index 41c81cc..ca86dce 100644 --- a/doc/html/quickbook/change_log.html +++ b/doc/html/quickbook/change_log.html @@ -1,21 +1,21 @@ - Change Log +Change Log - + - - + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,11 +24,12 @@
+

+ + Version 1.3 +

  • Quickbook file inclusion [include]. @@ -58,14 +59,13 @@
  • Better (intuitive) paragraph termination. Some markups may terminate a paragraph. Example: -
    -[section x]
    +
    [section x]
     blah...
     [endsect]
  • Fully qualified section and headers. Subsection names are concatenated to - the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name + the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name
  • Better &nbsp; and whitespace handling in code snippets. @@ -93,10 +93,10 @@ Replaceable, with the [~replacement] syntax.
-

- - Version 1.4 -

+

+ + Version 1.4 +

  • Generic Headers @@ -115,7 +115,7 @@
  • Allow escape of spaces. The escaped space is removed from the output. Syntax: - \ . + \ .
  • Nested comments are now allowed. @@ -124,7 +124,7 @@ Quickbook blocks can nest inside comments.
  • -Import facility. +Import facility.
  • Callouts on imported code @@ -133,21 +133,21 @@ Simple markups can now span a whole block.
  • -Blurbs, Admonitions - and table cells (see Tables) +Blurbs, Admonitions + and table cells (see Tables) may now contain paragraphs.
  • -\n - and [br] are now deprecated. +\n + and [br] are now deprecated.
  • -Conditional Generation. +Conditional Generation. Ala C++ #ifdef.
  • Searching of included and imported files in an extensible search path with - --include-path (-I) option. + --include-path (-I) option.
diff --git a/doc/html/quickbook/editors.html b/doc/html/quickbook/editors.html index 2900de5..4dffcf6 100644 --- a/doc/html/quickbook/editors.html +++ b/doc/html/quickbook/editors.html @@ -1,21 +1,21 @@ - Editor Support +Editor Support - + - - + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Scintilla Text Editor
KDE Support
@@ -34,11 +35,14 @@ The following sections list the settings for some editors which can help make editing quickbook files a bit easier.

-
diff --git a/doc/html/quickbook/editors/kde_support.html b/doc/html/quickbook/editors/kde_support.html index d772752..2ec12ab 100644 --- a/doc/html/quickbook/editors/kde_support.html +++ b/doc/html/quickbook/editors/kde_support.html @@ -3,19 +3,19 @@ KDE Support - + - - - + + +
- - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,11 +24,12 @@ +
+ + boost::hs::quickbook +

boost::hs::quickbook is a syntax highlighting designed to work with Katepart. It can be used in KWrite, Kate, Konqueror and KDevelop, and supports all @@ -48,11 +49,11 @@

- html generated from this .qbk file + html generated from this .qbk file

-

Table 7. Code examples

- +

Table 7. Code examples

+
@@ -84,8 +85,8 @@ -

- for(int k=0; - k<10; k++) v+=k; + for(int k=0; + k<10; k++) v+=k;

@@ -102,12 +103,12 @@

- { int + { int k; while( k < 10 ) - { v+=k; k++ } } + { v+=k; k++ } }

@@ -124,10 +125,10 @@

- while( + while( true ) { v+=1; - } + }

@@ -137,34 +138,34 @@
+
-

- - Code Folding +

+ + Code Folding -
+

boost::hs goes far beyond simple coloring. One useful thing you can get the editor to do is to mark regions. They appear in a small grey line and each region can be folded or unfolded independently.

-

- - Auto +

+ + Auto Comment / Uncomment -
+

Another important feature is the possibility to auto-comment or uncomment some piece of code (Tools - Comment). Commented regions can be uncommented simple calling the uncomment command while being in it.

-

- - Styles reference +

+ + Styles reference -
+
@@ -192,7 +193,7 @@

- plain text + plain text

@@ -209,7 +210,7 @@

- formatted text + formatted text

@@ -226,7 +227,7 @@

- structure + structure

@@ -244,7 +245,7 @@

- macros + macros

@@ -262,7 +263,7 @@

- templates + templates

@@ -279,7 +280,7 @@

- anchors + anchors

@@ -296,7 +297,7 @@

- comments + comments

@@ -313,7 +314,7 @@

- tables + tables

@@ -330,7 +331,7 @@

- variable lists + variable lists

@@ -347,7 +348,7 @@

- c++ code + c++ code

@@ -364,7 +365,7 @@

- paths + paths

@@ -381,7 +382,7 @@

- IDE specific + IDE specific

@@ -397,10 +398,10 @@
-

- - About boost::hs -

+
+ + About boost::hs +

boost.hs.logo

@@ -414,15 +415,15 @@ [Note] Note -

+

boost::hs::cpp support QuickBook code import comments style!

-

- - Installing +

+ + Installing boost::hs -
+

There exist an ongoing effort to push boost::hs upstream to the KatePart project. In a few months KDE may have native Quickbook support! For the moment @@ -436,13 +437,13 @@ [Note] Note -

- A copy of boost::hs::quickbook and boost::hs::cpp is available in boost/tools/quickbook/extra/katepart. +

+ A copy of boost::hs::quickbook and boost::hs::cpp is available in boost/tools/quickbook/extra/katepart.

- In order to install it you must copy the content in the folder katepart/syntax/ to the appropriate katepart syntax - folder in your machine. In general this folder will be in /usr/share/apps/katepart/syntax. + In order to install it you must copy the content in the folder katepart/syntax/ to the appropriate katepart syntax + folder in your machine. In general this folder will be in /usr/share/apps/katepart/syntax. A bash script named install.sh is included that copy the files to this folder.

diff --git a/doc/html/quickbook/editors/scite.html b/doc/html/quickbook/editors/scite.html index 3c6698d..1b2f8a0 100644 --- a/doc/html/quickbook/editors/scite.html +++ b/doc/html/quickbook/editors/scite.html @@ -1,12 +1,12 @@ - Scintilla Text Editor +Scintilla Text Editor - + - - + + @@ -14,8 +14,8 @@ Boost C++ Libraries Home Libraries -People -FAQ +People +FAQ More
@@ -24,7 +24,8 @@

@@ -38,9 +39,12 @@ The Scintilla Text Editor (SciTE) is a free source code editor for Win32 and X. It uses the SCIntilla source code editing component.

-

You can use the following settings to highlight quickbook tags when editing quickbook files. @@ -57,9 +61,12 @@ comment.box.start.props=[/ comment.box.middle.props= comment.box.end.props=]

- diff --git a/doc/html/quickbook/faq.html b/doc/html/quickbook/faq.html index 36a2094..8fa26a2 100644 --- a/doc/html/quickbook/faq.html +++ b/doc/html/quickbook/faq.html @@ -1,21 +1,21 @@ - Frequently Asked Questions +Frequently Asked Questions - + - +
- - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,12 +24,13 @@ +

+ + Can I use QuickBook for non-Boost documentation? -

+

QuickBook can be used for non-Boost documentation with a little extra work.

@@ -60,18 +61,18 @@ boostbook standalone : my_doc : - <xsl:param>boost.image.srcimages/my_project_logo.png - <xsl:param>boost.image.alt"\"My Project\"" + <xsl:param>boost.image.srcimages/my_project_logo.png + <xsl:param>boost.image.alt"\"My Project\"" <xsl:param>boost.image.w=100 <xsl:param>boost.image.h=50 <xsl:param>nav.layout=none ;
-

- - Is +

+ + Is there an easy way to convert BoostBook docs to QuickBook? -

+

There's a stylesheet that allows Boostbook generated HTML to be viewed as quickbook source, see http://svn.boost.org/trac/boost/wiki/QuickbookSourceStylesheetProject, diff --git a/doc/html/quickbook/install.html b/doc/html/quickbook/install.html index 7b33e1f..1c741ac 100644 --- a/doc/html/quickbook/install.html +++ b/doc/html/quickbook/install.html @@ -1,21 +1,21 @@ - Installation and configuration +Installation and configuration - + - - + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More


@@ -24,7 +24,8 @@
Mac OS X
Windows 2000, XP, 2003, Vista
@@ -37,8 +38,8 @@

Before continuing, it is very important that you keep this in mind: if you try to build some documents and the process breaks due to misconfiguration, - be absolutely sure to delete any bin - and bin.v2 directories generated by the build before + be absolutely sure to delete any bin + and bin.v2 directories generated by the build before trying again. Otherwise your configuration fixes will not take any effect.

diff --git a/doc/html/quickbook/install/linux.html b/doc/html/quickbook/install/linux.html index c6b7253..27d603c 100644 --- a/doc/html/quickbook/install/linux.html +++ b/doc/html/quickbook/install/linux.html @@ -1,21 +1,21 @@ - Debian, Ubuntu +Debian, Ubuntu - + - - - + + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,34 +24,33 @@

The following instructions apply to Debian and its derivatives. They are based on a Ubuntu Edgy install but should work on other Debian based systems.

- First install the bjam, - xsltproc, docbook-xsl and - docbook-xml packages. For example, using apt-get: + First install the bjam, + xsltproc, docbook-xsl and + docbook-xml packages. For example, using apt-get:

-
-sudo apt-get install xsltproc docbook-xsl docbook-xml
+
sudo apt-get install xsltproc docbook-xsl docbook-xml
 

If you're planning on building boost's documentation, you'll also need to - install the doxygen package + install the doxygen package as well.

Next, we need to configure Boost Build to compile BoostBook files. Add the - following to your user-config.jam file, which should be in your home + following to your user-config.jam file, which should be in your home directory. If you don't have one, create a file containing this text. For - more information on setting up user-config.jam, see + more information on setting up user-config.jam, see the Boost Build documentation.

-
-using xsltproc ;
+
using xsltproc ;
 
 using boostbook
     : /usr/share/xml/docbook/stylesheet/nwalsh
@@ -67,24 +66,23 @@
       

  1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook).
  2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
  3. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) - to a safe place. The traditional location is /usr/local/bin. + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) + to a safe place. The traditional location is /usr/local/bin.
  4. - Add the following to your user-config.jam + Add the following to your user-config.jam file, using the full path of the quickbook executable:
-
-using quickbook
+
using quickbook
     : /usr/local/bin/quickbook
     ;
 
diff --git a/doc/html/quickbook/install/macosx.html b/doc/html/quickbook/install/macosx.html index e664184..2638504 100644 --- a/doc/html/quickbook/install/macosx.html +++ b/doc/html/quickbook/install/macosx.html @@ -1,21 +1,21 @@ - Mac OS X +Mac OS X - + - - - + + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@

@@ -44,13 +45,13 @@

The text below assumes you want to install all the necessary utilities in a system-wide location, allowing any user in the machine to have access to - them. Therefore, all files will be put in the /usr/local + them. Therefore, all files will be put in the /usr/local hierarchy. If you do not want this, you can choose any other prefix such - as ~/Applications + as ~/Applications for a single-user installation.

- Mac OS X comes with xsltproc + Mac OS X comes with xsltproc and all related libraries preinstalled, so you do not need to take any extra steps to set them up. It is probable that future versions will include them too, but these instructions may not apply to older versions. @@ -61,22 +62,21 @@

  1. Download Docbook - XML 4.2 and unpack it inside /usr/local/share/xml/docbook/4.2. + XML 4.2 and unpack it inside /usr/local/share/xml/docbook/4.2.
  2. Download the latest Docbook - XSL version and unpack it. Put the results in /usr/local/share/xsl/docbook, thus effectively removing the + XSL version and unpack it. Put the results in /usr/local/share/xsl/docbook, thus effectively removing the version number from the directory name (for simplicity).
  3. - Add the following to your user-config.jam - file, which should live in your home directory (/Users/<your_username>). + Add the following to your user-config.jam + file, which should live in your home directory (/Users/<your_username>). You must already have it somewhere or otherwise you could not be building Boost (i.e. missing tools configuration).
-
-using xsltproc ;
+
using xsltproc ;
 
 using boostbook
     : "/usr/local/share/xsl/docbook"
@@ -90,25 +90,24 @@
       

  1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook).
  2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
  3. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) to a safe place. Following our previous example, you can install it into: - /usr/local/bin. + /usr/local/bin.
  4. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
-
-using quickbook
+
using quickbook
     : "/usr/local/bin/quickbook" ;
     ;
 
@@ -119,19 +118,18 @@
  1. Go to the downloads - section and get the disk image (dmg + section and get the disk image (dmg file) for Mac OS X.
  2. - Open the disk image and drag the Doxygen application to your Applications folder to install it. + Open the disk image and drag the Doxygen application to your Applications folder to install it.
  3. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
-
-using doxygen
+
using doxygen
     : /Applications/Doxygen.app/Contents/Resources/doxygen
     ;
 
diff --git a/doc/html/quickbook/install/windows.html b/doc/html/quickbook/install/windows.html index 605c89b..16dad50 100644 --- a/doc/html/quickbook/install/windows.html +++ b/doc/html/quickbook/install/windows.html @@ -1,21 +1,21 @@ - Windows 2000, XP, 2003, Vista +Windows 2000, XP, 2003, Vista - + - - - + + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@

@@ -44,45 +45,44 @@

  1. - First of all you need to have a copy of xsltproc + First of all you need to have a copy of xsltproc for Windows. There are many ways to get this tool, but to keep things simple, use the binary packages made by Igor Zlatkovic. At the very least, you need to download the following - packages: iconv, zlib, libxml2 - and libxslt. + packages: iconv, zlib, libxml2 + and libxslt.
  2. Unpack all these packages in the same directory so that you get unique - bin, include - and lib directories within - the hierarchy. These instructions use C:\Users\example\Documents\boost\xml + bin, include + and lib directories within + the hierarchy. These instructions use C:\Users\example\Documents\boost\xml as the root for all files.
  3. - From the command line, go to the bin - directory and launch xsltproc.exe + From the command line, go to the bin + directory and launch xsltproc.exe to ensure it works. You should get usage information on screen.
  4. Download Docbook XML 4.2 and unpack it in the same directory used above. That is: - C:\Users\example\Documents\boost\xml\docbook-xml. + C:\Users\example\Documents\boost\xml\docbook-xml.
  5. Download the latest Docbook XSL version and unpack it, again in the same directory used before. To make things easier, rename the directory created during the extraction - to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. + to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl.
  6. - Add the following to your user-config.jam - file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). + Add the following to your user-config.jam + file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). You must already have it somewhere or otherwise you could not be building Boost (i.e. missing tools configuration).
-
-using xsltproc
+
using xsltproc
     : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe"
     ;
 
@@ -97,25 +97,24 @@
       

  1. - Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). + Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook).
  2. - Build the utility by issuing bjam - --v2. + Build the utility by issuing bjam + --v2.
  3. - Copy the resulting quickbook.exe - binary (located under the BOOST_ROOT\bin.v2 hierarchy) + Copy the resulting quickbook.exe + binary (located under the BOOST_ROOT\bin.v2 hierarchy) to a safe place. Following our previous example, you can install it into: - C:\Users\example\Documents\boost\xml\bin. + C:\Users\example\Documents\boost\xml\bin.
  4. - Add the following to your user-config.jam + Add the following to your user-config.jam file:
-
-using quickbook
+
using quickbook
     : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe"
     ;
 
diff --git a/doc/html/quickbook/intro.html b/doc/html/quickbook/intro.html index 9a2a57c..d708858 100644 --- a/doc/html/quickbook/intro.html +++ b/doc/html/quickbook/intro.html @@ -1,21 +1,21 @@ - Introduction +Introduction - + - + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,13 +24,14 @@

- Why program by hand in five days - what you can spend five years of your life automating? + Why program by hand in five days + what you can spend five years of your life automating?

diff --git a/doc/html/quickbook/ref.html b/doc/html/quickbook/ref.html index c12acbc..dda1c48 100644 --- a/doc/html/quickbook/ref.html +++ b/doc/html/quickbook/ref.html @@ -1,20 +1,20 @@ - Quick Reference +Quick Reference - + - + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -23,12 +23,13 @@

-

Table 8. Syntax Compendium

- +

Table 8. Syntax Compendium

+
@@ -60,12 +61,12 @@ @@ -77,13 +78,13 @@ @@ -91,18 +92,18 @@ @@ -115,13 +116,13 @@ @@ -129,18 +130,18 @@ @@ -153,13 +154,13 @@ @@ -167,19 +168,19 @@ @@ -191,12 +192,12 @@ @@ -208,12 +209,12 @@ @@ -225,12 +226,12 @@ @@ -242,13 +243,12 @@ @@ -260,13 +260,13 @@ @@ -278,12 +278,12 @@ @@ -295,12 +295,12 @@ @@ -312,12 +312,12 @@ @@ -329,12 +329,12 @@ @@ -346,12 +346,12 @@ @@ -364,12 +364,12 @@ @@ -382,12 +382,12 @@ @@ -400,12 +400,12 @@ @@ -418,12 +418,12 @@ @@ -436,12 +436,12 @@ @@ -454,12 +454,30 @@ + + + + + @@ -472,12 +490,12 @@ @@ -489,13 +507,12 @@ @@ -508,12 +525,12 @@ @@ -525,12 +542,12 @@ @@ -542,12 +559,12 @@ @@ -565,7 +582,7 @@ @@ -588,8 +605,7 @@ @@ -612,8 +628,7 @@ @@ -631,7 +646,7 @@ @@ -643,12 +658,12 @@ @@ -660,12 +675,12 @@ @@ -677,12 +692,12 @@ @@ -694,12 +709,12 @@ @@ -711,12 +726,12 @@ @@ -728,12 +743,12 @@ @@ -745,12 +760,12 @@ @@ -762,12 +777,12 @@ @@ -779,12 +794,12 @@ @@ -796,12 +811,12 @@ @@ -813,12 +828,12 @@ @@ -830,12 +845,12 @@ @@ -859,7 +874,7 @@ @@ -883,7 +898,7 @@ @@ -895,12 +910,12 @@ @@ -912,18 +927,19 @@ -

- [/ some comment] + [/ some comment]

- Comments + Comments

- ['italics] or /italics/ + ['italics] or /italics/

- Font Styles - and Simple + Font Styles + and Simple formatting

- bold + bold

- [*bold] or *bold* + [*bold] or *bold*

- Font Styles - and Simple + Font Styles + and Simple formatting

- [_underline] or _underline_ + [_underline] or _underline_

- Font Styles - and Simple + Font Styles + and Simple formatting

- teletype + teletype

- [^teletype] or =teletype= + [^teletype] or =teletype=

- Font Styles - and Simple + Font Styles + and Simple formatting

- [-strikethrough] + [-strikethrough]

- Font Styles - and Simple + Font Styles + and Simple formatting

- + replaceable - +

- [~replaceable] + [~replaceable]

- Replaceble + Replaceble

- [c++] or [python] + [c++] or [python]

- Source Mode + Source Mode

- `int main();` + `int main();`

- Inline code + Inline code

- ``int main();`` + ``int main();``

- Code + Code

- ``from c++ to QuickBook`` + ``from c++ to QuickBook``

- Escaping Back To QuickBook + Escaping Back To QuickBook

- [br] or \n + [br] or \n

- line-break - DEPRECATED + line-break + DEPRECATED

- [#anchor] + [#anchor]

- Anchors + Anchors

- [@http://www.boost.org Boost] + [@http://www.boost.org Boost]

- Links + Links

- [link section.anchor Link text] + [link section.anchor Link text]

- Anchor links + Anchor links

- [link xml.refentry Link text] + [link xml.refentry Link text]

- refentry links + refentry links

- [funcref fully::qualified::function_name Link text] + [funcref fully::qualified::function_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [classref fully::qualified::class_name Link text] + [classref fully::qualified::class_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [memberref fully::qualified::member_name Link text] + [memberref fully::qualified::member_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [enumref fully::qualified::enum_name Link text] + [enumref fully::qualified::enum_name Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [macroref MACRO_NAME Link text] + [macroref MACRO_NAME Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [conceptref ConceptName Link text] + [conceptref ConceptName Link text]

- function, class, member, + function, class, member, enum, macro, concept or header links

- [headerref path/to/header.hpp Link text] + [headerref path/to/header.hpp Link text]

- function, class, member, + function, class, member, + enum, macro, concept or header links +

+
+

+ global link +

+
+

+ [globalref fully::qualified::global Link text] +

+
+

+ function, class, member, enum, macro, concept or header links

- '''escaped text (no processing/formatting)''' + '''escaped text (no processing/formatting)'''

- Escape + Escape

- \c + \c

- Single char + Single char escape

- [$image.jpg] + [$image.jpg]

- Images + Images

- [section The Section Title] + [section The Section Title]

- Section + Section

- [endsect] + [endsect]

- Section + Section

- Paragraphs + Paragraphs

- Ordered lists + Ordered lists

- Unordered + Unordered lists

- Code + Code

- [pre preformatted] + [pre preformatted]

- Preformatted + Preformatted

- [:sometext...] + [:sometext...]

- Blockquote + Blockquote

- [h1 Heading 1] + [h1 Heading 1]

- Heading + Heading

- [h2 Heading 2] + [h2 Heading 2]

- Heading + Heading

- [h3 Heading 3] + [h3 Heading 3]

- Heading + Heading

- [h4 Heading 4] + [h4 Heading 4]

- Heading + Heading

- [h5 Heading 5] + [h5 Heading 5]

- Heading + Heading

- [h6 Heading 6] + [h6 Heading 6]

- Heading + Heading

- [def macro_identifier some text] + [def macro_identifier some text]

- Macros + Macros

- [template[a b] [a] body [b]] + [template[a b] [a] body [b]]

- Templates + Templates

- [blurb advertisement or note...] + [blurb advertisement or note...]

- Blurbs + Blurbs

- [warning Warning text...] + [warning Warning text...]

- Admonitions + Admonitions

- Tables + Tables

- Variable Lists + Variable Lists

- [include someother.qbk] + [include someother.qbk]

- Include + Include

- [? symbol phrase] + [? symbol phrase]

- Conditional Generation + Conditional Generation

+
+
diff --git a/doc/html/quickbook/syntax.html b/doc/html/quickbook/syntax.html index 7fc2a0d..4d29c98 100644 --- a/doc/html/quickbook/syntax.html +++ b/doc/html/quickbook/syntax.html @@ -1,12 +1,12 @@ - Syntax Summary +Syntax Summary - + - + @@ -14,8 +14,8 @@ - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Comments
Phrase Level Elements
diff --git a/doc/html/quickbook/syntax/block.html b/doc/html/quickbook/syntax/block.html index d5e2474..8090413 100644 --- a/doc/html/quickbook/syntax/block.html +++ b/doc/html/quickbook/syntax/block.html @@ -1,21 +1,21 @@ - Block Level Elements +Block Level Elements - + - - - + + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Document
Section
@@ -51,7 +52,8 @@

Every document must begin with a Document Info section, which should look like this: @@ -112,21 +114,22 @@ for. In its absence, version 1.1 is assumed.

- version, id, dirname, - copyright, purpose, category, - authors, license, last-revision - and source-mode are optional information. + version, id, dirname, + copyright, purpose, category, + authors, license, last-revision + and source-mode are optional information.

- source-type is a lowercase string setting the initial - Source Mode. - If the source-mode field is omitted, a default value - of c++ will be used. + source-type is a lowercase string setting the initial + Source Mode. + If the source-mode field is omitted, a default value + of c++ will be used.

Starting a new section is accomplished with:

@@ -135,8 +138,8 @@

where id is optional. id will be the filename of the generated section. If it is not present, "The Section Title" - will be normalized and become the id. Valid characters are a-Z, - A-Z, 0-9 and _. + will be normalized and become the id. Valid characters are a-Z, + A-Z, 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower case. Thus: "The Section Title" will be normalized to "the_section_title". @@ -152,7 +155,8 @@

You can include another XML file with:

@@ -165,7 +169,8 @@

Paragraphs start left-flushed and are terminated by two or more newlines. No markup is needed for paragraphs. QuickBook automatically detects paragraphs @@ -179,7 +184,8 @@

Ordered lists
@@ -193,9 +199,9 @@
# One
 # Two
 # Three
@@ -217,9 +223,9 @@
 
 
 

List hierarchies are supported. Example:

@@ -280,9 +286,9 @@

Long lines will be wrapped appropriately. Example:

@@ -311,9 +317,9 @@
* First
 * Second
 * Third
@@ -335,7 +341,8 @@
 
 
 

Mixed lists (ordered and unordered) are supported. Example:

@@ -446,16 +453,16 @@
+Code +

Preformatted code starts with a space or a tab. The code will be syntax - highlighted according to the current Source + highlighted according to the current Source Mode:

-
-#include <iostream>
+
#include <iostream>
 
 int main()
 {
@@ -466,8 +473,7 @@
 

-
-import cgi
+
import cgi
 
 def cookForHtml(text):
     '''"Cooks" the input text for HTML.'''
@@ -487,15 +493,14 @@
 

Generates:

-
-using boost::array;
+
using boost::array;
 

Inside code, code blocks and inline code, QuickBook does not allow any markup to avoid conflicts with the target syntax (e.g. c++). In case you @@ -511,8 +516,7 @@

Will generate:

-
-void foo()
+
void foo()
 {
 }
 
@@ -523,10 +527,11 @@

Sometimes, you don't want some preformatted text to be parsed as C++. In - such cases, use the [pre ... ] markup block. + such cases, use the [pre ... ] markup block.

[pre
 
@@ -543,21 +548,22 @@
           level markup, pre (and Code) are the only ones that allow multiple newlines.
           The markup above will generate:
         

-
Some preformatted text                    Some preformatted text
+
Some preformatted text                    Some preformatted text
 
-    Some preformatted text            Some preformatted text
+    Some preformatted text            Some preformatted text
 
-        Some preformatted text    Some preformatted text
+        Some preformatted text    Some preformatted text
 
 

Notice that unlike Code, phrase markup such as font style is still permitted - inside pre blocks. + inside pre blocks.

[:sometext...]
 
@@ -572,7 +578,8 @@
[note This is a note]
 [tip This is a tip]
 [important This is important]
@@ -587,7 +594,7 @@
 [Note]
 Note
 
-

+

This is a note

@@ -596,7 +603,7 @@ [Tip] Tip -

+

This is a tip

@@ -605,7 +612,7 @@ [Important] Important -

+

This is important

@@ -614,7 +621,7 @@ [Caution] Caution -

+

This is a caution

@@ -623,19 +630,20 @@ [Warning] Warning -

+

This is a warning

These are the only admonitions supported by DocBook. - So, for example [information This is some information] + So, for example [information This is some information] is unlikely to produce the desired effect.

[h1 Heading 1]
 [h2 Heading 2]
 [h3 Heading 3]
@@ -643,50 +651,51 @@
 [h5 Heading 5]
 [h6 Heading 6]
 
-

- - Heading 1 -

-

- - Heading 2 +

+ + Heading 1

-

- - Heading 3 +

+ + Heading 2

-

- - Heading 4 +

+ + Heading 3

-
- - Heading 5 +
+ + Heading 4
+
+ + Heading 5 +
- - Heading 6 + + Heading 6

Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized - names with name="section_id.normalized_header_text" - (i.e. valid characters are a-z, A-Z, - 0-9 and _. All non-valid characters + names with name="section_id.normalized_header_text" + (i.e. valid characters are a-z, A-Z, + 0-9 and _. All non-valid characters are converted to underscore and all upper-case are converted to lower-case. - For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). + For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). You can use:

[link section_id.normalized_header_text The link text]
 

- to link to them. See Anchor - links and Section + to link to them. See Anchor + links and Section for more info.

In cases when you don't want to care about the heading level (1 to 6), you can use the Generic Heading: @@ -733,7 +742,8 @@

[def macro_identifier some text]
 

@@ -757,19 +767,19 @@ sf_logo [Tip] Tip -

+

It's a good idea to use macro identifiers that are distinguishable. For instance, in this document, macro identifiers have two leading and trailing - underscores (e.g. __spirit__). The reason is to avoid unwanted + underscores (e.g. __spirit__). The reason is to avoid unwanted macro replacement.

- Links (URLS) and images are good candidates for macros. 1) + Links (URLS) and images are good candidates for macros. 1) They tend to change a lot. It is a good idea to place all links and images - in one place near the top to make it easy to make changes. 2) - The syntax is not pretty. It's easier to read and write, e.g. __spirit__ - than [@http://spirit.sourceforge.net Spirit]. + in one place near the top to make it easy to make changes. 2) + The syntax is not pretty. It's easier to read and write, e.g. __spirit__ + than [@http://spirit.sourceforge.net Spirit].

Some more examples: @@ -778,8 +788,8 @@ sf_logo [def __spirit__ [@http://spirit.sourceforge.net Spirit]]

- (See Images and - Links) + (See Images and + Links)

Invoking these macros: @@ -795,15 +805,15 @@ sf_logo

Quickbook has some predefined macros that you can already use.

-

Table 3. Predefined Macros

- +

Table 3. Predefined Macros

+
@@ -840,7 +850,7 @@ sf_logo @@ -857,7 +867,7 @@ sf_logo @@ -874,17 +884,19 @@ sf_logo -

- 2008-May-21 + 2008-Jul-28

- 11:54:31 AM + 10:49:54 PM

- C:\dev\boost\tools\quickbook\doc\quickbook.qbk + C:\cygwin\home\ericne\boost\org\trunk\tools\quickbook\doc\quickbook.qbk

+
+

Templates provide a more versatile text substitution mechanism. Templates come in handy when you need to create parameterizable, multi-line, boilerplate @@ -902,11 +914,11 @@ Hi, my name is [name]. I am [age] years old. I am a [what]. ]

-
- - Template +
+ + Template Identifier -
+

Template identifiers can either consist of:

@@ -920,11 +932,11 @@ Hi, my name is [name]. I am [age] years old. I am a [what]. A single character punctuation (a non-alphanumeric printable character) -
- - Formal +
+ + Formal Template Arguments -
+

Template formal arguments are identifiers consisting of an initial alphabetic character or the underscore, followed by zero or more alphanumeric characters @@ -932,19 +944,19 @@ Hi, my name is [name]. I am [age] years old. I am a [what].

A template formal argument temporarily hides a template of the same name - at the point where the template - is expanded. Note that the body of the person - template above refers to name age - and what as [name] [age] - and [what]. name age - and what are actually templates that exist in the duration + at the point where the template + is expanded. Note that the body of the person + template above refers to name age + and what as [name] [age] + and [what]. name age + and what are actually templates that exist in the duration of the template call.

-
- - Template +
+ + Template Body -
+

The template body can be just about any QuickBook block or phrase. There are actually two forms. Templates may be phrase or block level. Phrase @@ -965,11 +977,11 @@ replacement text... Phrase templates are typically expanded as part of phrases. Like macros, block level elements are not allowed in phrase templates.

-
- - Template +
+ + Template Expansion -
+

You expand a template this way:

@@ -1002,7 +1014,7 @@ replacement text... [Caution] Caution -

+

A word of caution: Templates are recursive. A template can call another template or even itself, directly or indirectly. There are no control structures in QuickBook (yet) so this will always mean infinite recursion. @@ -1012,15 +1024,15 @@ replacement text...

Each actual argument can be a word, a text fragment or just about any - QuickBook phrase. Arguments - are separated by the double dot ".." and terminated + QuickBook phrase. Arguments + are separated by the double dot ".." and terminated by the close parenthesis.

-
- - Nullary +
+ + Nullary Templates -
+

Nullary templates look and act like simple macros. Example:

@@ -1035,14 +1047,14 @@ replacement text... We have:

- Some squiggles...αβ + Some squiggles...αβ

The difference with macros are

  • - The explicit template + The explicit template expansion syntax. This is an advantage because, now, we don't have to use obscure naming conventions like double underscores (e.g. __alpha__) to avoid unwanted macro replacement. @@ -1055,7 +1067,7 @@ replacement text...

- The empty brackets after the template identifier (alpha[]) + The empty brackets after the template identifier (alpha[]) indicates no arguments. If the template body does not look like a template argument list, we can elide the empty brackets. Example:

@@ -1071,15 +1083,15 @@ for the journey to old age.]]] We have:

- Here's a quote from Aristotle: Education - is the best provision for the journey to old age.. + Here's a quote from Aristotle: Education + is the best provision for the journey to old age..

The disadvantage is that you can't avoid the space between the template - identifier, aristotle_quote, + identifier, aristotle_quote, and the template body "Aristotle...". This space will be part of the template body. If that space is unwanted, use empty brackets or - use the space escape: "\ ". + use the space escape: "\ ". Example:

[template tag\ _tag]
@@ -1093,26 +1105,26 @@ for the journey to old age.]]]
           We have:
         

- struct x_tag; + struct x_tag;

You have a couple of ways to do it. I personally prefer the explicit empty brackets, though.

-
- - Simple +
+ + Simple Arguments -
+

- As mentioned, arguments are separated by the double dot "..". + As mentioned, arguments are separated by the double dot "..". If there are less arguments passed than expected, QuickBook attempts to break the last argument into two or more arguments following this logic:

  • - Break the last argument into two, at the first space found ('', - '\n', \t' or '\r'). + Break the last argument into two, at the first space found ('', + '\n', \t' or '\r').
  • Repeat until there are enough arguments or if there are no more spaces @@ -1133,8 +1145,8 @@ for the journey to old age.]]]

    "w x y z" is initially treated as a single argument because we - didn't supply any ".." separators. However, - since simple expects 4 arguments, "w x y z" + didn't supply any ".." separators. However, + since simple expects 4 arguments, "w x y z" is broken down iteratively (applying the logic above) until we have "w", "x", "y" and "z".

    @@ -1155,8 +1167,8 @@ for the journey to old age.]]]

    It should be obvious now that for simple arguments with no spaces, we can - get by without separating the arguments with ".." - separators. It is possible to combine ".." + get by without separating the arguments with ".." + separators. It is possible to combine ".." separators with the argument passing simplification presented above. Example:

    [simple what do you think ..m a n?]
    @@ -1167,17 +1179,17 @@ for the journey to old age.]]]
     

    what do you think man?

    -
    - - Punctuation +
    + + Punctuation Templates -
    +

    With templates, one of our objectives is to allow us to rewrite QuickBook in QuickBook (as a qbk library). For that to happen, we need to accommodate single character punctuation templates which are fairly common in QuickBook. You might have noticed that single character punctuations are allowed as - template + template identifiers. Example:

    [template ![bar] <hey>[bar]</hey>]
    @@ -1195,7 +1207,8 @@ for the journey to old age.]]]
     
[blurb :-) [*An eye catching advertisement or note...]
 
     __spirit__ is an object-oriented recursive-descent parser generator framework
@@ -1208,9 +1221,10 @@ for the journey to old age.]]]
           will generate this:
         

[table A Simple Table
     [[Heading 1] [Heading 2] [Heading 3]]
     [[R0-C0]     [R0-C1]     [R0-C2]]
@@ -1244,8 +1259,8 @@ for the journey to old age.]]]
           will generate:
         

-

Table 4. A Simple Table

- +

Table 4. A Simple Table

+
@@ -1321,11 +1336,11 @@ for the journey to old age.]]] -
+
-

+

The table title is optional. The first row of the table is automatically - treated as the table header; that is, it is wrapped in <thead>...</thead> + treated as the table header; that is, it is wrapped in <thead>...</thead> XML tags. Note that unlike the original QuickDoc, the columns are nested in [ cells... ]. The syntax is free-format and allows big cells to be formatted nicely. Example: @@ -1355,8 +1370,8 @@ for the journey to old age.]]] and thus:

-

Table 5. Table with fat cells

- +

Table 5. Table with fat cells

+
@@ -1408,9 +1423,9 @@ for the journey to old age.]]] -
+
-

+

Here's how to have preformatted blocks of code in a table cell:

[table Table with code
@@ -1430,8 +1445,8 @@ for the journey to old age.]]]
 ]
 
-

Table 6. Table with code

- +

Table 6. Table with code

+
@@ -1458,8 +1473,7 @@ for the journey to old age.]]]

-
-#include <iostream>
+
#include <iostream>
 
 int main()
 {
@@ -1471,12 +1485,14 @@ for the journey to old age.]]]
               

-
+
+
[variablelist A Variable List
     [[term 1] [The definition of term 1]]
     [[term 2] [The definition of term 2]]
@@ -1521,7 +1537,8 @@ for the journey to old age.]]]
 
 
 

You can include one QuickBook file from another. The syntax is simply:

@@ -1541,7 +1558,7 @@ for the journey to old age.]]]

- The [include] directive lets you specify a document + The [include] directive lets you specify a document id to use for the included file. When this id is not explicitly specified, the id defaults to the filename ("someother", in the example above). You can specify the id like this: @@ -1552,12 +1569,13 @@ for the journey to old age.]]] All auto-generated anchors will use the document id as a unique prefix. So for instance, if there is a top section in someother.qbk named "Intro", the named anchor for that section will be "someid.intro", and - you can link to it with [link someid.intro The Intro]. + you can link to it with [link someid.intro The Intro].

When documenting code, you'd surely need to present code from actual source files. While it is possible to copy some code and paste them in your QuickBook @@ -1569,10 +1587,10 @@ for the journey to old age.]]]

QuickBook's import facility provides a nice solution.

-
- - Example -
+
+ + Example +

You can effortlessly import code snippets from source code into your QuickBook. The following illustrates how this is done: @@ -1589,8 +1607,8 @@ for the journey to old age.]]]

collects specially marked-up code snippets from stub.cpp and places them in your QuickBook file as virtual templates. Each of the - specially marked-up code snippets has a name (e.g. foo - and bar in the example + specially marked-up code snippets has a name (e.g. foo + and bar in the example above). This shall be the template identifier for that particular code snippet. The second and third line above does the actual template expansion:

@@ -1603,7 +1621,7 @@ for the journey to old age.]]]

- This is the foo + This is the foo function.

@@ -1631,8 +1649,7 @@ for the journey to old age.]]]

-
-std::string foo()
+
std::string foo()
 {
     // return 'em, foo man!
     return "foo";
@@ -1643,7 +1660,7 @@ for the journey to old age.]]]
 

- This is the bar + This is the bar function

@@ -1651,8 +1668,7 @@ for the journey to old age.]]]

-
-std::string bar()
+
std::string bar()
 {
     // return 'em, bar man!
     return "bar";
@@ -1666,43 +1682,40 @@ for the journey to old age.]]]
           

-
- - Code +
+ + Code Snippet Markup -
+

Note how the code snippets in stub.cpp get marked up. We use distinguishable comments following the form:

-
-//[id
+
//[id
 some code here
 //]
 

The first comment line above initiates a named code-snippet. This prefix - will not be visible in quickbook. The entire code-snippet in between //[id and //] + will not be visible in quickbook. The entire code-snippet in between //[id and //] will be inserted as a template in quickbook with name id. - The comment //] ends a code-snippet + The comment //] ends a code-snippet This too will not be visible in quickbook.

-
- - Special +
+ + Special Comments -
+

Special comments of the form:

-
-//` some [*quickbook] markup here
+
//` some [*quickbook] markup here
 

and:

-
-/*` some [*quickbook] markup here */
+
/*` some [*quickbook] markup here */
 

will be parsed by QuickBook. This can contain quickbook blocks @@ -1713,20 +1726,17 @@ for the journey to old age.]]]

Special comments of the form:

-
-/*<- this C++ comment will be ignored ->*/
+
/*<- this C++ comment will be ignored ->*/
 

or

-
-/*<-*/ "this c++ code  will be ignored" /*->*/
+
/*<-*/ "this c++ code  will be ignored" /*->*/
 

or

-
-//<-
+
//<-
 private:
     int some_member;
 //->
@@ -1735,15 +1745,14 @@ for the journey to old age.]]]
           can be used to inhibit code from passing through to quickbook. All text
           between the delimeters will simply be ignored.
         

-
- - Callouts -
+
+ + Callouts +

Special comments of the form:

-
-/*< some [*quickbook] markup here >*/
+
/*< some [*quickbook] markup here >*/
 

will be regarded as callouts. These will be collected, numbered and rendered @@ -1756,10 +1765,9 @@ for the journey to old age.]]]

-
-std::string foo_bar() 1
+
std::string foo_bar() 1
 {
-    return "foo-bar"; 2
+    return "foo-bar"; 2
 }
 

@@ -1770,14 +1778,12 @@ for the journey to old age.]]]

- + - +
-1

1

The Mythical FooBar. See Foobar for details

-2

2

return 'em, foo-bar man!

@@ -1788,8 +1794,7 @@ for the journey to old age.]]]

This is the actual code:

-
-//[ foo_bar
+
//[ foo_bar
 std::string foo_bar() /*< The /Mythical/ FooBar.
                       See [@http://en.wikipedia.org/wiki/Foobar Foobar for details] >*/
 {
@@ -1803,8 +1808,7 @@ for the journey to old age.]]]
           however. They get in the way of the clarity of the code. Another special
           callout comment style is available:
         

-
-/*<< some [*quickbook] markup here >>*/
+
/*<< some [*quickbook] markup here >>*/
 

This is the line-oriented version of the callout. With this, the "bug" @@ -1816,25 +1820,24 @@ for the journey to old age.]]]

-
-class x
+
class x
 {
 public:
 
-    1x() : n(0)
+    1x() : n(0)
     {
     }
 
-    2~x()
+    2~x()
     {
     }
 
-    3int get() const
+    3int get() const
     {
         return n; 
     }
 
-    4void set(int n_)
+    4void set(int n_)
     {
         n = n_;
     }
@@ -1848,25 +1851,21 @@ for the journey to old age.]]]
             

- + - + - - + - - +
-1

1

Constructor

-2

2

Destructor

-3

Get the n +

3

Get the n member variable

-4

Set the n +

4

Set the n member variable

diff --git a/doc/html/quickbook/syntax/comments.html b/doc/html/quickbook/syntax/comments.html index 880a2ab..5a557b9 100644 --- a/doc/html/quickbook/syntax/comments.html +++ b/doc/html/quickbook/syntax/comments.html @@ -3,19 +3,19 @@ Comments - + - - - + + + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@

Can be placed anywhere.

diff --git a/doc/html/quickbook/syntax/phrase.html b/doc/html/quickbook/syntax/phrase.html index 6a4a156..a7d2a84 100644 --- a/doc/html/quickbook/syntax/phrase.html +++ b/doc/html/quickbook/syntax/phrase.html @@ -1,21 +1,21 @@ - Phrase Level Elements +Phrase Level Elements - + - + - + - - + +
Boost C++ Libraries Home LibrariesPeopleFAQPeopleFAQ More

@@ -24,7 +24,8 @@
Font Styles
Replaceable
@@ -48,14 +49,15 @@
['italic], [*bold], [_underline], [^teletype], [-strikethrough]
 

will generate:

- italic, bold, underline, teletype, strikethrough + italic, bold, underline, teletype, strikethrough

Like all non-terminal phrase level elements, this can of course be nested: @@ -66,12 +68,13 @@ will generate:

- bold-italic + bold-italic

When you want content that may or must be replaced by the user, use the syntax: @@ -82,14 +85,15 @@ This will generate:

- + replacement - +

["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein
 

@@ -120,7 +124,8 @@ the true business precept.]

Simple markup for formatting text, common in many applications, is now supported: @@ -131,12 +136,12 @@ the true business precept.] will generate:

- italic, bold, underline, teletype + italic, bold, underline, teletype

Unlike QuickBook's standard formatting scheme, the rules for simpler alternatives are much stricter - [1] + [1] .

    @@ -166,14 +171,13 @@ the true business precept.]
  • A line starting with the star will be interpreted as an unordered list. - See Unordered + See Unordered lists.
-

Table 1. More Formatting Samples

- +

Table 1. More Formatting Samples

+
@@ -194,31 +198,31 @@ the true business precept.] -

- *Bold* + *Bold*

- Bold + Bold

- *Is bold* + *Is bold*

- Is bold + Is bold

- * Not bold* *Not bold * * Not bold * + * Not bold* *Not bold * * Not bold *

@@ -230,7 +234,7 @@ the true business precept.]

- This*Isn't*Bold (no bold) + This*Isn't*Bold (no bold)

@@ -242,31 +246,31 @@ the true business precept.]

- (*Bold Inside*) (parenthesis not bold) + (*Bold Inside*) (parenthesis not bold)

- (Bold Inside) (parenthesis not bold) + (Bold Inside) (parenthesis not bold)

- *(Bold Outside)* (parenthesis bold) + *(Bold Outside)* (parenthesis bold)

- (Bold Outside) (parenthesis bold) + (Bold Outside) (parenthesis bold)

- 3*4*5 = 60 (no bold) + 3*4*5 = 60 (no bold)

@@ -278,7 +282,7 @@ the true business precept.]

- 3 * 4 * 5 = 60 (no bold) + 3 * 4 * 5 = 60 (no bold)

@@ -290,79 +294,79 @@ the true business precept.]

- 3 *4* 5 = 60 (4 is bold) + 3 *4* 5 = 60 (4 is bold)

- 3 4 5 = 60 (4 is bold) + 3 4 5 = 60 (4 is bold)

- *This is bold* this is not *but this is* + *This is bold* this is not *but this is*

- This is bold this is not but this is + This is bold this is not but this is

- *This is bold*. + *This is bold*.

- This is bold. + This is bold.

- *B*. (bold B) + *B*. (bold B)

- B. (bold B) + B. (bold B)

- ['*Bold-Italic*] + ['*Bold-Italic*]

- Bold-Italic + Bold-Italic

- *side-by*/-side/ + *side-by*/-side/

- side-by-side + side-by-side

+
-

+

As mentioned, simple markups cannot go past a single block. The text from "have" to "full" in the following paragraph will be rendered as bold: @@ -373,8 +377,8 @@ One for the master, one for the dame, And one for the little boy who lives down the lane.

- Baa baa black sheep, have you any wool? Yes sir, - yes sir, three bags full! One for the master, one for the dame, + Baa baa black sheep, have you any wool? Yes sir, + yes sir, three bags full! One for the master, one for the dame, And one for the little boy who lives down the lane.

@@ -393,7 +397,8 @@ And one for the little boy who lives down the lane.

Inlining code in paragraphs is quite common when writing C++ documentation. We provide a very simple markup for this. For example, this: @@ -404,7 +409,7 @@ And one for the little boy who lives down the lane. will generate:

- This text has inlined code int main() { return 0; } + This text has inlined code int main() { return 0; } in it. The code will be syntax highlighted.

@@ -412,24 +417,23 @@ And one for the little boy who lives down the lane. -
[Note] Note

- We simply enclose the code with the tick: "`", not the - single quote: "'". - Note too that `some code` is preferred over [^some code]. +

+ We simply enclose the code with the tick: "`", not the + single quote: "'". + Note too that `some code` is preferred over [^some code].

- Preformatted code simply starts with a space or a tab (See Code). + Preformatted code simply starts with a space or a tab (See Code). However, such a simple syntax cannot be used as phrase elements in lists - (See Ordered - lists and Unordered - lists), tables (See Tables), + (See Ordered + lists and Unordered + lists), tables (See Tables), etc. Inline code (see above) can. The problem is, inline code does not allow formatting with newlines, spaces, and tabs. These are lost.

@@ -454,8 +458,7 @@ And one for the little boy who lives down the lane.

-
-#include <iostream>
+
#include <iostream>
 
 int main()
 {
@@ -468,17 +471,18 @@ And one for the little boy who lives down the lane.
 
 
 

If a document contains more than one type of source code then the source mode may be changed dynamically as the document is processed. All QuickBook documents are initially in C++ mode by default, though an alternative initial - value may be set in the Document + value may be set in the Document section.

- To change the source mode, use the [source-mode] markup, - where source-mode is one of the supported modes. For + To change the source mode, use the [source-mode] markup, + where source-mode is one of the supported modes. For example, this:

Python's [python] `import` is rather like C++'s [c++] `#include`. A
@@ -489,14 +493,14 @@ C++ comment `// looks like this` whereas a Python comment [python]
           will generate:
         

- Python's import is rather - like C++'s #include. - A C++ comment // looks like this - whereas a Python comment #looks like this. + Python's import is rather + like C++'s #include. + A C++ comment // looks like this + whereas a Python comment #looks like this.

-

Table 2. Supported Source Modes

- +

Table 2. Supported Source Modes

+
@@ -522,7 +526,7 @@ C++ comment `// looks like this` whereas a Python comment [python] @@ -534,26 +538,27 @@ C++ comment `// looks like this` whereas a Python comment [python] -

- [c++] + [c++]

- [python] + [python]

+
-
+
-
[Note] Note

+

The source mode strings are lowercase.

[br]
 
@@ -561,37 +566,39 @@ C++ comment `// looks like this` whereas a Python comment [python] -
[Warning] Warning

- [br] is now deprecated. Blurbs, - Admonitions - and table cells (see Tables) +

+ [br] is now deprecated. Blurbs, + Admonitions + and table cells (see Tables) may now contain paragraphs.

[#named_anchor]
 

A named anchor is a hook that can be referenced by a link elsewhere in - the document. You can then reference an anchor with [link named_anchor -Some link text]. - See Anchor links, - Section and Heading. + the document. You can then reference an anchor with [link named_anchor +Some link text]. + See Anchor links, + Section and Heading.

[@http://www.boost.org this is [*boost's] website....]
 

will generate:

- this is boost's + this is boost's website....

@@ -613,29 +620,31 @@ Some link text].

You can link within a document using:

[link section_id.normalized_header_text The link text]
 

- See sections Section - and Heading for + See sections Section + and Heading for more info.

In addition, you can link internally to an XML refentry like:

[link xml.refentry The link text]
 

- This gets converted into <link linkend="xml.refentry">The - link text</link>. + This gets converted into <link linkend="xml.refentry">The + link text</link>.

Like URLs, the link text is optional. If this is not present, the link @@ -644,15 +653,16 @@ Some link text].

[link xml.refentry]
 

- This gets converted into <link linkend="xml.refentry">xml.refentry</link>. + This gets converted into <link linkend="xml.refentry">xml.refentry</link>.

- If you want to link to a function, class, member, enum, concept or header - in the reference section, you can use: + If you want to link to a function, class, member, enum, concept, global, + or header in the reference section, you can use:

[funcref fully::qualified::function_name The link text]
 [classref fully::qualified::class_name The link text]
@@ -661,11 +671,12 @@ Some link text].
 [macroref MACRO_NAME The link text]
 [conceptref ConceptName The link text]
 [headerref path/to/header.hpp The link text]
+[globalref fully::qualified::global The link text]
 

Again, the link text is optional. If this is not present, the link text - will automatically be the function, class, member, enum, macro, concept - or header. Example: + will automatically be the function, class, member, enum, macro, concept, + global, or header name. Example:

[classref boost::bar::baz]
 
@@ -675,7 +686,8 @@ Some link text].

The escape mark-up is used when we don't want to do any processing.

@@ -692,31 +704,31 @@ escape (no processing/formatting) '''

- This is direct XML markup + This is direct XML markup

-
[Important] Important

+

Be careful when using the escape. The text must conform to BoostBook/DocBook syntax.

The backslash may be used to escape a single punctuation character. The punctuation immediately after the backslash is passed without any processing. - This is useful when we need to escape QuickBook punctuations such as [ and ]. - For example, how do you escape the triple quote? Simple: \'\'\' + This is useful when we need to escape QuickBook punctuations such as [ and ]. + For example, how do you escape the triple quote? Simple: \'\'\'

- \n + \n has a special meaning. It is used to generate line breaks.

@@ -724,28 +736,30 @@ escape (no processing/formatting) -
[Warning] Warning

- \n - and [br] are now deprecated. Blurbs, - Admonitions - and table cells (see Tables) +

+ \n + and [br] are now deprecated. Blurbs, + Admonitions + and table cells (see Tables) may now contain paragraphs.

- The escaped space: \ also + The escaped space: \ also has a special meaning. The escaped space is removed from the output.

[$image.jpg]
 
Macro Expansion
@@ -754,45 +768,46 @@ escape (no processing/formatting)

As of version 1.3, QuickBook supports footnotes. Just put the text of the - footnote in a [footnote] block, and the text will be put at the + footnote in a [footnote] block, and the text will be put at the bottom of the current page. For example, this:

[footnote A sample footnote]
 

will generate this - [2] + [2] .

__a_macro_identifier__
 

- See Macros for details. + See Macros for details.

[a_template_identifier]
 

- See Templates + See Templates for details.

- Like C++ #ifdef, you can generate + Like C++ #ifdef, you can generate phrases depending on the presence of a macro. Example:

[? __to_be__ To be or not to be]
@@ -814,22 +829,22 @@ escape (no processing/formatting)
         

Yes! - [3] + [3]



-

[1] +

[1] Thanks to David Barrett, author of Qwiki, for sharing these samples and teaching me these obscure formatting rules. I wasn't sure at all if Spirit, being more or less a formal EBNF parser, can handle the context sensitivity and ambiguity.

-

[2] +

[2] A sample footnote

-

[3] +

[3] Conditional Generation makes quickbook turing complete.

diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk old mode 100755 new mode 100644 index 4df48ad..67857f7 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -522,8 +522,8 @@ This gets converted into [^xml.refentry]. [endsect] [section:code_links Code Links] -If you want to link to a function, class, member, enum, concept or header in the reference -section, you can use: +If you want to link to a function, class, member, enum, concept, global, or header in +the reference section, you can use: [pre''' [funcref fully::qualified::function_name The link text] @@ -533,10 +533,12 @@ section, you can use: [macroref MACRO_NAME The link text] [conceptref ConceptName The link text] [headerref path/to/header.hpp The link text] +[globalref fully::qualified::global The link text] '''] Again, the link text is optional. If this is not present, the link text will -automatically be the function, class, member, enum, macro, concept or header. Example: +automatically be the function, class, member, enum, macro, concept, global, or header name. +Example: [pre''' [classref boost::bar::baz] @@ -2139,6 +2141,7 @@ QuickBook (which IMO is a whole lot easier to edit and maintain). [[macro link] [[^'''[macroref MACRO_NAME Link text]''']] [__code_links__]] [[concept link] [[^'''[conceptref ConceptName Link text]''']] [__code_links__]] [[header link] [[^'''[headerref path/to/header.hpp Link text]''']] [__code_links__]] + [[global link] [[^'''[globalref fully::qualified::global Link text]''']] [__code_links__]] [[escape] [[^\'\'\'escaped text (no processing/formatting)\'\'\']] [__escape__]] [[single char escape] [[^\\c]] [__single_char_escape__]] [[images] [[^'''[$image.jpg]''']] [__images__]] diff --git a/phrase.hpp b/phrase.hpp index 4255ad4..f637d72 100644 --- a/phrase.hpp +++ b/phrase.hpp @@ -224,6 +224,7 @@ namespace quickbook | macroref | headerref | conceptref + | globalref | bold | italic | underline @@ -354,6 +355,15 @@ namespace quickbook ) [actions.conceptref_post] ; + globalref = + "globalref" >> hard_space + >> (*(anychar_p - + (']' | hard_space))) [actions.globalref_pre] + >> ( eps_p(']') + | (hard_space >> phrase) + ) [actions.globalref_post] + ; + bold = ch_p('*') [actions.bold_pre] >> blank >> phrase [actions.bold_post] @@ -404,8 +414,8 @@ namespace quickbook rule space, blank, comment, phrase, phrase_markup, image, phrase_end, bold, italic, underline, teletype, - strikethrough, escape, url, common, funcref, - classref, memberref, enumref, macroref, headerref, conceptref, + strikethrough, escape, url, common, funcref, classref, + memberref, enumref, macroref, headerref, conceptref, globalref, anchor, link, hard_space, eol, inline_code, simple_format, simple_bold, simple_italic, simple_underline, simple_teletype, source_mode, template_, template_arg, From 28dd9943324e96f1a6029bef7f7d83c29458229a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 24 Sep 2008 22:55:00 +0000 Subject: [PATCH 17/94] Merge some documentation changes. Merged revisions 48927-48930,48934,48938 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r48927 | danieljames | 2008-09-23 20:29:01 +0100 (Tue, 23 Sep 2008) | 5 lines Rewrite the id code to convert the characters of parts of the id at the time of generating the id. This means that characters are translated to underscores for ids as well as for filenames, since in the eventual documents they have to be percent encoded this is probably an approvement. It also lets us deal with the translation more intelligently and truncate long identifiers. ........ r48928 | danieljames | 2008-09-23 20:42:06 +0100 (Tue, 23 Sep 2008) | 1 line Copy extra images from quickbook to the combined documentation. ........ r48929 | danieljames | 2008-09-23 20:44:20 +0100 (Tue, 23 Sep 2008) | 1 line Change quickbook so that the links are relative to the combined documentation. ........ r48930 | danieljames | 2008-09-23 20:44:39 +0100 (Tue, 23 Sep 2008) | 1 line Remove the prebuilt version of quickbook. ........ [SVN r48957] --- doc/html/images/alert.png | Bin 603 -> 0 bytes doc/html/images/caution.png | Bin 1250 -> 0 bytes doc/html/images/home.png | Bin 358 -> 0 bytes doc/html/images/important.png | Bin 722 -> 0 bytes doc/html/images/next.png | Bin 336 -> 0 bytes doc/html/images/note.png | Bin 658 -> 0 bytes doc/html/images/prev.png | Bin 334 -> 0 bytes doc/html/images/smiley.png | Bin 867 -> 0 bytes doc/html/images/tip.png | Bin 640 -> 0 bytes doc/html/images/up.png | Bin 370 -> 0 bytes doc/html/images/warning.png | Bin 1241 -> 0 bytes doc/html/index.html | 79 - doc/html/quickbook/change_log.html | 168 -- doc/html/quickbook/editors.html | 61 - doc/html/quickbook/editors/kde_support.html | 465 ----- doc/html/quickbook/editors/scite.html | 85 - doc/html/quickbook/faq.html | 100 - doc/html/quickbook/install.html | 60 - doc/html/quickbook/install/linux.html | 104 - doc/html/quickbook/install/macosx.html | 156 -- doc/html/quickbook/install/windows.html | 136 -- doc/html/quickbook/intro.html | 115 -- doc/html/quickbook/ref.html | 958 ---------- doc/html/quickbook/syntax.html | 64 - doc/html/quickbook/syntax/block.html | 1895 ------------------- doc/html/quickbook/syntax/comments.html | 53 - doc/html/quickbook/syntax/phrase.html | 866 --------- doc/quickbook.qbk | 11 +- extra/katepart/katepart.qbk | 6 +- 29 files changed, 9 insertions(+), 5373 deletions(-) delete mode 100755 doc/html/images/alert.png delete mode 100644 doc/html/images/caution.png delete mode 100755 doc/html/images/home.png delete mode 100644 doc/html/images/important.png delete mode 100755 doc/html/images/next.png delete mode 100755 doc/html/images/note.png delete mode 100755 doc/html/images/prev.png delete mode 100755 doc/html/images/smiley.png delete mode 100755 doc/html/images/tip.png delete mode 100755 doc/html/images/up.png delete mode 100644 doc/html/images/warning.png delete mode 100644 doc/html/index.html delete mode 100644 doc/html/quickbook/change_log.html delete mode 100644 doc/html/quickbook/editors.html delete mode 100644 doc/html/quickbook/editors/kde_support.html delete mode 100644 doc/html/quickbook/editors/scite.html delete mode 100644 doc/html/quickbook/faq.html delete mode 100644 doc/html/quickbook/install.html delete mode 100644 doc/html/quickbook/install/linux.html delete mode 100644 doc/html/quickbook/install/macosx.html delete mode 100644 doc/html/quickbook/install/windows.html delete mode 100644 doc/html/quickbook/intro.html delete mode 100644 doc/html/quickbook/ref.html delete mode 100644 doc/html/quickbook/syntax.html delete mode 100644 doc/html/quickbook/syntax/block.html delete mode 100644 doc/html/quickbook/syntax/comments.html delete mode 100644 doc/html/quickbook/syntax/phrase.html diff --git a/doc/html/images/alert.png b/doc/html/images/alert.png deleted file mode 100755 index b4645bc7e7cd81f2818bf22aa898e95f89f7b154..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 603 zcmeAS@N?(olHy`uVBq!ia0y~yV31^BU=ZVAW?*1oN<7}ez`(#Bl2vQw%VQUVy#($c(b7<_!Z&&*`7 zwYIFTuIA!kP?6(!`t<3^g$y0J3{Q73WQH(YSjJ#(AQj-}VXe>LZ_gkv$q?hiVP&Xj ztS4or%^)MjpsB?1|Nnp9pi5p13=F0vL4Lvi$p8#BTQ7jZgtNdSvY3H^>jMZgI;}C8 z!N9FSxfgB=H7N+NC77H_+N#nawR{=RqTMBX)(LXL|IjinhDSdCyWWZ3S$0kBOZbahGm>{cU3L4X z*xaKNrl+L*2&>`tT{GF}sK6TCoSy58@94C>csZ@3se0z)OD!J`ePg?KNk!eRu!nuZ zwIuy5g5`UyU*2!`JMiPV^UIVvmW1t{f1*^~1#9h_jDIZO*R6JmbN8&QBXd?)zY=(& z`HG+Mis#k2-hNM1nwI_8efYU@yAuCZhY42|Be;Juo!svFUA16}A_D^hgQu&X%Q~lo FCIA+53ZVc1 diff --git a/doc/html/images/caution.png b/doc/html/images/caution.png deleted file mode 100644 index 5b7809ca4a9c8d778087522e5ce04b6e90099595..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1250 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4rT@hhU+WOo?>8NW(e>Jab;j&;NV~o5MYpy zU{F+KFf?Rva$<;zVn|MA$j)XcE@r5%W@u?)XlW_#>0#*UDemd%nKFf8%9P?MQ>y38 zVVEwkZjIWyHF@jSt$X(}?A@Du?i|Cp zbLXyIW4Lzh+_h`h?%iX!chB(NJdh*`E$$X&!4}4&+z{J`|sZwzJC|^ z{$1kxcf;@BzyJTw@c+NS|Nj#IN5NBISn~R-X--a%afBxQ|J!3zMjr_SU zk_iHr)f*lf{$5^Qz}I)@3FlWvw(w~u=1P@VsTP+$RNGvxbHL-(%M6nc6`{zlU zjGQJeveps+!&Jb&mD)L@hA} z1_tL6*NBqf{Irtt#G+IN2MuLS&)mfHRNut(%;anZ6Fnn63k6F{eFF=914D)6qRirw zN{8Ia;*!i{z0_j8l+uFyyb`_S{M?DV6n8K%Fld2|%S_KpEGaEYWk@zRFt#waFg8d` zG)YZPF-fe)lBATd3a!N{b-$VA&f+n^|#(~yCI Ofx*+&&t;ucLK6T%G-N*j diff --git a/doc/html/images/home.png b/doc/html/images/home.png deleted file mode 100755 index 5584aacb097a80e66a5320312b6e4eb017af1a06..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 358 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?WS z3GfMV6&Dfg?(A@OuseF>a6(*+nzF*onKLh6zO-%YmOy{sw6wJU|Nk%gvq74Hfq|za z$S?Rm0x$^OKX;CSfq}EYBeIx*fm;ZK886+f`@_J%pjzS@Q4*Y=R#Ki=l*-_nm|T>f zo0^iDsNj}alvU8YOY t9}F9JU6`43jMG5vNQA&8NcoN_f;wr$vARr(hAt9lu zscC6x>EvV>6{VS+EaBwj6ciMco$ZvI98_E!l$@NLot<4>UER|o(bHqOcQ41TYc{y!?kM?_wFg)yJvXsp5^oB z9Pi&Vyniq7|3Ab3{~Z7S3p{_W`TV)z`}cpO z$(;G%_wGG* z?AW<;=dNA5cJJQ3=g*(NfB*jb_wWDz|6hCQ@I3|w2F4_BcNgdM3%p4T42R|DNig) zWpL0?*7VFxOi%SqOwUZtRxr^s(z8&owA44S&^IttNG{4OE~#|Ltt>9dOx8;+)=McZ z$j>X$OU}=oxJz*d0|SE=*tpE}yu^~yqEv=t diff --git a/doc/html/images/next.png b/doc/html/images/next.png deleted file mode 100755 index 59800b4e87f60c0e3383ede2b384b9be0f5ffe8d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 336 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?WS z3GfMV6&Dfg?(8r&Hr}>%OQ656nzF)*4nJa0`Jj)#l9-t%+}PK^d+g590~2^trx_V+aGYt)W#Kgko@Q{~>i6>w}LxPb)_bi1gN;4a>^d{wcURt*495hZOYc8|NsA=8=F$dz`$Tq666>BpLD?B9j=thz`(#+;1OBOz`*qZgc+UI zn9N{cU{Eb_jVKAuPb(=;EJ|hYO-wGz&rMCqOjK~oEJ`iUFUl@f@QqL~GB7Y{FI#h- zfq_xR)5S5QVovU)+hxrP02oy7clOl(|F;(fCx<^{O+3$d{!GJf zAT>%@)+Kac%o^ zm8~at%dZNSg`XDA>HpujeRb(tA@xWH1+`xhu}_a!eJ{ORYJcMi$Ma>cBHv0)HBxa4 zSGC~^nY{G5@1(nj{7!xJ-s1V$LbWCK_xDFLe3_MRf4msHv}xJrfBaF7=BYjUcQ!FF PFfe$!`njxgN@xNAS|c%7 diff --git a/doc/html/images/prev.png b/doc/html/images/prev.png deleted file mode 100755 index d88a40f923e3c554125f01cd366707c60cfcad04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 334 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?WS z3GfMV6&DdqOG`60Hr}>%%ZlYo1O0u~loc*tzSP~>;p||S5Et|R|Noh1c$yg)73T~N2spa`a*~JRJ5eh~I1}5!gYtAz;Fo=OPI2WZRmSpDVDTHL^rZN~B=o=X8 z8<-ql-^0nkz!2u?;uumfC;0|1OPoRyGxLNShYX~Tl_Wf9G1_imu)%RA9}mw<0X2^e zQioc&m}WXSvRw^OFi2qFa&lm1W^U?K=~^Ook|m{hVvche^Q6-g?(V)Vn8U=toEqFE UkjD9gfq{X+)78&qol`;+00?PtqyPW_ diff --git a/doc/html/images/smiley.png b/doc/html/images/smiley.png deleted file mode 100755 index 30a77f71ce16872d046a1a5d6fd698a2f65a3f62..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 867 zcmeAS@N?(olHy`uVBq!ia0y~yU=U|uV36QoW?*1YTQtp`fq{X!*vT`5gM;JtL;nX1 z42*&SJ|V8+B7&<|tz5IBw4@*~EXexT*H!m!O?Pp!sH>^CckiyDuKJ|Dl+(w%CQay1 zOYu8%=FGd73zHKgmoF}|u{3I~kKDVXVbQ_`9c`_Fz7{iQrl~4QMTGi1fByW=jcKLD z*?C#s*_rWAAIx@f)c16=+qAB-t1T`u&hzVsWjnTSn>lml<@5cSX&!B@jUfSci{|F_ z_w^KKXB!)+#6)_3`t<4gwQEt~&MzL%J+!ao-_JD<@64PzGws6Z-hv$8-Me=7btN{` zl~t96rKP3$c$&I9TcsogXQl?mL%y{W;-5&-92C)*?h!W?b)Wnj^{5*w_%-mE4Lj!$7BYguC zr{Y6*7#J8-K`Mgt(@M${i&7bU6O)Vbb5m0?6BXPti&D$;i?WLqd?OT$3=B-#%hsG{ zU|`huba4!+n3FrHHoVC|#v<-Y&ynX`2+ z)ci{*-@n^>-frGI_MA-9eHCQCFMs-NiTvCzJ8a&6h<9#D<(d3(^{E}JLTitR9GSK2 z$*O4*8tU!OHS*&Yg~mSMD)7~hd93j+u`cf5MM<4*zJ;yfFKhYEn9bv3Xeg3g;K-G= z;q?Q<5Qk-d*rznCncd{p+umG~t-YZ3L%_f9;YyrSd?k7nE}0j~xg-T!p1r_pXw_8J z^q9XtRP=q)pSk7_!?YePxacL!`8E4~v$oZii_iB4y^t?YSBana!LlH(Q{_whcc+EB z6^^opPM-68`QEg&=hc<^;brIeKBf1+k=uTZ@Aa)4^R8_EExPXM@|~g)-OB%bBP#i` ie0$=QHXfdLO8@!p%oni+1)dBH3=E#GelF{r5}E*N2(Kal diff --git a/doc/html/images/tip.png b/doc/html/images/tip.png deleted file mode 100755 index 9f596b0b88eb42562b2d0b0e30d054509be42af2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 640 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4rT@hhU+WOo?>8NU@ms@4B_D5xc$)o0Rsa= zZ-7sTtD>UflSfBq&1}s`kJ`U?skgWH)2B~oOmF`E^TxIg4+D?5M~H-?Y?- zI&~E<1_lQGk|4j}{|LZEaktF(-D? z%Sp`&0xgDm?d}|!0v)M>{a+K-KKU!3@9L8LOa5Z1>0OX+j1SY)GfWc?{l8U z$2VD9PtNu%kvS~%Xw8E;=95FN9-q3V{gPE~*|fjR%QkDRKeb=t2Ll5GgQu&X%Q~lo FCIFO8ExiB$ diff --git a/doc/html/images/up.png b/doc/html/images/up.png deleted file mode 100755 index 17d9c3ec491ae1ba22188ce85985623c92ffa9be..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 370 zcmeAS@N?(olHy`uVBq!ia0y~yU=Rjj7G?$phK4%r{|pQa%*9TgAsieWw;%dHU|?X- z3h)VW6&DdqOG|Thu-mqE%ZlYoyE{8BU%nLR@2jS)FmvY2qel)W#Kk;%^zi@x|I?Un z*fKCM@RbDl1^-6|46X<6oM2#J;4JWnEM{Qf76M_$OLy!3FfcHvmbgZg1m~xflqVLY zGWaGY7v<-srer26xMdclmgg5`7c2NiC>R+Sn6#IzInThrAO_OlT$Gwvl9`{U5R#dj z%3x@qZ(yu%U~+tY4<`cyLy@P8V@SoEspmFwHW&!FJyeg_(XezvV9WvAI|r@_>dZZG zPW6aiOT!J--9O?NG0%AP;}ge|4lDQN4=-}8`?JGwx}?mMnO)OdyQdu$nQCjPRV}jm z$u!Qa8E-cQ-r3Nz>Y(YPTd#BPEH+&8GWqfD!}4*53%dA!%#3$cIv;a~fq{X+)78&q Iol`;+0POUaApigX diff --git a/doc/html/images/warning.png b/doc/html/images/warning.png deleted file mode 100644 index 1c33db8f34a8b42b373179b46a2d8d8a10e061a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1241 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4rT@hhU+WOo?>8NW(e>JaphoO5CF?5GB9W| zFc>m0I59AIF)#!%FhnshWHT@nGcZ&$Ftji*^e`|?VPKe2T|Fl#Xiikroa*YO3=B&x zEth(EEp2I8I%UezrAyZ`FswB+TsvjTRtAQxnwndCdbZA)vvujxty{P5WnkF5cJ1D+ zTaPg?91{>YCLwX`*s*gA4Ce#{&Phm|)6~4iz;I1d^V+p*_ZS%N-Mjakf#JEL;`8Uv z-!m}0=iqq%{{43bhVS3M|7T$MKMF=efJz}yVEuRs0|NtNlDE4HLkFv@2Ll7c3r`ov zkcwNmlWOyu3izvS7ejxP>R-!INP5f(XN|IS^C^Iyp?`SUk1vQO?s(K&l| zi|Nkt0@~*ymDp65*E-HED6u(s{Mfrxmah{JrgAMTIq)Du?nC5nnYTRgThA|azEdIl zD^uvV>~q(b?>`Fd;xnAbe7so1I$-&keKN}|vNNOCvX<~g{)wp7{&hR__v^cBU*Gq* zV3YS!cBPWsl#eNWc|~nAXWMOB8tQWBuXo=4>}cytyX_5F^Az{bVJ>7~U~n#RjVKAu zPb(=;EJ|f?&`{R&%uP&B^-WCAOwLv?(KFJsP_VSrH?Yt*FjPn`$}BFabjYnNF3C*R zOD)z*DJ{s)E742N&z-nSaR&nfgBIAh%=Em(lG377hGY|?B=Z!b6jL*k#Ka_13kwTN zLrZf@a|7cv1EVApQ-8txlNlHo_&~Y>64O%|j7%zwOtcNO4T_>U4H+017(8A5T-G@y GGywozG)2h( diff --git a/doc/html/index.html b/doc/html/index.html deleted file mode 100644 index df00600..0000000 --- a/doc/html/index.html +++ /dev/null @@ -1,79 +0,0 @@ - - - -Quickbook 1.4 - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
Next
-
-
-
-

-Quickbook 1.4

-
-

-Joel de Guzman -

-

-Eric Niebler -

-
-
-
-

- Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -

-
-
-
-
- -
- - - -

Last revised: July 29, 2008 at 05:49:54 GMT

-
-
Next
- - diff --git a/doc/html/quickbook/change_log.html b/doc/html/quickbook/change_log.html deleted file mode 100644 index ca86dce..0000000 --- a/doc/html/quickbook/change_log.html +++ /dev/null @@ -1,168 +0,0 @@ - - - -Change Log - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -

- - Version 1.3 -

-
    -
  • - Quickbook file inclusion [include]. -
  • -
  • - Better xml output (pretty layout). Check out the generated XML. -
  • -
  • - Regression testing facility: to make sure your document will always be compatible - (full backward compatibility) regardless of changes to QuickBook. -
  • -
  • - Code cleanup and refactoring. -
  • -
  • - Allow phrase markup in the doc-info. -
  • -
  • - Preformatted code blocks via ``code`` (double ticks) allows code in tables - and lists, for example. -
  • -
  • - Quickbook versioning; allows full backward compatibility. You have to add - [quickbook 1.3] to the doc-info header to enable the new features. Without - this, QuickBook will assume that the document is a pre-1.3 document. -
  • -
  • - Better (intuitive) paragraph termination. Some markups may terminate a paragraph. - Example: -
    [section x]
    -blah...
    -[endsect]
    -
  • -
  • - Fully qualified section and headers. Subsection names are concatenated to - the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name -
  • -
  • - Better &nbsp; and whitespace handling in code snippets. -
  • -
  • - [xinclude] fixes up the relative path to the target XML file when input_directory - is not the same as the output_directory. -
  • -
  • - Allow untitled tables. -
  • -
  • - Allow phrase markups in section titles. -
  • -
  • - Allow escaping back to QuickBook from code, code blocks and inline code. -
  • -
  • - Footnotes, with the [footnote This is the footnote] syntax. -
  • -
  • - Post-processor bug fix for escaped XML code that it does not recognize. -
  • -
  • - Replaceable, with the [~replacement] syntax. -
  • -
-

- - Version 1.4 -

-
    -
  • - Generic Headers -
  • -
  • - Code changes to allow full recursion (i.e. Collectors and push/pop functions) -
  • -
  • - Various code cleanup/maintenance -
  • -
  • - Templates! -
  • -
  • - [conceptref] for referencing BoostBook <concept> entities. -
  • -
  • - Allow escape of spaces. The escaped space is removed from the output. Syntax: - \ . -
  • -
  • - Nested comments are now allowed. -
  • -
  • - Quickbook blocks can nest inside comments. -
  • -
  • -Import facility. -
  • -
  • - Callouts on imported code -
  • -
  • - Simple markups can now span a whole block. -
  • -
  • -Blurbs, Admonitions - and table cells (see Tables) - may now contain paragraphs. -
  • -
  • -\n - and [br] are now deprecated. -
  • -
  • -Conditional Generation. - Ala C++ #ifdef. -
  • -
  • - Searching of included and imported files in an extensible search path with - --include-path (-I) option. -
  • -
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/editors.html b/doc/html/quickbook/editors.html deleted file mode 100644 index 4dffcf6..0000000 --- a/doc/html/quickbook/editors.html +++ /dev/null @@ -1,61 +0,0 @@ - - - -Editor Support - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- - -

- Editing quickbook files is usually done with text editors both simple and powerful. - The following sections list the settings for some editors which can help make - editing quickbook files a bit easier. -

- -
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/editors/kde_support.html b/doc/html/quickbook/editors/kde_support.html deleted file mode 100644 index 2ec12ab..0000000 --- a/doc/html/quickbook/editors/kde_support.html +++ /dev/null @@ -1,465 +0,0 @@ - - - -KDE Support - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -
- - boost::hs::quickbook -
-

- boost::hs::quickbook is a syntax highlighting designed to work with Katepart. - It can be used in KWrite, Kate, Konqueror and KDevelop, and supports all - the constructs of Quickbook 1.4 including tables, list, templates and macros. -

-
-

-
-
.qbk loaded in a text editor
-

- table.text.editor -

-
.qbk loaded with boost::hs support
-

- table.boost.hs -

-
-
-

- html generated from this .qbk file -

-
-

Table 7. Code examples

-
----- - - - - - - - - - - - - - - - - - - - - - - -
-

- Name -

-
-

- Code -

-
-

- Description -

-
-

- for loop -

-
-

- for(int k=0; - k<10; k++) v+=k; -

-
-

- Sums some numbers. -

-
-

- while loop -

-
-

- { int - k; - while( - k < - 10 ) - { v+=k; k++ } } -

-
-

- Same effect. -

-
-

- infinite loop -

-
-

- while( - true ) - { v+=1; - } -

-
-

- Not a good example. -

-
-
-
- - Code Folding - -
-

- boost::hs goes far beyond simple coloring. One useful thing you can get the - editor to do is to mark regions. They appear in a small grey line and each - region can be folded or unfolded independently. -

-
- - Auto - Comment / Uncomment -
-

- Another important feature is the possibility to auto-comment or uncomment - some piece of code (Tools - Comment). Commented regions - can be uncommented simple calling the uncomment command - while being in it. -

-
- - Styles reference - -
-
----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Name -

-
-

- Style -

-
-

- Description -

-
-

- plain text -

-
-

- normal black -

-
-

- Plain text at each level. -

-
-

- formatted text -

-
-

- formatted black -

-
-

- Bold, italic, underline and mixes. Teletype, replaceable, strikeout. -

-
-

- structure -

-
-

- light blue -

-
-

- All quickbook structures characters ([, ], [block-type, simple formating - boundaries, lists keywords (*, #) -

-
-

- macros -

-
-

- red -

-
-

- Names in macro definitions, macros insertion if it is used the __xxx__ - proposed sintaxis. -

-
-

- templates -

-
-

- red -

-
-

- Names in template definitions -

-
-

- anchors -

-
-

- red -

-
-

- All the keywords that are used to link quickbooks together. -

-
-

- comments -

-
-

- italic light gray -

-
-

- Inside the commentaries. -

-
-

- tables -

-
-

- HTML like -

-
-

- Reveal the structure, bold title, higlighted HTML like columns titles. -

-
-

- variable lists -

-
-

- HTML like -

-
-

- Reveal the structure, bold title, bold HTML like items names. -

-
-

- c++ code -

-
-

- cpp Kate syntax -

-
-

- Code blocks and inline code. -

-
-

- paths -

-
-

- green -

-
-

- Image, files and web paths -

-
-

- IDE specific -

-
-

- dark blue -

-
-

- IDE commands -

-
-
- - About boost::hs -
-

- boost.hs.logo -

-

- boost::hs::quickbook is a component of boost::hs, a syntax highlighting for - C++, doxygen, Boost.Build jamfiles and QuickBook. boost::hs has his own page - here. -

-
- - - - - -
[Note]Note

- boost::hs::cpp support QuickBook code import comments style! -

-
- - Installing - boost::hs -
-

- There exist an ongoing effort to push boost::hs upstream to the KatePart - project. In a few months KDE may have native Quickbook support! For the moment - you must download and install it. -

-

- You can download boost::hs from here. -

-
- - - - - -
[Note]Note

- A copy of boost::hs::quickbook and boost::hs::cpp is available in boost/tools/quickbook/extra/katepart. -

-

- In order to install it you must copy the content in the folder katepart/syntax/ to the appropriate katepart syntax - folder in your machine. In general this folder will be in /usr/share/apps/katepart/syntax. - A bash script named install.sh is included that copy - the files to this folder. -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/editors/scite.html b/doc/html/quickbook/editors/scite.html deleted file mode 100644 index 1b2f8a0..0000000 --- a/doc/html/quickbook/editors/scite.html +++ /dev/null @@ -1,85 +0,0 @@ - - - -Scintilla Text Editor - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -
-

-

-

- Section contributed by Dean Michael Berris -

-

-

-
-

- The Scintilla Text Editor (SciTE) is a free source code editor for Win32 - and X. It uses the SCIntilla source code editing component. -

- -

- You can use the following settings to highlight quickbook tags when editing - quickbook files. -

-
qbk=*.qbk
-lexer.*.qbk=props
-use.tabs.$(qbk)=0
-tab.size.$(qbk)=4
-indent.size.$(qbk)=4
-style.props.32=$(font.base)
-comment.stream.start.props=[/
-comment.stream.end.props=]
-comment.box.start.props=[/
-comment.box.middle.props=
-comment.box.end.props=]
-
- -
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/faq.html b/doc/html/quickbook/faq.html deleted file mode 100644 index 8fa26a2..0000000 --- a/doc/html/quickbook/faq.html +++ /dev/null @@ -1,100 +0,0 @@ - - - -Frequently Asked Questions - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -

- - Can - I use QuickBook for non-Boost documentation? -

-

- QuickBook can be used for non-Boost documentation with a little extra work. -

-
-

-

-

- Faq contributed by Michael Marcin -

-

-

-
-

- When building HTML documentation with BoostBook a Boost C++ Libraries header - is added to the files. When using QuickBook to document projects outside of - Boost this is not desirable. This behavior can be overridden at the BoostBook - level by specifying some XSLT options. When using Boost Build version 2 (BBv2) - this can be achieved by adding parameters to the BoostBook target declaration. -

-

- For example: -

-
using quickbook ;
-
-xml my_doc : my_doc.qbk ;
-
-boostbook standalone
-    :
-        my_doc
-    :
-        <xsl:param>boost.image.srcimages/my_project_logo.png
-        <xsl:param>boost.image.alt"\"My Project\""
-        <xsl:param>boost.image.w=100
-        <xsl:param>boost.image.h=50
-        <xsl:param>nav.layout=none
-    ;
-
-

- - Is - there an easy way to convert BoostBook docs to QuickBook? -

-

- There's a stylesheet that allows Boostbook generated HTML to be viewed as quickbook - source, see http://svn.boost.org/trac/boost/wiki/QuickbookSourceStylesheetProject, - so it's then just a cut and paste job to convert the BoostBook to QuickBook - (which IMO is a whole lot easier to edit and maintain). -

-

- --John Maddock -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/install.html b/doc/html/quickbook/install.html deleted file mode 100644 index 1c741ac..0000000 --- a/doc/html/quickbook/install.html +++ /dev/null @@ -1,60 +0,0 @@ - - - -Installation and configuration - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- - -

- This section provides some guidelines on how to install and configure BoostBook - and Quickbook under several operating systems. -

-

- Before continuing, it is very important that you keep this in mind: if you - try to build some documents and the process breaks due to misconfiguration, - be absolutely sure to delete any bin - and bin.v2 directories generated by the build before - trying again. Otherwise your configuration fixes will not take any effect. -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/install/linux.html b/doc/html/quickbook/install/linux.html deleted file mode 100644 index 27d603c..0000000 --- a/doc/html/quickbook/install/linux.html +++ /dev/null @@ -1,104 +0,0 @@ - - - -Debian, Ubuntu - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -

- The following instructions apply to Debian and its derivatives. They are - based on a Ubuntu Edgy install but should work on other Debian based systems. -

-

- First install the bjam, - xsltproc, docbook-xsl and - docbook-xml packages. For example, using apt-get: -

-
sudo apt-get install xsltproc docbook-xsl docbook-xml
-
-

- If you're planning on building boost's documentation, you'll also need to - install the doxygen package - as well. -

-

- Next, we need to configure Boost Build to compile BoostBook files. Add the - following to your user-config.jam file, which should be in your home - directory. If you don't have one, create a file containing this text. For - more information on setting up user-config.jam, see - the Boost - Build documentation. -

-
using xsltproc ;
-
-using boostbook
-    : /usr/share/xml/docbook/stylesheet/nwalsh
-    : /usr/share/xml/docbook/schema/dtd/4.2
-    ;
-
-# Remove this line if you're not using doxygen
-using doxygen ;
-
-

- The above steps are enough to get a functional BoostBook setup. Quickbook - will be automatically built when needed. If you want to avoid these rebuilds: -

-
    -
  1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). -
  2. -
  3. - Build the utility by issuing bjam - --v2. -
  4. -
  5. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) - to a safe place. The traditional location is /usr/local/bin. -
  6. -
  7. - Add the following to your user-config.jam - file, using the full path of the quickbook executable: -
  8. -
-
using quickbook
-    : /usr/local/bin/quickbook
-    ;
-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/install/macosx.html b/doc/html/quickbook/install/macosx.html deleted file mode 100644 index 2638504..0000000 --- a/doc/html/quickbook/install/macosx.html +++ /dev/null @@ -1,156 +0,0 @@ - - - -Mac OS X - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -
-

-

-

- Section contributed by Julio M. Merino Vidal -

-

-

-
-

- The following instructions explain how to install Docbook XML, Docbook XSL - and Doxygen in a Mac OS X system, how to configure Boost.Build v2 to recognize - them and how to build and install Quickbook. They were taken from a 10.4 - (Tiger) machine so it is likely that they also apply to future versions; - they may not work with older ones, though. -

-

- The text below assumes you want to install all the necessary utilities in - a system-wide location, allowing any user in the machine to have access to - them. Therefore, all files will be put in the /usr/local - hierarchy. If you do not want this, you can choose any other prefix such - as ~/Applications - for a single-user installation. -

-

- Mac OS X comes with xsltproc - and all related libraries preinstalled, so you do not need to take any extra - steps to set them up. It is probable that future versions will include them - too, but these instructions may not apply to older versions. -

-

- To get started: -

-
    -
  1. - Download Docbook - XML 4.2 and unpack it inside /usr/local/share/xml/docbook/4.2. -
  2. -
  3. - Download the latest Docbook - XSL version and unpack it. Put the results in /usr/local/share/xsl/docbook, thus effectively removing the - version number from the directory name (for simplicity). -
  4. -
  5. - Add the following to your user-config.jam - file, which should live in your home directory (/Users/<your_username>). - You must already have it somewhere or otherwise you could not be building - Boost (i.e. missing tools configuration). -
  6. -
-
using xsltproc ;
-
-using boostbook
-    : "/usr/local/share/xsl/docbook"
-    : "/usr/local/share/xml/docbook/4.2"
-    ;
-
-

- The above steps are enough to get a functional BoostBook setup. Quickbook - will be automatically built when needed. If you want to avoid these rebuilds - and install a system-wide Quickbook instead: -

-
    -
  1. - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). -
  2. -
  3. - Build the utility by issuing bjam - --v2. -
  4. -
  5. - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) - to a safe place. Following our previous example, you can install it into: - /usr/local/bin. -
  6. -
  7. - Add the following to your user-config.jam - file: -
  8. -
-
using quickbook
-    : "/usr/local/bin/quickbook" ;
-    ;
-
-

- Additionally, if you need to build documentation that uses Doxygen, - you will need to install it too: -

-
    -
  1. - Go to the downloads - section and get the disk image (dmg - file) for Mac OS X. -
  2. -
  3. - Open the disk image and drag the Doxygen application to your Applications folder to install it. -
  4. -
  5. - Add the following to your user-config.jam - file: -
  6. -
-
using doxygen
-    : /Applications/Doxygen.app/Contents/Resources/doxygen
-    ;
-
-

- Alternatively, you may want to install all the prerequistes through a package - system to avoid manual management of the installations. In that case, check - out pkgsrc. -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/install/windows.html b/doc/html/quickbook/install/windows.html deleted file mode 100644 index 16dad50..0000000 --- a/doc/html/quickbook/install/windows.html +++ /dev/null @@ -1,136 +0,0 @@ - - - -Windows 2000, XP, 2003, Vista - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -

-

-
-

-

-

- Section contributed by Julio M. Merino Vidal -

-

-

-
-

- The following instructions apply to any Windows system based on Windows 2000, - including Windows XP, Windows 2003 Server and Windows Vista. The paths shown - below are taken from a Windows Vista machine; you will need to adjust them - to match your system in case you are running an older version. -

-
    -
  1. - First of all you need to have a copy of xsltproc - for Windows. There are many ways to get this tool, but to keep things simple, - use the binary packages - made by Igor Zlatkovic. At the very least, you need to download the following - packages: iconv, zlib, libxml2 - and libxslt. -
  2. -
  3. - Unpack all these packages in the same directory so that you get unique - bin, include - and lib directories within - the hierarchy. These instructions use C:\Users\example\Documents\boost\xml - as the root for all files. -
  4. -
  5. - From the command line, go to the bin - directory and launch xsltproc.exe - to ensure it works. You should get usage information on screen. -
  6. -
  7. - Download Docbook - XML 4.2 and unpack it in the same directory used above. That is: - C:\Users\example\Documents\boost\xml\docbook-xml. -
  8. -
  9. - Download the latest Docbook - XSL version and unpack it, again in the same directory used before. - To make things easier, rename the directory created during the extraction - to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. -
  10. -
  11. - Add the following to your user-config.jam - file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). - You must already have it somewhere or otherwise you could not be building - Boost (i.e. missing tools configuration). -
  12. -
-
using xsltproc
-    : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe"
-    ;
-
-using boostbook
-    : "C:/Users/example/Documents/boost/xml/docbook-xsl"
-    : "C:/Users/example/Documents/boost/xml/docbook-xml"
-    ;
-
-

- The above steps are enough to get a functional BoostBook setup. Quickbook - will be automatically built when needed. If you want to avoid these rebuilds: -

-
    -
  1. - Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). -
  2. -
  3. - Build the utility by issuing bjam - --v2. -
  4. -
  5. - Copy the resulting quickbook.exe - binary (located under the BOOST_ROOT\bin.v2 hierarchy) - to a safe place. Following our previous example, you can install it into: - C:\Users\example\Documents\boost\xml\bin. -
  6. -
  7. - Add the following to your user-config.jam - file: -
  8. -
-
using quickbook
-    : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe"
-    ;
-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/intro.html b/doc/html/quickbook/intro.html deleted file mode 100644 index d708858..0000000 --- a/doc/html/quickbook/intro.html +++ /dev/null @@ -1,115 +0,0 @@ - - - -Introduction - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -
-

-

-

- Why program by hand in five days - what you can spend five years of your life automating? -

-

-

-

- -- Terrence Parr, author ANTLR/PCCTS -

-

-

-
-

- Well, QuickBook started as a weekend hack. It was originally intended to be - a sample application using Spirit. - What is it? What you are viewing now, this documentation, is autogenerated - by QuickBook. These files were generated from one master: -

-
-

-

-

- quickbook.qbk -

-

-

-
-

- Originally named QuickDoc, this funky tool that never dies, evolved into a - funkier tool thanks to Eric Niebler who resurrected the project making it generate - BoostBook - instead of HTML. The BoostBook - documentation format is an extension of DocBook, - an SGML or XML based format for describing documentation. -

-

- QuickBook is a WikiWiki style documentation tool geared towards C++ documentation - using simple rules and markup for simple formatting tasks. QuickBook extends - the WikiWiki concept. Like the WikiWiki, QuickBook documents are simple text - files. A single QuickBook document can generate a fully linked set of nice - HTML and PostScript/PDF documents complete with images and syntax- colorized - source code. -

-

- Features include: -

-
    -
  • - generate BoostBook - xml, to generate HTML, PostScript and PDF -
  • -
  • - simple markup to link to Doxygen-generated entities -
  • -
  • - macro system for simple text substitution -
  • -
  • - simple markup for italics, bold, preformatted, blurbs, code samples, tables, - URLs, anchors, images, etc. -
  • -
  • - automatic syntax coloring of code samples -
  • -
  • - CSS support -
  • -
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/ref.html b/doc/html/quickbook/ref.html deleted file mode 100644 index dda1c48..0000000 --- a/doc/html/quickbook/ref.html +++ /dev/null @@ -1,958 +0,0 @@ - - - -Quick Reference - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHome -
-
- -

-

-
-

Table 8. Syntax Compendium

-
----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- To do this... -

-
-

- Use this... -

-
-

- See this... -

-
-

- comment -

-
-

- [/ some comment] -

-
-

- Comments -

-
-

- italics -

-
-

- ['italics] or /italics/ -

-
-

- Font Styles - and Simple - formatting -

-
-

- bold -

-
-

- [*bold] or *bold* -

-
-

- Font Styles - and Simple - formatting -

-
-

- underline -

-
-

- [_underline] or _underline_ -

-
-

- Font Styles - and Simple - formatting -

-
-

- teletype -

-
-

- [^teletype] or =teletype= -

-
-

- Font Styles - and Simple - formatting -

-
-

- strikethrough -

-
-

- [-strikethrough] -

-
-

- Font Styles - and Simple - formatting -

-
-

- - replaceable - -

-
-

- [~replaceable] -

-
-

- Replaceble -

-
-

- source mode -

-
-

- [c++] or [python] -

-
-

- Source Mode -

-
-

- inline code -

-
-

- `int main();` -

-
-

- Inline code -

-
-

- code block -

-
-

- ``int main();`` -

-
-

- Code -

-
-

- code escape -

-
-

- ``from c++ to QuickBook`` -

-
-

- Escaping Back To QuickBook -

-
-

- line break -

-
-

- [br] or \n -

-
-

- line-break - DEPRECATED -

-
-

- anchor -

-
-

- [#anchor] -

-
-

- Anchors -

-
-

- link -

-
-

- [@http://www.boost.org Boost] -

-
-

- Links -

-
-

- anchor link -

-
-

- [link section.anchor Link text] -

-
-

- Anchor links -

-
-

- refentry link -

-
-

- [link xml.refentry Link text] -

-
-

- refentry links -

-
-

- function link -

-
-

- [funcref fully::qualified::function_name Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- class link -

-
-

- [classref fully::qualified::class_name Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- member link -

-
-

- [memberref fully::qualified::member_name Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- enum link -

-
-

- [enumref fully::qualified::enum_name Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- macro link -

-
-

- [macroref MACRO_NAME Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- concept link -

-
-

- [conceptref ConceptName Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- header link -

-
-

- [headerref path/to/header.hpp Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- global link -

-
-

- [globalref fully::qualified::global Link text] -

-
-

- function, class, member, - enum, macro, concept or header links -

-
-

- escape -

-
-

- '''escaped text (no processing/formatting)''' -

-
-

- Escape -

-
-

- single char escape -

-
-

- \c -

-
-

- Single char - escape -

-
-

- images -

-
-

- [$image.jpg] -

-
-

- Images -

-
-

- begin section -

-
-

- [section The Section Title] -

-
-

- Section -

-
-

- end section -

-
-

- [endsect] -

-
-

- Section -

-
-

- paragraph -

-
-

- No markup. Paragraphs start left-flushed and are terminated by two or - more newlines. -

-
-

- Paragraphs -

-
-

- ordered list -

-
-

- -

-
# one
-# two
-# three
-
-

-

-
-

- Ordered lists -

-
-

- unordered list -

-
-

- -

-
* one
-* two
-* three
-
-

-

-
-

- Unordered - lists -

-
-

- code -

-
-

- No markup. Preformatted code starts with a space or a tab. -

-
-

- Code -

-
-

- preformatted -

-
-

- [pre preformatted] -

-
-

- Preformatted -

-
-

- block quote -

-
-

- [:sometext...] -

-
-

- Blockquote -

-
-

- heading 1 -

-
-

- [h1 Heading 1] -

-
-

- Heading -

-
-

- heading 2 -

-
-

- [h2 Heading 2] -

-
-

- Heading -

-
-

- heading 3 -

-
-

- [h3 Heading 3] -

-
-

- Heading -

-
-

- heading 4 -

-
-

- [h4 Heading 4] -

-
-

- Heading -

-
-

- heading 5 -

-
-

- [h5 Heading 5] -

-
-

- Heading -

-
-

- heading 6 -

-
-

- [h6 Heading 6] -

-
-

- Heading -

-
-

- macro -

-
-

- [def macro_identifier some text] -

-
-

- Macros -

-
-

- template -

-
-

- [template[a b] [a] body [b]] -

-
-

- Templates -

-
-

- blurb -

-
-

- [blurb advertisement or note...] -

-
-

- Blurbs -

-
-

- admonition -

-
-

- [warning Warning text...] -

-
-

- Admonitions -

-
-

- table -

-
-

- -

-
[table Title
-[[a][b][c]]
-[[a][b][c]]
-]
-
-

-

-
-

- Tables -

-
-

- variablelist -

-
-

- -

-
[variablelist Title
-[[a][b]]
-[[a][b]]
-]
-
-

-

-
-

- Variable Lists -

-
-

- include -

-
-

- [include someother.qbk] -

-
-

- Include -

-
-

- conditional generation -

-
-

- [? symbol phrase] -

-
-

- Conditional Generation -

-
-
-
-
- - - -
-
-
-PrevUpHome -
- - diff --git a/doc/html/quickbook/syntax.html b/doc/html/quickbook/syntax.html deleted file mode 100644 index 4d29c98..0000000 --- a/doc/html/quickbook/syntax.html +++ /dev/null @@ -1,64 +0,0 @@ - - - -Syntax Summary - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- - -

- A QuickBook document is composed of one or more blocks. An example of a block - is the paragraph or a C++ code snippet. Some blocks have special mark-ups. - Blocks, except code snippets which have their own grammar (C++ or Python), - are composed of one or more phrases. A phrase can be a simple contiguous run - of characters. Phrases can have special mark-ups. Marked up phrases can recursively - contain other phrases, but cannot contain blocks. A terminal is a self contained - block-level or phrase-level element that does not nest anything. -

-

- Blocks, in general, are delimited by two end-of-lines (the block terminator). - Phrases in each block cannot contain a block terminator. This way, syntax errors - such as un-matched closing brackets do not go haywire and corrupt anything - past a single block. -

-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/syntax/block.html b/doc/html/quickbook/syntax/block.html deleted file mode 100644 index 8090413..0000000 --- a/doc/html/quickbook/syntax/block.html +++ /dev/null @@ -1,1895 +0,0 @@ - - - -Block Level Elements - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- - -
- -

- Every document must begin with a Document Info section, which should look - like this: -

-
[document-type The Document Title
-    [quickbook 1.3]
-    [version 1.0]
-    [id the_document_name]
-    [dirname the_document_dir]
-    [copyright 2000 2002 2003 Joe Blow, Jane Doe]
-    [purpose The document's reason for being]
-    [category The document's category]
-    [authors [Blow, Joe], [Doe, Jane]]
-    [license The document's license]
-    [source-mode source-type]
-]
-
-

- Where document-type is one of: -

-
    -
  • - book -
  • -
  • - article -
  • -
  • - library -
  • -
  • - chapter -
  • -
  • - part -
  • -
  • - appendix -
  • -
  • - preface -
  • -
  • - qandadiv -
  • -
  • - qandaset -
  • -
  • - reference -
  • -
  • - set -
  • -
-

- quickbook 1.3 declares the version of quickbook the document is written - for. In its absence, version 1.1 is assumed. -

-

- version, id, dirname, - copyright, purpose, category, - authors, license, last-revision - and source-mode are optional information. -

-

- source-type is a lowercase string setting the initial - Source Mode. - If the source-mode field is omitted, a default value - of c++ will be used. -

-
-
- -

- Starting a new section is accomplished with: -

-
[section:id The Section Title]
-
-

- where id is optional. id will be the filename of the - generated section. If it is not present, "The Section Title" - will be normalized and become the id. Valid characters are a-Z, - A-Z, 0-9 and _. - All non-valid characters are converted to underscore and all upper-case - are converted to lower case. Thus: "The Section Title" will be - normalized to "the_section_title". -

-

- End a section with: -

-
[endsect]
-
-

- Sections can nest, and that results in a hierarchy in the table of contents. -

-
-
- -

- You can include another XML file with: -

-
[xinclude file.xml]
-
-

- This is useful when file.xml has been generated by Doxygen and contains - your reference section. -

-
-
- -

- Paragraphs start left-flushed and are terminated by two or more newlines. - No markup is needed for paragraphs. QuickBook automatically detects paragraphs - from the context. Block markups [section, endsect, h1, h2, h3, h4, h5, - h6, blurb, (block-quote) ':', pre, def, table and include ] may also terminate - a paragraph. -

-

- This is a new paragraph... -

-
-
-

-Lists -

- -
- -
# One
-# Two
-# Three
-
-

- will generate: -

-
    -
  1. - One -
  2. -
  3. - Two -
  4. -
  5. - Three -
  6. -
-
-
- -

- List hierarchies are supported. Example: -

-
# One
-# Two
-# Three
-    # Three.a
-    # Three.b
-    # Three.c
-# Four
-    # Four.a
-        # Four.a.i
-        # Four.a.ii
-# Five
-
-

- will generate: -

-
    -
  1. - One -
  2. -
  3. - Two -
  4. -
  5. - Three -
      -
    1. - Three.a -
    2. -
    3. - Three.b -
    4. -
    5. - Three.c -
    6. -
    -
  6. -
  7. - Fourth -
    1. - Four.a -
        -
      1. - Four.a.i -
      2. -
      3. - Four.a.ii -
      4. -
      -
    -
  8. -
  9. - Five -
  10. -
-
-
- -

- Long lines will be wrapped appropriately. Example: -

-
# A short item.
-# A very long item. A very long item. A very long item.
-  A very long item. A very long item. A very long item.
-  A very long item. A very long item. A very long item.
-  A very long item. A very long item. A very long item.
-  A very long item. A very long item. A very long item.
-# A short item.
-
-
    -
  1. - A short item. -
  2. -
  3. - A very long item. A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. -
  4. -
  5. - A short item. -
  6. -
-
-
- -
* First
-* Second
-* Third
-
-

- will generate: -

-
    -
  • - First -
  • -
  • - Second -
  • -
  • - Third -
  • -
-
-
- -

- Mixed lists (ordered and unordered) are supported. Example: -

-
# One
-# Two
-# Three
-    * Three.a
-    * Three.b
-    * Three.c
-# Four
-
-

- will generate: -

-
    -
  1. - One -
  2. -
  3. - Two -
  4. -
  5. - Three -
      -
    • - Three.a -
    • -
    • - Three.b -
    • -
    • - Three.c -
    • -
    -
  6. -
  7. - Four -
  8. -
-

- And... -

-
# 1
-    * 1.a
-        # 1.a.1
-        # 1.a.2
-    * 1.b
-# 2
-    * 2.a
-    * 2.b
-        # 2.b.1
-        # 2.b.2
-            * 2.b.2.a
-            * 2.b.2.b
-
-

- will generate: -

-
    -
  1. - 1 -
      -
    • - 1.a -
        -
      1. - 1.a.1 -
      2. -
      3. - 1.a.2 -
      4. -
      -
    • -
    • - 1.b -
    • -
    -
  2. -
  3. - 2 -
      -
    • - 2.a -
    • -
    • - 2.b -
        -
      1. - 2.b.1 -
      2. -
      3. - 2.b.2 -
          -
        • - 2.b.2.a -
        • -
        • - 2.b.2.b -
        • -
        -
      4. -
      -
    • -
    -
  4. -
-
-
-
-

-Code -

-

- Preformatted code starts with a space or a tab. The code will be syntax - highlighted according to the current Source - Mode: -

-

-

-
#include <iostream>
-
-int main()
-{
-    // Sample code
-    std::cout << "Hello, World\n";
-    return 0;
-}
-
-

-

-
import cgi
-
-def cookForHtml(text):
-    '''"Cooks" the input text for HTML.'''
-
-    return cgi.escape(text)
-
-

-

-

- Macros that are already defined are expanded in source code. Example: -

-
[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]]
-[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]]
-
-    using __boost__::__array__;
-
-

- Generates: -

-
using boost::array;
-
-
-
- -

- Inside code, code blocks and inline code, QuickBook does not allow any - markup to avoid conflicts with the target syntax (e.g. c++). In case you - need to switch back to QuickBook markup inside code, you can do so using - a language specific escape-back delimiter. In C++ - and Python, the delimiter is the double tick (back-quote): "``" - and "``". Example: -

-
void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``()
-{
-}
-
-

- Will generate: -

-
void foo()
-{
-}
-
-

- When escaping from code to QuickBook, only phrase level markups are allowed. - Block level markups like lists, tables etc. are not allowed. -

-
-
- -

- Sometimes, you don't want some preformatted text to be parsed as C++. In - such cases, use the [pre ... ] markup block. -

-
[pre
-
-    Some *preformatted* text                    Some *preformatted* text
-
-        Some *preformatted* text            Some *preformatted* text
-
-            Some *preformatted* text    Some *preformatted* text
-
-]
-
-

- Spaces, tabs and newlines are rendered as-is. Unlike all quickbook block - level markup, pre (and Code) are the only ones that allow multiple newlines. - The markup above will generate: -

-
Some preformatted text                    Some preformatted text
-
-    Some preformatted text            Some preformatted text
-
-        Some preformatted text    Some preformatted text
-
-
-

- Notice that unlike Code, phrase markup such as font style is still permitted - inside pre blocks. -

-
-
- -
[:sometext...]
-
-
-

-

-

- Indents the paragraph. This applies to one paragraph only. -

-

-

-
-
-
- -
[note This is a note]
-[tip This is a tip]
-[important This is important]
-[caution This is a caution]
-[warning This is a warning]
-
-

- generates DocBook admonitions: -

-
- - - - - -
[Note]Note

- This is a note -

-
- - - - - -
[Tip]Tip

- This is a tip -

-
- - - - - -
[Important]Important

- This is important -

-
- - - - - -
[Caution]Caution

- This is a caution -

-
- - - - - -
[Warning]Warning

- This is a warning -

-

- These are the only admonitions supported by DocBook. - So, for example [information This is some information] - is unlikely to produce the desired effect. -

-
-
- -
[h1 Heading 1]
-[h2 Heading 2]
-[h3 Heading 3]
-[h4 Heading 4]
-[h5 Heading 5]
-[h6 Heading 6]
-
-

- - Heading 1 -

-

- - Heading 2 -

-

- - Heading 3 -

-
- - Heading 4 -
-
- - Heading 5 -
-
- - Heading 6 -
-

- Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized - names with name="section_id.normalized_header_text" - (i.e. valid characters are a-z, A-Z, - 0-9 and _. All non-valid characters - are converted to underscore and all upper-case are converted to lower-case. - For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). - You can use: -

-
[link section_id.normalized_header_text The link text]
-
-

- to link to them. See Anchor - links and Section - for more info. -

-
-
- -

- In cases when you don't want to care about the heading level (1 to 6), - you can use the Generic Heading: -

-
[heading Heading]
-
-

- The Generic Heading assumes the level, plus one, of - the innermost section where it is placed. For example, if it is placed - in the outermost section, then, it assumes h2. -

-

- Headings are often used as an alternative to sections. It is used particularly - if you do not want to start a new section. In many cases, however, headings - in a particular section is just flat. Example: -

-
[section A]
-[h2 X]
-[h2 Y]
-[h2 Z]
-[endsect]
-
-

- Here we use h2 assuming that section A is the outermost level. If it is - placed in an inner level, you'll have to use h3, h4, etc. depending on - where the section is. In general, it is the section level plus one. It - is rather tedious, however, to scan the section level everytime. If you - rewrite the example above as shown below, this will be automatic: -

-
[section A]
-[heading X]
-[heading Y]
-[heading Z]
-[endsect]
-
-

- They work well regardless where you place them. You can rearrange sections - at will without any extra work to ensure correct heading levels. In fact, - with section and heading, you - have all you need. h1..h6 becomes - redundant. h1..h6 might be deprecated - in the future. -

-
-
-

-Macros -

-
[def macro_identifier some text]
-
-

- When a macro is defined, the identifier replaces the text anywhere in the - file, in paragraphs, in markups, etc. macro_identifier is a string of non- - white space characters except ']'. A macro may not follow an alphabetic - character or the underscore. The replacement text can be any phrase (even - marked up). Example: -

-
[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]]
-sf_logo
-
-

- Now everywhere the sf_logo is placed, the picture will be inlined. -

-

- -

-
- - - - - -
[Tip]Tip

- It's a good idea to use macro identifiers that are distinguishable. For - instance, in this document, macro identifiers have two leading and trailing - underscores (e.g. __spirit__). The reason is to avoid unwanted - macro replacement. -

-

- Links (URLS) and images are good candidates for macros. 1) - They tend to change a lot. It is a good idea to place all links and images - in one place near the top to make it easy to make changes. 2) - The syntax is not pretty. It's easier to read and write, e.g. __spirit__ - than [@http://spirit.sourceforge.net Spirit]. -

-

- Some more examples: -

-
[def :-)            [$theme/smiley.png]]
-[def __spirit__     [@http://spirit.sourceforge.net Spirit]]
-
-

- (See Images and - Links) -

-

- Invoking these macros: -

-
Hi __spirit__  :-)
-
-

- will generate this: -

-

- Hi Spirit smiley -

-
-
- -

- Quickbook has some predefined macros that you can already use. -

-
-

Table 3. Predefined Macros

-
----- - - - - - - - - - - - - - - - - - - - - - - -
-

- Macro -

-
-

- Meaning -

-
-

- Example -

-
-

- __DATE__ -

-
-

- Today's date -

-
-

- 2008-Jul-28 -

-
-

- __TIME__ -

-
-

- The current time -

-
-

- 10:49:54 PM -

-
-

- __FILENAME__ -

-
-

- Quickbook source filename -

-
-

- C:\cygwin\home\ericne\boost\org\trunk\tools\quickbook\doc\quickbook.qbk -

-
-
-
-
-
- -

- Templates provide a more versatile text substitution mechanism. Templates - come in handy when you need to create parameterizable, multi-line, boilerplate - text that you specify once and expand many times. Templates accept one - or more arguments. These arguments act like place-holders for text replacement. - Unlike simple macros, which are limited to phrase level markup, templates - can contain block level markup (e.g. paragraphs, code blocks and tables). -

-

- Example template: -

-
[template person[name age what]
-
-Hi, my name is [name]. I am [age] years old. I am a [what].
-
-]
-
-
- - Template - Identifier -
-

- Template identifiers can either consist of: -

-
    -
  • - An initial alphabetic character or the underscore, followed by zero or - more alphanumeric characters or the underscore. This is similar to your - typical C/C++ identifier. -
  • -
  • - A single character punctuation (a non-alphanumeric printable character) -
  • -
-
- - Formal - Template Arguments -
-

- Template formal arguments are identifiers consisting of an initial alphabetic - character or the underscore, followed by zero or more alphanumeric characters - or the underscore. This is similar to your typical C/C++ identifier. -

-

- A template formal argument temporarily hides a template of the same name - at the point where the template - is expanded. Note that the body of the person - template above refers to name age - and what as [name] [age] - and [what]. name age - and what are actually templates that exist in the duration - of the template call. -

-
- - Template - Body -
-

- The template body can be just about any QuickBook block or phrase. There - are actually two forms. Templates may be phrase or block level. Phrase - templates are of the form: -

-
[template sample[arg1 arg2...argN] replacement text... ]
-
-

- Block templates are of the form: -

-
[template sample[arg1 arg2...argN]
-replacement text...
-]
-
-

- The basic rule is as follows: if a newline immediately follows the argument - list, then it is a block template, otherwise, it is a phrase template. - Phrase templates are typically expanded as part of phrases. Like macros, - block level elements are not allowed in phrase templates. -

-
- - Template - Expansion -
-

- You expand a template this way: -

-
[template_identifier arg1..arg2..arg3]
-
-

- At template expansion, you supply the actual arguments. The template will - be expanded with your supplied arguments. Example: -

-
[person James Bond..39..Spy]
-[person Santa Clause..87..Big Red Fatso]
-
-

- Which will expand to: -

-

-

-

- Hi, my name is James Bond. I am 39 years old. I am a Spy. -

-

-

-

- Hi, my name is Santa Clause. I am 87 years old. I am a Big Red Fatso. -

-

-

-
- - - - - -
[Caution]Caution

- A word of caution: Templates are recursive. A template can call another - template or even itself, directly or indirectly. There are no control - structures in QuickBook (yet) so this will always mean infinite recursion. - QuickBook can detect this situation and report an error if recursion - exceeds a certain limit. -

-

- Each actual argument can be a word, a text fragment or just about any - QuickBook phrase. Arguments - are separated by the double dot ".." and terminated - by the close parenthesis. -

-
- - Nullary - Templates -
-

- Nullary templates look and act like simple macros. Example: -

-
[template alpha[]'''&#945;''']
-[template beta[]'''&#946;''']
-
-

- Expanding: -

-
Some squigles...[*[alpha][beta]]
-

- We have: -

-

- Some squiggles...αβ -

-

- The difference with macros are -

-
    -
  • - The explicit template - expansion syntax. This is an advantage because, now, we don't - have to use obscure naming conventions like double underscores (e.g. - __alpha__) to avoid unwanted macro replacement. -
  • -
  • - The template is expanded at the point where it is invoked. A macro is - expanded immediately at its point of declaration. This is subtle and - can cause a slight difference in behavior especially if you refer to - other macros and templates in the body. -
  • -
-

- The empty brackets after the template identifier (alpha[]) - indicates no arguments. If the template body does not look like a template - argument list, we can elide the empty brackets. Example: -

-
[template aristotle_quote Aristotle: [*['Education is the best provision
-for the journey to old age.]]]
-
-

- Expanding: -

-
Here's a quote from [aristotle_quote].
-
-

- We have: -

-

- Here's a quote from Aristotle: Education - is the best provision for the journey to old age.. -

-

- The disadvantage is that you can't avoid the space between the template - identifier, aristotle_quote, - and the template body "Aristotle...". This space will be part - of the template body. If that space is unwanted, use empty brackets or - use the space escape: "\ ". - Example: -

-
[template tag\ _tag]
-
-

- Then expanding: -

-
`struct` x[tag];
-
-

- We have: -

-

- struct x_tag; -

-

- You have a couple of ways to do it. I personally prefer the explicit empty - brackets, though. -

-
- - Simple - Arguments -
-

- As mentioned, arguments are separated by the double dot "..". - If there are less arguments passed than expected, QuickBook attempts to - break the last argument into two or more arguments following this logic: -

-
    -
  • - Break the last argument into two, at the first space found ('', - '\n', \t' or '\r'). -
  • -
  • - Repeat until there are enough arguments or if there are no more spaces - found (in which case, an error is reported). -
  • -
-

- For example: -

-
[template simple[a b c d] [a][b][c][d]]
-[simple w x y z]
-
-

- will produce: -

-

- wxyz -

-

- "w x y z" is initially treated as a single argument because we - didn't supply any ".." separators. However, - since simple expects 4 arguments, "w x y z" - is broken down iteratively (applying the logic above) until we have "w", - "x", "y" and "z". -

-

- QuickBook only tries to get the arguments it needs. For example: -

-
[simple w x y z trail]
-
-

- will produce: -

-

- wxyz trail -

-

- The arguments being: "w", "x", "y" and "z - trail". -

-

- It should be obvious now that for simple arguments with no spaces, we can - get by without separating the arguments with ".." - separators. It is possible to combine ".." - separators with the argument passing simplification presented above. Example: -

-
[simple what do you think ..m a n?]
-
-

- will produce: -

-

- what do you think man? -

-
- - Punctuation - Templates -
-

- With templates, one of our objectives is to allow us to rewrite QuickBook - in QuickBook (as a qbk library). For that to happen, we need to accommodate - single character punctuation templates which are fairly common in QuickBook. - You might have noticed that single character punctuations are allowed as - template - identifiers. Example: -

-
[template ![bar] <hey>[bar]</hey>]
-
-

- Now, expanding this: -

-
[!baz]
-
-

- We will have: -

-
<hey>baz</hey>
-
-
-
-

-Blurbs -

-
[blurb :-) [*An eye catching advertisement or note...]
-
-    __spirit__ is an object-oriented recursive-descent parser generator framework
-    implemented using template meta-programming techniques. Expression templates
-    allow us to approximate the syntax of Extended Backus-Normal Form (EBNF)
-    completely in C++.
-]
-
-

- will generate this: -

- -
- - - - - -
[Note]Note

- Prefer admonitions - wherever appropriate. -

-
-
-

-Tables -

-
[table A Simple Table
-    [[Heading 1] [Heading 2] [Heading 3]]
-    [[R0-C0]     [R0-C1]     [R0-C2]]
-    [[R1-C0]     [R1-C1]     [R1-C2]]
-    [[R2-C0]     [R2-C1]     [R2-C2]]
-]
-
-

- will generate: -

-
-

Table 4. A Simple Table

-
----- - - - - - - - - - - - - - - - - - - - - - - -
-

- Heading 1 -

-
-

- Heading 2 -

-
-

- Heading 3 -

-
-

- R0-C0 -

-
-

- R0-C1 -

-
-

- R0-C2 -

-
-

- R2-C0 -

-
-

- R2-C1 -

-
-

- R2-C2 -

-
-

- R3-C0 -

-
-

- R3-C1 -

-
-

- R3-C2 -

-
-
-

- The table title is optional. The first row of the table is automatically - treated as the table header; that is, it is wrapped in <thead>...</thead> - XML tags. Note that unlike the original QuickDoc, the columns are nested - in [ cells... ]. The syntax is free-format and allows big cells to be formatted - nicely. Example: -

-
[table Table with fat cells
-    [[Heading 1] [Heading 2]]
-    [
-        [Row 0, Col 0: a small cell]
-        [
-            Row 0, Col 1: a big fat cell with paragraphs
-
-            Boost provides free peer-reviewed portable C++ source libraries.
-
-            We emphasize libraries that work well with the C++ Standard Library.
-            Boost libraries are intended to be widely useful, and usable across
-            a broad spectrum of applications. The Boost license encourages both
-            commercial and non-commercial use.
-        ]
-    ]
-    [
-        [Row 1, Col 0: a small cell]
-        [Row 1, Col 1: a small cell]
-    ]
-]
-
-

- and thus: -

-
-

Table 5. Table with fat cells

-
---- - - - - - - - - - - - - - - -
-

- Heading 1 -

-
-

- Heading 2 -

-
-

- Row 0, Col 0: a small cell -

-
-

- Row 0, Col 1: a big fat cell with paragraphs -

-

- Boost provides free peer-reviewed portable C++ source libraries. -

-

- We emphasize libraries that work well with the C++ Standard Library. - Boost libraries are intended to be widely useful, and usable across - a broad spectrum of applications. The Boost license encourages both - commercial and non-commercial use. -

-
-

- Row 1, Col 0: a small cell -

-
-

- Row 1, Col 1: a small cell -

-
-
-

- Here's how to have preformatted blocks of code in a table cell: -

-
[table Table with code
-    [[Comment] [Code]]
-    [
-        [My first program]
-        [``
-            #include <iostream>
-
-            int main()
-            {
-                std::cout << "Hello, World!" << std::endl;
-                return 0;
-            }
-        ``]
-    ]
-]
-
-
-

Table 6. Table with code

-
---- - - - - - - - - -
-

- Comment -

-
-

- Code -

-
-

- My first program -

-
-

- -

-
#include <iostream>
-
-int main()
-{
-    std::cout << "Hello, World!" << std::endl;
-    return 0;
-}
-
-

-

-
-
-
-
-
- -
[variablelist A Variable List
-    [[term 1] [The definition of term 1]]
-    [[term 2] [The definition of term 2]]
-    [[term 3] [
-    The definition of term 3.
-
-    Definitions may contain paragraphs.
-    ]]
-]
-
-

- will generate: -

-
-

A Variable List

-
-
term 1
-

- The definition of term 1 -

-
term 2
-

- The definition of term 2 -

-
term 3
-
-

- The definition of term 3. -

-

- Definitions may contain paragraphs. -

-
-
-
-

- The rules for variable lists are the same as for tables, except that only - 2 "columns" are allowed. The first column contains the terms, - and the second column contains the definitions. Those familiar with HTML - will recognize this as a "definition list". -

-
-
- -

- You can include one QuickBook file from another. The syntax is simply: -

-
[include someother.qbk]
-
-

- The included file will be processed as if it had been cut and pasted into - the current document, with the following exceptions: -

-
    -
  • - The __FILENAME__ predefined macro will reflect the name of the file currently being - processed. -
  • -
  • - Any macros defined in the included file are scoped to that file. -
  • -
-

- The [include] directive lets you specify a document - id to use for the included file. When this id is not explicitly specified, - the id defaults to the filename ("someother", in the example - above). You can specify the id like this: -

-
[include:someid someother.qbk]
-
-

- All auto-generated anchors will use the document id as a unique prefix. - So for instance, if there is a top section in someother.qbk named "Intro", - the named anchor for that section will be "someid.intro", and - you can link to it with [link someid.intro The Intro]. -

-
-
-

-Import -

-

- When documenting code, you'd surely need to present code from actual source - files. While it is possible to copy some code and paste them in your QuickBook - file, doing so is error prone and the extracted code in the documentation - tends to get out of sync with the actual code as the code evolves. The - problem, as always, is that once documentation is written, the tendency - is for the docs to languish in the archives without maintenance. -

-

- QuickBook's import facility provides a nice solution. -

-
- - Example -
-

- You can effortlessly import code snippets from source code into your QuickBook. - The following illustrates how this is done: -

-
[import ../test/stub.cpp]
-[foo]
-[bar]
-
-

- The first line: -

-
[import ../test/stub.cpp]
-
-

- collects specially marked-up code snippets from stub.cpp - and places them in your QuickBook file as virtual templates. Each of the - specially marked-up code snippets has a name (e.g. foo - and bar in the example - above). This shall be the template identifier for that particular code - snippet. The second and third line above does the actual template expansion: -

-
[foo]
-[bar]
-
-

- And the result is: -

-

-

-

- This is the foo - function. -

-

-

-

- This description can have paragraphs... -

-

-

-
    -
  • - lists -
  • -
  • - etc. -
  • -
-

-

-

- And any quickbook block markup. -

-

-

-

- -

-
std::string foo()
-{
-    // return 'em, foo man!
-    return "foo";
-}
-
-

-

-

-

-

- This is the bar - function -

-

-

-

- -

-
std::string bar()
-{
-    // return 'em, bar man!
-    return "bar";
-}
-

-

-

-

-

- Some trailing text here -

-

-

-
- - Code - Snippet Markup -
-

- Note how the code snippets in stub.cpp - get marked up. We use distinguishable comments following the form: -

-
//[id
-some code here
-//]
-
-

- The first comment line above initiates a named code-snippet. This prefix - will not be visible in quickbook. The entire code-snippet in between //[id and //] - will be inserted as a template in quickbook with name id. - The comment //] ends a code-snippet - This too will not be visible in quickbook. -

-
- - Special - Comments -
-

- Special comments of the form: -

-
//` some [*quickbook] markup here
-
-

- and: -

-
/*` some [*quickbook] markup here */
-
-

- will be parsed by QuickBook. This can contain quickbook blocks - (e.g. sections, paragraphs, tables, etc). In the first case, the initial - slash-slash, tick and white-space shall be ignored. In the second, the - initial slash-star-tick and the final star-slash shall be ignored. -

-

- Special comments of the form: -

-
/*<- this C++ comment will be ignored ->*/
-
-

- or -

-
/*<-*/ "this c++ code  will be ignored" /*->*/
-
-

- or -

-
//<-
-private:
-    int some_member;
-//->
-
-

- can be used to inhibit code from passing through to quickbook. All text - between the delimeters will simply be ignored. -

-
- - Callouts -
-

- Special comments of the form: -

-
/*< some [*quickbook] markup here >*/
-
-

- will be regarded as callouts. These will be collected, numbered and rendered - as a "callout bug" (a small icon with a number). After the whole - snippet is parsed, the callout list is generated. See Callouts - for details. Example: -

-

-

-

- -

-
std::string foo_bar() 1
-{
-    return "foo-bar"; 2
-}
-
-

-

-

-

-

-

-
- - - - - - - - -

1

The Mythical FooBar. See Foobar - for details

2

return 'em, foo-bar man!

-

-

-

-

-

- This is the actual code: -

-
//[ foo_bar
-std::string foo_bar() /*< The /Mythical/ FooBar.
-                      See [@http://en.wikipedia.org/wiki/Foobar Foobar for details] >*/
-{
-    return "foo-bar"; /*< return 'em, foo-bar man! >*/
-}
-//]
-
-

- The callouts bugs are placed exactly where the special callout comment - is situated. It can be anywhere in the code. The bugs can be rather obtrusive, - however. They get in the way of the clarity of the code. Another special - callout comment style is available: -

-
/*<< some [*quickbook] markup here >>*/
-
-

- This is the line-oriented version of the callout. With this, the "bug" - is placed at the very left of the code block, away from the actual code. - By placing it at the far left, the code is rendered un-obscured. Example: -

-

-

-

- -

-
class x
-{
-public:
-
-    1x() : n(0)
-    {
-    }
-
-    2~x()
-    {
-    }
-
-    3int get() const
-    {
-        return n; 
-    }
-
-    4void set(int n_)
-    {
-        n = n_;
-    }
-};
-
-

-

-

-

-

-

-
- - - - - - - - - - - - - - - - -

1

Constructor

2

Destructor

3

Get the n - member variable

4

Set the n - member variable

-

-

-

-

-

- See the actual code here: ../../test/stub.cpp -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/syntax/comments.html b/doc/html/quickbook/syntax/comments.html deleted file mode 100644 index 5a557b9..0000000 --- a/doc/html/quickbook/syntax/comments.html +++ /dev/null @@ -1,53 +0,0 @@ - - - -Comments - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- -

- Can be placed anywhere. -

-
[/ comment (no output generated) ]
-
-
[/ comments can be nested [/ some more here] ]
-
-
[/ Quickbook blocks can nest inside comments. [*Comment this out too!] ]
-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/quickbook/syntax/phrase.html b/doc/html/quickbook/syntax/phrase.html deleted file mode 100644 index a7d2a84..0000000 --- a/doc/html/quickbook/syntax/phrase.html +++ /dev/null @@ -1,866 +0,0 @@ - - - -Phrase Level Elements - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-
-
-PrevUpHomeNext -
-
- - -
- -
['italic], [*bold], [_underline], [^teletype], [-strikethrough]
-
-

- will generate: -

-

- italic, bold, underline, teletype, strikethrough -

-

- Like all non-terminal phrase level elements, this can of course be nested: -

-
[*['bold-italic]]
-
-

- will generate: -

-

- bold-italic -

-
-
- -

- When you want content that may or must be replaced by the user, use the - syntax: -

-
[~replacement]
-
-

- This will generate: -

-

- - replacement - -

-
-
- -
["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein
-
-

- will generate: -

-

- “A question that sometimes drives me hazy: am I or are the others - crazy?”--Einstein -

-

- Note the proper left and right quote marks. Also, while you can simply - use ordinary quote marks like "quoted", our quotation, above, - will generate correct DocBook quotations (e.g. <quote>quoted</quote>). -

-

- Like all phrase elements, quotations may be nested. Example: -

-
["Here's the rule for bargains: ["Do other men, for they would do you.] That's
-the true business precept.]
-
-

- will generate: -

-

- “Here's the rule for bargains: ‘Do other men, for they would - do you.’ That's the true business precept.” -

-
-
- -

- Simple markup for formatting text, common in many applications, is now - supported: -

-
/italic/, *bold*, _underline_, =teletype=
-
-

- will generate: -

-

- italic, bold, underline, teletype -

-

- Unlike QuickBook's standard formatting scheme, the rules for simpler alternatives - are much stricter - [1] - . -

-
    -
  • - Simple markups cannot nest. You can combine a simple markup with a nestable - markup. -
  • -
  • - Simple markups cannot contain any other form of quickbook markup. -
  • -
  • - A non-space character must follow the leading markup -
  • -
  • - A non-space character must precede the trailing markup -
  • -
  • - A space or a punctuation must follow the trailing markup -
  • -
  • - If the matching markup cannot be found within a block, the formatting - will not be applied. This is to ensure that un-matched formatting markups, - which can be a common mistake, does not corrupt anything past a single - block. We do not want the rest of the document to be rendered bold just - because we forgot a trailing '*'. A single block is terminated by two - end of lines or the close bracket: ']'. -
  • -
  • - A line starting with the star will be interpreted as an unordered list. - See Unordered - lists. -
  • -
-
-

Table 1. More Formatting Samples

-
---- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Markup -

-
-

- Result -

-
-

- *Bold* -

-
-

- Bold -

-
-

- *Is bold* -

-
-

- Is bold -

-
-

- * Not bold* *Not bold * * Not bold * -

-
-

- * Not bold* *Not bold * * Not bold * -

-
-

- This*Isn't*Bold (no bold) -

-
-

- This*Isn't*Bold (no bold) -

-
-

- (*Bold Inside*) (parenthesis not bold) -

-
-

- (Bold Inside) (parenthesis not bold) -

-
-

- *(Bold Outside)* (parenthesis bold) -

-
-

- (Bold Outside) (parenthesis bold) -

-
-

- 3*4*5 = 60 (no bold) -

-
-

- 3*4*5 = 60 (no bold) -

-
-

- 3 * 4 * 5 = 60 (no bold) -

-
-

- 3 * 4 * 5 = 60 (no bold) -

-
-

- 3 *4* 5 = 60 (4 is bold) -

-
-

- 3 4 5 = 60 (4 is bold) -

-
-

- *This is bold* this is not *but this is* -

-
-

- This is bold this is not but this is -

-
-

- *This is bold*. -

-
-

- This is bold. -

-
-

- *B*. (bold B) -

-
-

- B. (bold B) -

-
-

- ['*Bold-Italic*] -

-
-

- Bold-Italic -

-
-

- *side-by*/-side/ -

-
-

- side-by-side -

-
-
-

- As mentioned, simple markups cannot go past a single block. The text from - "have" to "full" in the following paragraph will be - rendered as bold: -

-
Baa baa black sheep, *have you any wool?
-Yes sir, yes sir, three bags full!*
-One for the master, one for the dame,
-And one for the little boy who lives down the lane.
-
-

- Baa baa black sheep, have you any wool? Yes sir, - yes sir, three bags full! One for the master, one for the dame, - And one for the little boy who lives down the lane. -

-

- But in the following paragraph, bold is not applied: -

-
Baa baa black sheep, *have you any wool?
-Yes sir, yes sir, three bags full!
-One for the master, one for the dame,
-And one for the little boy who lives down the lane.
-
-

- Baa baa black sheep, *have you any wool? Yes sir, yes sir, three bags full! - One for the master, one for the dame, And one for the little boy who lives - down the lane. -

-
-
- -

- Inlining code in paragraphs is quite common when writing C++ documentation. - We provide a very simple markup for this. For example, this: -

-
This text has inlined code `int main() { return 0; }` in it.
-
-

- will generate: -

-

- This text has inlined code int main() { return 0; } - in it. The code will be syntax highlighted. -

-
- - - - - -
[Note]Note

- We simply enclose the code with the tick: "`", not the - single quote: "'". - Note too that `some code` is preferred over [^some code]. -

-
-
- -

- Preformatted code simply starts with a space or a tab (See Code). - However, such a simple syntax cannot be used as phrase elements in lists - (See Ordered - lists and Unordered - lists), tables (See Tables), - etc. Inline code (see above) can. The problem is, inline code does not - allow formatting with newlines, spaces, and tabs. These are lost. -

-

- We provide a phrase level markup that is a mix between the two. By using - the double-tick, instead of the single-tick, we are telling QuickBook to - use preformatted blocks of code. Example: -

-
``
-    #include <iostream>
-
-    int main()
-    {
-        std::cout << "Hello, World!" << std::endl;
-        return 0;
-    }
-``
-
-

- will generate: -

-

- -

-
#include <iostream>
-
-int main()
-{
-    std::cout << "Hello, World!" << std::endl;
-    return 0;
-}
-
-

-

-
-
- -

- If a document contains more than one type of source code then the source - mode may be changed dynamically as the document is processed. All QuickBook - documents are initially in C++ mode by default, though an alternative initial - value may be set in the Document - section. -

-

- To change the source mode, use the [source-mode] markup, - where source-mode is one of the supported modes. For - example, this: -

-
Python's [python] `import` is rather like C++'s [c++] `#include`. A
-C++ comment `// looks like this` whereas a Python comment [python]
-`# looks like this`.
-
-

- will generate: -

-

- Python's import is rather - like C++'s #include. - A C++ comment // looks like this - whereas a Python comment #looks like this. -

-
-

Table 2. Supported Source Modes

-
---- - - - - - - - - - - - - - - -
-

- Mode -

-
-

- Source Mode Markup -

-
-

- C++ -

-
-

- [c++] -

-
-

- Python -

-
-

- [python] -

-
-
-
- - - - - -
[Note]Note

- The source mode strings are lowercase. -

-
-
- -
[br]
-
-
- - - - - -
[Warning]Warning

- [br] is now deprecated. Blurbs, - Admonitions - and table cells (see Tables) - may now contain paragraphs. -

-
-
- -
[#named_anchor]
-
-

- A named anchor is a hook that can be referenced by a link elsewhere in - the document. You can then reference an anchor with [link named_anchor -Some link text]. - See Anchor links, - Section and Heading. -

-
-
-

-Links -

-
[@http://www.boost.org this is [*boost's] website....]
-
-

- will generate: -

-

- this is boost's - website.... -

-

- URL links where the link text is the link itself is common. Example: -

-
see http://spirit.sourceforge.net/
-
-

- so, when the text is absent in a link markup, the URL is assumed. Example: -

-
see [@http://spirit.sourceforge.net/]
-
-

- will generate: -

-

- see http://spirit.sourceforge.net/ -

-
-
- -

- You can link within a document using: -

-
[link section_id.normalized_header_text The link text]
-
-

- See sections Section - and Heading for - more info. -

-
-
- -

- In addition, you can link internally to an XML refentry like: -

-
[link xml.refentry The link text]
-
-

- This gets converted into <link linkend="xml.refentry">The - link text</link>. -

-

- Like URLs, the link text is optional. If this is not present, the link - text will automatically be the refentry. Example: -

-
[link xml.refentry]
-
-

- This gets converted into <link linkend="xml.refentry">xml.refentry</link>. -

-
-
- -

- If you want to link to a function, class, member, enum, concept, global, - or header in the reference section, you can use: -

-
[funcref fully::qualified::function_name The link text]
-[classref fully::qualified::class_name The link text]
-[memberref fully::qualified::member_name The link text]
-[enumref fully::qualified::enum_name The link text]
-[macroref MACRO_NAME The link text]
-[conceptref ConceptName The link text]
-[headerref path/to/header.hpp The link text]
-[globalref fully::qualified::global The link text]
-
-

- Again, the link text is optional. If this is not present, the link text - will automatically be the function, class, member, enum, macro, concept, - global, or header name. Example: -

-
[classref boost::bar::baz]
-
-

- would have "boost::bar::baz" as the link text. -

-
-
-

-Escape -

-

- The escape mark-up is used when we don't want to do any processing. -

-
'''
-escape (no processing/formatting)
-'''
-
-

- Escaping allows us to pass XML markup to BoostBook - or DocBook. For example: -

-
'''
-<emphasis role="bold">This is direct XML markup</emphasis>
-'''
-
-

- This is direct XML markup -

-
- - - - - -
[Important]Important

- Be careful when using the escape. The text must conform to BoostBook/DocBook syntax. -

-
-
- -

- The backslash may be used to escape a single punctuation character. The - punctuation immediately after the backslash is passed without any processing. - This is useful when we need to escape QuickBook punctuations such as [ and ]. - For example, how do you escape the triple quote? Simple: \'\'\' -

-

- \n - has a special meaning. It is used to generate line breaks. -

-
- - - - - -
[Warning]Warning

- \n - and [br] are now deprecated. Blurbs, - Admonitions - and table cells (see Tables) - may now contain paragraphs. -

-

- The escaped space: \ also - has a special meaning. The escaped space is removed from the output. -

-
-
-

-Images -

-
[$image.jpg]
-
-
-
- - -

- As of version 1.3, QuickBook supports footnotes. Just put the text of the - footnote in a [footnote] block, and the text will be put at the - bottom of the current page. For example, this: -

-
[footnote A sample footnote]
-
-

- will generate this - [2] - . -

-
- -
__a_macro_identifier__
-
-

- See Macros for details. -

-
-
- -
[a_template_identifier]
-
-

- See Templates - for details. -

-
-
-
- -

- Like C++ #ifdef, you can generate - phrases depending on the presence of a macro. Example: -

-
[? __to_be__ To be or not to be]
-
-

-

-

- Here, the phrase "To be or not to be" will only be generated - if the macro symbol __to_be__ has been previously defined. The phrase above will - not do anything since we haven't defined __to_be__. Now, let's define the symbol: -

-
[def __to_be__]
-
-

- And try again: -

-

- To be or not to be -

-

- Yes! - [3] -

-
-
-

-

[1] - Thanks to David Barrett, author of Qwiki, - for sharing these samples and teaching me these obscure formatting - rules. I wasn't sure at all if Spirit, - being more or less a formal EBNF parser, can handle the context sensitivity - and ambiguity. -

-

[2] - A sample footnote -

-

[3] - Conditional Generation makes quickbook turing complete. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 67857f7..6fffa65 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -84,7 +84,7 @@ sample application using __spirit__. What is it? What you are viewing now, this documentation, is autogenerated by QuickBook. These files were generated from one master: -[:[@../quickbook.qbk quickbook.qbk]] +[:[@../../tools/quickbook/doc/quickbook.qbk quickbook.qbk]] Originally named QuickDoc, this funky tool that never dies, evolved into a funkier tool thanks to Eric Niebler who resurrected the project making it @@ -1661,7 +1661,8 @@ The first line: [import ../test/stub.cpp] '''] -collects specially marked-up code snippets from [@../../test/stub.cpp stub.cpp] +collects specially marked-up code snippets from +[@../../tools/quickbook/test/stub.cpp stub.cpp] and places them in your QuickBook file as virtual templates. Each of the specially marked-up code snippets has a name (e.g. `foo` and `bar` in the example above). This shall be the template identifier for that particular code @@ -1680,8 +1681,8 @@ And the result is: [heading Code Snippet Markup] -Note how the code snippets in [@../../test/stub.cpp stub.cpp] get marked up. We -use distinguishable comments following the form: +Note how the code snippets in [@../../tools/quickbook/test/stub.cpp stub.cpp] +get marked up. We use distinguishable comments following the form: //[id some code here @@ -1763,7 +1764,7 @@ Example: [class_] -See the actual code here: [@../../test/stub.cpp] +See the actual code here: [@../../tools/quickbook/test/stub.cpp] [endsect] diff --git a/extra/katepart/katepart.qbk b/extra/katepart/katepart.qbk index 2e07efc..5af40af 100644 --- a/extra/katepart/katepart.qbk +++ b/extra/katepart/katepart.qbk @@ -18,10 +18,10 @@ constructs of Quickbook 1.4 including tables, list, templates and macros. [variablelist [[.qbk loaded in a text editor][ -[$images/extra/katepart/table.text.editor.png] +[$../../tools/quickbook/doc/html/images/extra/katepart/table.text.editor.png] ]] [[.qbk loaded with boost::hs support][ -[$images/extra/katepart/table.boost.hs.png] +[$../../tools/quickbook/doc/html/images/extra/katepart/table.boost.hs.png] ]] ] @@ -93,7 +93,7 @@ proposed sintaxis. ]] [heading About boost::hs] -[$images/extra/katepart/boost.hs.logo.png] +[$../../tools/quickbook/doc/html/images/extra/katepart/boost.hs.logo.png] boost::hs::quickbook is a component of boost::hs, a syntax highlighting for C++, doxygen, Boost.Build jamfiles and QuickBook. From a9f6e3fec8d4bcefc69156be169ab1a486fe977a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 10 Oct 2008 09:29:21 +0000 Subject: [PATCH 18/94] Merge quickbook workaround and fix some links. Merged revisions 48987,49230-49231 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r48987 | danieljames | 2008-09-28 13:21:39 +0100 (Sun, 28 Sep 2008) | 1 line Clean up some link errors. ........ r49230 | danieljames | 2008-10-09 23:13:48 +0100 (Thu, 09 Oct 2008) | 1 line position_iterator is meant to be a forward iterator, so avoid using operator+ with it. ........ r49231 | danieljames | 2008-10-09 23:14:14 +0100 (Thu, 09 Oct 2008) | 4 lines Work around the problems with window newlines in position_iterator. (I'm about to fix them, but this will get quickbook working immediately). Fixes #2155 ........ [SVN r49242] --- detail/template_stack.hpp | 3 ++- detail/utils.cpp | 21 ++++++++++++++++++++- index.html | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) mode change 100755 => 100644 index.html diff --git a/detail/template_stack.hpp b/detail/template_stack.hpp index ecf2d9b..3f9db1e 100644 --- a/detail/template_stack.hpp +++ b/detail/template_stack.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace quickbook { @@ -63,7 +64,7 @@ namespace quickbook scan.first = f; } if (len >= 0) - scan.first = f+len; + scan.first = boost::next(f, len); return len; } diff --git a/detail/utils.cpp b/detail/utils.cpp index 093a10a..9736a0f 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -181,6 +181,25 @@ namespace quickbook { namespace detail } } + // Copy a string, converting mac and windows style newlines to unix + // newlines. + + template + void normalize_newlines(InputIterator begin, InputIterator end, + OutputIterator out) + { + while(begin != end) { + if(*begin == '\r') { + *out++ = '\n'; + ++begin; + if(begin != end && *begin == '\n') ++begin; + } + else { + *out++ = *begin++; + } + } + } + int load(std::string const& filename, std::string& storage) { using std::cerr; @@ -200,7 +219,7 @@ namespace quickbook { namespace detail // Turn off white space skipping on the stream in.unsetf(ios::skipws); - std::copy( + normalize_newlines( istream_iterator(in), istream_iterator(), std::back_inserter(storage)); diff --git a/index.html b/index.html old mode 100755 new mode 100644 index b6ce29b..1258a7f --- a/index.html +++ b/index.html @@ -1,10 +1,10 @@ - + Automatic redirection failed, click this - link + link From daf37f8a3e8f36d003e889c7d775a74ab842e687 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 18 Oct 2008 09:42:19 +0000 Subject: [PATCH 19/94] Rollback the quickbook workaround for windows newlines in case it is the cause of the recent problems with the release documentation build. Rolled back revisions 49230-49231 via svnmerge from https://svn.boost.org/svn/boost/trunk [SVN r49377] --- detail/template_stack.hpp | 3 +-- detail/utils.cpp | 21 +-------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/detail/template_stack.hpp b/detail/template_stack.hpp index 3f9db1e..ecf2d9b 100644 --- a/detail/template_stack.hpp +++ b/detail/template_stack.hpp @@ -17,7 +17,6 @@ #include #include #include -#include namespace quickbook { @@ -64,7 +63,7 @@ namespace quickbook scan.first = f; } if (len >= 0) - scan.first = boost::next(f, len); + scan.first = f+len; return len; } diff --git a/detail/utils.cpp b/detail/utils.cpp index 9736a0f..093a10a 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -181,25 +181,6 @@ namespace quickbook { namespace detail } } - // Copy a string, converting mac and windows style newlines to unix - // newlines. - - template - void normalize_newlines(InputIterator begin, InputIterator end, - OutputIterator out) - { - while(begin != end) { - if(*begin == '\r') { - *out++ = '\n'; - ++begin; - if(begin != end && *begin == '\n') ++begin; - } - else { - *out++ = *begin++; - } - } - } - int load(std::string const& filename, std::string& storage) { using std::cerr; @@ -219,7 +200,7 @@ namespace quickbook { namespace detail // Turn off white space skipping on the stream in.unsetf(ios::skipws); - normalize_newlines( + std::copy( istream_iterator(in), istream_iterator(), std::back_inserter(storage)); From cb639fb17d45cdc4b9ef14808b8f0b18d164c655 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 18 Oct 2008 12:49:17 +0000 Subject: [PATCH 20/94] Merged revisions 49230 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r49230 | danieljames | 2008-10-09 23:13:48 +0100 (Thu, 09 Oct 2008) | 1 line position_iterator is meant to be a forward iterator, so avoid using operator+ with it. ........ [SVN r49379] --- detail/template_stack.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/detail/template_stack.hpp b/detail/template_stack.hpp index ecf2d9b..3f9db1e 100644 --- a/detail/template_stack.hpp +++ b/detail/template_stack.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace quickbook { @@ -63,7 +64,7 @@ namespace quickbook scan.first = f; } if (len >= 0) - scan.first = f+len; + scan.first = boost::next(f, len); return len; } From 08062df544c0fa53fe506d388f1cafb97265e9b7 Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 24 Jan 2009 18:57:20 +0000 Subject: [PATCH 21/94] merge of cmake build files from trunk per beman [SVN r50756] --- CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5a79d2b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +boost_tool_project(Quickbook + DESCRIPTION "A WikiWiki style documentation tool geared towards C++ documentation" + AUTHORS "Joel de Guzman " + "Eric Niebler ") + +if (BUILD_QUICKBOOK) + if (MSVC) + add_definitions(/wd4511 /wd4512 /wd4701 /wd4702 /wd4244 /wd4267 /wd4800) + endif (MSVC) + + boost_add_executable(quickbook + detail/quickbook.cpp + detail/actions.cpp + detail/actions_class.cpp + detail/utils.cpp + detail/post_process.cpp + detail/collector.cpp + detail/template_stack.cpp + DEPENDS boost_program_options boost_filesystem + ) +endif (BUILD_QUICKBOOK) \ No newline at end of file From 07ff92c6196cb267b77f529cef88e7c943be5635 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 17 Feb 2009 00:01:03 +0000 Subject: [PATCH 22/94] Merge several changes to boostbook and quickbook. Fixes #1399 Merged revisions 49231,49459,49988,50068,50084,50091,50109,50125,50142,50159,50163,50175,50193,50207,50210-50213,50215,50222,50246,50513 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r49231 | danieljames | 2008-10-09 23:14:14 +0100 (Thu, 09 Oct 2008) | 4 lines Work around the problems with window newlines in position_iterator. (I'm about to fix them, but this will get quickbook working immediately). ........ r49459 | eric_niebler | 2008-10-26 20:24:59 +0000 (Sun, 26 Oct 2008) | 1 line give data members with in synopses the same treatment as functions and typedefs ........ r49988 | danieljames | 2008-11-28 15:05:21 +0000 (Fri, 28 Nov 2008) | 1 line When processing template arguments, deal with the case when there's no content after the last space or there are more arguments than expected. ........ r50068 | johnmaddock | 2008-12-02 13:13:57 +0000 (Tue, 02 Dec 2008) | 1 line Fix Jamfile by adding on to test requirements. ........ r50084 | johnmaddock | 2008-12-03 09:42:52 +0000 (Wed, 03 Dec 2008) | 1 line Added quickbook-fail-test rule and two tests that make use of it: note that these currently fail. ........ r50091 | danieljames | 2008-12-03 19:14:42 +0000 (Wed, 03 Dec 2008) | 2 lines Keep a count of errors in quickbook, and return an error code when appropriate. ........ r50109 | johnmaddock | 2008-12-04 10:14:19 +0000 (Thu, 04 Dec 2008) | 1 line Added dependency to the test file. ........ r50125 | djowel | 2008-12-05 02:13:59 +0000 (Fri, 05 Dec 2008) | 1 line updated to use "classic" spirit includes and namespace ........ r50142 | danieljames | 2008-12-05 19:03:19 +0000 (Fri, 05 Dec 2008) | 1 line Defined BOOST_CYGWIN_PATH when building quickbook on cygwin. ........ r50159 | danieljames | 2008-12-06 14:07:35 +0000 (Sat, 06 Dec 2008) | 1 line Copy boostbook.dtd into the correct position for the 1.1 uri. I'm not sure what should be done with the existing location. ........ r50163 | danieljames | 2008-12-06 19:22:32 +0000 (Sat, 06 Dec 2008) | 1 line Revert my change to the quickbook jamfile, it isn't adequately tested. ........ r50175 | danieljames | 2008-12-07 12:37:07 +0000 (Sun, 07 Dec 2008) | 1 line Fix processing of unmatched escape characters in code - and issue a warning for unexpected characters. ........ r50193 | danieljames | 2008-12-08 16:17:13 +0000 (Mon, 08 Dec 2008) | 1 line Use new include paths for classic spirit in quickbook text_diff utility. ........ r50207 | danieljames | 2008-12-08 21:51:56 +0000 (Mon, 08 Dec 2008) | 1 line Fail on a mismatched '' in the python and c++ syntax highlighters. And then ignore the rest of the code block to avoid further errors and warnings. ........ r50210 | danieljames | 2008-12-08 23:14:23 +0000 (Mon, 08 Dec 2008) | 1 line Hard fail on quickbook post process errors. ........ r50211 | danieljames | 2008-12-08 23:20:26 +0000 (Mon, 08 Dec 2008) | 1 line Since I accidently added a quickbook fail tests to the Jamfile in the last checkin, I might as well add them. ........ r50212 | danieljames | 2008-12-08 23:35:08 +0000 (Mon, 08 Dec 2008) | 1 line Remove an unused variable in order to avoid a gcc warning. ........ r50213 | danieljames | 2008-12-08 23:35:20 +0000 (Mon, 08 Dec 2008) | 1 line Run the docbook chunker quietly, unless boostbook.verbose is set. ........ r50215 | danieljames | 2008-12-08 23:38:29 +0000 (Mon, 08 Dec 2008) | 1 line Put the markup strings in their own cpp file to avoid gcc warnings. ........ r50222 | danieljames | 2008-12-09 13:52:07 +0000 (Tue, 09 Dec 2008) | 1 line Fix some xsl type errors. ........ r50246 | speedsnail | 2008-12-12 15:06:44 +0000 (Fri, 12 Dec 2008) | 1 line Make doxygen command "\throw" work with boostbook. ........ r50513 | danieljames | 2009-01-08 12:01:50 +0000 (Thu, 08 Jan 2009) | 1 line Support both windows and cygwin paths in cygwin quickbook. ........ [SVN r51281] --- Jamfile.v2 | 2 + block.hpp | 14 +- code_snippet.hpp | 4 +- detail/actions.cpp | 67 ++++--- detail/actions.hpp | 24 ++- detail/actions_class.cpp | 7 +- detail/actions_class.hpp | 3 +- detail/input_path.cpp | 42 +++++ detail/input_path.hpp | 39 ++++ detail/markups.cpp | 101 +++++++++++ detail/markups.hpp | 176 +++++++++---------- detail/post_process.cpp | 9 +- detail/post_process.hpp | 2 +- detail/quickbook.cpp | 34 ++-- detail/template_stack.cpp | 6 +- detail/template_stack.hpp | 26 +-- detail/utils.cpp | 23 ++- doc_info.hpp | 10 +- phrase.hpp | 12 +- syntax_highlight.hpp | 61 ++++--- test/Jamfile.v2 | 14 +- test/fail-cpp-mismatched-escape.quickbook | 5 + test/fail-import.quickbook | 11 ++ test/fail-include.quickbook | 11 ++ test/fail-parse-error1.quickbook | 3 + test/fail-parse-error2.quickbook | 5 + test/fail-post-process.quickbook | 3 + test/fail-python-mismatched-escape.quickbook | 5 + test/fail-template-arguments1.quickbook | 13 ++ test/fail-template-arguments2.quickbook | 13 ++ test/quickbook-testing.jam | 25 +++ test/src/text_diff.cpp | 6 +- 32 files changed, 578 insertions(+), 198 deletions(-) mode change 100755 => 100644 Jamfile.v2 mode change 100755 => 100644 detail/actions.hpp create mode 100644 detail/input_path.cpp create mode 100644 detail/input_path.hpp create mode 100644 detail/markups.cpp mode change 100755 => 100644 detail/quickbook.cpp mode change 100755 => 100644 doc_info.hpp mode change 100755 => 100644 syntax_highlight.hpp create mode 100644 test/fail-cpp-mismatched-escape.quickbook create mode 100644 test/fail-import.quickbook create mode 100644 test/fail-include.quickbook create mode 100644 test/fail-parse-error1.quickbook create mode 100644 test/fail-parse-error2.quickbook create mode 100644 test/fail-post-process.quickbook create mode 100644 test/fail-python-mismatched-escape.quickbook create mode 100644 test/fail-template-arguments1.quickbook create mode 100644 test/fail-template-arguments2.quickbook diff --git a/Jamfile.v2 b/Jamfile.v2 old mode 100755 new mode 100644 index ccf923e..a957c5b --- a/Jamfile.v2 +++ b/Jamfile.v2 @@ -14,9 +14,11 @@ exe quickbook detail/actions.cpp detail/actions_class.cpp detail/utils.cpp + detail/input_path.cpp detail/post_process.cpp detail/collector.cpp detail/template_stack.cpp + detail/markups.cpp /boost//program_options /boost//filesystem : #QUICKBOOK_NO_DATES diff --git a/block.hpp b/block.hpp index aba5489..2ea6711 100644 --- a/block.hpp +++ b/block.hpp @@ -12,16 +12,16 @@ #include "./detail/utils.hpp" #include "./phrase.hpp" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace quickbook { - using namespace boost::spirit; + using namespace boost::spirit::classic; template struct block_grammar : grammar > diff --git a/code_snippet.hpp b/code_snippet.hpp index f6f2911..5f2c3b4 100644 --- a/code_snippet.hpp +++ b/code_snippet.hpp @@ -9,8 +9,8 @@ #if !defined(BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_HPP) #define BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_HPP -#include -#include +#include +#include #include "./detail/template_stack.hpp" namespace quickbook diff --git a/detail/actions.cpp b/detail/actions.cpp index ffe59ca..dc230ee 100644 --- a/detail/actions.cpp +++ b/detail/actions.cpp @@ -27,7 +27,7 @@ namespace quickbook // Handles line-breaks (DEPRECATED!!!) void break_action::operator()(iterator first, iterator) const { - boost::spirit::file_position const pos = first.get_position(); + boost::spirit::classic::file_position const pos = first.get_position(); detail::outwarn(pos.file,pos.line) << "in column:" << pos.column << ", " << "[br] and \\n are deprecated" << ".\n"; phrase << break_mark; @@ -35,9 +35,10 @@ namespace quickbook void error_action::operator()(iterator first, iterator /*last*/) const { - boost::spirit::file_position const pos = first.get_position(); + boost::spirit::classic::file_position const pos = first.get_position(); detail::outerr(pos.file,pos.line) << "Syntax Error near column " << pos.column << ".\n"; + ++error_count; } void phrase_action::operator()(iterator first, iterator last) const @@ -224,11 +225,12 @@ namespace quickbook if (mark != list_marks.top().first) // new_indent == list_indent { - boost::spirit::file_position const pos = first.get_position(); + boost::spirit::classic::file_position const pos = first.get_position(); detail::outerr(pos.file,pos.line) << "Illegal change of list style near column " << pos.column << ".\n"; detail::outwarn(pos.file,pos.line) << "Ignoring change of list style" << std::endl; + ++error_count; } } @@ -240,8 +242,15 @@ namespace quickbook out << ""; } - void unexpected_char::operator()(char) const + void unexpected_char::operator()(iterator first, iterator last) const { + boost::spirit::classic::file_position const pos = first.get_position(); + + detail::outwarn(pos.file, pos.line) + << "in column:" << pos.column + << ", unexpected character: " << std::string(first, last) + << "\n"; + out << '#'; // print out an unexpected character } @@ -481,9 +490,10 @@ namespace quickbook BOOST_ASSERT(actions.template_info.size()); if (actions.templates.find_top_scope(actions.template_info[0])) { - boost::spirit::file_position const pos = first.get_position(); + boost::spirit::classic::file_position const pos = first.get_position(); detail::outerr(pos.file,pos.line) << "Template Redefinition: " << actions.template_info[0] << std::endl; + ++actions.error_count; } actions.template_info.push_back(std::string(first, last)); @@ -498,12 +508,12 @@ namespace quickbook bool break_arguments( std::vector& template_info , std::vector const& template_ - , boost::spirit::file_position const& pos + , boost::spirit::classic::file_position const& pos ) { if (template_.size()-1 != template_info.size()) { - while (template_.size()-1 != template_info.size()) + while (template_.size()-1 > template_info.size()) { // Try to break the last argument at the first space found // and push it into the back of template_info. Do this @@ -516,6 +526,8 @@ namespace quickbook break; std::string first(str.begin(), str.begin()+l_pos); std::string::size_type r_pos = str.find_first_not_of(" \t\r\n", l_pos); + if (r_pos == std::string::npos) + break; std::string second(str.begin()+r_pos, str.end()); str = first; template_info.push_back(second); @@ -540,7 +552,7 @@ namespace quickbook get_arguments( std::vector& template_info , std::vector const& template_ - , boost::spirit::file_position const& pos + , boost::spirit::classic::file_position const& pos , quickbook::actions& actions ) { @@ -555,10 +567,11 @@ namespace quickbook tinfo.push_back(*arg); template_symbol template_(tinfo, pos); - if (template_symbol* p = actions.templates.find_top_scope(*tpl)) + if (actions.templates.find_top_scope(*tpl)) { detail::outerr(pos.file,pos.line) << "Duplicate Symbol Found" << std::endl; + ++actions.error_count; return std::make_pair(false, tpl); } else @@ -573,7 +586,7 @@ namespace quickbook bool parse_template( std::string& body , std::string& result - , boost::spirit::file_position const& template_pos + , boost::spirit::classic::file_position const& template_pos , quickbook::actions& actions ) { @@ -604,7 +617,7 @@ namespace quickbook iterator first(body.begin(), body.end(), actions.filename.native_file_string().c_str()); first.set_position(template_pos); iterator last(body.end(), body.end()); - r = boost::spirit::parse(first, last, phrase_p).full; + r = boost::spirit::classic::parse(first, last, phrase_p).full; actions.phrase.swap(result); } else @@ -619,7 +632,7 @@ namespace quickbook iterator first(iter, body.end(), actions.filename.native_file_string().c_str()); first.set_position(template_pos); iterator last(body.end(), body.end()); - r = boost::spirit::parse(first, last, block_p).full; + r = boost::spirit::classic::parse(first, last, block_p).full; actions.out.swap(result); } return r; @@ -628,13 +641,14 @@ namespace quickbook void do_template_action::operator()(iterator first, iterator) const { - boost::spirit::file_position const pos = first.get_position(); + boost::spirit::classic::file_position const pos = first.get_position(); ++actions.template_depth; if (actions.template_depth > actions.max_template_depth) { detail::outerr(pos.file,pos.line) << "Infinite loop detected" << std::endl; --actions.template_depth; + ++actions.error_count; return; } @@ -646,7 +660,7 @@ namespace quickbook BOOST_ASSERT(symbol); std::vector template_ = boost::get<0>(*symbol); - boost::spirit::file_position template_pos = boost::get<1>(*symbol); + boost::spirit::classic::file_position template_pos = boost::get<1>(*symbol); std::vector template_info; std::swap(template_info, actions.template_info); @@ -657,6 +671,7 @@ namespace quickbook { actions.pop(); // restore the actions' states --actions.template_depth; + ++actions.error_count; return; } @@ -682,7 +697,7 @@ namespace quickbook if (!parse_template(body, result, template_pos, actions)) { - boost::spirit::file_position const pos = first.get_position(); + boost::spirit::classic::file_position const pos = first.get_position(); detail::outerr(pos.file,pos.line) << "Expanding template:" << template_info[0] << std::endl << "------------------begin------------------" << std::endl @@ -691,6 +706,7 @@ namespace quickbook << std::endl; actions.pop(); // restore the actions' states --actions.template_depth; + ++actions.error_count; return; } } @@ -885,9 +901,11 @@ namespace quickbook --section_level; if (section_level < 0) { - boost::spirit::file_position const pos = first.get_position(); + boost::spirit::classic::file_position const pos = first.get_position(); detail::outerr(pos.file,pos.line) << "Mismatched [endsect] near column " << pos.column << ".\n"; + ++error_count; + // $$$ TODO: somehow fail parse else BOOST_ASSERT(std::string::npos != n) // $$$ below will assert. } @@ -1040,7 +1058,7 @@ namespace quickbook id.clear(); } - void load_snippets( + int load_snippets( std::string const& file , std::vector& storage // snippets are stored in a // vector of template_symbols @@ -1050,14 +1068,17 @@ namespace quickbook std::string code; int err = detail::load(file, code); if (err != 0) - return; // return early on error + return err; // return early on error typedef position_iterator iterator_type; iterator_type first(code.begin(), code.end(), file); iterator_type last(code.end(), code.end()); cpp_code_snippet_grammar g(storage, doc_id); - boost::spirit::parse(first, last, g); + // TODO: Should I check that parse succeeded? + boost::spirit::classic::parse(first, last, g); + + return 0; } namespace @@ -1096,16 +1117,18 @@ namespace quickbook fs::path path = include_search(actions.filename.branch_path(), std::string(first,last)); std::string ext = fs::extension(path); std::vector storage; - load_snippets(path.string(), storage, ext, actions.doc_id); + actions.error_count += + load_snippets(path.string(), storage, ext, actions.doc_id); BOOST_FOREACH(template_symbol const& ts, storage) { std::string tname = boost::get<0>(ts)[0]; if (actions.templates.find_top_scope(tname)) { - boost::spirit::file_position const pos = boost::get<1>(ts); + boost::spirit::classic::file_position const pos = boost::get<1>(ts); detail::outerr(pos.file, pos.line) << "Template Redefinition: " << tname << std::endl; + ++actions.error_count; } else { @@ -1142,7 +1165,7 @@ namespace quickbook } // update the __FILENAME__ macro - *boost::spirit::find(actions.macro, "__FILENAME__") = actions.filename.native_file_string(); + *boost::spirit::classic::find(actions.macro, "__FILENAME__") = actions.filename.native_file_string(); // parse the file quickbook::parse(actions.filename.native_file_string().c_str(), actions, true); diff --git a/detail/actions.hpp b/detail/actions.hpp old mode 100755 new mode 100644 index 036f137..b0f9f8d --- a/detail/actions.hpp +++ b/detail/actions.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -54,7 +54,13 @@ namespace quickbook { // Prints an error message to std::cerr + error_action( + int& error_count) + : error_count(error_count) {} + void operator()(iterator first, iterator /*last*/) const; + + int& error_count; }; struct phrase_action @@ -230,16 +236,19 @@ namespace quickbook list_format_action( collector& out , int& list_indent - , std::stack& list_marks) + , std::stack& list_marks + , int& error_count) : out(out) , list_indent(list_indent) - , list_marks(list_marks) {} + , list_marks(list_marks) + , error_count(error_count) {} void operator()(iterator first, iterator last) const; collector& out; int& list_indent; std::stack& list_marks; + int& error_count; }; struct span @@ -262,7 +271,7 @@ namespace quickbook unexpected_char(collector& out) : out(out) {} - void operator()(char) const; + void operator()(iterator first, iterator last) const; collector& out; }; @@ -671,16 +680,19 @@ namespace quickbook end_section_action( collector& out , int& section_level - , std::string& qualified_section_id) + , std::string& qualified_section_id + , int& error_count) : out(out) , section_level(section_level) - , qualified_section_id(qualified_section_id) {} + , qualified_section_id(qualified_section_id) + , error_count(error_count) {} void operator()(iterator first, iterator last) const; collector& out; int& section_level; std::string& qualified_section_id; + int& error_count; }; struct xinclude_action diff --git a/detail/actions_class.cpp b/detail/actions_class.cpp index d5f6bf2..7abeac5 100644 --- a/detail/actions_class.cpp +++ b/detail/actions_class.cpp @@ -62,9 +62,10 @@ namespace quickbook , template_depth(0) , template_escape(false) , templates() + , error_count(0) // actions - , error() + , error(error_count) , extract_doc_license(doc_license, phrase) , extract_doc_purpose(doc_purpose, phrase) @@ -96,7 +97,7 @@ namespace quickbook , cond_phrase_post(phrase, conditions, macro) , list(out, list_buffer, list_indent, list_marks) - , list_format(list_buffer, list_indent, list_marks) + , list_format(list_buffer, list_indent, list_marks, error_count) , list_item(list_buffer, phrase, list_item_pre, list_item_post) , funcref_pre(phrase, funcref_pre_) @@ -165,7 +166,7 @@ namespace quickbook , anchor(out) , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id) - , end_section(out, section_level, qualified_section_id) + , end_section(out, section_level, qualified_section_id, error_count) , xinclude(out, *this) , include(*this) , import(out, *this) diff --git a/detail/actions_class.hpp b/detail/actions_class.hpp index 332d581..b0170fe 100644 --- a/detail/actions_class.hpp +++ b/detail/actions_class.hpp @@ -15,7 +15,7 @@ namespace quickbook { - using namespace boost::spirit; + using namespace boost::spirit::classic; namespace fs = boost::filesystem; struct actions @@ -90,6 +90,7 @@ namespace quickbook int template_depth; bool template_escape; template_stack templates; + int error_count; // push/pop the states and the streams void push(); diff --git a/detail/input_path.cpp b/detail/input_path.cpp new file mode 100644 index 0000000..076c7b8 --- /dev/null +++ b/detail/input_path.cpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2009 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include +#include "./input_path.hpp" + +#if defined(__cygwin__) || defined(__CYGWIN__) +#include +#include +#include +#endif + + +namespace quickbook { namespace detail +{ + void validate(boost::any& v, + const std::vector& values, + input_path*, int) + { + std::string path + = boost::program_options::validators::get_single_string(values); + +#if !(defined(__cygwin__) || defined(__CYGWIN__)) + v = input_path(path); +#elif defined(BOOST_WINDOWS_PATH) + char result[MAX_PATH + 1]; + cygwin_conv_to_win32_path(path.c_str(), result); + v = input_path(result); +#elif defined(BOOST_POSIX_PATH) + char result[MAX_PATH + 1]; + cygwin_conv_to_posix_path(path.c_str(), result); + v = input_path(result); +#else +# error "Bosot filesystem path type doesn't seem to be set." +#endif + } +}} \ No newline at end of file diff --git a/detail/input_path.hpp b/detail/input_path.hpp new file mode 100644 index 0000000..91badca --- /dev/null +++ b/detail/input_path.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2009 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#if !defined(BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP) +#define BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP + +#include +#include +#include + +namespace quickbook { namespace detail +{ + // Use this class with Boost.Program Options to convert paths to the format + // the Boost.Filesystem expects. This is needed on cygwin to convert cygwin + // paths to windows paths (or vice versa, depending on how filesystem is set + // up). + // + // Note that we don't want to convert paths in quickbook files, as they + // should be platform independent, and aren't necessarily relative to the + // current directory. + + class input_path { + std::string path_; + public: + explicit input_path(char const* c) : path_(c) {} + explicit input_path(std::string const& c) : path_(c) {} + operator std::string() const { return path_; } + + friend void validate(boost::any&, const std::vector&, + input_path*, int); + }; +}} + +#endif diff --git a/detail/markups.cpp b/detail/markups.cpp new file mode 100644 index 0000000..7ed6bfb --- /dev/null +++ b/detail/markups.cpp @@ -0,0 +1,101 @@ +/*============================================================================= + Copyright (c) 2002 2004 2006 Joel de Guzman + Copyright (c) 2004 Eric Niebler + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include "./markups.hpp" + +namespace quickbook +{ + const char* comment_pre = ""; + const char* paragraph_pre = "\n"; + const char* paragraph_post = "\n"; + const char* h1_pre = ""; + const char* h1_post = ""; + const char* h2_pre = ""; + const char* h2_post = ""; + const char* h3_pre = ""; + const char* h3_post = ""; + const char* h4_pre = ""; + const char* h4_post = ""; + const char* h5_pre = ""; + const char* h5_post = ""; + const char* h6_pre = ""; + const char* h6_post = ""; + const char* hr_ = ""; + const char* blurb_pre = "\n"; + const char* blurb_post = "\n"; + const char* blockquote_pre = "
"; + const char* blockquote_post = "
"; + const char* preformatted_pre = ""; + const char* preformatted_post = ""; + const char* warning_pre = ""; + const char* warning_post = ""; + const char* caution_pre = ""; + const char* caution_post = ""; + const char* important_pre = ""; + const char* important_post = ""; + const char* note_pre = ""; + const char* note_post = ""; + const char* tip_pre = ""; + const char* tip_post = ""; + const char* list_item_pre = "\n"; + const char* list_item_post = "\n"; + const char* bold_pre_ = ""; + const char* bold_post_ = ""; + const char* italic_pre_ = ""; + const char* italic_post_ = ""; + const char* underline_pre_ = ""; + const char* underline_post_ = ""; + const char* teletype_pre_ = ""; + const char* teletype_post_ = ""; + const char* strikethrough_pre_ = ""; + const char* strikethrough_post_ = ""; + const char* quote_pre_ = ""; + const char* quote_post_ = ""; + const char* break_mark = "\n"; + const char* url_pre_ = ""; - const char* h1_post = ""; - const char* h2_pre = ""; - const char* h2_post = ""; - const char* h3_pre = ""; - const char* h3_post = ""; - const char* h4_pre = ""; - const char* h4_post = ""; - const char* h5_pre = ""; - const char* h5_post = ""; - const char* h6_pre = ""; - const char* h6_post = ""; - const char* hr_ = ""; - const char* blurb_pre = "\n"; - const char* blurb_post = "\n"; - const char* blockquote_pre = "
"; - const char* blockquote_post = "
"; - const char* preformatted_pre = ""; - const char* preformatted_post = ""; - const char* warning_pre = ""; - const char* warning_post = ""; - const char* caution_pre = ""; - const char* caution_post = ""; - const char* important_pre = ""; - const char* important_post = ""; - const char* note_pre = ""; - const char* note_post = ""; - const char* tip_pre = ""; - const char* tip_post = ""; - const char* list_item_pre = "\n"; - const char* list_item_post = "\n"; - const char* bold_pre_ = ""; - const char* bold_post_ = ""; - const char* italic_pre_ = ""; - const char* italic_post_ = ""; - const char* underline_pre_ = ""; - const char* underline_post_ = ""; - const char* teletype_pre_ = ""; - const char* teletype_post_ = ""; - const char* strikethrough_pre_ = ""; - const char* strikethrough_post_ = ""; - const char* quote_pre_ = ""; - const char* quote_post_ = ""; - const char* break_mark = "\n"; - const char* url_pre_ = " +#include #include #include #include @@ -16,7 +16,7 @@ namespace quickbook { - using namespace boost::spirit; + using namespace boost::spirit::classic; using boost::bind; typedef std::string::const_iterator iter_type; @@ -417,7 +417,7 @@ namespace quickbook int indent; }; - void post_process( + int post_process( std::string const& in , std::ostream& out , int indent @@ -437,6 +437,7 @@ namespace quickbook if (r.full) { out << tidy; + return 0; } else { @@ -445,6 +446,7 @@ namespace quickbook << "Warning: Post Processing Failed." << std::endl; out << in; + return 1; } } @@ -455,6 +457,7 @@ namespace quickbook << "Warning: Post Processing Failed." << std::endl; out << in; + return 1; } } } diff --git a/detail/post_process.hpp b/detail/post_process.hpp index 9f9941c..cfe220f 100644 --- a/detail/post_process.hpp +++ b/detail/post_process.hpp @@ -14,7 +14,7 @@ namespace quickbook { - void post_process( + int post_process( std::string const& in , std::ostream& out , int indent diff --git a/detail/quickbook.cpp b/detail/quickbook.cpp old mode 100755 new mode 100644 index 4335b1e..ece0154 --- a/detail/quickbook.cpp +++ b/detail/quickbook.cpp @@ -12,7 +12,8 @@ #include "../doc_info.hpp" #include "./post_process.hpp" #include "./utils.hpp" -#include +#include "./input_path.hpp" +#include #include #include #include @@ -31,7 +32,7 @@ namespace quickbook { - using namespace boost::spirit; + using namespace boost::spirit::classic; namespace fs = boost::filesystem; tm* current_time; // the current time tm* current_gm_time; // the current UTC time @@ -56,8 +57,10 @@ namespace quickbook std::string storage; int err = detail::load(filein_, storage); - if (err != 0) + if (err != 0) { + ++actor.error_count; return err; + } typedef position_iterator iterator_type; iterator_type first(storage.begin(), storage.end(), filein_); @@ -83,10 +86,10 @@ namespace quickbook file_position const pos = info.stop.get_position(); detail::outerr(pos.file,pos.line) << "Syntax Error near column " << pos.column << ".\n"; - return 1; + ++actor.error_count; } - return 0; + return actor.error_count ? 1 : 0; } static int @@ -120,7 +123,7 @@ namespace quickbook result = parse(filein_, outdir, buffer); if (result == 0) { - post_process(buffer.str(), fileout, indent, linewidth); + result = post_process(buffer.str(), fileout, indent, linewidth); } } else @@ -162,11 +165,11 @@ main(int argc, char* argv[]) ("no-pretty-print", "disable XML pretty printing") ("indent", value(), "indent spaces") ("linewidth", value(), "line width") - ("input-file", value(), "input file") - ("output-file", value(), "output file") + ("input-file", value(), "input file") + ("output-file", value(), "output file") ("debug", "debug mode (for developers)") ("ms-errors", "use Microsoft Visual Studio style error & warn message format") - ("include-path,I", value< std::vector >(), "include path") + ("include-path,I", value< std::vector >(), "include path") ; positional_options_description p; @@ -230,17 +233,22 @@ main(int argc, char* argv[]) if (vm.count("include-path")) { - quickbook::include_path = vm["include-path"].as< std::vector >(); + std::vector paths + = vm["include-path"].as< + std::vector >(); + quickbook::include_path + = std::vector(paths.begin(), paths.end()); } if (vm.count("input-file")) { - std::string filein = vm["input-file"].as(); + std::string filein + = vm["input-file"].as(); std::string fileout; if (vm.count("output-file")) { - fileout = vm["output-file"].as(); + fileout = vm["output-file"].as(); } else { @@ -257,6 +265,7 @@ main(int argc, char* argv[]) else { quickbook::detail::outerr("",0) << "Error: No filename given" << std::endl; + return 1; } } @@ -269,6 +278,7 @@ main(int argc, char* argv[]) catch(...) { quickbook::detail::outerr("",0) << "Error: Exception of unknown type caught\n"; + return 1; } return 0; diff --git a/detail/template_stack.cpp b/detail/template_stack.cpp index 9489c76..51e7b6e 100644 --- a/detail/template_stack.cpp +++ b/detail/template_stack.cpp @@ -25,7 +25,7 @@ namespace quickbook { for (deque::const_iterator i = scopes.begin(); i != scopes.end(); ++i) { - if (template_symbol* ts = boost::spirit::find(*i, symbol.c_str())) + if (template_symbol* ts = boost::spirit::classic::find(*i, symbol.c_str())) return ts; } return 0; @@ -33,7 +33,7 @@ namespace quickbook template_symbol* template_stack::find_top_scope(std::string const& symbol) const { - return boost::spirit::find(scopes.front(), symbol.c_str()); + return boost::spirit::classic::find(scopes.front(), symbol.c_str()); } template_symbols const& template_stack::top() const @@ -45,7 +45,7 @@ namespace quickbook void template_stack::add(std::string const& symbol, template_symbol const& ts) { BOOST_ASSERT(!scopes.empty()); - boost::spirit::add(scopes.front(), symbol.c_str(), ts); + boost::spirit::classic::add(scopes.front(), symbol.c_str(), ts); } void template_stack::push() diff --git a/detail/template_stack.hpp b/detail/template_stack.hpp index 3f9db1e..78d1529 100644 --- a/detail/template_stack.hpp +++ b/detail/template_stack.hpp @@ -14,9 +14,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include namespace quickbook @@ -26,16 +26,16 @@ namespace quickbook // template name // template param name[0] // template param name[1] - // ... + // ... // template param name[N] // template body typedef boost::tuple< std::vector - , boost::spirit::file_position> + , boost::spirit::classic::file_position> template_symbol; - typedef boost::spirit::symbols template_symbols; + typedef boost::spirit::classic::symbols template_symbols; struct template_stack { @@ -43,8 +43,8 @@ namespace quickbook struct parser { - typedef boost::spirit::nil_t result_t; - + typedef boost::spirit::classic::nil_t result_t; + parser(template_stack& ts) : ts(ts) {} @@ -58,7 +58,7 @@ namespace quickbook for (template_stack::deque::const_iterator i = ts.scopes.begin(); i != ts.scopes.end(); ++i) { - boost::spirit::match<> m = i->parse(scan); + boost::spirit::classic::match<> m = i->parse(scan); if (m.length() > len) len = m.length(); scan.first = f; @@ -67,7 +67,7 @@ namespace quickbook scan.first = boost::next(f, len); return len; } - + template_stack& ts; }; @@ -78,11 +78,11 @@ namespace quickbook void add(std::string const& symbol, template_symbol const& ts); void push(); void pop(); - - boost::spirit::functor_parser scope; + + boost::spirit::classic::functor_parser scope; private: - + friend struct parser; deque scopes; }; diff --git a/detail/utils.cpp b/detail/utils.cpp index 093a10a..a054539 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -8,7 +8,7 @@ http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #include "./utils.hpp" -#include +#include #include #include @@ -181,6 +181,25 @@ namespace quickbook { namespace detail } } + // Copy a string, converting mac and windows style newlines to unix + // newlines. + + template + void normalize_newlines(InputIterator begin, InputIterator end, + OutputIterator out) + { + while(begin != end) { + if(*begin == '\r') { + *out++ = '\n'; + ++begin; + if(begin != end && *begin == '\n') ++begin; + } + else { + *out++ = *begin++; + } + } + } + int load(std::string const& filename, std::string& storage) { using std::cerr; @@ -200,7 +219,7 @@ namespace quickbook { namespace detail // Turn off white space skipping on the stream in.unsetf(ios::skipws); - std::copy( + normalize_newlines( istream_iterator(in), istream_iterator(), std::back_inserter(storage)); diff --git a/doc_info.hpp b/doc_info.hpp old mode 100755 new mode 100644 index 874daf8..a473ad7 --- a/doc_info.hpp +++ b/doc_info.hpp @@ -11,14 +11,14 @@ #define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP #include "./phrase.hpp" -#include -#include -#include -#include +#include +#include +#include +#include namespace quickbook { - using namespace boost::spirit; + using namespace boost::spirit::classic; extern unsigned qbk_major_version; extern unsigned qbk_minor_version; diff --git a/phrase.hpp b/phrase.hpp index f637d72..4760e7f 100644 --- a/phrase.hpp +++ b/phrase.hpp @@ -11,15 +11,15 @@ #define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP #include "detail/utils.hpp" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace quickbook { - using namespace boost::spirit; + using namespace boost::spirit::classic; template inline void diff --git a/syntax_highlight.hpp b/syntax_highlight.hpp old mode 100755 new mode 100644 index c037cb0..01e2f1c --- a/syntax_highlight.hpp +++ b/syntax_highlight.hpp @@ -10,16 +10,17 @@ #if !defined(BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP) #define BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "./phrase.hpp" namespace quickbook { - using namespace boost::spirit; + using namespace boost::spirit::classic; // Grammar for C++ highlighting template < @@ -58,7 +59,7 @@ namespace quickbook | string_ [Process("string", self.out)] | char_ [Process("char", self.out)] | number [Process("number", self.out)] - | anychar_p [Unexpected(self.out)] + | repeat_p(1)[anychar_p] [Unexpected(self.out)] ) ; @@ -74,13 +75,23 @@ namespace quickbook ) ; - escape - = str_p("``") [PreEscape(self.escape_actions, save)] - >> ( - (+(anychar_p - "``") >> eps_p("``")) - & qbk_phrase + escape = + str_p("``") [PreEscape(self.escape_actions, save)] + >> + ( + ( + ( + (+(anychar_p - "``") >> eps_p("``")) + & qbk_phrase + ) + >> str_p("``") ) - >> str_p("``") [PostEscape(self.out, self.escape_actions, save)] + | + ( + eps_p [self.escape_actions.error] + >> *anychar_p + ) + ) [PostEscape(self.out, self.escape_actions, save)] ; preprocessor @@ -193,7 +204,7 @@ namespace quickbook | special [Process("special", self.out)] | string_ [Process("string", self.out)] | number [Process("number", self.out)] - | anychar_p [Unexpected(self.out)] + | repeat_p(1)[anychar_p] [Unexpected(self.out)] ) ; @@ -209,13 +220,23 @@ namespace quickbook ) ; - escape - = str_p("``") [PreEscape(self.escape_actions, save)] - >> ( - (+(anychar_p - "``") >> eps_p("``")) - & qbk_phrase + escape = + str_p("``") [PreEscape(self.escape_actions, save)] + >> + ( + ( + ( + (+(anychar_p - "``") >> eps_p("``")) + & qbk_phrase + ) + >> str_p("``") ) - >> str_p("``") [PostEscape(self.out, self.escape_actions, save)] + | + ( + eps_p [self.escape_actions.error] + >> *anychar_p + ) + ) [PostEscape(self.out, self.escape_actions, save)] ; comment diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 516e60f..5559257 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -8,7 +8,7 @@ project test ; -import quickbook-testing : quickbook-test ; +import quickbook-testing : quickbook-test quickbook-fail-test ; test-suite quickbook.test : [ quickbook-test quickbook-manual ] @@ -21,4 +21,16 @@ test-suite quickbook.test : [ quickbook-test templates ] [ quickbook-test xinclude ] [ quickbook-test import ] + [ quickbook-fail-test fail-include ] + [ quickbook-fail-test fail-import ] + [ quickbook-fail-test fail-template-arguments1 ] + [ quickbook-fail-test fail-template-arguments2 ] + [ quickbook-fail-test fail-cpp-mismatched-escape ] + [ quickbook-fail-test fail-python-mismatched-escape ] + [ quickbook-fail-test fail-post-process ] + [ quickbook-fail-test fail-parse-error1 ] + [ quickbook-fail-test fail-parse-error2 ] ; + + + diff --git a/test/fail-cpp-mismatched-escape.quickbook b/test/fail-cpp-mismatched-escape.quickbook new file mode 100644 index 0000000..d5d332c --- /dev/null +++ b/test/fail-cpp-mismatched-escape.quickbook @@ -0,0 +1,5 @@ +[article Odd code markup. [quickbook 1.4] ] + +[c++] + + `` int main() {} diff --git a/test/fail-import.quickbook b/test/fail-import.quickbook new file mode 100644 index 0000000..d3bd31f --- /dev/null +++ b/test/fail-import.quickbook @@ -0,0 +1,11 @@ +[article Expect import Fail +] + +[section Failure] + +[import this-is-not-a-file.cpp] + +[endsect] + + + diff --git a/test/fail-include.quickbook b/test/fail-include.quickbook new file mode 100644 index 0000000..2268a1e --- /dev/null +++ b/test/fail-include.quickbook @@ -0,0 +1,11 @@ +[article Expect xinclude Fail +] + +[section Failure] + +[include this-is-not-a-file.qbk] + +[endsect] + + + diff --git a/test/fail-parse-error1.quickbook b/test/fail-parse-error1.quickbook new file mode 100644 index 0000000..79bf3d7 --- /dev/null +++ b/test/fail-parse-error1.quickbook @@ -0,0 +1,3 @@ +[article Parse error [quickbook 1.4]] + +[heading Incomplete heading diff --git a/test/fail-parse-error2.quickbook b/test/fail-parse-error2.quickbook new file mode 100644 index 0000000..a7e5896 --- /dev/null +++ b/test/fail-parse-error2.quickbook @@ -0,0 +1,5 @@ +[article Parse error [quickbook 1.4]] + +[variablelist Variable List +[[1234]] +] diff --git a/test/fail-post-process.quickbook b/test/fail-post-process.quickbook new file mode 100644 index 0000000..994a635 --- /dev/null +++ b/test/fail-post-process.quickbook @@ -0,0 +1,3 @@ +[article Fail post process due to invalid embedded xml [quickbook 1.4] ] + +Invalid xml follows: '''<>''' diff --git a/test/fail-python-mismatched-escape.quickbook b/test/fail-python-mismatched-escape.quickbook new file mode 100644 index 0000000..e93cf13 --- /dev/null +++ b/test/fail-python-mismatched-escape.quickbook @@ -0,0 +1,5 @@ +[article Odd code markup. [quickbook 1.4] ] + +[python] + + print "Hello World." `` diff --git a/test/fail-template-arguments1.quickbook b/test/fail-template-arguments1.quickbook new file mode 100644 index 0000000..de54836 --- /dev/null +++ b/test/fail-template-arguments1.quickbook @@ -0,0 +1,13 @@ +[article Expect template to fail because there are too many arguments. +] + +[template unary[x] [x]] + +[section Failure] + +[unary a..b ] + +[endsect] + + + diff --git a/test/fail-template-arguments2.quickbook b/test/fail-template-arguments2.quickbook new file mode 100644 index 0000000..6de33fe --- /dev/null +++ b/test/fail-template-arguments2.quickbook @@ -0,0 +1,13 @@ +[article Expect template to fail because there are not enough arguments. +] + +[template ternary[x y z] [x][y][z]] + +[section Failure] + +[ternary a b ] + +[endsect] + + + diff --git a/test/quickbook-testing.jam b/test/quickbook-testing.jam index b4f50d0..ed0ae3b 100644 --- a/test/quickbook-testing.jam +++ b/test/quickbook-testing.jam @@ -60,6 +60,30 @@ rule quickbook-test ( target-name : input ? : reference-output ? : requirements $(target-name).test $(reference-output) $(target-name).boostbook + on + ] + ; + + modules.poke testing : .all-tests : \$\(all-tests\) $(t) ; + + return $(t) ; +} + +rule quickbook-fail-test ( target-name : input ? : requirements * ) +{ + input ?= $(target-name).quickbook ; + + local project = [ project.current ] ; + requirements += $(input:J=" ") ; + + local t = + [ targets.create-typed-target RUN_FAIL + : $(project) + : $(target-name) + : ..//quickbook + : $(requirements) + on + $(input) ] ; @@ -79,3 +103,4 @@ actions process-quickbook bind quickbook-command { $(quickbook-command) $(>) --output-file=$(<) --debug } + diff --git a/test/src/text_diff.cpp b/test/src/text_diff.cpp index 9409dc5..bcac672 100644 --- a/test/src/text_diff.cpp +++ b/test/src/text_diff.cpp @@ -10,10 +10,10 @@ #include #include -#include -#include +#include +#include -namespace spirit = boost::spirit; +namespace spirit = boost::spirit::classic; typedef std::istream_iterator iterator; typedef spirit::scanner scanner; From 495d6fa9d378ba64ac6eaa9dced1d367b8f735cf Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 23 Feb 2009 18:39:32 +0000 Subject: [PATCH 23/94] Merge PDF build changes from Trunk. [SVN r51417] --- doc/Jamfile.v2 | 4 ++++ 1 file changed, 4 insertions(+) mode change 100755 => 100644 doc/Jamfile.v2 diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 old mode 100755 new mode 100644 index 1ddf3ba..1b19f03 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -5,6 +5,8 @@ using quickbook ; xml quickbook : quickbook.qbk ; +path-constant images : ../../../doc/html ; + boostbook standalone : quickbook @@ -17,4 +19,6 @@ boostbook standalone chunk.first.sections=1 #callout.graphics.path=../../images/callouts// + pdf:img.src.path=$(images)/ + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html ; From 4e019bf5dc7471651babfe944d15c3e30991d71e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 12 Mar 2009 21:50:30 +0000 Subject: [PATCH 24/94] Fix properties on some quickbook files, which wasn't merged properly before. [SVN r51742] --- test/code-block-1.gold | 46 +- test/code-block-1.quickbook | 32 +- test/code-block-2.gold | 50 +- test/code-block-2.quickbook | 36 +- test/code-snippet.gold | 40 +- test/code-snippet.quickbook | 20 +- test/escape.gold | 34 +- test/escape.quickbook | 26 +- test/import.gold | 72 +- test/import.quickbook | 12 +- test/link-side-by-side.gold | 36 +- test/link-side-by-side.quickbook | 26 +- test/preformatted.gold | 58 +- test/preformatted.quickbook | 44 +- test/quickbook-manual.gold | 7402 +++++++++++++++--------------- test/quickbook-manual.quickbook | 3962 ++++++++-------- 16 files changed, 5948 insertions(+), 5948 deletions(-) diff --git a/test/code-block-1.gold b/test/code-block-1.gold index 7cd06b3..f610d68 100644 --- a/test/code-block-1.gold +++ b/test/code-block-1.gold @@ -1,23 +1,23 @@ - - -
- - - Code Block 1 -
- A code block - - A code block with proper indentation ;-) - - -#include <iostream> - -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; -} - -
-
+ + +
+ + + Code Block 1 +
+ A code block + + A code block with proper indentation ;-) + + +#include <iostream> + +int main() +{ + std::cout << "Hello, World!" << std::endl; + return 0; +} + +
+
diff --git a/test/code-block-1.quickbook b/test/code-block-1.quickbook index 11c276c..416655f 100644 --- a/test/code-block-1.quickbook +++ b/test/code-block-1.quickbook @@ -1,16 +1,16 @@ -[article Code Block 1 -] - -[section A code block] - -A code block with proper indentation ;-) - - #include - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } - -[endsect] +[article Code Block 1 +] + +[section A code block] + +A code block with proper indentation ;-) + + #include + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } + +[endsect] diff --git a/test/code-block-2.gold b/test/code-block-2.gold index 7b87673..532cb9f 100644 --- a/test/code-block-2.gold +++ b/test/code-block-2.gold @@ -1,25 +1,25 @@ - - -
- - - Code Block 2 -
- A code block - - A code block with proper indentation ;-) - - - -#include <iostream> - -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; -} - - -
-
+ + +
+ + + Code Block 2 +
+ A code block + + A code block with proper indentation ;-) + + + +#include <iostream> + +int main() +{ + std::cout << "Hello, World!" << std::endl; + return 0; +} + + +
+
diff --git a/test/code-block-2.quickbook b/test/code-block-2.quickbook index cc5e4d4..39d8020 100644 --- a/test/code-block-2.quickbook +++ b/test/code-block-2.quickbook @@ -1,18 +1,18 @@ -[article Code Block 2 -] - -[section A code block] - -A code block with proper indentation ;-) - -`` - #include - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } -`` - -[endsect] +[article Code Block 2 +] + +[section A code block] + +A code block with proper indentation ;-) + +`` + #include + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } +`` + +[endsect] diff --git a/test/code-snippet.gold b/test/code-snippet.gold index 590c35b..e3852ff 100644 --- a/test/code-snippet.gold +++ b/test/code-snippet.gold @@ -1,20 +1,20 @@ - - -
- - - Code Snippets -
- A code snippet - - Code snippets inlined in text, as in namespace - quickbook { - static const - int value - = 0; - }, should be properly formatted and - not glued to the surrounding text. - -
-
+ + +
+ + + Code Snippets +
+ A code snippet + + Code snippets inlined in text, as in namespace + quickbook { + static const + int value + = 0; + }, should be properly formatted and + not glued to the surrounding text. + +
+
diff --git a/test/code-snippet.quickbook b/test/code-snippet.quickbook index ebfb435..8c4e94c 100644 --- a/test/code-snippet.quickbook +++ b/test/code-snippet.quickbook @@ -1,10 +1,10 @@ -[article Code Snippets -] - -[section A code snippet] - -Code snippets inlined in text, as in `namespace quickbook { static const int -value = 0; }`, should be properly formatted and not glued to the surrounding -text. - -[endsect] +[article Code Snippets +] + +[section A code snippet] + +Code snippets inlined in text, as in `namespace quickbook { static const int +value = 0; }`, should be properly formatted and not glued to the surrounding +text. + +[endsect] diff --git a/test/escape.gold b/test/escape.gold index d9f3c80..cd04ea1 100644 --- a/test/escape.gold +++ b/test/escape.gold @@ -1,17 +1,17 @@ - - -
- - - Escape -
- Escape - - Da do do do. Da da da da. That's all I have to say to you. - - - This letter α should have a space either side of it. - -
-
+ + +
+ + + Escape +
+ Escape + + Da do do do. Da da da da. That's all I have to say to you. + + + This letter α should have a space either side of it. + +
+
diff --git a/test/escape.quickbook b/test/escape.quickbook index c564afb..82b8d33 100644 --- a/test/escape.quickbook +++ b/test/escape.quickbook @@ -1,13 +1,13 @@ -[article Escape -] - -[section Escape] - -''' -Da do do do. Da da da da. That's all I have to say to you. -''' - -This letter '''α''' should have a space either side of it. - -[endsect] - +[article Escape +] + +[section Escape] + +''' +Da do do do. Da da da da. That's all I have to say to you. +''' + +This letter '''α''' should have a space either side of it. + +[endsect] + diff --git a/test/import.gold b/test/import.gold index 358a559..e984259 100644 --- a/test/import.gold +++ b/test/import.gold @@ -1,36 +1,36 @@ - - -
- - - Import - - - This is the foo function. - - - This description can have paragraphs... - - - - lists - - - etc. - - - - And any quickbook block markup. - - - -std::string foo() -{ - // return 'em, foo man! - return "foo"; -} - - - -
+ + +
+ + + Import + + + This is the foo function. + + + This description can have paragraphs... + + + + lists + + + etc. + + + + And any quickbook block markup. + + + +std::string foo() +{ + // return 'em, foo man! + return "foo"; +} + + + +
diff --git a/test/import.quickbook b/test/import.quickbook index 9bd5f24..88bf400 100644 --- a/test/import.quickbook +++ b/test/import.quickbook @@ -1,6 +1,6 @@ -[article Import] - -[import stub.cpp] - -[foo] - +[article Import] + +[import stub.cpp] + +[foo] + diff --git a/test/link-side-by-side.gold b/test/link-side-by-side.gold index b6e8d58..887742c 100644 --- a/test/link-side-by-side.gold +++ b/test/link-side-by-side.gold @@ -1,18 +1,18 @@ - - - + + + diff --git a/test/link-side-by-side.quickbook b/test/link-side-by-side.quickbook index 822a892..aa3e1e4 100644 --- a/test/link-side-by-side.quickbook +++ b/test/link-side-by-side.quickbook @@ -1,13 +1,13 @@ -[article Side-by-side links -] - -[section Side-by-side links] - -[link x] and [link y] are two distinct links, which should be separated by -whitespace when they appear together as in [link x] [link y]. Also in [link x] -[link y], and in -[link x] -[link y] -as well. - -[endsect] +[article Side-by-side links +] + +[section Side-by-side links] + +[link x] and [link y] are two distinct links, which should be separated by +whitespace when they appear together as in [link x] [link y]. Also in [link x] +[link y], and in +[link x] +[link y] +as well. + +[endsect] diff --git a/test/preformatted.gold b/test/preformatted.gold index 30f9acb..87e1165 100644 --- a/test/preformatted.gold +++ b/test/preformatted.gold @@ -1,29 +1,29 @@ - - -
- - - Preformatted -
- Preformatted - - Here's the ubiquitous Hello World program in C++. - - -#include <iostream> - -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; -} - - - The code should appear as a single block of code in a monospaced font and with - no syntax highlighting. The fifth and sixth lines should appear indented to - the right, aligning under main, - on line 3. - -
-
+ + +
+ + + Preformatted +
+ Preformatted + + Here's the ubiquitous Hello World program in C++. + + +#include <iostream> + +int main() +{ + std::cout << "Hello, World!" << std::endl; + return 0; +} + + + The code should appear as a single block of code in a monospaced font and with + no syntax highlighting. The fifth and sixth lines should appear indented to + the right, aligning under main, + on line 3. + +
+
diff --git a/test/preformatted.quickbook b/test/preformatted.quickbook index f95b1d5..272025a 100644 --- a/test/preformatted.quickbook +++ b/test/preformatted.quickbook @@ -1,22 +1,22 @@ -[article Preformatted -] - -[section Preformatted] - -Here's the ubiquitous /Hello World/ program in C++. - -[pre -#include - -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; -} -] - -The code should appear as a single block of code in a monospaced font and with -no syntax highlighting. The fifth and sixth lines should appear indented to the -right, aligning under `main`, on line 3. - -[endsect] +[article Preformatted +] + +[section Preformatted] + +Here's the ubiquitous /Hello World/ program in C++. + +[pre +#include + +int main() +{ + std::cout << "Hello, World!" << std::endl; + return 0; +} +] + +The code should appear as a single block of code in a monospaced font and with +no syntax highlighting. The fifth and sixth lines should appear indented to the +right, aligning under `main`, on line 3. + +[endsect] diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold index 0b8c0b7..adb8251 100644 --- a/test/quickbook-manual.gold +++ b/test/quickbook-manual.gold @@ -1,3701 +1,3701 @@ - - -
- - - - Joel de Guzman - - - Eric Niebler - - - - 2002 2004 2006 Joel de Guzman, - Eric Niebler - - - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - - - WikiWiki style documentation tool - - - Quickbook 1.4 -
- <link linkend="quickbook.intro"> Introduction</link> -
- - - Why program by hand in five days - what you can spend five years of your life automating? - - - -- Terrence Parr, author ANTLR/PCCTS - - -
- - Well, QuickBook started as a weekend hack. It was originally intended to be - a sample application using Spirit. - What is it? What you are viewing now, this documentation, is autogenerated - by QuickBook. These files were generated from one master: - -
- - - quickbook.qbk - - -
- - Originally named QuickDoc, this funky tool that never dies evolved into a funkier - tool thanks to Eric Niebler who resurrected the project making it generate - BoostBook - instead of HTML. The BoostBook - documentation format is an extension of DocBook, - an SGML or XML based format for describing documentation. - - - QuickBook is a WikiWiki style documentation tool geared towards C++ documentation - using simple rules and markup for simple formatting tasks. QuickBook extends - the WikiWiki concept. Like the WikiWiki, QuickBook documents are simple text - files. A single QuickBook document can generate a fully linked set of nice - HTML and PostScript/PDF documents complete with images and syntax- colorized - source code. - - - Features include: - - - - generate BoostBook - xml, to generate HTML, PostScript and PDF - - - simple markup to link to Doxygen-generated entities - - - macro system for simple text substitution - - - simple markup for italics, bold, preformatted, blurbs, code samples, tables, - URLs, anchors, images, etc. - - - automatic syntax coloring of code samples - - - CSS support - - -
-
- <link linkend="quickbook.change_log"> Change Log</link> - - Version 1.3 - - - - Quickbook file inclusion [include]. - - - Better xml output (pretty layout). Check out the generated XML. - - - Regression testing facility: to make sure your document will always be compatible - (full backward compatibility) regardless of changes to QuickBook. - - - Code cleanup and refactoring. - - - Allow phrase markup in the doc-info. - - - Preformatted code blocks via ``code`` (double ticks) allows code in tables - and lists, for example. - - - Quickbook versioning; allows full backward compatibility. You have to add - [quickbook 1.3] to the doc-info header to enable the new features. Without - this, QuickBook will assume that the document is a pre-1.3 document. - - - Better (intuitive) paragraph termination. Some markups may terminate a paragraph. - Example: -[section x] -blah... -[endsect] - - - Fully qualified section and headers. Subsection names are concatenated to - the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name - - - Better &nbsp; and whitespace handling in code snippets. - - - [xinclude] fixes up the relative path to the target XML file when input_directory - is not the same as the output_directory. - - - Allow untitled tables. - - - Allow phrase markups in section titles. - - - Allow escaping back to QuickBook from code, code blocks and inline code. - - - Footnotes, with the [footnote This is the footnote] syntax. - - - Post-processor bug fix for escaped XML code that it does not recognize. - - - Replaceable, with the [~replacement] syntax. - - - Generic Headers - - - Code changes to allow full recursion (i.e. Collectors and push/pop functions) - - - Various code cleanup/maintenance - - - Templates! - - - [conceptref] for referencing BoostBook <concept> entities. - - - Allow escape of spaces. The escaped space is removed from the output. Syntax: - \ . - - - Nested comments are now allowed. - - - Quickbook blocks can nest inside comments. - - - Import facility. - - - Callouts on imported code - - - Simple markups can now span a whole block. - - - Blurbs, Admonitions - and table cells (see Tables) - may now contain paragraphs. - - - \n - and [br] are now deprecated. - - -
-
- <link linkend="quickbook.syntax"> Syntax Summary</link> - - A QuickBook document is composed of one or more blocks. An example of a block - is the paragraph or a C++ code snippet. Some blocks have special mark-ups. - Blocks, except code snippets which have their own grammar (C++ or Python), - are composed of one or more phrases. A phrase can be a simple contiguous run - of characters. Phrases can have special mark-ups. Marked up phrases can recursively - contain other phrases, but cannot contain blocks. A terminal is a self contained - block-level or phrase-level element that does not nest anything. - - - Blocks, in general, are delimited by two end-of-lines (the block terminator). - Phrases in each block cannot contain a block terminator. This way, syntax errors - such as un-matched closing brackets do not go haywire and corrupt anything - past a single block. - -
- <link linkend="quickbook.syntax.comments">Comments</link> - - Can be placed anywhere. - - -[/ comment (no output generated) ] - - -[/ comments can be nested [/ some more here] ] - - -[/ Quickbook blocks can nest inside comments. [*Comment this out too!] ] - -
-
- <link linkend="quickbook.syntax.phrase"> Phrase Level Elements</link> -
- <link linkend="quickbook.syntax.phrase.font_styles">Font Styles</link> - -['italic], [*bold], [_underline], [^teletype], [-strikethrough] - - - will generate: - - - italic, bold, underline, teletype, strikethrough - - - Like all non-terminal phrase level elements, this can of course be nested: - - -[*['bold-italic]] - - - will generate: - - - bold-italic - -
-
- <link linkend="quickbook.syntax.phrase.replaceable">Replaceable</link> - - When you want content that may or must be replaced by the user, use the - syntax: - - -[~replacement] - - - This will generate: - - - - replacement - - -
-
- <link linkend="quickbook.syntax.phrase.quotations">Quotations</link> - -["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein - - - will generate: - - - A question that sometimes drives me hazy: am I or are the others - crazy?--Einstein - - - Note the proper left and right quote marks. Also, while you can simply - use ordinary quote marks like "quoted", our quotation, above, - will generate correct DocBook quotations (e.g. <quote>quoted</quote>). - - - Like all phrase elements, quotations may be nested. Example: - - -["Here's the rule for bargains: ["Do other men, for they would do you.] That's -the true business precept.] - - - will generate: - - - Here's the rule for bargains: Do other men, for they would - do you. That's the true business precept. - -
-
- <link linkend="quickbook.syntax.phrase.simple_formatting">Simple formatting</link> - - Simple markup for formatting text, common in many applications, is now - supported: - - -/italic/, *bold*, _underline_, =teletype= - - - will generate: - - - italic, bold, underline, teletype - - - Unlike QuickBook's standard formatting scheme, the rules for simpler alternatives - are much stricter - - - Thanks to David Barrett, author of Qwiki, - for sharing these samples and teaching me these obscure formatting - rules. I wasn't sure at all if Spirit, - being more or less a formal EBNF parser, can handle the context sensitivity - and ambiguity. - - - . - - - - Simple markups cannot nest. You can combine a simple markup with a nestable - markup. - - - Simple markups cannot contain any other form of quickbook markup. - - - A non-space character must follow the leading markup - - - A non-space character must precede the trailing markup - - - A space or a punctuation must follow the trailing markup - - - If the matching markup cannot be found within a block, the formatting - will not be applied. This is to ensure that un-matched formatting markups, - which can be a common mistake, does not corrupt anything past a single - block. We do not want the rest of the document to be rendered bold just - because we forgot a trailing '*'. A single block is terminated by two - end of lines or the close bracket: ']'. - - - A line starting with the star will be interpreted as an unordered list. - See Unordered - lists. - - - More Formatting Samples - - - - - - Markup - - - - Result - - - - - - - - - *Bold* - - - - Bold - - - - - - - *Is bold* - - - - Is bold - - - - - - - * Not bold* *Not bold * * Not bold * - - - - * Not bold* *Not bold * * Not bold * - - - - - - - This*Isn't*Bold (no bold) - - - - This*Isn't*Bold (no bold) - - - - - - - (*Bold Inside*) (parenthesis not bold) - - - - (Bold Inside) (parenthesis not bold) - - - - - - - *(Bold Outside)* (parenthesis bold) - - - - (Bold Outside) (parenthesis bold) - - - - - - - 3*4*5 = 60 (no bold) - - - - 3*4*5 = 60 (no bold) - - - - - - - 3 * 4 * 5 = 60 (no bold) - - - - 3 * 4 * 5 = 60 (no bold) - - - - - - - 3 *4* 5 = 60 (4 is bold) - - - - 3 4 5 = 60 (4 is bold) - - - - - - - *This is bold* this is not *but this is* - - - - This is bold this is not but this is - - - - - - - *This is bold*. - - - - This is bold. - - - - - - - *B*. (bold B) - - - - B. (bold B) - - - - - - - ['*Bold-Italic*] - - - - Bold-Italic - - - - - - - *side-by*/-side/ - - - - side-by-side - - - - - -
- - As mentioned, simple markups cannot go past a single block. The text from - "have" to "full" in the following paragraph will be - rendered as bold: - - -Baa baa black sheep, *have you any wool? -Yes sir, yes sir, three bags full!* -One for the master, one for the dame, -And one for the little boy who lives down the lane. - - - Baa baa black sheep, have you any wool? Yes sir, - yes sir, three bags full! One for the master, one for the dame, - And one for the little boy who lives down the lane. - - - But in the following paragraph, bold is not applied: - - -Baa baa black sheep, *have you any wool? -Yes sir, yes sir, three bags full! -One for the master, one for the dame, -And one for the little boy who lives down the lane. - - - Baa baa black sheep, *have you any wool? Yes sir, yes sir, three bags full! - One for the master, one for the dame, And one for the little boy who lives - down the lane. - -
-
- <link linkend="quickbook.syntax.phrase.inline_code">Inline code</link> - - Inlining code in paragraphs is quite common when writing C++ documentation. - We provide a very simple markup for this. For example, this: - - -This text has inlined code `int main() { return 0; }` in it. - - - will generate: - - - This text has inlined code int main() { return 0; } - in it. The code will be syntax highlighted. - - - - We simply enclose the code with the tick: "`", not the - single quote: "'". - Note too that `some code` is preferred over [^some code]. - - -
-
- <link linkend="quickbook.syntax.phrase.code_blocks">Code blocks</link> - - Preformatted code simply starts with a space or a tab (See Code). - However, such a simple syntax cannot be used as phrase elements in lists - (See Ordered - lists and Unordered - lists), tables (See Tables), - etc. Inline code (see above) can. The problem is, inline code does not - allow formatting with newlines, spaces, and tabs. These are lost. - - - We provide a phrase level markup that is a mix between the two. By using - the double-tick, instead of the single-tick, we are telling QuickBook to - use preformatted blocks of code. Example: - - -`` - #include <iostream> - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } -`` - - - will generate: - - - -#include <iostream> - -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; -} - - -
-
- <link linkend="quickbook.syntax.phrase.source_mode">Source Mode</link> - - If a document contains more than one type of source code then the source - mode may be changed dynamically as the document is processed. All QuickBook - documents are initially in C++ mode by default, though an alternative initial - value may be set in the Document - section. - - - To change the source mode, use the [source-mode] markup, - where source-mode is one of the supported modes. For - example, this: - - -Python's [python] `import` is rather like C++'s [c++] `#include`. A -C++ comment `// looks like this` whereas a Python comment [python] -`# looks like this`. - - - will generate: - - - Python's import is rather - like C++'s #include. - A C++ comment // looks like this - whereas a Python comment #looks like this. - - Supported Source Modes - - - - - - Mode - - - - Source Mode Markup - - - - - - - - - C++ - - - - [c++] - - - - - - - Python - - - - [python] - - - - - -
- - - The source mode strings are lowercase. - - -
-
- <link linkend="quickbook.syntax.phrase.line_break">line-break</link> - -[br] - - - - [br] is now deprecated. Blurbs, - Admonitions - and table cells (see Tables) - may now contain paragraphs. - - -
-
- <link linkend="quickbook.syntax.phrase.anchors">Anchors</link> - -[#named_anchor] - - - A named anchor is a hook that can be referenced by a link elsewhere in - the document. You can then reference an anchor with [link named_anchor -Some link text]. - See Anchor links, - Section and Heading. - -
- - - - -
- <link linkend="quickbook.syntax.phrase.escape">Escape</link> - - The escape mark-up is used when we don't want to do any processing. - - -''' -escape (no processing/formatting) -''' - - - Escaping allows us to pass XML markup to BoostBook - or DocBook. For example: - - -''' -<emphasis role="bold">This is direct XML markup</emphasis> -''' - - - This is direct XML markup - - - - Be careful when using the escape. The text must conform to BoostBook/DocBook syntax. - - -
-
- <link linkend="quickbook.syntax.phrase.single_char_escape">Single - char escape</link> - - The backslash may be used to escape a single punctuation character. The - punctuation immediately after the backslash is passed without any processing. - This is useful when we need to escape QuickBook punctuations such as [ and ]. - For example, how do you escape the triple quote? Simple: \'\'\' - - - \n - has a special meaning. It is used to generate line breaks. - - - - \n - and [br] are now deprecated. Blurbs, - Admonitions - and table cells (see Tables) - may now contain paragraphs. - - - - The escaped space: \ also - has a special meaning. The escaped space is removed from the output. - -
-
- <link linkend="quickbook.syntax.phrase.images">Images</link> - -[$image.jpg] - -
-
- <link linkend="quickbook.syntax.phrase.footnotes">Footnotes</link> - - As of version 1.3, QuickBook supports footnotes. Just put the text of the - footnote in a [footnote] block, and the text will be put at the - bottom of the current page. For example, this: - - -[footnote A sample footnote] - - - will generate this - - - A sample footnote - - - . - -
- <link linkend="quickbook.syntax.phrase.footnotes.macro_expansion">Macro - Expansion</link> -__a_macro_identifier__ - - - See Macros for details. - -
-
- <link linkend="quickbook.syntax.phrase.footnotes.template_expansion">Template - Expansion</link> -[a_template_identifier] - - - See Templates - for details. - -
-
-
-
- <link linkend="quickbook.syntax.block"> Block Level Elements</link> -
- <link linkend="quickbook.syntax.block.document">Document</link> - - Every document must begin with a Document Info section, which should look - like this: - - -[document-type The Document Title - [quickbook 1.3] - [version 1.0] - [id the_document_name] - [dirname the_document_dir] - [copyright 2000 2002 2003 Joe Blow, Jane Doe] - [purpose The document's reason for being] - [category The document's category] - [authors [Blow, Joe], [Doe, Jane]] - [license The document's license] - [source-mode source-type] -] - - - Where document-type is one of: - - - - book - - - article - - - library - - - chapter - - - part - - - appendix - - - preface - - - qandadiv - - - qandaset - - - reference - - - set - - - - quickbook 1.3 declares the version of quickbook the document is written - for. In its absence, version 1.1 is assumed. - - - version, id, dirname, - copyright, purpose, category, - authors, license, last-revision - and source-mode are optional information. - - - source-type is a lowercase string setting the initial - Source Mode. - If the source-mode field is omitted, a default value - of c++ will be used. - -
-
- <link linkend="quickbook.syntax.block.section">Section</link> - - Starting a new section is accomplished with: - - -[section:id The Section Title] - - - where id is optional. id will be the filename of the - generated section. If it is not present, "The Section Title" - will be normalized and become the id. Valid characters are a-Z, - A-Z, 0-9 and _. - All non-valid characters are converted to underscore and all upper-case - are converted to lower case. Thus: "The Section Title" will be - normalized to "the_section_title". - - - End a section with: - - -[endsect] - - - Sections can nest, and that results in a hierarchy in the table of contents. - -
-
- <link linkend="quickbook.syntax.block.xinclude">xinclude</link> - - You can include another XML file with: - - -[xinclude file.xml] - - - This is useful when file.xml has been generated by Doxygen and contains - your reference section. - -
-
- <link linkend="quickbook.syntax.block.paragraphs">Paragraphs</link> - - Paragraphs start left-flushed and are terminated by two or more newlines. - No markup is needed for paragraphs. QuickBook automatically detects paragraphs - from the context. Block markups [section, endsect, h1, h2, h3, h4, h5, - h6, blurb, (block-quote) ':', pre, def, table and include ] may also terminate - a paragraph. - -
-
- <link linkend="quickbook.syntax.block.lists">Lists</link> -
- <link linkend="quickbook.syntax.block.lists.ordered_lists">Ordered - lists</link> -# One -# Two -# Three - - - will generate: - - - - One - - - Two - - - Three - - -
-
- <link linkend="quickbook.syntax.block.lists.list_hierarchies">List - Hierarchies</link> - - List hierarchies are supported. Example: - - -# One -# Two -# Three - # Three.a - # Three.b - # Three.c -# Four - # Four.a - # Four.a.i - # Four.a.ii -# Five - - - will generate: - - - - One - - - Two - - - Three - - - Three.a - - - Three.b - - - Three.c - - - - - Fourth - - - Four.a - - - Four.a.i - - - Four.a.ii - - - - - - - Five - - -
-
- <link linkend="quickbook.syntax.block.lists.long_list_lines">Long - List Lines</link> - - Long lines will be wrapped appropriately. Example: - - -# A short item. -# A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. -# A short item. - - - - A short item. - - - A very long item. A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - - - A short item. - - -
-
- <link linkend="quickbook.syntax.block.lists.unordered_lists">Unordered - lists</link> -* First -* Second -* Third - - - will generate: - - - - First - - - Second - - - Third - - -
-
- <link linkend="quickbook.syntax.block.lists.mixed_lists">Mixed lists</link> - - Mixed lists (ordered and unordered) are supported. Example: - - -# One -# Two -# Three - * Three.a - * Three.b - * Three.c -# Four - - - will generate: - - - - One - - - Two - - - Three - - - Three.a - - - Three.b - - - Three.c - - - - - Four - - - - And... - - -# 1 - * 1.a - # 1.a.1 - # 1.a.2 - * 1.b -# 2 - * 2.a - * 2.b - # 2.b.1 - # 2.b.2 - * 2.b.2.a - * 2.b.2.b - - - will generate: - - - - 1 - - - 1.a - - - 1.a.1 - - - 1.a.2 - - - - - 1.b - - - - - 2 - - - 2.a - - - 2.b - - - 2.b.1 - - - 2.b.2 - - - 2.b.2.a - - - 2.b.2.b - - - - - - - - -
-
-
- <link linkend="quickbook.syntax.block.code">Code</link> - - Preformatted code starts with a space or a tab. The code will be syntax - highlighted according to the current Source - Mode: - - - - -#include <iostream> - -int main() -{ - // Sample code - std::cout << "Hello, World\n"; - return 0; -} - - - - -import cgi - -def cookForHtml(text): - '''"Cooks" the input text for HTML.''' - - return cgi.escape(text) - - - - - Macros that are already defined are expanded in source code. Example: - - -[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] -[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] - - using __boost__::__array__; - - - Generates: - - -using boost::array; - -
-
- <link linkend="quickbook.syntax.block.escape_back"> Escaping Back - To QuickBook</link> - - Inside code, code blocks and inline code, QuickBook does not allow any - markup to avoid conflicts with the target syntax (e.g. c++). In case you - need to switch back to QuickBook markup inside code, you can do so using - a language specific escape-back delimiter. In C++ - and Python, the delimiter is the double tick (back-quote): "``" - and "``". Example: - - -void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() -{ -} - - - Will generate: - - -void foo() -{ -} - - - When escaping from code to QuickBook, only phrase level markups are allowed. - Block level markups like lists, tables etc. are not allowed. - -
-
- <link linkend="quickbook.syntax.block.preformatted">Preformatted</link> - - Sometimes, you don't want some preformatted text to be parsed as C++. In - such cases, use the [pre ... ] markup block. - - -[pre - - Some *preformatted* text Some *preformatted* text - - Some *preformatted* text Some *preformatted* text - - Some *preformatted* text Some *preformatted* text - -] - - - Spaces, tabs and newlines are rendered as-is. Unlike all quickbook block - level markup, pre (and Code) are the only ones that allow multiple newlines. - The markup above will generate: - - -Some preformatted text Some preformatted text - - Some preformatted text Some preformatted text - - Some preformatted text Some preformatted text - - - - Notice that unlike Code, phrase markup such as font style is still permitted - inside pre blocks. - -
-
- <link linkend="quickbook.syntax.block.blockquote">Blockquote</link> - -[:sometext...] - -
- - - Indents the paragraph. This applies to one paragraph only. - - -
-
-
- <link linkend="quickbook.syntax.block.admonitions">Admonitions</link> - -[note This is a note] -[tip This is a tip] -[important This is important] -[caution This is a caution] -[warning This is a warning] - - - generates DocBook admonitions: - - - - This is a note - - - - - This is a tip - - - - - This is important - - - - - This is a caution - - - - - This is a warning - - - - These are the only admonitions supported by DocBook. - So, for example [information This is some information] - is unlikely to produce the desired effect. - -
-
- <link linkend="quickbook.syntax.block.headings">Headings</link> - -[h1 Heading 1] -[h2 Heading 2] -[h3 Heading 3] -[h4 Heading 4] -[h5 Heading 5] -[h6 Heading 6] - - - - Heading 1 - - - - Heading 2 - - - - Heading 3 - - - - Heading 4 - - - - Heading 5 - - - - Heading 6 - - - Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized - names with name="section_id.normalized_header_text" - (i.e. valid characters are a-z, A-Z, - 0-9 and _. All non-valid characters - are converted to underscore and all upper-case are converted to lower-case. - For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). - You can use: - - -[link section_id.normalized_header_text The link text] - - - to link to them. See Anchor - links and Section - for more info. - -
-
- <link linkend="quickbook.syntax.block.generic_heading">Generic Heading</link> - - In cases when you don't want to care about the heading level (1 to 6), - you can use the Generic Heading: - - -[heading Heading] - - - The Generic Heading assumes the level, plus one, of - the innermost section where it is placed. For example, if it is placed - in the outermost section, then, it assumes h2. - - - Headings are often used as an alternative to sections. It is used particularly - if you do not want to start a new section. In many cases, however, headings - in a particular section is just flat. Example: - - -[section A] -[h2 X] -[h2 Y] -[h2 Z] -[endsect] - - - Here we use h2 assuming that section A is the outermost level. If it is - placed in an inner level, you'll have to use h3, h4, etc. depending on - where the section is. In general, it is the section level plus one. It - is rather tedious, however, to scan the section level everytime. If you - rewrite the example above as shown below, this will be automatic: - - -[section A] -[heading X] -[heading Y] -[heading Z] -[endsect] - - - They work well regardless where you place them. You can rearrange sections - at will without any extra work to ensure correct heading levels. In fact, - with section and heading, you - have all you need. h1..h6 becomes - redundant. h1..h6 might be deprecated - in the future. - -
-
- <link linkend="quickbook.syntax.block.macros">Macros</link> - -[def macro_identifier some text] - - - When a macro is defined, the identifier replaces the text anywhere in the - file, in paragraphs, in markups, etc. macro_identifier is a string of non- - white space characters except ']'. A macro may not follow an alphabetic - character or the underscore. The replacement text can be any phrase (even - marked up). Example: - - -[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] -sf_logo - - - Now everywhere the sf_logo is placed, the picture will be inlined. - - - - - sflogo - - - - - - It's a good idea to use macro identifiers that are distinguishable. For - instance, in this document, macro identifiers have two leading and trailing - underscores (e.g. __spirit__). The reason is to avoid unwanted - macro replacement. - - - - Links (URLS) and images are good candidates for macros. 1) - They tend to change a lot. It is a good idea to place all links and images - in one place near the top to make it easy to make changes. 2) - The syntax is not pretty. It's easier to read and write, e.g. __spirit__ - than [@http://spirit.sourceforge.net Spirit]. - - - Some more examples: - - -[def :-) [$theme/smiley.png]] -[def __spirit__ [@http://spirit.sourceforge.net Spirit]] - - - (See Images and - Links) - - - Invoking these macros: - - -Hi __spirit__ :-) - - - will generate this: - - - Hi Spirit - - smiley - - - -
-
- <link linkend="quickbook.syntax.block.predefined_macros">Predefined - Macros</link> - - Quickbook has some predefined macros that you can already use. - - Predefined Macros - - - - - - Macro - - - - Meaning - - - - Example - - - - - - - - - __DATE__ - - - - Today's date - - - - 2000-Dec-20 - - - - - - - __TIME__ - - - - The current time - - - - 12:00:00 PM - - - - - - - __FILENAME__ - - - - Quickbook source filename - - - - NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE - - - - - -
-
-
- <link linkend="quickbook.syntax.block.templates">Templates</link> - - Templates provide a more versatile text substitution mechanism. Templates - come in handy when you need to create parameterizable, multi-line, boilerplate - text that you specify once and expand many times. Templates accept one - or more arguments. These arguments act like place-holders for text replacement. - Unlike simple macros, which are limited to phrase level markup, templates - can contain block level markup (e.g. paragraphs, code blocks and tables). - - - Example template: - - -[template person[name age what] - -Hi, my name is [name]. I am [age] years old. I am a [what]. - -] - - - - Template - Identifier - - - Template identifiers can either consist of: - - - - An initial alphabetic character or the underscore, followed by zero or - more alphanumeric characters or the underscore. This is similar to your - typical C/C++ identifier. - - - A single character punctuation (a non-alphanumeric printable character) - - - - - Formal - Template Arguments - - - Template formal arguments are identifiers consisting of an initial alphabetic - character or the underscore, followed by zero or more alphanumeric characters - or the underscore. This is similar to your typical C/C++ identifier. - - - A template formal argument temporarily hides a template of the same name - at the point where the template - is expanded. Note that the body of the person - template above refers to name age - and what as [name] [age] - and [what]. name age - and what are actually templates that exist in the duration - of the template call. - - - - Template - Body - - - The template body can be just about any QuickBook block or phrase. There - are actually two forms. Templates may be phrase or block level. Phrase - templates are of the form: - - -[template sample[arg1 arg2...argN] replacement text... ] - - - Block templates are of the form: - - -[template sample[arg1 arg2...argN] -replacement text... -] - - - The basic rule is as follows: if a newline immediately follows the argument - list, then it is a block template, otherwise, it is a phrase template. - Phrase templates are typically expanded as part of phrases. Like macros, - block level elements are not allowed in phrase templates. - - - - Template - Expansion - - - You expand a template this way: - - -[template_identifier arg1..arg2..arg3] - - - At template expansion, you supply the actual arguments. The template will - be expanded with your supplied arguments. Example: - - -[person James Bond..39..Spy] -[person Santa Clause..87..Big Red Fatso] - - - Which will expand to: - - - - Hi, my name is James Bond. I am 39 years old. I am a Spy. - - - Hi, my name is Santa Clause. I am 87 years old. I am a Big Red Fatso. - - - - - A word of caution: Templates are recursive. A template can call another - template or even itself, directly or indirectly. There are no control - structures in QuickBook (yet) so this will always mean infinite recursion. - QuickBook can detect this situation and report an error if recursion - exceeds a certain limit. - - - - Each actual argument can be a word, a text fragment or just about any - QuickBook phrase. Arguments - are separated by the double dot ".." and terminated - by the close parenthesis. - - - - Nullary - Templates - - - Nullary templates look and act like simple macros. Example: - - -[template alpha[]'''&#945;'''] -[template beta[]'''&#946;'''] - - - Expanding: - - -Some squigles...[*[alpha][beta]] - - We have: - - - Some squiggles...αβ - - - The difference with macros are - - - - The explicit template - expansion syntax. This is an advantage because, now, we don't - have to use obscure naming conventions like double underscores (e.g. - __alpha__) to avoid unwanted macro replacement. - - - The template is expanded at the point where it is invoked. A macro is - expanded immediately at its point of declaration. This is subtle and - can cause a slight difference in behavior especially if you refer to - other macros and templates in the body. - - - - The empty brackets after the template identifier (alpha[]) - indicates no arguments. If the template body does not look like a template - argument list, we can elide the empty brackets. Example: - - -[template aristotle_quote Aristotle: [*['Education is the best provision -for the journey to old age.]]] - - - Expanding: - - -Here's a quote from [aristotle_quote]. - - - We have: - - - Here's a quote from Aristotle: Education - is the best provision for the journey to old age.. - - - The disadvantage is that you can't avoid the space between the template - identifier, aristotle_quote, - and the template body "Aristotle...". This space will be part - of the template body. If that space is unwanted, use empty brackets or - use the space escape: "\ ". - Example: - - -[template tag\ _tag] - - - Then expanding: - - -`struct` x[tag]; - - - We have: - - - struct x_tag; - - - You have a couple of ways to do it. I personally prefer the explicit empty - brackets, though. - - - - Simple - Arguments - - - As mentioned, arguments are separated by the double dot "..". - If there are less arguments passed than expected, QuickBook attempts to - break the last argument into two or more arguments following this logic: - - - - Break the last argument into two, at the first space found ('', - '\n', \t' or '\r'). - - - Repeat until there are enough arguments or if there are no more spaces - found (in which case, an error is reported). - - - - For example: - - -[template simple[a b c d] [a][b][c][d]] -[simple w x y z] - - - will produce: - - - wxyz - - - "w x y z" is initially treated as a single argument because we - didn't supply any ".." separators. However, - since simple expects 4 arguments, "w x y z" - is broken down iteratively (applying the logic above) until we have "w", - "x", "y" and "z". - - - QuickBook only tries to get the arguments it needs. For example: - - -[simple w x y z trail] - - - will produce: - - - wxyz trail - - - The arguments being: "w", "x", "y" and "z - trail". - - - It should be obvious now that for simple arguments with no spaces, we can - get by without separating the arguments with ".." - separators. It is possible to combine ".." - separators with the argument passing simplification presented above. Example: - - -[simple what do you think ..m a n?] - - - will produce: - - - what do you think man? - - - - Punctuation - Templates - - - With templates, one of our objectives is to allow us to rewrite QuickBook - in QuickBook (as a qbk library). For that to happen, we need to accommodate - single character punctuation templates which are fairly common in QuickBook. - You might have noticed that single character punctuations are allowed as - template - identifiers. Example: - - -[template ![bar] <hey>[bar]</hey>] - - - Now, expanding this: - - -[!baz] - - - We will have: - - -<hey>baz</hey> - -
-
- <link linkend="quickbook.syntax.block.blurbs">Blurbs</link> - -[blurb :-) [*An eye catching advertisement or note...] - - __spirit__ is an object-oriented recursive-descent parser generator framework - implemented using template meta-programming techniques. Expression templates - allow us to approximate the syntax of Extended Backus-Normal Form (EBNF) - completely in C++. -] - - - will generate this: - - - - - - smiley - - An eye catching advertisement - or note... - - - Spirit is an object-oriented - recursive-descent parser generator framework implemented using template - meta-programming techniques. Expression templates allow us to approximate - the syntax of Extended Backus-Normal Form (EBNF) completely in C++. - - - - - Prefer admonitions - wherever appropriate. - - -
-
- <link linkend="quickbook.syntax.block.tables">Tables</link> - -[table A Simple Table - [[Heading 1] [Heading 2] [Heading 3]] - [[R0-C0] [R0-C1] [R0-C2]] - [[R1-C0] [R1-C1] [R1-C2]] - [[R2-C0] [R2-C1] [R2-C2]] -] - - - will generate: - - A Simple Table - - - - - - Heading 1 - - - - Heading 2 - - - - Heading 3 - - - - - - - - - R0-C0 - - - - R0-C1 - - - - R0-C2 - - - - - - - R2-C0 - - - - R2-C1 - - - - R2-C2 - - - - - - - R3-C0 - - - - R3-C1 - - - - R3-C2 - - - - - -
- - The table title is optional. The first row of the table is automatically - treated as the table header; that is, it is wrapped in <thead>...</thead> - XML tags. Note that unlike the original QuickDoc, the columns are nested - in [ cells... ]. The syntax is free-format and allows big cells to be formatted - nicely. Example: - - -[table Table with fat cells - [[Heading 1] [Heading 2]] - [ - [Row 0, Col 0: a small cell] - [ - Row 0, Col 1: a big fat cell with paragraphs - - Boost provides free peer-reviewed portable C++ source libraries. - - We emphasize libraries that work well with the C++ Standard Library. - Boost libraries are intended to be widely useful, and usable across - a broad spectrum of applications. The Boost license encourages both - commercial and non-commercial use. - ] - ] - [ - [Row 1, Col 0: a small cell] - [Row 1, Col 1: a small cell] - ] -] - - - and thus: - - Table with fat cells - - - - - - Heading 1 - - - - Heading 2 - - - - - - - - - Row 0, Col 0: a small cell - - - - Row 0, Col 1: a big fat cell with paragraphs - - - Boost provides free peer-reviewed portable C++ source libraries. - - - We emphasize libraries that work well with the C++ Standard Library. - Boost libraries are intended to be widely useful, and usable across - a broad spectrum of applications. The Boost license encourages both - commercial and non-commercial use. - - - - - - - Row 1, Col 0: a small cell - - - - Row 1, Col 1: a small cell - - - - - -
- - Here's how to have preformatted blocks of code in a table cell: - - -[table Table with code - [[Comment] [Code]] - [ - [My first program] - [`` - #include <iostream> - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } - ``] - ] -] - - Table with code - - - - - - Comment - - - - Code - - - - - - - - - My first program - - - - -#include <iostream> - -int main() -{ - std::cout << "Hello, World!" << std::endl; - return 0; -} - - - - - - -
-
-
- <link linkend="quickbook.syntax.block.variable_lists">Variable Lists</link> - -[variablelist A Variable List - [[term 1] [The definition of term 1]] - [[term 2] [The definition of term 2]] - [[term 3] [The definition of term 3]] -] - - - will generate: - - - A Variable List term 1 - - - The definition of term 1 - - - term 2 - - - The definition of term 2 - - - term 3 - - - The definition of term 3 - - - - - - The rules for variable lists are the same as for tables, except that only - 2 "columns" are allowed. The first column contains the terms, - and the second column contains the definitions. Those familiar with HTML - will recognize this as a "definition list". - -
-
- <link linkend="quickbook.syntax.block.include">Include</link> - - You can include one QuickBook file from another. The syntax is simply: - - -[include someother.qbk] - - - The included file will be processed as if it had been cut and pasted into - the current document, with the following exceptions: - - - - The __FILENAME__ predefined macro will reflect the name of the file currently being - processed. - - - Any macros defined in the included file are scoped to that file. - - - - The [include] directive lets you specify a document - id to use for the included file. When this id is not explicitly specified, - the id defaults to the filename ("someother", in the example - above). You can specify the id like this: - - -[include:someid someother.qbk] - - - All auto-generated anchors will use the document id as a unique prefix. - So for instance, if there is a top section in someother.qbk named "Intro", - the named anchor for that section will be "someid.intro", and - you can link to it with [link someid.intro The Intro]. - -
-
- <link linkend="quickbook.syntax.block.import">Import</link> - - When documenting code, you'd surely need to present code from actual source - files. While it is possible to copy some code and paste them in your QuickBook - file, doing so is error prone and the extracted code in the documentation - tends to get out of sync with the actual code as the code evolves. The - problem, as always, is that once documentation is written, the tendency - is for the docs to languish in the archives without maintenance. - - - QuickBook's import facility provides a nice solution. - - - - Example - - - You can effortlessly import code snippets from source code into your QuickBook. - The following illustrates how this is done: - - -[import ../test/stub.cpp] -[foo] -[bar] - - - The first line: - - -[import ../test/stub.cpp] - - - collects specially marked-up code snippets from stub.cpp - and places them in your QuickBook file as virtual templates. Each of the - specially marked-up code snippets has a name (e.g. foo - and bar in the example - above). This shall be the template identifier for that particular code - snippet. The second and third line above does the actual template expansion: - - -[foo] -[bar] - - - And the result is: - - - - This is the foo - function. - - - This description can have paragraphs... - - - - lists - - - etc. - - - - And any quickbook block markup. - - - -std::string foo() -{ - // return 'em, foo man! - return "foo"; -} - - - - This is the bar - function - - - -std::string bar() -{ - // return 'em, bar man! - return "bar"; -} - - - Some trailing text here - - - - - Code - Snippet Markup - - - Note how the code snippets in stub.cpp - get marked up. We use distinguishable comments following the form: - - -//[id -some code here -//] - - - The first comment line above initiates a named code-snippet. This prefix - will not be visible in quickbook. The entire code-snippet in between //[id and //] - will be inserted as a template in quickbook with name id. - The comment //] ends a code-snippet - This too will not be visible in quickbook. - - - - Special - Comments - - - Special comments of the form: - - -//` some [*quickbook] markup here - - - and: - - -/*` some [*quickbook] markup here */ - - - will be parsed by QuickBook. This can contain quickbook blocks - (e.g. sections, paragraphs, tables, etc). In the first case, the initial - slash-slash, tick and white-space shall be ignored. In the second, the - initial slash-star-tick and the final star-slash shall be ignored. - - - - Callouts - - - Special comments of the form: - - -/*< some [*quickbook] markup here >*/ - - - will be regarded as callouts. These will be collected, numbered and rendered - as a "callout bug" (a small icon with a number). After the whole - snippet is parsed, the callout list is generated. See Callouts - for details. Example: - - - - -std::string foo_bar() -{ - return "foo-bar"; -} - - - - The Mythical FooBar. See Foobar - for details return 'em, foo-bar man! - - - - Checkout stub.cpp to see the actual - code. - -
-
-
-
- <link linkend="quickbook.install"> Installation and configuration</link> - - This section provides some guidelines on how to install and configure BoostBook - and Quickbook under several operating systems. - - - Before continuing, it is very important that you keep this in mind: if you - try to build some documents and the process breaks due to misconfiguration, - be absolutely sure to delete any bin - and bin.v2 directories generated by the build before - trying again. Otherwise your configuration fixes will not take any effect. - -
- <link linkend="quickbook.install.windows"> Windows 2000, XP, 2003, Vista</link> - - -
- - - Section contributed by Julio M. Merino Vidal - - -
- - The following instructions apply to any Windows system based on Windows 2000, - including Windows XP, Windows 2003 Server and Windows Vista. The paths shown - below are taken from a Windows Vista machine; you will need to adjust them - to match your system in case you are running an older version. - - - - First of all you need to have a copy of xsltproc - for Windows. There are many ways to get this tool, but to keep things simple, - use the binary packages - made by Igor Zlatkovic. At the very least, you need to download the following - packages: iconv, zlib, libxml2 - and libxslt. - - - Unpack all these packages in the same directory so that you get unique - bin, include - and lib directories within - the hierarchy. These instructions use C:\Users\example\Documents\boost\xml - as the root for all files. - - - From the command line, go to the bin - directory and launch xsltproc.exe - to ensure it works. You should get usage information on screen. - - - Download Docbook - XML 4.2 and unpack it in the same directory used above. That is: - C:\Users\example\Documents\boost\xml\docbook-xml. - - - Download the latest Docbook - XSL version and unpack it, again in the same directory used before. - To make things easier, rename the directory created during the extraction - to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. - - - Add the following to your user-config.jam - file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). - You must already have it somewhere or otherwise you could not be building - Boost (i.e. missing tools configuration). - - - -using xsltproc - : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe" - ; - -using boostbook - : "C:/Users/example/Documents/boost/xml/docbook-xsl" - : "C:/Users/example/Documents/boost/xml/docbook-xml" - ; - - - The above steps are enough to get a functional BoostBook setup. Quickbook - will be automatically built when needed. If you want to avoid these rebuilds: - - - - Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). - - - Build the utility by issuing bjam - --v2. - - - Copy the resulting quickbook.exe - binary (located under the BOOST_ROOT\bin.v2 hierarchy) - to a safe place. Following our previous example, you can install it into: - C:\Users\example\Documents\boost\xml\bin. - - - Add the following to your user-config.jam - file: - - - -using quickbook - : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe" - ; - -
-
- <link linkend="quickbook.install.linux"> Debian, Ubuntu</link> - - The following instructions apply to Debian and its derivatives. They are - based on a Ubuntu Edgy install but should work on other Debian based systems. - - - First install the bjam, - xsltproc, docbook-xsl and - docbook-xml packages. For example, using apt-get: - - -sudo apt-get install xsltprc docbook-xsl docbook-xml - - - If you're planning on building boost's documentation, you'll also need to - install the doxygen package - as well. - - - Next, we need to configure Boost Build to compile BoostBook files. Add the - following to your user-config.jam file, which should be in your home - directory. If you don't have one, create a file containing this text. For - more information on setting up user-config.jam, see - the Boost - Build documentation. - - -using xsltproc ; - -using boostbook - : /usr/share/xml/docbook/stylesheet/nwalsh - : /usr/share/xml/docbook/schema/dtd/4.2 - ; - -# Remove this line if you're not using doxygen -using doxygen ; - - - The above steps are enough to get a functional BoostBook setup. Quickbook - will be automatically built when needed. If you want to avoid these rebuilds: - - - - Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). - - - Build the utility by issuing bjam - --v2. - - - Copy the resulting quickbook - binary (located under the BOOST_ROOT/bin.v2 hierarchy) - to a safe place. The traditional location is /usr/local/bin. - - - Add the following to your user-config.jam - file, using the full path of the quickbook executable: - - - -using quickbook - : /usr/local/bin/quickbook - ; - -
-
-
- <link linkend="quickbook.editors"> Editor Support</link> - - Editing quickbook files is usually done with text editors both simple and powerful. - The following sections list the settings for some editors which can help make - editing quickbook files a bit easier. - - - - - - note - - You may submit your settings, tips, and suggestions to - the authors, or through the docs - Boost Docs mailing list. - - -
- <link linkend="quickbook.editors.scite"> Scintilla Text Editor</link> -
- - - Section contributed by Dean Michael Berris - - -
- - The Scintilla Text Editor (SciTE) is a free source code editor for Win32 - and X. It uses the SCIntilla source code editing component. - - - - - - tip - - SciTE can be downloaded from http://www.scintilla.org/SciTE.html - - - - You can use the following settings to highlight quickbook tags when editing - quickbook files. - - -qbk=*.qbk -lexer.*.qbk=props -use.tabs.$(qbk)=0 -tab.size.$(qbk)=4 -indent.size.$(qbk)=4 -style.props.32=$(font.base) -comment.stream.start.props=[/ -comment.stream.end.props=] -comment.box.start.props=[/ -comment.box.middle.props= -comment.box.end.props=] - - - - - - note - - Thanks to Rene Rivera for the above SciTE settings. - - -
-
-
- <link linkend="quickbook.faq"> Frequently Asked Questions</link> - - - Can - I use QuickBook for non-Boost documentation? - - - QuickBook can be used for non-Boost documentation with a little extra work. - -
- - - Faq contributed by Michael Marcin - - -
- - When building HTML documentation with BoostBook a Boost C++ Libraries header - is added to the files. When using QuickBook to document projects outside of - Boost this is not desirable. This behavior can be overridden at the BoostBook - level by specifying some XSLT options. When using Boost Build version 2 (BBv2) - this can be achieved by adding parameters to the BoostBook target declaration. - - - For example: - - -using quickbook ; - -xml my_doc : my_doc.qbk ; - -boostbook standalone - : - my_doc - : - <xsl:param>boost.image.srcimages/my_project_logo.png - <xsl:param>boost.image.alt"\"My Project\"" - <xsl:param>boost.image.w=100 - <xsl:param>boost.image.h=50 - <xsl:param>nav.layout=none - ; - -
-
- <link linkend="quickbook.ref"> Quick Reference</link> - - [cpp] - - Syntax Compendium - - - - - - To do this... - - - - Use this... - - - - See this... - - - - - - - - - comment - - - - [/ some comment] - - - - Comments - - - - - - - italics - - - - ['italics] or /italics/ - - - - Font Styles - and Simple - formatting - - - - - - - bold - - - - [*bold] or *bold* - - - - Font Styles - and Simple - formatting - - - - - - - underline - - - - [_underline] or _underline_ - - - - Font Styles - and Simple - formatting - - - - - - - teletype - - - - [^teletype] or =teletype= - - - - Font Styles - and Simple - formatting - - - - - - - strikethrough - - - - [-strikethrough] - - - - Font Styles - and Simple - formatting - - - - - - - - replaceable - - - - - [~replaceable] - - - - Replaceble - - - - - - - source mode - - - - [c++] or [python] - - - - Source Mode - - - - - - - inline code - - - - `int main();` - - - - Inline code - - - - - - - code block - - - - ``int main();`` - - - - Code - - - - - - - code escape - - - - ``from c++ to QuickBook`` - - - - Escaping Back To QuickBook - - - - - - - line break - - - - [br] or \n - - - - line-break - DEPRECATED - - - - - - - anchor - - - - [#anchor] - - - - Anchors - - - - - - - link - - - - [@http://www.boost.org Boost] - - - - Links - - - - - - - anchor link - - - - [link section.anchor Link text] - - - - Anchor links - - - - - - - refentry link - - - - [link xml.refentry Link text] - - - - refentry links - - - - - - - function link - - - - [funcref fully::qualified::function_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - class link - - - - [classref fully::qualified::class_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - member link - - - - [memberref fully::qualified::member_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - enum link - - - - [enumref fully::qualified::enum_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - macro link - - - - [macroref MACRO_NAME Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - concept link - - - - [conceptref ConceptName Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - header link - - - - [headerref path/to/header.hpp Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - escape - - - - '''escaped text (no processing/formatting)''' - - - - Escape - - - - - - - single char escape - - - - \c - - - - Single char - escape - - - - - - - images - - - - [$image.jpg] - - - - Images - - - - - - - begin section - - - - [section The Section Title] - - - - Section - - - - - - - end section - - - - [endsect] - - - - Section - - - - - - - paragraph - - - - No markup. Paragraphs start left-flushed and are terminated by two or - more newlines. - - - - Paragraphs - - - - - - - ordered list - - - - -# one -# two -# three - - - - - Ordered lists - - - - - - - unordered list - - - - -* one -* two -* three - - - - - Unordered - lists - - - - - - - code - - - - No markup. Preformatted code starts with a space or a tab. - - - - Code - - - - - - - preformatted - - - - [pre preformatted] - - - - Preformatted - - - - - - - block quote - - - - [:sometext...] - - - - Blockquote - - - - - - - heading 1 - - - - [h1 Heading 1] - - - - Heading - - - - - - - heading 2 - - - - [h2 Heading 2] - - - - Heading - - - - - - - heading 3 - - - - [h3 Heading 3] - - - - Heading - - - - - - - heading 4 - - - - [h4 Heading 4] - - - - Heading - - - - - - - heading 5 - - - - [h5 Heading 5] - - - - Heading - - - - - - - heading 6 - - - - [h6 Heading 6] - - - - Heading - - - - - - - macro - - - - [def macro_identifier some text] - - - - Macros - - - - - - - template - - - - [template[a b] [a] body [b]] - - - - Templates - - - - - - - blurb - - - - [blurb advertisement or note...] - - - - Blurbs - - - - - - - admonition - - - - [warning Warning text...] - - - - Admonitions - - - - - - - table - - - - -[table Title -[[a][b][c]] -[[a][b][c]] -] - - - - - Tables - - - - - - - variablelist - - - - -[variablelist Title -[[a][b]] -[[a][b]] -] - - - - - Variable Lists - - - - - - - include - - - - [include someother.qbk] - - - - Include - - - - - -
-
-
+ + +
+ + + + Joel de Guzman + + + Eric Niebler + + + + 2002 2004 2006 Joel de Guzman, + Eric Niebler + + + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + + + WikiWiki style documentation tool + + + Quickbook 1.4 +
+ <link linkend="quickbook.intro"> Introduction</link> +
+ + + Why program by hand in five days + what you can spend five years of your life automating? + + + -- Terrence Parr, author ANTLR/PCCTS + + +
+ + Well, QuickBook started as a weekend hack. It was originally intended to be + a sample application using Spirit. + What is it? What you are viewing now, this documentation, is autogenerated + by QuickBook. These files were generated from one master: + +
+ + + quickbook.qbk + + +
+ + Originally named QuickDoc, this funky tool that never dies evolved into a funkier + tool thanks to Eric Niebler who resurrected the project making it generate + BoostBook + instead of HTML. The BoostBook + documentation format is an extension of DocBook, + an SGML or XML based format for describing documentation. + + + QuickBook is a WikiWiki style documentation tool geared towards C++ documentation + using simple rules and markup for simple formatting tasks. QuickBook extends + the WikiWiki concept. Like the WikiWiki, QuickBook documents are simple text + files. A single QuickBook document can generate a fully linked set of nice + HTML and PostScript/PDF documents complete with images and syntax- colorized + source code. + + + Features include: + + + + generate BoostBook + xml, to generate HTML, PostScript and PDF + + + simple markup to link to Doxygen-generated entities + + + macro system for simple text substitution + + + simple markup for italics, bold, preformatted, blurbs, code samples, tables, + URLs, anchors, images, etc. + + + automatic syntax coloring of code samples + + + CSS support + + +
+
+ <link linkend="quickbook.change_log"> Change Log</link> + + Version 1.3 + + + + Quickbook file inclusion [include]. + + + Better xml output (pretty layout). Check out the generated XML. + + + Regression testing facility: to make sure your document will always be compatible + (full backward compatibility) regardless of changes to QuickBook. + + + Code cleanup and refactoring. + + + Allow phrase markup in the doc-info. + + + Preformatted code blocks via ``code`` (double ticks) allows code in tables + and lists, for example. + + + Quickbook versioning; allows full backward compatibility. You have to add + [quickbook 1.3] to the doc-info header to enable the new features. Without + this, QuickBook will assume that the document is a pre-1.3 document. + + + Better (intuitive) paragraph termination. Some markups may terminate a paragraph. + Example: +[section x] +blah... +[endsect] + + + Fully qualified section and headers. Subsection names are concatenated to + the ID to avoid clashing. Example: doc_name.sect_name.sub_sect_name.sub_sub_sect_name + + + Better &nbsp; and whitespace handling in code snippets. + + + [xinclude] fixes up the relative path to the target XML file when input_directory + is not the same as the output_directory. + + + Allow untitled tables. + + + Allow phrase markups in section titles. + + + Allow escaping back to QuickBook from code, code blocks and inline code. + + + Footnotes, with the [footnote This is the footnote] syntax. + + + Post-processor bug fix for escaped XML code that it does not recognize. + + + Replaceable, with the [~replacement] syntax. + + + Generic Headers + + + Code changes to allow full recursion (i.e. Collectors and push/pop functions) + + + Various code cleanup/maintenance + + + Templates! + + + [conceptref] for referencing BoostBook <concept> entities. + + + Allow escape of spaces. The escaped space is removed from the output. Syntax: + \ . + + + Nested comments are now allowed. + + + Quickbook blocks can nest inside comments. + + + Import facility. + + + Callouts on imported code + + + Simple markups can now span a whole block. + + + Blurbs, Admonitions + and table cells (see Tables) + may now contain paragraphs. + + + \n + and [br] are now deprecated. + + +
+
+ <link linkend="quickbook.syntax"> Syntax Summary</link> + + A QuickBook document is composed of one or more blocks. An example of a block + is the paragraph or a C++ code snippet. Some blocks have special mark-ups. + Blocks, except code snippets which have their own grammar (C++ or Python), + are composed of one or more phrases. A phrase can be a simple contiguous run + of characters. Phrases can have special mark-ups. Marked up phrases can recursively + contain other phrases, but cannot contain blocks. A terminal is a self contained + block-level or phrase-level element that does not nest anything. + + + Blocks, in general, are delimited by two end-of-lines (the block terminator). + Phrases in each block cannot contain a block terminator. This way, syntax errors + such as un-matched closing brackets do not go haywire and corrupt anything + past a single block. + +
+ <link linkend="quickbook.syntax.comments">Comments</link> + + Can be placed anywhere. + + +[/ comment (no output generated) ] + + +[/ comments can be nested [/ some more here] ] + + +[/ Quickbook blocks can nest inside comments. [*Comment this out too!] ] + +
+
+ <link linkend="quickbook.syntax.phrase"> Phrase Level Elements</link> +
+ <link linkend="quickbook.syntax.phrase.font_styles">Font Styles</link> + +['italic], [*bold], [_underline], [^teletype], [-strikethrough] + + + will generate: + + + italic, bold, underline, teletype, strikethrough + + + Like all non-terminal phrase level elements, this can of course be nested: + + +[*['bold-italic]] + + + will generate: + + + bold-italic + +
+
+ <link linkend="quickbook.syntax.phrase.replaceable">Replaceable</link> + + When you want content that may or must be replaced by the user, use the + syntax: + + +[~replacement] + + + This will generate: + + + + replacement + + +
+
+ <link linkend="quickbook.syntax.phrase.quotations">Quotations</link> + +["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein + + + will generate: + + + A question that sometimes drives me hazy: am I or are the others + crazy?--Einstein + + + Note the proper left and right quote marks. Also, while you can simply + use ordinary quote marks like "quoted", our quotation, above, + will generate correct DocBook quotations (e.g. <quote>quoted</quote>). + + + Like all phrase elements, quotations may be nested. Example: + + +["Here's the rule for bargains: ["Do other men, for they would do you.] That's +the true business precept.] + + + will generate: + + + Here's the rule for bargains: Do other men, for they would + do you. That's the true business precept. + +
+
+ <link linkend="quickbook.syntax.phrase.simple_formatting">Simple formatting</link> + + Simple markup for formatting text, common in many applications, is now + supported: + + +/italic/, *bold*, _underline_, =teletype= + + + will generate: + + + italic, bold, underline, teletype + + + Unlike QuickBook's standard formatting scheme, the rules for simpler alternatives + are much stricter + + + Thanks to David Barrett, author of Qwiki, + for sharing these samples and teaching me these obscure formatting + rules. I wasn't sure at all if Spirit, + being more or less a formal EBNF parser, can handle the context sensitivity + and ambiguity. + + + . + + + + Simple markups cannot nest. You can combine a simple markup with a nestable + markup. + + + Simple markups cannot contain any other form of quickbook markup. + + + A non-space character must follow the leading markup + + + A non-space character must precede the trailing markup + + + A space or a punctuation must follow the trailing markup + + + If the matching markup cannot be found within a block, the formatting + will not be applied. This is to ensure that un-matched formatting markups, + which can be a common mistake, does not corrupt anything past a single + block. We do not want the rest of the document to be rendered bold just + because we forgot a trailing '*'. A single block is terminated by two + end of lines or the close bracket: ']'. + + + A line starting with the star will be interpreted as an unordered list. + See Unordered + lists. + + + More Formatting Samples + + + + + + Markup + + + + Result + + + + + + + + + *Bold* + + + + Bold + + + + + + + *Is bold* + + + + Is bold + + + + + + + * Not bold* *Not bold * * Not bold * + + + + * Not bold* *Not bold * * Not bold * + + + + + + + This*Isn't*Bold (no bold) + + + + This*Isn't*Bold (no bold) + + + + + + + (*Bold Inside*) (parenthesis not bold) + + + + (Bold Inside) (parenthesis not bold) + + + + + + + *(Bold Outside)* (parenthesis bold) + + + + (Bold Outside) (parenthesis bold) + + + + + + + 3*4*5 = 60 (no bold) + + + + 3*4*5 = 60 (no bold) + + + + + + + 3 * 4 * 5 = 60 (no bold) + + + + 3 * 4 * 5 = 60 (no bold) + + + + + + + 3 *4* 5 = 60 (4 is bold) + + + + 3 4 5 = 60 (4 is bold) + + + + + + + *This is bold* this is not *but this is* + + + + This is bold this is not but this is + + + + + + + *This is bold*. + + + + This is bold. + + + + + + + *B*. (bold B) + + + + B. (bold B) + + + + + + + ['*Bold-Italic*] + + + + Bold-Italic + + + + + + + *side-by*/-side/ + + + + side-by-side + + + + + +
+ + As mentioned, simple markups cannot go past a single block. The text from + "have" to "full" in the following paragraph will be + rendered as bold: + + +Baa baa black sheep, *have you any wool? +Yes sir, yes sir, three bags full!* +One for the master, one for the dame, +And one for the little boy who lives down the lane. + + + Baa baa black sheep, have you any wool? Yes sir, + yes sir, three bags full! One for the master, one for the dame, + And one for the little boy who lives down the lane. + + + But in the following paragraph, bold is not applied: + + +Baa baa black sheep, *have you any wool? +Yes sir, yes sir, three bags full! +One for the master, one for the dame, +And one for the little boy who lives down the lane. + + + Baa baa black sheep, *have you any wool? Yes sir, yes sir, three bags full! + One for the master, one for the dame, And one for the little boy who lives + down the lane. + +
+
+ <link linkend="quickbook.syntax.phrase.inline_code">Inline code</link> + + Inlining code in paragraphs is quite common when writing C++ documentation. + We provide a very simple markup for this. For example, this: + + +This text has inlined code `int main() { return 0; }` in it. + + + will generate: + + + This text has inlined code int main() { return 0; } + in it. The code will be syntax highlighted. + + + + We simply enclose the code with the tick: "`", not the + single quote: "'". + Note too that `some code` is preferred over [^some code]. + + +
+
+ <link linkend="quickbook.syntax.phrase.code_blocks">Code blocks</link> + + Preformatted code simply starts with a space or a tab (See Code). + However, such a simple syntax cannot be used as phrase elements in lists + (See Ordered + lists and Unordered + lists), tables (See Tables), + etc. Inline code (see above) can. The problem is, inline code does not + allow formatting with newlines, spaces, and tabs. These are lost. + + + We provide a phrase level markup that is a mix between the two. By using + the double-tick, instead of the single-tick, we are telling QuickBook to + use preformatted blocks of code. Example: + + +`` + #include <iostream> + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } +`` + + + will generate: + + + +#include <iostream> + +int main() +{ + std::cout << "Hello, World!" << std::endl; + return 0; +} + + +
+
+ <link linkend="quickbook.syntax.phrase.source_mode">Source Mode</link> + + If a document contains more than one type of source code then the source + mode may be changed dynamically as the document is processed. All QuickBook + documents are initially in C++ mode by default, though an alternative initial + value may be set in the Document + section. + + + To change the source mode, use the [source-mode] markup, + where source-mode is one of the supported modes. For + example, this: + + +Python's [python] `import` is rather like C++'s [c++] `#include`. A +C++ comment `// looks like this` whereas a Python comment [python] +`# looks like this`. + + + will generate: + + + Python's import is rather + like C++'s #include. + A C++ comment // looks like this + whereas a Python comment #looks like this. + + Supported Source Modes + + + + + + Mode + + + + Source Mode Markup + + + + + + + + + C++ + + + + [c++] + + + + + + + Python + + + + [python] + + + + + +
+ + + The source mode strings are lowercase. + + +
+
+ <link linkend="quickbook.syntax.phrase.line_break">line-break</link> + +[br] + + + + [br] is now deprecated. Blurbs, + Admonitions + and table cells (see Tables) + may now contain paragraphs. + + +
+
+ <link linkend="quickbook.syntax.phrase.anchors">Anchors</link> + +[#named_anchor] + + + A named anchor is a hook that can be referenced by a link elsewhere in + the document. You can then reference an anchor with [link named_anchor +Some link text]. + See Anchor links, + Section and Heading. + +
+ + + + +
+ <link linkend="quickbook.syntax.phrase.escape">Escape</link> + + The escape mark-up is used when we don't want to do any processing. + + +''' +escape (no processing/formatting) +''' + + + Escaping allows us to pass XML markup to BoostBook + or DocBook. For example: + + +''' +<emphasis role="bold">This is direct XML markup</emphasis> +''' + + + This is direct XML markup + + + + Be careful when using the escape. The text must conform to BoostBook/DocBook syntax. + + +
+
+ <link linkend="quickbook.syntax.phrase.single_char_escape">Single + char escape</link> + + The backslash may be used to escape a single punctuation character. The + punctuation immediately after the backslash is passed without any processing. + This is useful when we need to escape QuickBook punctuations such as [ and ]. + For example, how do you escape the triple quote? Simple: \'\'\' + + + \n + has a special meaning. It is used to generate line breaks. + + + + \n + and [br] are now deprecated. Blurbs, + Admonitions + and table cells (see Tables) + may now contain paragraphs. + + + + The escaped space: \ also + has a special meaning. The escaped space is removed from the output. + +
+
+ <link linkend="quickbook.syntax.phrase.images">Images</link> + +[$image.jpg] + +
+
+ <link linkend="quickbook.syntax.phrase.footnotes">Footnotes</link> + + As of version 1.3, QuickBook supports footnotes. Just put the text of the + footnote in a [footnote] block, and the text will be put at the + bottom of the current page. For example, this: + + +[footnote A sample footnote] + + + will generate this + + + A sample footnote + + + . + +
+ <link linkend="quickbook.syntax.phrase.footnotes.macro_expansion">Macro + Expansion</link> +__a_macro_identifier__ + + + See Macros for details. + +
+
+ <link linkend="quickbook.syntax.phrase.footnotes.template_expansion">Template + Expansion</link> +[a_template_identifier] + + + See Templates + for details. + +
+
+
+
+ <link linkend="quickbook.syntax.block"> Block Level Elements</link> +
+ <link linkend="quickbook.syntax.block.document">Document</link> + + Every document must begin with a Document Info section, which should look + like this: + + +[document-type The Document Title + [quickbook 1.3] + [version 1.0] + [id the_document_name] + [dirname the_document_dir] + [copyright 2000 2002 2003 Joe Blow, Jane Doe] + [purpose The document's reason for being] + [category The document's category] + [authors [Blow, Joe], [Doe, Jane]] + [license The document's license] + [source-mode source-type] +] + + + Where document-type is one of: + + + + book + + + article + + + library + + + chapter + + + part + + + appendix + + + preface + + + qandadiv + + + qandaset + + + reference + + + set + + + + quickbook 1.3 declares the version of quickbook the document is written + for. In its absence, version 1.1 is assumed. + + + version, id, dirname, + copyright, purpose, category, + authors, license, last-revision + and source-mode are optional information. + + + source-type is a lowercase string setting the initial + Source Mode. + If the source-mode field is omitted, a default value + of c++ will be used. + +
+
+ <link linkend="quickbook.syntax.block.section">Section</link> + + Starting a new section is accomplished with: + + +[section:id The Section Title] + + + where id is optional. id will be the filename of the + generated section. If it is not present, "The Section Title" + will be normalized and become the id. Valid characters are a-Z, + A-Z, 0-9 and _. + All non-valid characters are converted to underscore and all upper-case + are converted to lower case. Thus: "The Section Title" will be + normalized to "the_section_title". + + + End a section with: + + +[endsect] + + + Sections can nest, and that results in a hierarchy in the table of contents. + +
+
+ <link linkend="quickbook.syntax.block.xinclude">xinclude</link> + + You can include another XML file with: + + +[xinclude file.xml] + + + This is useful when file.xml has been generated by Doxygen and contains + your reference section. + +
+
+ <link linkend="quickbook.syntax.block.paragraphs">Paragraphs</link> + + Paragraphs start left-flushed and are terminated by two or more newlines. + No markup is needed for paragraphs. QuickBook automatically detects paragraphs + from the context. Block markups [section, endsect, h1, h2, h3, h4, h5, + h6, blurb, (block-quote) ':', pre, def, table and include ] may also terminate + a paragraph. + +
+
+ <link linkend="quickbook.syntax.block.lists">Lists</link> +
+ <link linkend="quickbook.syntax.block.lists.ordered_lists">Ordered + lists</link> +# One +# Two +# Three + + + will generate: + + + + One + + + Two + + + Three + + +
+
+ <link linkend="quickbook.syntax.block.lists.list_hierarchies">List + Hierarchies</link> + + List hierarchies are supported. Example: + + +# One +# Two +# Three + # Three.a + # Three.b + # Three.c +# Four + # Four.a + # Four.a.i + # Four.a.ii +# Five + + + will generate: + + + + One + + + Two + + + Three + + + Three.a + + + Three.b + + + Three.c + + + + + Fourth + + + Four.a + + + Four.a.i + + + Four.a.ii + + + + + + + Five + + +
+
+ <link linkend="quickbook.syntax.block.lists.long_list_lines">Long + List Lines</link> + + Long lines will be wrapped appropriately. Example: + + +# A short item. +# A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. +# A short item. + + + + A short item. + + + A very long item. A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + + + A short item. + + +
+
+ <link linkend="quickbook.syntax.block.lists.unordered_lists">Unordered + lists</link> +* First +* Second +* Third + + + will generate: + + + + First + + + Second + + + Third + + +
+
+ <link linkend="quickbook.syntax.block.lists.mixed_lists">Mixed lists</link> + + Mixed lists (ordered and unordered) are supported. Example: + + +# One +# Two +# Three + * Three.a + * Three.b + * Three.c +# Four + + + will generate: + + + + One + + + Two + + + Three + + + Three.a + + + Three.b + + + Three.c + + + + + Four + + + + And... + + +# 1 + * 1.a + # 1.a.1 + # 1.a.2 + * 1.b +# 2 + * 2.a + * 2.b + # 2.b.1 + # 2.b.2 + * 2.b.2.a + * 2.b.2.b + + + will generate: + + + + 1 + + + 1.a + + + 1.a.1 + + + 1.a.2 + + + + + 1.b + + + + + 2 + + + 2.a + + + 2.b + + + 2.b.1 + + + 2.b.2 + + + 2.b.2.a + + + 2.b.2.b + + + + + + + + +
+
+
+ <link linkend="quickbook.syntax.block.code">Code</link> + + Preformatted code starts with a space or a tab. The code will be syntax + highlighted according to the current Source + Mode: + + + + +#include <iostream> + +int main() +{ + // Sample code + std::cout << "Hello, World\n"; + return 0; +} + + + + +import cgi + +def cookForHtml(text): + '''"Cooks" the input text for HTML.''' + + return cgi.escape(text) + + + + + Macros that are already defined are expanded in source code. Example: + + +[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] +[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] + + using __boost__::__array__; + + + Generates: + + +using boost::array; + +
+
+ <link linkend="quickbook.syntax.block.escape_back"> Escaping Back + To QuickBook</link> + + Inside code, code blocks and inline code, QuickBook does not allow any + markup to avoid conflicts with the target syntax (e.g. c++). In case you + need to switch back to QuickBook markup inside code, you can do so using + a language specific escape-back delimiter. In C++ + and Python, the delimiter is the double tick (back-quote): "``" + and "``". Example: + + +void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() +{ +} + + + Will generate: + + +void foo() +{ +} + + + When escaping from code to QuickBook, only phrase level markups are allowed. + Block level markups like lists, tables etc. are not allowed. + +
+
+ <link linkend="quickbook.syntax.block.preformatted">Preformatted</link> + + Sometimes, you don't want some preformatted text to be parsed as C++. In + such cases, use the [pre ... ] markup block. + + +[pre + + Some *preformatted* text Some *preformatted* text + + Some *preformatted* text Some *preformatted* text + + Some *preformatted* text Some *preformatted* text + +] + + + Spaces, tabs and newlines are rendered as-is. Unlike all quickbook block + level markup, pre (and Code) are the only ones that allow multiple newlines. + The markup above will generate: + + +Some preformatted text Some preformatted text + + Some preformatted text Some preformatted text + + Some preformatted text Some preformatted text + + + + Notice that unlike Code, phrase markup such as font style is still permitted + inside pre blocks. + +
+
+ <link linkend="quickbook.syntax.block.blockquote">Blockquote</link> + +[:sometext...] + +
+ + + Indents the paragraph. This applies to one paragraph only. + + +
+
+
+ <link linkend="quickbook.syntax.block.admonitions">Admonitions</link> + +[note This is a note] +[tip This is a tip] +[important This is important] +[caution This is a caution] +[warning This is a warning] + + + generates DocBook admonitions: + + + + This is a note + + + + + This is a tip + + + + + This is important + + + + + This is a caution + + + + + This is a warning + + + + These are the only admonitions supported by DocBook. + So, for example [information This is some information] + is unlikely to produce the desired effect. + +
+
+ <link linkend="quickbook.syntax.block.headings">Headings</link> + +[h1 Heading 1] +[h2 Heading 2] +[h3 Heading 3] +[h4 Heading 4] +[h5 Heading 5] +[h6 Heading 6] + + + + Heading 1 + + + + Heading 2 + + + + Heading 3 + + + + Heading 4 + + + + Heading 5 + + + + Heading 6 + + + Headings 1-3 [h1 h2 and h3] will automatically have anchors with normalized + names with name="section_id.normalized_header_text" + (i.e. valid characters are a-z, A-Z, + 0-9 and _. All non-valid characters + are converted to underscore and all upper-case are converted to lower-case. + For example: Heading 1 in section Section 2 will be normalized to section_2.heading_1). + You can use: + + +[link section_id.normalized_header_text The link text] + + + to link to them. See Anchor + links and Section + for more info. + +
+
+ <link linkend="quickbook.syntax.block.generic_heading">Generic Heading</link> + + In cases when you don't want to care about the heading level (1 to 6), + you can use the Generic Heading: + + +[heading Heading] + + + The Generic Heading assumes the level, plus one, of + the innermost section where it is placed. For example, if it is placed + in the outermost section, then, it assumes h2. + + + Headings are often used as an alternative to sections. It is used particularly + if you do not want to start a new section. In many cases, however, headings + in a particular section is just flat. Example: + + +[section A] +[h2 X] +[h2 Y] +[h2 Z] +[endsect] + + + Here we use h2 assuming that section A is the outermost level. If it is + placed in an inner level, you'll have to use h3, h4, etc. depending on + where the section is. In general, it is the section level plus one. It + is rather tedious, however, to scan the section level everytime. If you + rewrite the example above as shown below, this will be automatic: + + +[section A] +[heading X] +[heading Y] +[heading Z] +[endsect] + + + They work well regardless where you place them. You can rearrange sections + at will without any extra work to ensure correct heading levels. In fact, + with section and heading, you + have all you need. h1..h6 becomes + redundant. h1..h6 might be deprecated + in the future. + +
+
+ <link linkend="quickbook.syntax.block.macros">Macros</link> + +[def macro_identifier some text] + + + When a macro is defined, the identifier replaces the text anywhere in the + file, in paragraphs, in markups, etc. macro_identifier is a string of non- + white space characters except ']'. A macro may not follow an alphabetic + character or the underscore. The replacement text can be any phrase (even + marked up). Example: + + +[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] +sf_logo + + + Now everywhere the sf_logo is placed, the picture will be inlined. + + + + + sflogo + + + + + + It's a good idea to use macro identifiers that are distinguishable. For + instance, in this document, macro identifiers have two leading and trailing + underscores (e.g. __spirit__). The reason is to avoid unwanted + macro replacement. + + + + Links (URLS) and images are good candidates for macros. 1) + They tend to change a lot. It is a good idea to place all links and images + in one place near the top to make it easy to make changes. 2) + The syntax is not pretty. It's easier to read and write, e.g. __spirit__ + than [@http://spirit.sourceforge.net Spirit]. + + + Some more examples: + + +[def :-) [$theme/smiley.png]] +[def __spirit__ [@http://spirit.sourceforge.net Spirit]] + + + (See Images and + Links) + + + Invoking these macros: + + +Hi __spirit__ :-) + + + will generate this: + + + Hi Spirit + + smiley + + + +
+
+ <link linkend="quickbook.syntax.block.predefined_macros">Predefined + Macros</link> + + Quickbook has some predefined macros that you can already use. + + Predefined Macros + + + + + + Macro + + + + Meaning + + + + Example + + + + + + + + + __DATE__ + + + + Today's date + + + + 2000-Dec-20 + + + + + + + __TIME__ + + + + The current time + + + + 12:00:00 PM + + + + + + + __FILENAME__ + + + + Quickbook source filename + + + + NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE + + + + + +
+
+
+ <link linkend="quickbook.syntax.block.templates">Templates</link> + + Templates provide a more versatile text substitution mechanism. Templates + come in handy when you need to create parameterizable, multi-line, boilerplate + text that you specify once and expand many times. Templates accept one + or more arguments. These arguments act like place-holders for text replacement. + Unlike simple macros, which are limited to phrase level markup, templates + can contain block level markup (e.g. paragraphs, code blocks and tables). + + + Example template: + + +[template person[name age what] + +Hi, my name is [name]. I am [age] years old. I am a [what]. + +] + + + + Template + Identifier + + + Template identifiers can either consist of: + + + + An initial alphabetic character or the underscore, followed by zero or + more alphanumeric characters or the underscore. This is similar to your + typical C/C++ identifier. + + + A single character punctuation (a non-alphanumeric printable character) + + + + + Formal + Template Arguments + + + Template formal arguments are identifiers consisting of an initial alphabetic + character or the underscore, followed by zero or more alphanumeric characters + or the underscore. This is similar to your typical C/C++ identifier. + + + A template formal argument temporarily hides a template of the same name + at the point where the template + is expanded. Note that the body of the person + template above refers to name age + and what as [name] [age] + and [what]. name age + and what are actually templates that exist in the duration + of the template call. + + + + Template + Body + + + The template body can be just about any QuickBook block or phrase. There + are actually two forms. Templates may be phrase or block level. Phrase + templates are of the form: + + +[template sample[arg1 arg2...argN] replacement text... ] + + + Block templates are of the form: + + +[template sample[arg1 arg2...argN] +replacement text... +] + + + The basic rule is as follows: if a newline immediately follows the argument + list, then it is a block template, otherwise, it is a phrase template. + Phrase templates are typically expanded as part of phrases. Like macros, + block level elements are not allowed in phrase templates. + + + + Template + Expansion + + + You expand a template this way: + + +[template_identifier arg1..arg2..arg3] + + + At template expansion, you supply the actual arguments. The template will + be expanded with your supplied arguments. Example: + + +[person James Bond..39..Spy] +[person Santa Clause..87..Big Red Fatso] + + + Which will expand to: + + + + Hi, my name is James Bond. I am 39 years old. I am a Spy. + + + Hi, my name is Santa Clause. I am 87 years old. I am a Big Red Fatso. + + + + + A word of caution: Templates are recursive. A template can call another + template or even itself, directly or indirectly. There are no control + structures in QuickBook (yet) so this will always mean infinite recursion. + QuickBook can detect this situation and report an error if recursion + exceeds a certain limit. + + + + Each actual argument can be a word, a text fragment or just about any + QuickBook phrase. Arguments + are separated by the double dot ".." and terminated + by the close parenthesis. + + + + Nullary + Templates + + + Nullary templates look and act like simple macros. Example: + + +[template alpha[]'''&#945;'''] +[template beta[]'''&#946;'''] + + + Expanding: + + +Some squigles...[*[alpha][beta]] + + We have: + + + Some squiggles...αβ + + + The difference with macros are + + + + The explicit template + expansion syntax. This is an advantage because, now, we don't + have to use obscure naming conventions like double underscores (e.g. + __alpha__) to avoid unwanted macro replacement. + + + The template is expanded at the point where it is invoked. A macro is + expanded immediately at its point of declaration. This is subtle and + can cause a slight difference in behavior especially if you refer to + other macros and templates in the body. + + + + The empty brackets after the template identifier (alpha[]) + indicates no arguments. If the template body does not look like a template + argument list, we can elide the empty brackets. Example: + + +[template aristotle_quote Aristotle: [*['Education is the best provision +for the journey to old age.]]] + + + Expanding: + + +Here's a quote from [aristotle_quote]. + + + We have: + + + Here's a quote from Aristotle: Education + is the best provision for the journey to old age.. + + + The disadvantage is that you can't avoid the space between the template + identifier, aristotle_quote, + and the template body "Aristotle...". This space will be part + of the template body. If that space is unwanted, use empty brackets or + use the space escape: "\ ". + Example: + + +[template tag\ _tag] + + + Then expanding: + + +`struct` x[tag]; + + + We have: + + + struct x_tag; + + + You have a couple of ways to do it. I personally prefer the explicit empty + brackets, though. + + + + Simple + Arguments + + + As mentioned, arguments are separated by the double dot "..". + If there are less arguments passed than expected, QuickBook attempts to + break the last argument into two or more arguments following this logic: + + + + Break the last argument into two, at the first space found ('', + '\n', \t' or '\r'). + + + Repeat until there are enough arguments or if there are no more spaces + found (in which case, an error is reported). + + + + For example: + + +[template simple[a b c d] [a][b][c][d]] +[simple w x y z] + + + will produce: + + + wxyz + + + "w x y z" is initially treated as a single argument because we + didn't supply any ".." separators. However, + since simple expects 4 arguments, "w x y z" + is broken down iteratively (applying the logic above) until we have "w", + "x", "y" and "z". + + + QuickBook only tries to get the arguments it needs. For example: + + +[simple w x y z trail] + + + will produce: + + + wxyz trail + + + The arguments being: "w", "x", "y" and "z + trail". + + + It should be obvious now that for simple arguments with no spaces, we can + get by without separating the arguments with ".." + separators. It is possible to combine ".." + separators with the argument passing simplification presented above. Example: + + +[simple what do you think ..m a n?] + + + will produce: + + + what do you think man? + + + + Punctuation + Templates + + + With templates, one of our objectives is to allow us to rewrite QuickBook + in QuickBook (as a qbk library). For that to happen, we need to accommodate + single character punctuation templates which are fairly common in QuickBook. + You might have noticed that single character punctuations are allowed as + template + identifiers. Example: + + +[template ![bar] <hey>[bar]</hey>] + + + Now, expanding this: + + +[!baz] + + + We will have: + + +<hey>baz</hey> + +
+
+ <link linkend="quickbook.syntax.block.blurbs">Blurbs</link> + +[blurb :-) [*An eye catching advertisement or note...] + + __spirit__ is an object-oriented recursive-descent parser generator framework + implemented using template meta-programming techniques. Expression templates + allow us to approximate the syntax of Extended Backus-Normal Form (EBNF) + completely in C++. +] + + + will generate this: + + + + + + smiley + + An eye catching advertisement + or note... + + + Spirit is an object-oriented + recursive-descent parser generator framework implemented using template + meta-programming techniques. Expression templates allow us to approximate + the syntax of Extended Backus-Normal Form (EBNF) completely in C++. + + + + + Prefer admonitions + wherever appropriate. + + +
+
+ <link linkend="quickbook.syntax.block.tables">Tables</link> + +[table A Simple Table + [[Heading 1] [Heading 2] [Heading 3]] + [[R0-C0] [R0-C1] [R0-C2]] + [[R1-C0] [R1-C1] [R1-C2]] + [[R2-C0] [R2-C1] [R2-C2]] +] + + + will generate: + + A Simple Table + + + + + + Heading 1 + + + + Heading 2 + + + + Heading 3 + + + + + + + + + R0-C0 + + + + R0-C1 + + + + R0-C2 + + + + + + + R2-C0 + + + + R2-C1 + + + + R2-C2 + + + + + + + R3-C0 + + + + R3-C1 + + + + R3-C2 + + + + + +
+ + The table title is optional. The first row of the table is automatically + treated as the table header; that is, it is wrapped in <thead>...</thead> + XML tags. Note that unlike the original QuickDoc, the columns are nested + in [ cells... ]. The syntax is free-format and allows big cells to be formatted + nicely. Example: + + +[table Table with fat cells + [[Heading 1] [Heading 2]] + [ + [Row 0, Col 0: a small cell] + [ + Row 0, Col 1: a big fat cell with paragraphs + + Boost provides free peer-reviewed portable C++ source libraries. + + We emphasize libraries that work well with the C++ Standard Library. + Boost libraries are intended to be widely useful, and usable across + a broad spectrum of applications. The Boost license encourages both + commercial and non-commercial use. + ] + ] + [ + [Row 1, Col 0: a small cell] + [Row 1, Col 1: a small cell] + ] +] + + + and thus: + + Table with fat cells + + + + + + Heading 1 + + + + Heading 2 + + + + + + + + + Row 0, Col 0: a small cell + + + + Row 0, Col 1: a big fat cell with paragraphs + + + Boost provides free peer-reviewed portable C++ source libraries. + + + We emphasize libraries that work well with the C++ Standard Library. + Boost libraries are intended to be widely useful, and usable across + a broad spectrum of applications. The Boost license encourages both + commercial and non-commercial use. + + + + + + + Row 1, Col 0: a small cell + + + + Row 1, Col 1: a small cell + + + + + +
+ + Here's how to have preformatted blocks of code in a table cell: + + +[table Table with code + [[Comment] [Code]] + [ + [My first program] + [`` + #include <iostream> + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } + ``] + ] +] + + Table with code + + + + + + Comment + + + + Code + + + + + + + + + My first program + + + + +#include <iostream> + +int main() +{ + std::cout << "Hello, World!" << std::endl; + return 0; +} + + + + + + +
+
+
+ <link linkend="quickbook.syntax.block.variable_lists">Variable Lists</link> + +[variablelist A Variable List + [[term 1] [The definition of term 1]] + [[term 2] [The definition of term 2]] + [[term 3] [The definition of term 3]] +] + + + will generate: + + + A Variable List term 1 + + + The definition of term 1 + + + term 2 + + + The definition of term 2 + + + term 3 + + + The definition of term 3 + + + + + + The rules for variable lists are the same as for tables, except that only + 2 "columns" are allowed. The first column contains the terms, + and the second column contains the definitions. Those familiar with HTML + will recognize this as a "definition list". + +
+
+ <link linkend="quickbook.syntax.block.include">Include</link> + + You can include one QuickBook file from another. The syntax is simply: + + +[include someother.qbk] + + + The included file will be processed as if it had been cut and pasted into + the current document, with the following exceptions: + + + + The __FILENAME__ predefined macro will reflect the name of the file currently being + processed. + + + Any macros defined in the included file are scoped to that file. + + + + The [include] directive lets you specify a document + id to use for the included file. When this id is not explicitly specified, + the id defaults to the filename ("someother", in the example + above). You can specify the id like this: + + +[include:someid someother.qbk] + + + All auto-generated anchors will use the document id as a unique prefix. + So for instance, if there is a top section in someother.qbk named "Intro", + the named anchor for that section will be "someid.intro", and + you can link to it with [link someid.intro The Intro]. + +
+
+ <link linkend="quickbook.syntax.block.import">Import</link> + + When documenting code, you'd surely need to present code from actual source + files. While it is possible to copy some code and paste them in your QuickBook + file, doing so is error prone and the extracted code in the documentation + tends to get out of sync with the actual code as the code evolves. The + problem, as always, is that once documentation is written, the tendency + is for the docs to languish in the archives without maintenance. + + + QuickBook's import facility provides a nice solution. + + + + Example + + + You can effortlessly import code snippets from source code into your QuickBook. + The following illustrates how this is done: + + +[import ../test/stub.cpp] +[foo] +[bar] + + + The first line: + + +[import ../test/stub.cpp] + + + collects specially marked-up code snippets from stub.cpp + and places them in your QuickBook file as virtual templates. Each of the + specially marked-up code snippets has a name (e.g. foo + and bar in the example + above). This shall be the template identifier for that particular code + snippet. The second and third line above does the actual template expansion: + + +[foo] +[bar] + + + And the result is: + + + + This is the foo + function. + + + This description can have paragraphs... + + + + lists + + + etc. + + + + And any quickbook block markup. + + + +std::string foo() +{ + // return 'em, foo man! + return "foo"; +} + + + + This is the bar + function + + + +std::string bar() +{ + // return 'em, bar man! + return "bar"; +} + + + Some trailing text here + + + + + Code + Snippet Markup + + + Note how the code snippets in stub.cpp + get marked up. We use distinguishable comments following the form: + + +//[id +some code here +//] + + + The first comment line above initiates a named code-snippet. This prefix + will not be visible in quickbook. The entire code-snippet in between //[id and //] + will be inserted as a template in quickbook with name id. + The comment //] ends a code-snippet + This too will not be visible in quickbook. + + + + Special + Comments + + + Special comments of the form: + + +//` some [*quickbook] markup here + + + and: + + +/*` some [*quickbook] markup here */ + + + will be parsed by QuickBook. This can contain quickbook blocks + (e.g. sections, paragraphs, tables, etc). In the first case, the initial + slash-slash, tick and white-space shall be ignored. In the second, the + initial slash-star-tick and the final star-slash shall be ignored. + + + + Callouts + + + Special comments of the form: + + +/*< some [*quickbook] markup here >*/ + + + will be regarded as callouts. These will be collected, numbered and rendered + as a "callout bug" (a small icon with a number). After the whole + snippet is parsed, the callout list is generated. See Callouts + for details. Example: + + + + +std::string foo_bar() +{ + return "foo-bar"; +} + + + + The Mythical FooBar. See Foobar + for details return 'em, foo-bar man! + + + + Checkout stub.cpp to see the actual + code. + +
+
+
+
+ <link linkend="quickbook.install"> Installation and configuration</link> + + This section provides some guidelines on how to install and configure BoostBook + and Quickbook under several operating systems. + + + Before continuing, it is very important that you keep this in mind: if you + try to build some documents and the process breaks due to misconfiguration, + be absolutely sure to delete any bin + and bin.v2 directories generated by the build before + trying again. Otherwise your configuration fixes will not take any effect. + +
+ <link linkend="quickbook.install.windows"> Windows 2000, XP, 2003, Vista</link> + + +
+ + + Section contributed by Julio M. Merino Vidal + + +
+ + The following instructions apply to any Windows system based on Windows 2000, + including Windows XP, Windows 2003 Server and Windows Vista. The paths shown + below are taken from a Windows Vista machine; you will need to adjust them + to match your system in case you are running an older version. + + + + First of all you need to have a copy of xsltproc + for Windows. There are many ways to get this tool, but to keep things simple, + use the binary packages + made by Igor Zlatkovic. At the very least, you need to download the following + packages: iconv, zlib, libxml2 + and libxslt. + + + Unpack all these packages in the same directory so that you get unique + bin, include + and lib directories within + the hierarchy. These instructions use C:\Users\example\Documents\boost\xml + as the root for all files. + + + From the command line, go to the bin + directory and launch xsltproc.exe + to ensure it works. You should get usage information on screen. + + + Download Docbook + XML 4.2 and unpack it in the same directory used above. That is: + C:\Users\example\Documents\boost\xml\docbook-xml. + + + Download the latest Docbook + XSL version and unpack it, again in the same directory used before. + To make things easier, rename the directory created during the extraction + to docbook-xsl (bypassing the version name): C:\Users\example\Documents\boost\xml\docbook-xsl. + + + Add the following to your user-config.jam + file, which should live in your home directory (%HOMEDRIVE%%HOMEPATH%). + You must already have it somewhere or otherwise you could not be building + Boost (i.e. missing tools configuration). + + + +using xsltproc + : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe" + ; + +using boostbook + : "C:/Users/example/Documents/boost/xml/docbook-xsl" + : "C:/Users/example/Documents/boost/xml/docbook-xml" + ; + + + The above steps are enough to get a functional BoostBook setup. Quickbook + will be automatically built when needed. If you want to avoid these rebuilds: + + + + Go to Quickbook's source directory (BOOST_ROOT\tools\quickbook). + + + Build the utility by issuing bjam + --v2. + + + Copy the resulting quickbook.exe + binary (located under the BOOST_ROOT\bin.v2 hierarchy) + to a safe place. Following our previous example, you can install it into: + C:\Users\example\Documents\boost\xml\bin. + + + Add the following to your user-config.jam + file: + + + +using quickbook + : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe" + ; + +
+
+ <link linkend="quickbook.install.linux"> Debian, Ubuntu</link> + + The following instructions apply to Debian and its derivatives. They are + based on a Ubuntu Edgy install but should work on other Debian based systems. + + + First install the bjam, + xsltproc, docbook-xsl and + docbook-xml packages. For example, using apt-get: + + +sudo apt-get install xsltprc docbook-xsl docbook-xml + + + If you're planning on building boost's documentation, you'll also need to + install the doxygen package + as well. + + + Next, we need to configure Boost Build to compile BoostBook files. Add the + following to your user-config.jam file, which should be in your home + directory. If you don't have one, create a file containing this text. For + more information on setting up user-config.jam, see + the Boost + Build documentation. + + +using xsltproc ; + +using boostbook + : /usr/share/xml/docbook/stylesheet/nwalsh + : /usr/share/xml/docbook/schema/dtd/4.2 + ; + +# Remove this line if you're not using doxygen +using doxygen ; + + + The above steps are enough to get a functional BoostBook setup. Quickbook + will be automatically built when needed. If you want to avoid these rebuilds: + + + + Go to Quickbook's source directory (BOOST_ROOT/tools/quickbook). + + + Build the utility by issuing bjam + --v2. + + + Copy the resulting quickbook + binary (located under the BOOST_ROOT/bin.v2 hierarchy) + to a safe place. The traditional location is /usr/local/bin. + + + Add the following to your user-config.jam + file, using the full path of the quickbook executable: + + + +using quickbook + : /usr/local/bin/quickbook + ; + +
+
+
+ <link linkend="quickbook.editors"> Editor Support</link> + + Editing quickbook files is usually done with text editors both simple and powerful. + The following sections list the settings for some editors which can help make + editing quickbook files a bit easier. + + + + + + note + + You may submit your settings, tips, and suggestions to + the authors, or through the docs + Boost Docs mailing list. + + +
+ <link linkend="quickbook.editors.scite"> Scintilla Text Editor</link> +
+ + + Section contributed by Dean Michael Berris + + +
+ + The Scintilla Text Editor (SciTE) is a free source code editor for Win32 + and X. It uses the SCIntilla source code editing component. + + + + + + tip + + SciTE can be downloaded from http://www.scintilla.org/SciTE.html + + + + You can use the following settings to highlight quickbook tags when editing + quickbook files. + + +qbk=*.qbk +lexer.*.qbk=props +use.tabs.$(qbk)=0 +tab.size.$(qbk)=4 +indent.size.$(qbk)=4 +style.props.32=$(font.base) +comment.stream.start.props=[/ +comment.stream.end.props=] +comment.box.start.props=[/ +comment.box.middle.props= +comment.box.end.props=] + + + + + + note + + Thanks to Rene Rivera for the above SciTE settings. + + +
+
+
+ <link linkend="quickbook.faq"> Frequently Asked Questions</link> + + + Can + I use QuickBook for non-Boost documentation? + + + QuickBook can be used for non-Boost documentation with a little extra work. + +
+ + + Faq contributed by Michael Marcin + + +
+ + When building HTML documentation with BoostBook a Boost C++ Libraries header + is added to the files. When using QuickBook to document projects outside of + Boost this is not desirable. This behavior can be overridden at the BoostBook + level by specifying some XSLT options. When using Boost Build version 2 (BBv2) + this can be achieved by adding parameters to the BoostBook target declaration. + + + For example: + + +using quickbook ; + +xml my_doc : my_doc.qbk ; + +boostbook standalone + : + my_doc + : + <xsl:param>boost.image.srcimages/my_project_logo.png + <xsl:param>boost.image.alt"\"My Project\"" + <xsl:param>boost.image.w=100 + <xsl:param>boost.image.h=50 + <xsl:param>nav.layout=none + ; + +
+
+ <link linkend="quickbook.ref"> Quick Reference</link> + + [cpp] + + Syntax Compendium + + + + + + To do this... + + + + Use this... + + + + See this... + + + + + + + + + comment + + + + [/ some comment] + + + + Comments + + + + + + + italics + + + + ['italics] or /italics/ + + + + Font Styles + and Simple + formatting + + + + + + + bold + + + + [*bold] or *bold* + + + + Font Styles + and Simple + formatting + + + + + + + underline + + + + [_underline] or _underline_ + + + + Font Styles + and Simple + formatting + + + + + + + teletype + + + + [^teletype] or =teletype= + + + + Font Styles + and Simple + formatting + + + + + + + strikethrough + + + + [-strikethrough] + + + + Font Styles + and Simple + formatting + + + + + + + + replaceable + + + + + [~replaceable] + + + + Replaceble + + + + + + + source mode + + + + [c++] or [python] + + + + Source Mode + + + + + + + inline code + + + + `int main();` + + + + Inline code + + + + + + + code block + + + + ``int main();`` + + + + Code + + + + + + + code escape + + + + ``from c++ to QuickBook`` + + + + Escaping Back To QuickBook + + + + + + + line break + + + + [br] or \n + + + + line-break + DEPRECATED + + + + + + + anchor + + + + [#anchor] + + + + Anchors + + + + + + + link + + + + [@http://www.boost.org Boost] + + + + Links + + + + + + + anchor link + + + + [link section.anchor Link text] + + + + Anchor links + + + + + + + refentry link + + + + [link xml.refentry Link text] + + + + refentry links + + + + + + + function link + + + + [funcref fully::qualified::function_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + class link + + + + [classref fully::qualified::class_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + member link + + + + [memberref fully::qualified::member_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + enum link + + + + [enumref fully::qualified::enum_name Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + macro link + + + + [macroref MACRO_NAME Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + concept link + + + + [conceptref ConceptName Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + header link + + + + [headerref path/to/header.hpp Link text] + + + + function, class, member, + enum, macro, concept or header links + + + + + + + escape + + + + '''escaped text (no processing/formatting)''' + + + + Escape + + + + + + + single char escape + + + + \c + + + + Single char + escape + + + + + + + images + + + + [$image.jpg] + + + + Images + + + + + + + begin section + + + + [section The Section Title] + + + + Section + + + + + + + end section + + + + [endsect] + + + + Section + + + + + + + paragraph + + + + No markup. Paragraphs start left-flushed and are terminated by two or + more newlines. + + + + Paragraphs + + + + + + + ordered list + + + + +# one +# two +# three + + + + + Ordered lists + + + + + + + unordered list + + + + +* one +* two +* three + + + + + Unordered + lists + + + + + + + code + + + + No markup. Preformatted code starts with a space or a tab. + + + + Code + + + + + + + preformatted + + + + [pre preformatted] + + + + Preformatted + + + + + + + block quote + + + + [:sometext...] + + + + Blockquote + + + + + + + heading 1 + + + + [h1 Heading 1] + + + + Heading + + + + + + + heading 2 + + + + [h2 Heading 2] + + + + Heading + + + + + + + heading 3 + + + + [h3 Heading 3] + + + + Heading + + + + + + + heading 4 + + + + [h4 Heading 4] + + + + Heading + + + + + + + heading 5 + + + + [h5 Heading 5] + + + + Heading + + + + + + + heading 6 + + + + [h6 Heading 6] + + + + Heading + + + + + + + macro + + + + [def macro_identifier some text] + + + + Macros + + + + + + + template + + + + [template[a b] [a] body [b]] + + + + Templates + + + + + + + blurb + + + + [blurb advertisement or note...] + + + + Blurbs + + + + + + + admonition + + + + [warning Warning text...] + + + + Admonitions + + + + + + + table + + + + +[table Title +[[a][b][c]] +[[a][b][c]] +] + + + + + Tables + + + + + + + variablelist + + + + +[variablelist Title +[[a][b]] +[[a][b]] +] + + + + + Variable Lists + + + + + + + include + + + + [include someother.qbk] + + + + Include + + + + + +
+
+
diff --git a/test/quickbook-manual.quickbook b/test/quickbook-manual.quickbook index 76b4b38..00fc9ca 100644 --- a/test/quickbook-manual.quickbook +++ b/test/quickbook-manual.quickbook @@ -1,1981 +1,1981 @@ -[article Quickbook - [quickbook 1.4] - [version 1.4] - [authors [de Guzman, Joel], [Niebler, Eric]] - [copyright 2002 2004 2006 Joel de Guzman, Eric Niebler] - [purpose /WikiWiki/ style documentation tool] - [license - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or copy at - [@http://www.boost.org/LICENSE_1_0.txt]) - ] -] - -[/ QuickBook Document version 1.3 ] -[/ Sept 24, 2002 ] -[/ Sept 2, 2004 ] -[/ Feb 14, 2005 ] -[/ Sept 13, 2005 ] - -[/ Some links] - -[def __note__ [$images/note.png]] -[def __alert__ [$images/alert.png]] -[def __tip__ [$images/tip.png]] -[def :-) [$images/smiley.png]] -[def __spirit__ [@http://spirit.sourceforge.net Spirit]] -[def __boostbook__ [@http://www.boost.org/doc/html/boostbook.html BoostBook]] -[def __docbook__ [@http://www.docbook.org/ DocBook]] - -[def __comments__ [link quickbook.syntax.comments Comments]] - -[def __font_styles__ [link quickbook.syntax.phrase.font_styles Font Styles]] -[def __quotations__ [link quickbook.syntax.phrase.quotations Quotations]] -[def __replaceable__ [link quickbook.syntax.phrase.replaceable Replaceble]] -[def __simple_formatting__ [link quickbook.syntax.phrase.simple_formatting Simple formatting]] -[def __inline_code__ [link quickbook.syntax.phrase.inline_code Inline code]] -[def __code_blocks__ [link quickbook.syntax.phrase.code_blocks Code blocks]] -[def __source_mode__ [link quickbook.syntax.phrase.source_mode Source Mode]] -[def __line_break__ [link quickbook.syntax.phrase.line_break line-break]] -[def __anchors__ [link quickbook.syntax.phrase.anchors Anchors]] -[def __links__ [link quickbook.syntax.phrase.links Links]] -[def __anchor_links__ [link quickbook.syntax.phrase.anchor_links Anchor links]] -[def __refentry_links__ [link quickbook.syntax.phrase.refentry_links refentry links]] -[def __code_links__ [link quickbook.syntax.phrase.code_links function, class, member, enum, macro, concept or header links]] -[def __escape__ [link quickbook.syntax.phrase.escape Escape]] -[def __single_char_escape__ [link quickbook.syntax.phrase.single_char_escape Single char escape]] -[def __images__ [link quickbook.syntax.phrase.images Images]] - -[def __document__ [link quickbook.syntax.block.document Document]] -[def __section__ [link quickbook.syntax.block.section Section]] -[def __xinclude__ [link quickbook.syntax.block.xinclude xinclude]] -[def __paragraphs__ [link quickbook.syntax.block.paragraphs Paragraphs]] -[def __ordered_lists__ [link quickbook.syntax.block.lists.ordered_lists Ordered lists]] -[def __list_hierarchies__ [link quickbook.syntax.block.lists.list_hierarchies List Hierarchies]] -[def __long_list_lines__ [link quickbook.syntax.block.lists.long_list_lines Long List Lines]] -[def __unordered_lists__ [link quickbook.syntax.block.lists.unordered_lists Unordered lists]] -[def __mixed_lists__ [link quickbook.syntax.block.lists.mixed_lists Mixed lists]] -[def __code__ [link quickbook.syntax.block.code Code]] -[def __escape_back__ [link quickbook.syntax.block.escape_back Escaping Back To QuickBook]] -[def __preformatted__ [link quickbook.syntax.block.preformatted Preformatted]] -[def __blockquote__ [link quickbook.syntax.block.blockquote Blockquote]] -[def __heading__ [link quickbook.syntax.block.headings Heading]] -[def __macros__ [link quickbook.syntax.block.macros Macros]] -[def __templates__ [link quickbook.syntax.block.templates Templates]] -[def __predefined_macros__ [link quickbook.syntax.block.predefined_macros Predefined Macros]] -[def __blurbs__ [link quickbook.syntax.block.blurbs Blurbs]] -[def __admonitions__ [link quickbook.syntax.block.admonitions Admonitions]] -[def __tables__ [link quickbook.syntax.block.tables Tables]] -[def __variable_lists__ [link quickbook.syntax.block.variable_lists Variable Lists]] -[def __include__ [link quickbook.syntax.block.include Include]] -[def __import__ [link quickbook.syntax.block.import Import]] - -[section:intro Introduction] - -[:[*['["Why program by hand in five days what you can spend five years of your -life automating?]]] - --- Terrence Parr, author ANTLR/PCCTS -] - -Well, QuickBook started as a weekend hack. It was originally intended to be a -sample application using __spirit__. What is it? What you are viewing now, this -documentation, is autogenerated by QuickBook. These files were generated from -one master: - -[:[@../quickbook.qbk quickbook.qbk]] - -Originally named QuickDoc, this funky tool that never dies evolved into a -funkier tool thanks to Eric Niebler who resurrected the project making it -generate __boostbook__ instead of HTML. The __boostbook__ documentation format -is an extension of __docbook__, an SGML or XML based format for describing -documentation. - -QuickBook is a WikiWiki style documentation tool geared towards C++ -documentation using simple rules and markup for simple formatting tasks. -QuickBook extends the WikiWiki concept. Like the WikiWiki, QuickBook documents are -simple text files. A single QuickBook document can generate a fully linked set -of nice HTML and PostScript/PDF documents complete with images and syntax- -colorized source code. - -Features include: - -* generate __boostbook__ xml, to generate HTML, PostScript and PDF -* simple markup to link to Doxygen-generated entities -* macro system for simple text substitution -* simple markup for italics, bold, preformatted, blurbs, code samples, - tables, URLs, anchors, images, etc. -* automatic syntax coloring of code samples -* CSS support - -[endsect] - -[section:change_log Change Log] - -[h3 Version 1.3] - -* Quickbook file inclusion \[include\]. -* Better xml output (pretty layout). Check out the generated XML. -* Regression testing facility: to make sure your document will always be - compatible (full backward compatibility) regardless of changes to - QuickBook. -* Code cleanup and refactoring. -* Allow phrase markup in the doc-info. -* Preformatted code blocks via \`\`code\`\` (double ticks) allows code in tables - and lists, for example. -* Quickbook versioning; allows full backward compatibility. You have to add - \[quickbook 1.3\] to the doc-info header to enable the new features. Without - this, QuickBook will assume that the document is a pre-1.3 document. -* Better (intuitive) paragraph termination. Some markups may terminate a paragraph. - Example:`` - [section x] - blah... - [endsect]`` -* Fully qualified section and headers. Subsection names are concatenated to the - ID to avoid clashing. Example: `doc_name.sect_name.sub_sect_name.sub_sub_sect_name` -* Better   and whitespace handling in code snippets. -* \[xinclude\] fixes up the relative path to the target XML file when - input_directory is not the same as the output_directory. -* Allow untitled tables. -* Allow phrase markups in section titles. -* Allow escaping back to QuickBook from code, code blocks and inline code. -* Footnotes, with the \[footnote This is the footnote\] syntax. -* Post-processor bug fix for escaped XML code that it does not recognize. -* Replaceable, with the \[~replacement\] syntax. -* Generic Headers -* Code changes to allow full recursion (i.e. Collectors and push/pop functions) -* Various code cleanup/maintenance -* Templates! -* \[conceptref\] for referencing BoostBook entities. -* Allow escape of spaces. The escaped space is removed from the output. Syntax: - `\ `. -* Nested comments are now allowed. -* Quickbook blocks can nest inside comments. -* __import__ facility. -* Callouts on imported code -* Simple markups can now span a whole block. -* __blurbs__, __admonitions__ and table cells (see __tables__) may now - contain paragraphs. -* `\n` and `[br]` are now deprecated. - -[endsect] - -[section:syntax Syntax Summary] - -A QuickBook document is composed of one or more blocks. An example of -a block is the paragraph or a C++ code snippet. Some blocks have -special mark-ups. Blocks, except code snippets which have their own -grammar (C++ or Python), are composed of one or more phrases. A phrase -can be a simple contiguous run of characters. Phrases can have special -mark-ups. Marked up phrases can recursively contain other phrases, but -cannot contain blocks. A terminal is a self contained block-level or -phrase-level element that does not nest anything. - -Blocks, in general, are delimited by two end-of-lines (the block terminator). -Phrases in each block cannot contain a block terminator. This way, syntax errors -such as un-matched closing brackets do not go haywire and corrupt anything past -a single block. - -[section Comments] - -Can be placed anywhere. - -[pre -'''[/ comment (no output generated) ]''' -] - -[/ for testing only... ] - -[pre -'''[/ comments can be nested [/ some more here] ]''' -] - -[/ for testing [/ only ] ] - -[pre -'''[/ Quickbook blocks can nest inside comments. [*Comment this out too!] ]''' -] - -[/ for testing [*only ] ] - -[endsect] - -[section:phrase Phrase Level Elements] - -[section Font Styles] - -[pre''' -['italic], [*bold], [_underline], [^teletype], [-strikethrough] -'''] - -will generate: - -['italic], [*bold], [_underline], [^teletype], [-strikethrough] - -Like all non-terminal phrase level elements, this can of course be nested: - -[pre''' -[*['bold-italic]] -'''] - -will generate: - -[*['bold-italic]] - -[endsect] - -[section Replaceable] - -When you want content that may or must be replaced by the user, use the syntax: - -[pre''' -[~replacement] -'''] - -This will generate: - -[~replacement] - -[endsect] - -[section Quotations] - -[pre''' -["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein -'''] - -will generate: - -["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein - -Note the proper left and right quote marks. Also, while you can simply use -ordinary quote marks like "quoted", our quotation, above, will generate correct -DocBook quotations (e.g. quoted). - -Like all phrase elements, quotations may be nested. Example: - -[pre''' -["Here's the rule for bargains: ["Do other men, for they would do you.] That's -the true business precept.] -'''] - -will generate: - -["Here's the rule for bargains: ["Do other men, for they would do you.] -That's the true business precept.] - -[endsect] -[section Simple formatting] - -Simple markup for formatting text, common in many applications, is now supported: - -[pre''' -/italic/, *bold*, _underline_, =teletype= -'''] - -will generate: - -/italic/, *bold*, _underline_, =teletype= - -Unlike QuickBook's standard formatting scheme, the rules for simpler -alternatives are much stricter[footnote Thanks to David Barrett, author of -[@http://quinthar.com/qwikiwiki/index.php?page=Home Qwiki], for sharing -these samples and teaching me these obscure formatting rules. I wasn't sure -at all if __spirit__, being more or less a formal EBNF parser, can handle -the context sensitivity and ambiguity.]. - -* Simple markups cannot nest. You can combine a simple markup with a nestable markup. -* Simple markups cannot contain any other form of quickbook markup. -* A non-space character must follow the leading markup -* A non-space character must precede the trailing markup -* A space or a punctuation must follow the trailing markup -* If the matching markup cannot be found within a block, the formatting - will not be applied. This is to ensure that un-matched formatting markups, - which can be a common mistake, does not corrupt anything past a single block. - We do not want the rest of the document to be rendered bold just because we - forgot a trailing '*'. A single block is terminated by two end of lines or - the close bracket: ']'. -* A line starting with the star will be interpreted as an unordered list. - See __unordered_lists__. - -[table More Formatting Samples - [[Markup] [Result]] - [[[^'''*Bold*''']] [*Bold*]] - [[[^'''*Is bold*''']] [*Is bold*]] - [[[^'''* Not bold* *Not bold * * Not bold *''']] [* Not bold* *Not bold * * Not bold *]] - [[[^'''This*Isn't*Bold (no bold)''']] [This*Isn't*Bold (no bold)]] - [[[^'''(*Bold Inside*) (parenthesis not bold)''']] [(*Bold Inside*) (parenthesis not bold)]] - [[[^'''*(Bold Outside)* (parenthesis bold)''']] [*(Bold Outside)* (parenthesis bold)]] - [[[^'''3*4*5 = 60 (no bold)''']] [3*4*5 = 60 (no bold)]] - [[[^'''3 * 4 * 5 = 60 (no bold)''']] [3 * 4 * 5 = 60 (no bold)]] - [[[^'''3 *4* 5 = 60 (4 is bold)''']] [3 *4* 5 = 60 (4 is bold)]] - [[[^'''*This is bold* this is not *but this is*''']][*This is bold* this is not *but this is*]] - [[[^'''*This is bold*.''']] [*This is bold*.]] - [[[^'''*B*. (bold B)''']] [*B*. (bold B)]] - [[[^'''['*Bold-Italic*]''']] [['*Bold-Italic*]]] - [[[^'''*side-by*/-side/''']] [*side-by*/-side/]] -] - -As mentioned, simple markups cannot go past a single block. The text -from "have" to "full" in the following paragraph will be rendered as -bold: - -[pre''' -Baa baa black sheep, *have you any wool? -Yes sir, yes sir, three bags full!* -One for the master, one for the dame, -And one for the little boy who lives down the lane. -'''] - -Baa baa black sheep, *have you any wool? -Yes sir, yes sir, three bags full!* -One for the master, one for the dame, -And one for the little boy who lives down the lane. - -But in the following paragraph, bold is not applied: - -[pre''' -Baa baa black sheep, *have you any wool? -Yes sir, yes sir, three bags full! -One for the master, one for the dame, -And one for the little boy who lives down the lane. -'''] - -Baa baa black sheep, *have you any wool? -Yes sir, yes sir, three bags full! -One for the master, one for the dame, -And one for the little boy who lives down the lane. - -[endsect] -[section Inline code] - -Inlining code in paragraphs is quite common when writing C++ documentation. We -provide a very simple markup for this. For example, this: - -[pre''' -This text has inlined code `int main() { return 0; }` in it. -'''] - -will generate: - -This text has inlined code `int main() { return 0; }` in it. The code will be -syntax highlighted. - -[note We simply enclose the code with the tick: [^'''"`"'''], not the -single quote: `"'"`. Note too that [^'''`some code`'''] is preferred over -[^'''[^some code]''']. ] - -[endsect] -[section Code blocks] - -Preformatted code simply starts with a space or a tab (See __code__). -However, such a simple syntax cannot be used as phrase elements in lists -(See __ordered_lists__ and __unordered_lists__), tables (See __tables__), -etc. Inline code (see above) can. The problem is, inline code does not -allow formatting with newlines, spaces, and tabs. These are lost. - -We provide a phrase level markup that is a mix between the two. By using the -double-tick, instead of the single-tick, we are telling QuickBook to use -preformatted blocks of code. Example: - -[pre -\`\` - #include - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } -\`\` -] - -will generate: - -`` - #include - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } -`` - -[endsect] -[section Source Mode] - -If a document contains more than one type of source code then the source -mode may be changed dynamically as the document is processed. All QuickBook -documents are initially in C++ mode by default, though an alternative -initial value may be set in the __document__ section. - -To change the source mode, use the [^\[source-mode\]] markup, where -=source-mode= is one of the supported modes. For example, this: - -[pre''' -Python's [python] `import` is rather like C++'s [c++] `#include`. A -C++ comment `// looks like this` whereas a Python comment [python] -`# looks like this`. -'''] - -will generate: - -Python's [python] `import` is rather like C++'s [c++] `#include`. A -C++ comment `// looks like this` whereas a Python comment [python] -`#looks like this`. - -[table Supported Source Modes - [[Mode] [Source Mode Markup]] - [[C++] [[^\[c++\]]]] - [[Python] [[^\[python\]]]] -] - -[note The source mode strings are lowercase.] - -[endsect] -[section line-break] - -[pre''' -[br] -'''] - -[warning `[br]` is now deprecated. __blurbs__, __admonitions__ and -table cells (see __tables__) may now contain paragraphs.] - -[endsect] -[section Anchors] - -[pre''' -[#named_anchor] -'''] - -A named anchor is a hook that can be referenced by a link elsewhere in the -document. You can then reference an anchor with [^'''[link named_anchor -Some link text]''']. See __anchor_links__, __section__ and __heading__. - -[endsect] -[section Links] - -[pre''' -[@http://www.boost.org this is [*boost's] website....] -'''] - -will generate: - -[@http://www.boost.org this is [*boost's] website....] - -URL links where the link text is the link itself is common. Example: - -[pre''' -see http://spirit.sourceforge.net/ -'''] - -so, when the text is absent in a link markup, the URL is assumed. Example: - -[pre -see '''[@http://spirit.sourceforge.net/]''' -] - -will generate: - -see [@http://spirit.sourceforge.net/] - -[endsect] -[section Anchor links] - -You can link within a document using: - -[pre''' -[link section_id.normalized_header_text The link text] -'''] - -See sections __section__ and __heading__ for more info. - -[endsect] -[section refentry links] - -In addition, you can link internally to an XML refentry like: - -[pre''' -[link xml.refentry The link text] -'''] - -This gets converted into [^The link text]. - -Like URLs, the link text is optional. If this is not present, the link text will -automatically be the refentry. Example: - -[pre''' -[link xml.refentry] -'''] - -This gets converted into [^xml.refentry]. - -[endsect] -[section:code_links Code Links] - -If you want to link to a function, class, member, enum, concept or header in the reference -section, you can use: - -[pre''' -[funcref fully::qualified::function_name The link text] -[classref fully::qualified::class_name The link text] -[memberref fully::qualified::member_name The link text] -[enumref fully::qualified::enum_name The link text] -[macroref MACRO_NAME The link text] -[conceptref ConceptName The link text] -[headerref path/to/header.hpp The link text] -'''] - -Again, the link text is optional. If this is not present, the link text will -automatically be the function, class, member, enum, macro, concept or header. Example: - -[pre''' -[classref boost::bar::baz] -'''] - -would have "boost::bar::baz" as the link text. - -[endsect] -[section Escape] - -The escape mark-up is used when we don't want to do any processing. - -[pre -\'\'\' -escape (no processing/formatting) -\'\'\' -] - -Escaping allows us to pass XML markup to __boostbook__ or __docbook__. For example: - -[pre -\'\'\' -This is direct XML markup -\'\'\' -] - -''' -This is direct XML markup -''' - -[important Be careful when using the escape. The text must conform to -__boostbook__/__docbook__ syntax.] - -[endsect] -[section Single char escape] - -The backslash may be used to escape a single punctuation character. The -punctuation immediately after the backslash is passed without any processing. -This is useful when we need to escape QuickBook punctuations such as `[` and `]`. -For example, how do you escape the triple quote? Simple: [^\\'\\'\\'] - - -`\n` has a special meaning. It is used to generate line breaks. - -[warning `\n` and `[br]` are now deprecated. __blurbs__, __admonitions__ -and table cells (see __tables__) may now contain paragraphs.] - -The escaped space: `\ ` also has a special meaning. The escaped space is removed -from the output. - -[endsect] -[section Images] - -[pre''' -[$image.jpg] -'''] - -[endsect] -[section Footnotes] - -As of version 1.3, QuickBook supports footnotes. Just put the text of the -footnote in a `[footnote]` block, and the text will be put at the bottom -of the current page. For example, this: - -[pre''' -[footnote A sample footnote] -'''] - -will generate this[footnote A sample footnote]. - -[section Macro Expansion] - -[pre''' -__a_macro_identifier__ -'''] - -See __macros__ for details. - -[endsect] - -[section Template Expansion] - -[pre''' -[a_template_identifier] -'''] - -See __templates__ for details. - -[endsect] - -[endsect] -[endsect] -[section:block Block Level Elements] - -[section Document] - -Every document must begin with a Document Info section, which should look -like this: - -[pre''' -[document-type The Document Title - [quickbook 1.3] - [version 1.0] - [id the_document_name] - [dirname the_document_dir] - [copyright 2000 2002 2003 Joe Blow, Jane Doe] - [purpose The document's reason for being] - [category The document's category] - [authors [Blow, Joe], [Doe, Jane]] - [license The document's license] - [source-mode source-type] -] -'''] - -Where document-type is one of: - -* book -* article -* library -* chapter -* part -* appendix -* preface -* qandadiv -* qandaset -* reference -* set - -quickbook 1.3 declares the version of quickbook the document is written for. -In its absence, version 1.1 is assumed. - -=version=, =id=, =dirname=, =copyright=, =purpose=, =category=, =authors=, -=license=, =last-revision= and =source-mode= are optional information. - -=source-type= is a lowercase string setting the initial __source_mode__. If -the =source-mode= field is omitted, a default value of =c++= will be used. - -[endsect] -[section Section] - -Starting a new section is accomplished with: - -[pre''' -[section:id The Section Title] -'''] - -where /id/ is optional. id will be the filename of the generated section. -If it is not present, "The Section Title" will be normalized and become the id. -Valid characters are =a-Z=, =A-Z=, =0-9= and =_=. All non-valid characters are -converted to underscore and all upper-case are converted to lower case. -Thus: "The Section Title" will be normalized to "the_section_title". - -End a section with: - -[pre''' -[endsect] -'''] - -Sections can nest, and that results in a hierarchy in the table of contents. - -[endsect] -[section xinclude] - -You can include another XML file with: - -[pre''' -[xinclude file.xml] -'''] - -This is useful when file.xml has been generated by Doxygen and contains your -reference section. - -[endsect] -[section Paragraphs] - -Paragraphs start left-flushed and are terminated by two or more newlines. No -markup is needed for paragraphs. QuickBook automatically detects paragraphs from -the context. Block markups \[section, endsect, h1, h2, h3, h4, h5, h6, blurb, -(block-quote) ':', pre, def, table and include \] may also terminate a paragraph. - -[endsect] - -[section Lists] -[section Ordered lists] - -[pre -# One -# Two -# Three -] - -will generate: - -# One -# Two -# Three - -[endsect] -[section List Hierarchies] - -List hierarchies are supported. Example: - -[pre -# One -# Two -# Three - # Three.a - # Three.b - # Three.c -# Four - # Four.a - # Four.a.i - # Four.a.ii -# Five -] - -will generate: - -# One -# Two -# Three - # Three.a - # Three.b - # Three.c -# Fourth - # Four.a - # Four.a.i - # Four.a.ii -# Five - -[endsect] -[section Long List Lines] - -Long lines will be wrapped appropriately. Example: - -[pre -# A short item. -# A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. -# A short item. -] - -# A short item. -# A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. - A very long item. A very long item. A very long item. -# A short item. - -[endsect] -[section Unordered lists] - -[pre''' -* First -* Second -* Third -'''] - -will generate: - -* First -* Second -* Third - -[endsect] -[section Mixed lists] - -Mixed lists (ordered and unordered) are supported. Example: - -[pre''' -# One -# Two -# Three - * Three.a - * Three.b - * Three.c -# Four -'''] - -will generate: - -# One -# Two -# Three - * Three.a - * Three.b - * Three.c -# Four - -And... - -[pre''' -# 1 - * 1.a - # 1.a.1 - # 1.a.2 - * 1.b -# 2 - * 2.a - * 2.b - # 2.b.1 - # 2.b.2 - * 2.b.2.a - * 2.b.2.b -'''] - -will generate: - -# 1 - * 1.a - # 1.a.1 - # 1.a.2 - * 1.b -# 2 - * 2.a - * 2.b - # 2.b.1 - # 2.b.2 - * 2.b.2.a - * 2.b.2.b - -[endsect] -[endsect] - -[section Code] - -Preformatted code starts with a space or a tab. The code will be -syntax highlighted according to the current __source_mode__: - -[c++] - - #include - - int main() - { - // Sample code - std::cout << "Hello, World\n"; - return 0; - } - -[python] - - import cgi - - def cookForHtml(text): - '''"Cooks" the input text for HTML.''' - - return cgi.escape(text) - -[c++] - -Macros that are already defined are expanded in source code. Example: - -[pre''' -[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] -[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] - - using __boost__::__array__; -'''] - -Generates: - -[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] -[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] - - using __boost__::__array__; - -[endsect] -[section:escape_back Escaping Back To QuickBook] - -Inside code, code blocks and inline code, QuickBook does not allow any -markup to avoid conflicts with the target syntax (e.g. c++). In case you -need to switch back to QuickBook markup inside code, you can do so using a -language specific /escape-back/ delimiter. In C++ and Python, the delimiter -is the double tick (back-quote): "\`\`" and "\`\`". Example: - -[pre''' -void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() -{ -} -'''] - -Will generate: - - void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() - { - } - -When escaping from code to QuickBook, only phrase level markups are -allowed. Block level markups like lists, tables etc. are not allowed. - -[endsect] -[section Preformatted] - -Sometimes, you don't want some preformatted text to be parsed as C++. In such -cases, use the [^[pre ... \]] markup block. - -[pre''' -[pre - - Some *preformatted* text Some *preformatted* text - - Some *preformatted* text Some *preformatted* text - - Some *preformatted* text Some *preformatted* text - -] -'''] - -Spaces, tabs and newlines are rendered as-is. Unlike all quickbook block level -markup, pre (and Code) are the only ones that allow multiple newlines. The -markup above will generate: - -[pre - -Some *preformatted* text Some *preformatted* text - - Some *preformatted* text Some *preformatted* text - - Some *preformatted* text Some *preformatted* text - -] - -Notice that unlike Code, phrase markup such as font style is still permitted -inside =pre= blocks. - -[endsect] -[section Blockquote] - -[pre -'''[:sometext...]''' -] - -[:Indents the paragraph. This applies to one paragraph only.] - -[endsect] -[section Admonitions] - -[pre''' -[note This is a note] -[tip This is a tip] -[important This is important] -[caution This is a caution] -[warning This is a warning] -'''] - -generates __docbook__ admonitions: - -[note This is a note] -[tip This is a tip] -[important This is important] -[caution This is a caution] -[warning This is a warning] - -These are the only admonitions supported by __docbook__. So, -for example [^\[information This is some information\]] is unlikely -to produce the desired effect. - -[endsect] -[section Headings] - -[pre''' -[h1 Heading 1] -[h2 Heading 2] -[h3 Heading 3] -[h4 Heading 4] -[h5 Heading 5] -[h6 Heading 6] -'''] - -[h1 Heading 1] -[h2 Heading 2] -[h3 Heading 3] -[h4 Heading 4] -[h5 Heading 5] -[h6 Heading 6] - -Headings 1-3 \[h1 h2 and h3\] will automatically have anchors with normalized -names with [^name="section_id.normalized_header_text"] (i.e. valid characters are -=a-z=, =A-Z=, =0-9= and =_=. All non-valid characters are converted to underscore -and all upper-case are converted to lower-case. For example: Heading -1 in section Section 2 will be normalized to [^section_2.heading_1]). You can use: - -[pre''' -[link section_id.normalized_header_text The link text] -'''] - -to link to them. See __anchor_links__ and __section__ for more info. - -[endsect] -[section Generic Heading] - -In cases when you don't want to care about the heading level (1 to 6), you -can use the /Generic Heading/: - -[pre''' -[heading Heading] -'''] - -The /Generic Heading/ assumes the level, plus one, of the innermost section -where it is placed. For example, if it is placed in the outermost section, -then, it assumes /h2/. - -Headings are often used as an alternative to sections. It is used -particularly if you do not want to start a new section. In many cases, -however, headings in a particular section is just flat. Example: - -[pre''' -[section A] -[h2 X] -[h2 Y] -[h2 Z] -[endsect] -'''] - -Here we use h2 assuming that section A is the outermost level. If it is -placed in an inner level, you'll have to use h3, h4, etc. depending on -where the section is. In general, it is the section level plus one. It is -rather tedious, however, to scan the section level everytime. If you -rewrite the example above as shown below, this will be automatic: - -[pre''' -[section A] -[heading X] -[heading Y] -[heading Z] -[endsect] -'''] - -They work well regardless where you place them. You can rearrange sections -at will without any extra work to ensure correct heading levels. In fact, -with /section/ and /heading/, you have all you need. /h1/../h6/ becomes -redundant. /h1/../h6/ might be deprecated in the future. - -[endsect] -[section Macros] - -[pre''' -[def macro_identifier some text] -'''] - -When a macro is defined, the identifier replaces the text anywhere in the -file, in paragraphs, in markups, etc. macro_identifier is a string of non- -white space characters except '\]'. A macro may not follow an alphabetic -character or the underscore. The replacement text can be any phrase (even -marked up). Example: - -[pre''' -[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] -sf_logo -'''] - -Now everywhere the sf_logo is placed, the picture will be inlined. - -[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] -sf_logo - -[tip It's a good idea to use macro identifiers that are distinguishable. -For instance, in this document, macro identifiers have two leading and -trailing underscores (e.g. [^'''__spirit__''']). The reason is to avoid -unwanted macro replacement.] - -Links (URLS) and images are good candidates for macros. *1*) They tend to -change a lot. It is a good idea to place all links and images in one place near the top -to make it easy to make changes. *2*) The syntax is not pretty. It's easier to read and -write, e.g. [^'''__spirit__'''] than [^'''[@http://spirit.sourceforge.net Spirit]''']. - -Some more examples: - -[pre''' -[def :-) [$theme/smiley.png]] -[def __spirit__ [@http://spirit.sourceforge.net Spirit]] -'''] - -(See __images__ and __links__) - -Invoking these macros: - -[pre''' -Hi __spirit__ :-) -'''] - -will generate this: - -Hi __spirit__ :-) - -[endsect] -[section Predefined Macros] - -Quickbook has some predefined macros that you can already use. - -[table Predefined Macros - [[Macro] [Meaning] [Example]] - [['''__DATE__'''] [Today's date] [__DATE__]] - [['''__TIME__'''] [The current time] [__TIME__]] - [['''__FILENAME__'''] [Quickbook source filename] [__FILENAME__]] -] - -[endsect] -[section Templates] - -Templates provide a more versatile text substitution mechanism. Templates -come in handy when you need to create parameterizable, multi-line, -boilerplate text that you specify once and expand many times. Templates -accept one or more arguments. These arguments act like place-holders for -text replacement. Unlike simple macros, which are limited to phrase level -markup, templates can contain block level markup (e.g. paragraphs, code -blocks and tables). - -Example template: - -[pre''' -[template person[name age what] - -Hi, my name is [name]. I am [age] years old. I am a [what]. - -] -'''] - -[template person[name age what] - -Hi, my name is [name]. I am [age] years old. I am a [what]. - -] - -[heading Template Identifier] - -Template identifiers can either consist of: - -* An initial alphabetic character or the underscore, followed by - zero or more alphanumeric characters or the underscore. This is - similar to your typical C/C++ identifier. -* A single character punctuation (a non-alphanumeric printable character) - -[heading Formal Template Arguments] - -Template formal arguments are identifiers consisting of an initial -alphabetic character or the underscore, followed by zero or more -alphanumeric characters or the underscore. This is similar to your typical -C/C++ identifier. - -A template formal argument temporarily hides a template of the same name at -the point where the [link quickbook.syntax.block.templates.template_expansion -template is expanded]. Note that the body of the [^person] template above -refers to [^name] [^age] and [^what] as [^\[name\]] [^\[age\]] and -[^\[what\]]. [^name] [^age] and [^what] are actually templates that exist -in the duration of the template call. - -[heading Template Body] - -The template body can be just about any QuickBook block or phrase. There -are actually two forms. Templates may be phrase or block level. Phrase -templates are of the form: - -[pre''' -[template sample[arg1 arg2...argN] replacement text... ] -'''] - -Block templates are of the form: - -[pre''' -[template sample[arg1 arg2...argN] -replacement text... -] -'''] - -The basic rule is as follows: if a newline immediately follows the argument -list, then it is a block template, otherwise, it is a phrase template. -Phrase templates are typically expanded as part of phrases. Like macros, -block level elements are not allowed in phrase templates. - -[heading Template Expansion] - -You expand a template this way: - -[pre''' -[template_identifier arg1..arg2..arg3] -'''] - -At template expansion, you supply the actual arguments. The template will -be expanded with your supplied arguments. Example: - -[pre''' -[person James Bond..39..Spy] -[person Santa Clause..87..Big Red Fatso] -'''] - -Which will expand to: - -[person James Bond..39..Spy] -[person Santa Clause..87..Big Red Fatso] - -[caution A word of caution: Templates are recursive. A template can call -another template or even itself, directly or indirectly. There are no -control structures in QuickBook (yet) so this will always mean infinite -recursion. QuickBook can detect this situation and report an error if -recursion exceeds a certain limit.] - -Each actual argument can be a word, a text fragment or just about any [link -quickbook.syntax.phrase QuickBook phrase]. Arguments are separated by the -double dot [^".."] and terminated by the close parenthesis. - -[heading Nullary Templates] - -Nullary templates look and act like simple macros. Example: - -[pre''' -[template alpha[]'''&#945;'''] -[template beta[]'''&#946;'''] -'''] - -[template alpha[]'''α'''] -[template beta[]'''β'''] - -Expanding: - -[pre'''Some squigles...[*[alpha][beta]]'''] - -We have: - -Some squiggles...[*[alpha][beta]] - -The difference with macros are - -* The explicit [link quickbook.syntax.block.templates.template_expansion - template expansion syntax]. This is an advantage because, now, we don't - have to use obscure naming conventions like double underscores (e.g. - \_\_alpha\_\_) to avoid unwanted - macro replacement. -* The template is expanded at the point where it is invoked. A macro is - expanded immediately at its point of declaration. This is subtle and - can cause a slight difference in behavior especially if you refer to - other macros and templates in the body. - -The empty brackets after the template identifier ([^alpha\[\]]) indicates no -arguments. If the template body does not look like a template argument list, we -can elide the empty brackets. Example: - -[pre''' -[template aristotle_quote Aristotle: [*['Education is the best provision -for the journey to old age.]]] -'''] - -[template aristotle_quote\ Aristotle: [*['Education is the best provision -for the journey to old age.]]] - -Expanding: - -[pre''' -Here's a quote from [aristotle_quote]. -'''] - -We have: - -Here's a quote from [aristotle_quote]. - -The disadvantage is that you can't avoid the space between the template -identifier, `aristotle_quote`, and the template body "Aristotle...". This space -will be part of the template body. If that space is unwanted, use empty -brackets or use the space escape: "`\ `". Example: - -[pre''' -[template tag\ _tag] -'''] - -[template tag\ _tag] - -Then expanding: - -[pre''' -`struct` x[tag]; -'''] - -We have: - -`struct` x[tag]; - -You have a couple of ways to do it. I personally prefer the explicit empty -brackets, though. - -[heading Simple Arguments] - -As mentioned, arguments are separated by the double dot [^".."]. If there -are less arguments passed than expected, QuickBook attempts to break the -last argument into two or more arguments following this logic: - -* Break the last argument into two, at the first space found ([^'', '\\n', - \\t' or '\\r']). -* Repeat until there are enough arguments or if there are no more spaces - found (in which case, an error is reported). - -For example: - -[pre''' -[template simple[a b c d] [a][b][c][d]] -[simple w x y z] -'''] - -will produce: - -[template simple[a b c d] [a][b][c][d]] -[simple w x y z] - -"w x y z" is initially treated as a single argument because we didn't -supply any [^".."] separators. However, since [^simple] expects 4 -arguments, "w x y z" is broken down iteratively (applying the logic above) -until we have "w", "x", "y" and "z". - -QuickBook only tries to get the arguments it needs. For example: - -[pre''' -[simple w x y z trail] -'''] - -will produce: - -[simple w x y z trail] - -The arguments being: "w", "x", "y" and "z trail". - -It should be obvious now that for simple arguments with no spaces, we can -get by without separating the arguments with [^".."] separators. It is -possible to combine [^".."] separators with the argument passing -simplification presented above. Example: - -[pre''' -[simple what do you think ..m a n?] -'''] - -will produce: - -[simple what do you think ..m a n?] - -[heading Punctuation Templates] - -With templates, one of our objectives is to allow us to rewrite QuickBook -in QuickBook (as a qbk library). For that to happen, we need to accommodate -single character punctuation templates which are fairly common in -QuickBook. You might have noticed that single character punctuations are -allowed as [link quickbook.syntax.block.templates.template_identifier -template identifiers]. Example: - -[pre''' -[template ![bar] ''''''[bar]''''''] -'''] - -Now, expanding this: - -[pre''' -[!baz] -'''] - -We will have: - -[pre -baz -] - -[endsect] -[section Blurbs] - -[pre''' -[blurb :-) [*An eye catching advertisement or note...] - - __spirit__ is an object-oriented recursive-descent parser generator framework - implemented using template meta-programming techniques. Expression templates - allow us to approximate the syntax of Extended Backus-Normal Form (EBNF) - completely in C++. -] -'''] - -will generate this: - -[blurb :-) [*An eye catching advertisement or note...] - - __spirit__ is an object-oriented recursive-descent parser generator - framework implemented using template meta-programming techniques. Expression - templates allow us to approximate the syntax of Extended Backus-Normal Form - (EBNF) completely in C++. -] - -[note Prefer [link quickbook.syntax.block.admonitions admonitions] wherever -appropriate.] - -[endsect] -[section Tables] - -[pre''' -[table A Simple Table - [[Heading 1] [Heading 2] [Heading 3]] - [[R0-C0] [R0-C1] [R0-C2]] - [[R1-C0] [R1-C1] [R1-C2]] - [[R2-C0] [R2-C1] [R2-C2]] -] -'''] - -will generate: - -[table A Simple Table - [[Heading 1] [Heading 2] [Heading 3]] - [[R0-C0] [R0-C1] [R0-C2]] - [[R2-C0] [R2-C1] [R2-C2]] - [[R3-C0] [R3-C1] [R3-C2]] -] - -The table title is optional. The first row of the table is automatically -treated as the table header; that is, it is wrapped in -[^...] XML tags. Note that unlike the original QuickDoc, the -columns are nested in [ cells... ]. The syntax is free-format and allows -big cells to be formatted nicely. Example: - -[pre''' -[table Table with fat cells - [[Heading 1] [Heading 2]] - [ - [Row 0, Col 0: a small cell] - [ - Row 0, Col 1: a big fat cell with paragraphs - - Boost provides free peer-reviewed portable C++ source libraries. - - We emphasize libraries that work well with the C++ Standard Library. - Boost libraries are intended to be widely useful, and usable across - a broad spectrum of applications. The Boost license encourages both - commercial and non-commercial use. - ] - ] - [ - [Row 1, Col 0: a small cell] - [Row 1, Col 1: a small cell] - ] -] -'''] - -and thus: - -[table Table with fat cells - [[Heading 1] [Heading 2]] - [ - [Row 0, Col 0: a small cell] - [ - Row 0, Col 1: a big fat cell with paragraphs - - Boost provides free peer-reviewed portable C++ source libraries. - - We emphasize libraries that work well with the C++ Standard Library. - Boost libraries are intended to be widely useful, and usable across - a broad spectrum of applications. The Boost license encourages both - commercial and non-commercial use. - ] - ] - [ - [Row 1, Col 0: a small cell] - [Row 1, Col 1: a small cell] - ] -] - -Here's how to have preformatted blocks of code in a table cell: - -[pre''' -[table Table with code - [[Comment] [Code]] - [ - [My first program] - ['''\`\` - #include - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } - \`\`'''] - ] -] -'''] - -[table Table with code - [[Comment] [Code]] - [ - [My first program] - [`` - #include - - int main() - { - std::cout << "Hello, World!" << std::endl; - return 0; - } - ``] - ] -] - -[endsect] -[section Variable Lists] - -[pre''' -[variablelist A Variable List - [[term 1] [The definition of term 1]] - [[term 2] [The definition of term 2]] - [[term 3] [The definition of term 3]] -] -'''] - -will generate: - -[variablelist A Variable List - [[term 1] [The definition of term 1]] - [[term 2] [The definition of term 2]] - [[term 3] [The definition of term 3]] -] - -The rules for variable lists are the same as for tables, except that -only 2 "columns" are allowed. The first column contains the terms, and -the second column contains the definitions. Those familiar with HTML -will recognize this as a "definition list". - -[endsect] -[section Include] - -You can include one QuickBook file from another. The syntax is simply: - -[pre''' -[include someother.qbk] -'''] - -The included file will be processed as if it had been cut and pasted -into the current document, with the following exceptions: - -* The '''__FILENAME__''' predefined macro will reflect the name of the - file currently being processed. -* Any macros defined in the included file are scoped to that file. - -The [^\[include\]] directive lets you specify a document id to use for the -included file. When this id is not explicitly specified, the id defaults to -the filename ("someother", in the example above). You can specify the id -like this: - -[pre''' -[include:someid someother.qbk] -'''] - -All auto-generated anchors will use the document id as a unique prefix. So -for instance, if there is a top section in someother.qbk named "Intro", the -named anchor for that section will be "someid.intro", and you can link to -it with [^\[link someid.intro The Intro\]]. - -[endsect] - -[section Import] - -When documenting code, you'd surely need to present code from actual source -files. While it is possible to copy some code and paste them in your QuickBook -file, doing so is error prone and the extracted code in the documentation tends -to get out of sync with the actual code as the code evolves. The problem, as -always, is that once documentation is written, the tendency is for the docs to -languish in the archives without maintenance. - -QuickBook's import facility provides a nice solution. - -[heading Example] - -You can effortlessly import code snippets from source code into your QuickBook. -The following illustrates how this is done: - -[pre''' -[import ../test/stub.cpp] -[foo] -[bar] -'''] - -The first line: - -[pre''' -[import ../test/stub.cpp] -'''] - -collects specially marked-up code snippets from [@../../test/stub.cpp stub.cpp] -and places them in your QuickBook file as virtual templates. Each of the -specially marked-up code snippets has a name (e.g. `foo` and `bar` in the -example above). This shall be the template identifier for that particular code -snippet. The second and third line above does the actual template expansion: - -[pre''' -[foo] -[bar] -'''] - -And the result is: - -[import ../test/stub.cpp] -[foo] -[bar] - -[heading Code Snippet Markup] - -Note how the code snippets in [@../../test/stub.cpp stub.cpp] get marked up. We -use distinguishable comments following the form: - - //[id - some code here - //] - -The first comment line above initiates a named code-snippet. This prefix will -not be visible in quickbook. The entire code-snippet in between `//[id` and -`//]` will be inserted as a template in quickbook with name ['/id/]. The comment -`//]` ends a code-snippet This too will not be visible in quickbook. - -[heading Special Comments] - -Special comments of the form: - - //` some [*quickbook] markup here - -and: - - /*` some [*quickbook] markup here */ - -will be parsed by QuickBook. This can contain quickbook /blocks/ (e.g. sections, -paragraphs, tables, etc). In the first case, the initial slash-slash, tick and -white-space shall be ignored. In the second, the initial slash-star-tick and the -final star-slash shall be ignored. - -[heading Callouts] - -Special comments of the form: - - /*< some [*quickbook] markup here >*/ - -will be regarded as callouts. These will be collected, numbered and -rendered as a "callout bug" (a small icon with a number). After the -whole snippet is parsed, the callout list is generated. See -[@http://www.docbook.org/tdg/en/html/callout.html Callouts] for details. -Example: - -[foo_bar] - -Checkout [@../../test/stub.cpp stub.cpp] to see the actual code. - -[endsect] - -[endsect] -[endsect] - -[section:install Installation and configuration] - -This section provides some guidelines on how to install and configure -BoostBook and Quickbook under several operating systems. - -Before continuing, it is very important that you keep this in mind: if you -try to build some documents and the process breaks due to misconfiguration, -be absolutely sure to delete any `bin` and `bin.v2` directories generated -by the build before trying again. Otherwise your configuration fixes will -not take any effect. - -[section:windows Windows 2000, XP, 2003, Vista] - -[python] - -[:['Section contributed by Julio M. Merino Vidal]] - -The following instructions apply to any Windows system based on Windows -2000, including Windows XP, Windows 2003 Server and Windows Vista. The -paths shown below are taken from a Windows Vista machine; you will need to -adjust them to match your system in case you are running an older version. - -# First of all you need to have a copy of `xsltproc` for Windows. There - are many ways to get this tool, but to keep things simple, use the - [@http://www.zlatkovic.com/pub/libxml/ binary packages] made by Igor - Zlatkovic. At the very least, you need to download the following - packages: `iconv`, `zlib`, `libxml2` and `libxslt`. - -# Unpack all these packages in the same directory so that you get unique - `bin`, `include` and `lib` directories within the hierarchy. These - instructions use `C:\Users\example\Documents\boost\xml` as the root for - all files. - -# From the command line, go to the `bin` directory and launch - `xsltproc.exe` to ensure it works. You should get usage information on - screen. - -# Download [@http://www.docbook.org/xml/4.2/docbook-xml-4.2.zip Docbook XML - 4.2] and unpack it in the same directory used above. That is: - `C:\Users\example\Documents\boost\xml\docbook-xml`. - -# Download the latest - [@http://sourceforge.net/project/showfiles.php?group_id=21935&package_id=16608 - Docbook XSL] version and unpack it, again in the same directory - used before. To make things easier, rename the directory created - during the extraction to `docbook-xsl` (bypassing the version name): - `C:\Users\example\Documents\boost\xml\docbook-xsl`. - -# Add the following to your `user-config.jam` file, which should live in - your home directory (`%HOMEDRIVE%%HOMEPATH%`). You must already have it - somewhere or otherwise you could not be building Boost (i.e. missing - tools configuration). - - using xsltproc - : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe" - ; - - using boostbook - : "C:/Users/example/Documents/boost/xml/docbook-xsl" - : "C:/Users/example/Documents/boost/xml/docbook-xml" - ; - -The above steps are enough to get a functional BoostBook setup. Quickbook -will be automatically built when needed. If you want to avoid these -rebuilds: - -# Go to Quickbook's source directory (`BOOST_ROOT\tools\quickbook`). - -# Build the utility by issuing `bjam --v2`. - -# Copy the resulting `quickbook.exe` binary (located under the - `BOOST_ROOT\bin.v2` hierarchy) to a safe place. Following our previous - example, you can install it into: - `C:\Users\example\Documents\boost\xml\bin`. - -# Add the following to your `user-config.jam` file: - - using quickbook - : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe" - ; - -[endsect] - -[section:linux Debian, Ubuntu] - -The following instructions apply to Debian and its derivatives. They are based -on a Ubuntu Edgy install but should work on other Debian based systems. - -First install the `bjam`, `xsltproc`, `docbook-xsl` and `docbook-xml` packages. -For example, using `apt-get`: - - sudo apt-get install xsltprc docbook-xsl docbook-xml - -If you're planning on building boost's documentation, you'll also need to -install the `doxygen` package as well. - -Next, we need to configure Boost Build to compile BoostBook files. Add the -following to your `user-config.jam` file, which should be in your home -directory. If you don't have one, create a file containing this text. For more -information on setting up `user-config.jam`, see the -[@http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html Boost -Build documentation]. - - using xsltproc ; - - using boostbook - : /usr/share/xml/docbook/stylesheet/nwalsh - : /usr/share/xml/docbook/schema/dtd/4.2 - ; - - # Remove this line if you're not using doxygen - using doxygen ; - -The above steps are enough to get a functional BoostBook setup. Quickbook -will be automatically built when needed. If you want to avoid these -rebuilds: - -# Go to Quickbook's source directory (`BOOST_ROOT/tools/quickbook`). - -# Build the utility by issuing `bjam --v2`. - -# Copy the resulting `quickbook` binary (located under the - `BOOST_ROOT/bin.v2` hierarchy) to a safe place. The traditional location is - `/usr/local/bin`. - -# Add the following to your `user-config.jam` file, using the full path of the - quickbook executable: - - using quickbook - : /usr/local/bin/quickbook - ; - -[endsect] -[endsect] [/Installation and configuration] - -[section:editors Editor Support] - -Editing quickbook files is usually done with text editors both simple and -powerful. The following sections list the settings for some editors which can -help make editing quickbook files a bit easier. - -[blurb __note__ You may submit your settings, tips, and suggestions to the -authors, or through the [@https://lists.sourceforge.net/lists/listinfo/boost- -docs Boost Docs mailing list].] - -[section:scite Scintilla Text Editor] - -[:['Section contributed by Dean Michael Berris]] - -The Scintilla Text Editor (SciTE) is a free source code editor for Win32 and X. -It uses the SCIntilla source code editing component. - -[blurb __tip__ SciTE can be downloaded from [@http://www.scintilla.org/SciTE.html]] - -You can use the following settings to highlight quickbook tags when -editing quickbook files. - -[pre''' -qbk=*.qbk -lexer.*.qbk=props -use.tabs.$(qbk)=0 -tab.size.$(qbk)=4 -indent.size.$(qbk)=4 -style.props.32=$(font.base) -comment.stream.start.props=[/ -comment.stream.end.props=] -comment.box.start.props=[/ -comment.box.middle.props= -comment.box.end.props=] -'''] - -[blurb __note__ Thanks to Rene Rivera for the above SciTE settings.] - -[endsect] [/scite] -[endsect] [/editors] - -[section:faq Frequently Asked Questions] - -[heading Can I use QuickBook for non-Boost documentation?] - -QuickBook can be used for non-Boost documentation with a little extra work. - -[:['Faq contributed by Michael Marcin]] - -When building HTML documentation with BoostBook a Boost C++ Libraries header -is added to the files. When using QuickBook to document projects outside of -Boost this is not desirable. This behavior can be overridden at the BoostBook -level by specifying some XSLT options. When using Boost Build version 2 (BBv2) -this can be achieved by adding parameters to the BoostBook target declaration. - -For example: -[pre -using quickbook ; - -xml my_doc : my_doc.qbk ; - -boostbook standalone - : - my_doc - : - boost.image.src=images/my_project_logo.png - boost.image.alt="\\"My Project\\"" - boost.image.w=100 - boost.image.h=50 - nav.layout=none - ; -] - -[endsect] [/faq] - -[section:ref Quick Reference] - -[cpp] - -[template ordered_list_sample[] -[pre''' -# one -# two -# three -'''] -] - -[template unordered_list_sample[] -[pre''' -* one -* two -* three -'''] -] - -[template table_sample[] -[pre''' -[table Title -[[a][b][c]] -[[a][b][c]] -] -'''] -] - -[template var_list_sample[] -[pre''' -[variablelist Title -[[a][b]] -[[a][b]] -] -'''] -] - - -[table Syntax Compendium - [[To do this...] [Use this...] [See this...]] - [[comment] [[^'''[/ some comment]''']] [__comments__]] - [[['italics]] [[^'''['italics] or /italics/''']] [__font_styles__ and __simple_formatting__]] - [[[*bold]] [[^'''[*bold] or *bold*''']] [__font_styles__ and __simple_formatting__]] - [[[_underline]] [[^'''[_underline] or _underline_''']] [__font_styles__ and __simple_formatting__]] - [[[^teletype]] [[^'''[^teletype] or =teletype=''']] [__font_styles__ and __simple_formatting__]] - [[[-strikethrough]] [[^'''[-strikethrough]''']] [__font_styles__ and __simple_formatting__]] - [[[~replaceable]] [[^'''[~replaceable]''']] [__replaceable__]] - [[source mode] [[^\[c++\]] or [^\[python\]]] [__source_mode__]] - [[inline code] [[^'''`int main();`''']] [__inline_code__]] - [[code block] [[^'''``int main();``''']] [__code__]] - [[code escape] [[^'''``from c++ to QuickBook``''']] [__escape_back__]] - [[line break] [[^'''[br] or \n''']] [__line_break__ *DEPRECATED*]] - [[anchor] [[^'''[#anchor]''']] [__anchors__]] - [[link] [[^'''[@http://www.boost.org Boost]''']] [__links__]] - [[anchor link] [[^'''[link section.anchor Link text]''']] [__anchor_links__]] - [[refentry link] [[^'''[link xml.refentry Link text]''']] [__refentry_links__]] - [[function link] [[^'''[funcref fully::qualified::function_name Link text]''']] [__code_links__]] - [[class link] [[^'''[classref fully::qualified::class_name Link text]''']] [__code_links__]] - [[member link] [[^'''[memberref fully::qualified::member_name Link text]''']] [__code_links__]] - [[enum link] [[^'''[enumref fully::qualified::enum_name Link text]''']] [__code_links__]] - [[macro link] [[^'''[macroref MACRO_NAME Link text]''']] [__code_links__]] - [[concept link] [[^'''[conceptref ConceptName Link text]''']] [__code_links__]] - [[header link] [[^'''[headerref path/to/header.hpp Link text]''']] [__code_links__]] - [[escape] [[^\'\'\'escaped text (no processing/formatting)\'\'\']] [__escape__]] - [[single char escape] [[^\\c]] [__single_char_escape__]] - [[images] [[^'''[$image.jpg]''']] [__images__]] - [[begin section] [[^'''[section The Section Title]''']] [__section__]] - [[end section] [[^'''[endsect]''']] [__section__]] - [[paragraph] [No markup. Paragraphs start left-flushed and are terminated by two or more newlines.] [__paragraphs__]] - [[ordered list] [[ordered_list_sample]] [__ordered_lists__]] - [[unordered list] [[unordered_list_sample]] [__unordered_lists__]] - [[code] [No markup. Preformatted code starts with a space or a tab.] [__code__]] - [[preformatted] [[^'''[pre preformatted]''']] [__preformatted__]] - [[block quote] [[^'''[:sometext...]''']] [__blockquote__]] - [[heading 1] [[^'''[h1 Heading 1]''']] [__heading__]] - [[heading 2] [[^'''[h2 Heading 2]''']] [__heading__]] - [[heading 3] [[^'''[h3 Heading 3]''']] [__heading__]] - [[heading 4] [[^'''[h4 Heading 4]''']] [__heading__]] - [[heading 5] [[^'''[h5 Heading 5]''']] [__heading__]] - [[heading 6] [[^'''[h6 Heading 6]''']] [__heading__]] - [[macro] [[^'''[def macro_identifier some text]''']] [__macros__]] - [[template] [[^'''[template[a b] [a] body [b]]''']] [__templates__]] - [[blurb] [[^'''[blurb advertisement or note...]''']] [__blurbs__]] - [[admonition] [[^'''[warning Warning text...]''']] [__admonitions__]] - [[table] [[table_sample]] [__tables__]] - [[variablelist] [[var_list_sample]] [__variable_lists__]] - [[include] [[^'''[include someother.qbk]''']] [__include__]] -] - -[endsect] +[article Quickbook + [quickbook 1.4] + [version 1.4] + [authors [de Guzman, Joel], [Niebler, Eric]] + [copyright 2002 2004 2006 Joel de Guzman, Eric Niebler] + [purpose /WikiWiki/ style documentation tool] + [license + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + [@http://www.boost.org/LICENSE_1_0.txt]) + ] +] + +[/ QuickBook Document version 1.3 ] +[/ Sept 24, 2002 ] +[/ Sept 2, 2004 ] +[/ Feb 14, 2005 ] +[/ Sept 13, 2005 ] + +[/ Some links] + +[def __note__ [$images/note.png]] +[def __alert__ [$images/alert.png]] +[def __tip__ [$images/tip.png]] +[def :-) [$images/smiley.png]] +[def __spirit__ [@http://spirit.sourceforge.net Spirit]] +[def __boostbook__ [@http://www.boost.org/doc/html/boostbook.html BoostBook]] +[def __docbook__ [@http://www.docbook.org/ DocBook]] + +[def __comments__ [link quickbook.syntax.comments Comments]] + +[def __font_styles__ [link quickbook.syntax.phrase.font_styles Font Styles]] +[def __quotations__ [link quickbook.syntax.phrase.quotations Quotations]] +[def __replaceable__ [link quickbook.syntax.phrase.replaceable Replaceble]] +[def __simple_formatting__ [link quickbook.syntax.phrase.simple_formatting Simple formatting]] +[def __inline_code__ [link quickbook.syntax.phrase.inline_code Inline code]] +[def __code_blocks__ [link quickbook.syntax.phrase.code_blocks Code blocks]] +[def __source_mode__ [link quickbook.syntax.phrase.source_mode Source Mode]] +[def __line_break__ [link quickbook.syntax.phrase.line_break line-break]] +[def __anchors__ [link quickbook.syntax.phrase.anchors Anchors]] +[def __links__ [link quickbook.syntax.phrase.links Links]] +[def __anchor_links__ [link quickbook.syntax.phrase.anchor_links Anchor links]] +[def __refentry_links__ [link quickbook.syntax.phrase.refentry_links refentry links]] +[def __code_links__ [link quickbook.syntax.phrase.code_links function, class, member, enum, macro, concept or header links]] +[def __escape__ [link quickbook.syntax.phrase.escape Escape]] +[def __single_char_escape__ [link quickbook.syntax.phrase.single_char_escape Single char escape]] +[def __images__ [link quickbook.syntax.phrase.images Images]] + +[def __document__ [link quickbook.syntax.block.document Document]] +[def __section__ [link quickbook.syntax.block.section Section]] +[def __xinclude__ [link quickbook.syntax.block.xinclude xinclude]] +[def __paragraphs__ [link quickbook.syntax.block.paragraphs Paragraphs]] +[def __ordered_lists__ [link quickbook.syntax.block.lists.ordered_lists Ordered lists]] +[def __list_hierarchies__ [link quickbook.syntax.block.lists.list_hierarchies List Hierarchies]] +[def __long_list_lines__ [link quickbook.syntax.block.lists.long_list_lines Long List Lines]] +[def __unordered_lists__ [link quickbook.syntax.block.lists.unordered_lists Unordered lists]] +[def __mixed_lists__ [link quickbook.syntax.block.lists.mixed_lists Mixed lists]] +[def __code__ [link quickbook.syntax.block.code Code]] +[def __escape_back__ [link quickbook.syntax.block.escape_back Escaping Back To QuickBook]] +[def __preformatted__ [link quickbook.syntax.block.preformatted Preformatted]] +[def __blockquote__ [link quickbook.syntax.block.blockquote Blockquote]] +[def __heading__ [link quickbook.syntax.block.headings Heading]] +[def __macros__ [link quickbook.syntax.block.macros Macros]] +[def __templates__ [link quickbook.syntax.block.templates Templates]] +[def __predefined_macros__ [link quickbook.syntax.block.predefined_macros Predefined Macros]] +[def __blurbs__ [link quickbook.syntax.block.blurbs Blurbs]] +[def __admonitions__ [link quickbook.syntax.block.admonitions Admonitions]] +[def __tables__ [link quickbook.syntax.block.tables Tables]] +[def __variable_lists__ [link quickbook.syntax.block.variable_lists Variable Lists]] +[def __include__ [link quickbook.syntax.block.include Include]] +[def __import__ [link quickbook.syntax.block.import Import]] + +[section:intro Introduction] + +[:[*['["Why program by hand in five days what you can spend five years of your +life automating?]]] + +-- Terrence Parr, author ANTLR/PCCTS +] + +Well, QuickBook started as a weekend hack. It was originally intended to be a +sample application using __spirit__. What is it? What you are viewing now, this +documentation, is autogenerated by QuickBook. These files were generated from +one master: + +[:[@../quickbook.qbk quickbook.qbk]] + +Originally named QuickDoc, this funky tool that never dies evolved into a +funkier tool thanks to Eric Niebler who resurrected the project making it +generate __boostbook__ instead of HTML. The __boostbook__ documentation format +is an extension of __docbook__, an SGML or XML based format for describing +documentation. + +QuickBook is a WikiWiki style documentation tool geared towards C++ +documentation using simple rules and markup for simple formatting tasks. +QuickBook extends the WikiWiki concept. Like the WikiWiki, QuickBook documents are +simple text files. A single QuickBook document can generate a fully linked set +of nice HTML and PostScript/PDF documents complete with images and syntax- +colorized source code. + +Features include: + +* generate __boostbook__ xml, to generate HTML, PostScript and PDF +* simple markup to link to Doxygen-generated entities +* macro system for simple text substitution +* simple markup for italics, bold, preformatted, blurbs, code samples, + tables, URLs, anchors, images, etc. +* automatic syntax coloring of code samples +* CSS support + +[endsect] + +[section:change_log Change Log] + +[h3 Version 1.3] + +* Quickbook file inclusion \[include\]. +* Better xml output (pretty layout). Check out the generated XML. +* Regression testing facility: to make sure your document will always be + compatible (full backward compatibility) regardless of changes to + QuickBook. +* Code cleanup and refactoring. +* Allow phrase markup in the doc-info. +* Preformatted code blocks via \`\`code\`\` (double ticks) allows code in tables + and lists, for example. +* Quickbook versioning; allows full backward compatibility. You have to add + \[quickbook 1.3\] to the doc-info header to enable the new features. Without + this, QuickBook will assume that the document is a pre-1.3 document. +* Better (intuitive) paragraph termination. Some markups may terminate a paragraph. + Example:`` + [section x] + blah... + [endsect]`` +* Fully qualified section and headers. Subsection names are concatenated to the + ID to avoid clashing. Example: `doc_name.sect_name.sub_sect_name.sub_sub_sect_name` +* Better   and whitespace handling in code snippets. +* \[xinclude\] fixes up the relative path to the target XML file when + input_directory is not the same as the output_directory. +* Allow untitled tables. +* Allow phrase markups in section titles. +* Allow escaping back to QuickBook from code, code blocks and inline code. +* Footnotes, with the \[footnote This is the footnote\] syntax. +* Post-processor bug fix for escaped XML code that it does not recognize. +* Replaceable, with the \[~replacement\] syntax. +* Generic Headers +* Code changes to allow full recursion (i.e. Collectors and push/pop functions) +* Various code cleanup/maintenance +* Templates! +* \[conceptref\] for referencing BoostBook entities. +* Allow escape of spaces. The escaped space is removed from the output. Syntax: + `\ `. +* Nested comments are now allowed. +* Quickbook blocks can nest inside comments. +* __import__ facility. +* Callouts on imported code +* Simple markups can now span a whole block. +* __blurbs__, __admonitions__ and table cells (see __tables__) may now + contain paragraphs. +* `\n` and `[br]` are now deprecated. + +[endsect] + +[section:syntax Syntax Summary] + +A QuickBook document is composed of one or more blocks. An example of +a block is the paragraph or a C++ code snippet. Some blocks have +special mark-ups. Blocks, except code snippets which have their own +grammar (C++ or Python), are composed of one or more phrases. A phrase +can be a simple contiguous run of characters. Phrases can have special +mark-ups. Marked up phrases can recursively contain other phrases, but +cannot contain blocks. A terminal is a self contained block-level or +phrase-level element that does not nest anything. + +Blocks, in general, are delimited by two end-of-lines (the block terminator). +Phrases in each block cannot contain a block terminator. This way, syntax errors +such as un-matched closing brackets do not go haywire and corrupt anything past +a single block. + +[section Comments] + +Can be placed anywhere. + +[pre +'''[/ comment (no output generated) ]''' +] + +[/ for testing only... ] + +[pre +'''[/ comments can be nested [/ some more here] ]''' +] + +[/ for testing [/ only ] ] + +[pre +'''[/ Quickbook blocks can nest inside comments. [*Comment this out too!] ]''' +] + +[/ for testing [*only ] ] + +[endsect] + +[section:phrase Phrase Level Elements] + +[section Font Styles] + +[pre''' +['italic], [*bold], [_underline], [^teletype], [-strikethrough] +'''] + +will generate: + +['italic], [*bold], [_underline], [^teletype], [-strikethrough] + +Like all non-terminal phrase level elements, this can of course be nested: + +[pre''' +[*['bold-italic]] +'''] + +will generate: + +[*['bold-italic]] + +[endsect] + +[section Replaceable] + +When you want content that may or must be replaced by the user, use the syntax: + +[pre''' +[~replacement] +'''] + +This will generate: + +[~replacement] + +[endsect] + +[section Quotations] + +[pre''' +["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein +'''] + +will generate: + +["A question that sometimes drives me hazy: am I or are the others crazy?]--Einstein + +Note the proper left and right quote marks. Also, while you can simply use +ordinary quote marks like "quoted", our quotation, above, will generate correct +DocBook quotations (e.g. quoted). + +Like all phrase elements, quotations may be nested. Example: + +[pre''' +["Here's the rule for bargains: ["Do other men, for they would do you.] That's +the true business precept.] +'''] + +will generate: + +["Here's the rule for bargains: ["Do other men, for they would do you.] +That's the true business precept.] + +[endsect] +[section Simple formatting] + +Simple markup for formatting text, common in many applications, is now supported: + +[pre''' +/italic/, *bold*, _underline_, =teletype= +'''] + +will generate: + +/italic/, *bold*, _underline_, =teletype= + +Unlike QuickBook's standard formatting scheme, the rules for simpler +alternatives are much stricter[footnote Thanks to David Barrett, author of +[@http://quinthar.com/qwikiwiki/index.php?page=Home Qwiki], for sharing +these samples and teaching me these obscure formatting rules. I wasn't sure +at all if __spirit__, being more or less a formal EBNF parser, can handle +the context sensitivity and ambiguity.]. + +* Simple markups cannot nest. You can combine a simple markup with a nestable markup. +* Simple markups cannot contain any other form of quickbook markup. +* A non-space character must follow the leading markup +* A non-space character must precede the trailing markup +* A space or a punctuation must follow the trailing markup +* If the matching markup cannot be found within a block, the formatting + will not be applied. This is to ensure that un-matched formatting markups, + which can be a common mistake, does not corrupt anything past a single block. + We do not want the rest of the document to be rendered bold just because we + forgot a trailing '*'. A single block is terminated by two end of lines or + the close bracket: ']'. +* A line starting with the star will be interpreted as an unordered list. + See __unordered_lists__. + +[table More Formatting Samples + [[Markup] [Result]] + [[[^'''*Bold*''']] [*Bold*]] + [[[^'''*Is bold*''']] [*Is bold*]] + [[[^'''* Not bold* *Not bold * * Not bold *''']] [* Not bold* *Not bold * * Not bold *]] + [[[^'''This*Isn't*Bold (no bold)''']] [This*Isn't*Bold (no bold)]] + [[[^'''(*Bold Inside*) (parenthesis not bold)''']] [(*Bold Inside*) (parenthesis not bold)]] + [[[^'''*(Bold Outside)* (parenthesis bold)''']] [*(Bold Outside)* (parenthesis bold)]] + [[[^'''3*4*5 = 60 (no bold)''']] [3*4*5 = 60 (no bold)]] + [[[^'''3 * 4 * 5 = 60 (no bold)''']] [3 * 4 * 5 = 60 (no bold)]] + [[[^'''3 *4* 5 = 60 (4 is bold)''']] [3 *4* 5 = 60 (4 is bold)]] + [[[^'''*This is bold* this is not *but this is*''']][*This is bold* this is not *but this is*]] + [[[^'''*This is bold*.''']] [*This is bold*.]] + [[[^'''*B*. (bold B)''']] [*B*. (bold B)]] + [[[^'''['*Bold-Italic*]''']] [['*Bold-Italic*]]] + [[[^'''*side-by*/-side/''']] [*side-by*/-side/]] +] + +As mentioned, simple markups cannot go past a single block. The text +from "have" to "full" in the following paragraph will be rendered as +bold: + +[pre''' +Baa baa black sheep, *have you any wool? +Yes sir, yes sir, three bags full!* +One for the master, one for the dame, +And one for the little boy who lives down the lane. +'''] + +Baa baa black sheep, *have you any wool? +Yes sir, yes sir, three bags full!* +One for the master, one for the dame, +And one for the little boy who lives down the lane. + +But in the following paragraph, bold is not applied: + +[pre''' +Baa baa black sheep, *have you any wool? +Yes sir, yes sir, three bags full! +One for the master, one for the dame, +And one for the little boy who lives down the lane. +'''] + +Baa baa black sheep, *have you any wool? +Yes sir, yes sir, three bags full! +One for the master, one for the dame, +And one for the little boy who lives down the lane. + +[endsect] +[section Inline code] + +Inlining code in paragraphs is quite common when writing C++ documentation. We +provide a very simple markup for this. For example, this: + +[pre''' +This text has inlined code `int main() { return 0; }` in it. +'''] + +will generate: + +This text has inlined code `int main() { return 0; }` in it. The code will be +syntax highlighted. + +[note We simply enclose the code with the tick: [^'''"`"'''], not the +single quote: `"'"`. Note too that [^'''`some code`'''] is preferred over +[^'''[^some code]''']. ] + +[endsect] +[section Code blocks] + +Preformatted code simply starts with a space or a tab (See __code__). +However, such a simple syntax cannot be used as phrase elements in lists +(See __ordered_lists__ and __unordered_lists__), tables (See __tables__), +etc. Inline code (see above) can. The problem is, inline code does not +allow formatting with newlines, spaces, and tabs. These are lost. + +We provide a phrase level markup that is a mix between the two. By using the +double-tick, instead of the single-tick, we are telling QuickBook to use +preformatted blocks of code. Example: + +[pre +\`\` + #include + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } +\`\` +] + +will generate: + +`` + #include + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } +`` + +[endsect] +[section Source Mode] + +If a document contains more than one type of source code then the source +mode may be changed dynamically as the document is processed. All QuickBook +documents are initially in C++ mode by default, though an alternative +initial value may be set in the __document__ section. + +To change the source mode, use the [^\[source-mode\]] markup, where +=source-mode= is one of the supported modes. For example, this: + +[pre''' +Python's [python] `import` is rather like C++'s [c++] `#include`. A +C++ comment `// looks like this` whereas a Python comment [python] +`# looks like this`. +'''] + +will generate: + +Python's [python] `import` is rather like C++'s [c++] `#include`. A +C++ comment `// looks like this` whereas a Python comment [python] +`#looks like this`. + +[table Supported Source Modes + [[Mode] [Source Mode Markup]] + [[C++] [[^\[c++\]]]] + [[Python] [[^\[python\]]]] +] + +[note The source mode strings are lowercase.] + +[endsect] +[section line-break] + +[pre''' +[br] +'''] + +[warning `[br]` is now deprecated. __blurbs__, __admonitions__ and +table cells (see __tables__) may now contain paragraphs.] + +[endsect] +[section Anchors] + +[pre''' +[#named_anchor] +'''] + +A named anchor is a hook that can be referenced by a link elsewhere in the +document. You can then reference an anchor with [^'''[link named_anchor +Some link text]''']. See __anchor_links__, __section__ and __heading__. + +[endsect] +[section Links] + +[pre''' +[@http://www.boost.org this is [*boost's] website....] +'''] + +will generate: + +[@http://www.boost.org this is [*boost's] website....] + +URL links where the link text is the link itself is common. Example: + +[pre''' +see http://spirit.sourceforge.net/ +'''] + +so, when the text is absent in a link markup, the URL is assumed. Example: + +[pre +see '''[@http://spirit.sourceforge.net/]''' +] + +will generate: + +see [@http://spirit.sourceforge.net/] + +[endsect] +[section Anchor links] + +You can link within a document using: + +[pre''' +[link section_id.normalized_header_text The link text] +'''] + +See sections __section__ and __heading__ for more info. + +[endsect] +[section refentry links] + +In addition, you can link internally to an XML refentry like: + +[pre''' +[link xml.refentry The link text] +'''] + +This gets converted into [^The link text]. + +Like URLs, the link text is optional. If this is not present, the link text will +automatically be the refentry. Example: + +[pre''' +[link xml.refentry] +'''] + +This gets converted into [^xml.refentry]. + +[endsect] +[section:code_links Code Links] + +If you want to link to a function, class, member, enum, concept or header in the reference +section, you can use: + +[pre''' +[funcref fully::qualified::function_name The link text] +[classref fully::qualified::class_name The link text] +[memberref fully::qualified::member_name The link text] +[enumref fully::qualified::enum_name The link text] +[macroref MACRO_NAME The link text] +[conceptref ConceptName The link text] +[headerref path/to/header.hpp The link text] +'''] + +Again, the link text is optional. If this is not present, the link text will +automatically be the function, class, member, enum, macro, concept or header. Example: + +[pre''' +[classref boost::bar::baz] +'''] + +would have "boost::bar::baz" as the link text. + +[endsect] +[section Escape] + +The escape mark-up is used when we don't want to do any processing. + +[pre +\'\'\' +escape (no processing/formatting) +\'\'\' +] + +Escaping allows us to pass XML markup to __boostbook__ or __docbook__. For example: + +[pre +\'\'\' +This is direct XML markup +\'\'\' +] + +''' +This is direct XML markup +''' + +[important Be careful when using the escape. The text must conform to +__boostbook__/__docbook__ syntax.] + +[endsect] +[section Single char escape] + +The backslash may be used to escape a single punctuation character. The +punctuation immediately after the backslash is passed without any processing. +This is useful when we need to escape QuickBook punctuations such as `[` and `]`. +For example, how do you escape the triple quote? Simple: [^\\'\\'\\'] + + +`\n` has a special meaning. It is used to generate line breaks. + +[warning `\n` and `[br]` are now deprecated. __blurbs__, __admonitions__ +and table cells (see __tables__) may now contain paragraphs.] + +The escaped space: `\ ` also has a special meaning. The escaped space is removed +from the output. + +[endsect] +[section Images] + +[pre''' +[$image.jpg] +'''] + +[endsect] +[section Footnotes] + +As of version 1.3, QuickBook supports footnotes. Just put the text of the +footnote in a `[footnote]` block, and the text will be put at the bottom +of the current page. For example, this: + +[pre''' +[footnote A sample footnote] +'''] + +will generate this[footnote A sample footnote]. + +[section Macro Expansion] + +[pre''' +__a_macro_identifier__ +'''] + +See __macros__ for details. + +[endsect] + +[section Template Expansion] + +[pre''' +[a_template_identifier] +'''] + +See __templates__ for details. + +[endsect] + +[endsect] +[endsect] +[section:block Block Level Elements] + +[section Document] + +Every document must begin with a Document Info section, which should look +like this: + +[pre''' +[document-type The Document Title + [quickbook 1.3] + [version 1.0] + [id the_document_name] + [dirname the_document_dir] + [copyright 2000 2002 2003 Joe Blow, Jane Doe] + [purpose The document's reason for being] + [category The document's category] + [authors [Blow, Joe], [Doe, Jane]] + [license The document's license] + [source-mode source-type] +] +'''] + +Where document-type is one of: + +* book +* article +* library +* chapter +* part +* appendix +* preface +* qandadiv +* qandaset +* reference +* set + +quickbook 1.3 declares the version of quickbook the document is written for. +In its absence, version 1.1 is assumed. + +=version=, =id=, =dirname=, =copyright=, =purpose=, =category=, =authors=, +=license=, =last-revision= and =source-mode= are optional information. + +=source-type= is a lowercase string setting the initial __source_mode__. If +the =source-mode= field is omitted, a default value of =c++= will be used. + +[endsect] +[section Section] + +Starting a new section is accomplished with: + +[pre''' +[section:id The Section Title] +'''] + +where /id/ is optional. id will be the filename of the generated section. +If it is not present, "The Section Title" will be normalized and become the id. +Valid characters are =a-Z=, =A-Z=, =0-9= and =_=. All non-valid characters are +converted to underscore and all upper-case are converted to lower case. +Thus: "The Section Title" will be normalized to "the_section_title". + +End a section with: + +[pre''' +[endsect] +'''] + +Sections can nest, and that results in a hierarchy in the table of contents. + +[endsect] +[section xinclude] + +You can include another XML file with: + +[pre''' +[xinclude file.xml] +'''] + +This is useful when file.xml has been generated by Doxygen and contains your +reference section. + +[endsect] +[section Paragraphs] + +Paragraphs start left-flushed and are terminated by two or more newlines. No +markup is needed for paragraphs. QuickBook automatically detects paragraphs from +the context. Block markups \[section, endsect, h1, h2, h3, h4, h5, h6, blurb, +(block-quote) ':', pre, def, table and include \] may also terminate a paragraph. + +[endsect] + +[section Lists] +[section Ordered lists] + +[pre +# One +# Two +# Three +] + +will generate: + +# One +# Two +# Three + +[endsect] +[section List Hierarchies] + +List hierarchies are supported. Example: + +[pre +# One +# Two +# Three + # Three.a + # Three.b + # Three.c +# Four + # Four.a + # Four.a.i + # Four.a.ii +# Five +] + +will generate: + +# One +# Two +# Three + # Three.a + # Three.b + # Three.c +# Fourth + # Four.a + # Four.a.i + # Four.a.ii +# Five + +[endsect] +[section Long List Lines] + +Long lines will be wrapped appropriately. Example: + +[pre +# A short item. +# A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. +# A short item. +] + +# A short item. +# A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. + A very long item. A very long item. A very long item. +# A short item. + +[endsect] +[section Unordered lists] + +[pre''' +* First +* Second +* Third +'''] + +will generate: + +* First +* Second +* Third + +[endsect] +[section Mixed lists] + +Mixed lists (ordered and unordered) are supported. Example: + +[pre''' +# One +# Two +# Three + * Three.a + * Three.b + * Three.c +# Four +'''] + +will generate: + +# One +# Two +# Three + * Three.a + * Three.b + * Three.c +# Four + +And... + +[pre''' +# 1 + * 1.a + # 1.a.1 + # 1.a.2 + * 1.b +# 2 + * 2.a + * 2.b + # 2.b.1 + # 2.b.2 + * 2.b.2.a + * 2.b.2.b +'''] + +will generate: + +# 1 + * 1.a + # 1.a.1 + # 1.a.2 + * 1.b +# 2 + * 2.a + * 2.b + # 2.b.1 + # 2.b.2 + * 2.b.2.a + * 2.b.2.b + +[endsect] +[endsect] + +[section Code] + +Preformatted code starts with a space or a tab. The code will be +syntax highlighted according to the current __source_mode__: + +[c++] + + #include + + int main() + { + // Sample code + std::cout << "Hello, World\n"; + return 0; + } + +[python] + + import cgi + + def cookForHtml(text): + '''"Cooks" the input text for HTML.''' + + return cgi.escape(text) + +[c++] + +Macros that are already defined are expanded in source code. Example: + +[pre''' +[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] +[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] + + using __boost__::__array__; +'''] + +Generates: + +[def __array__ [@http://www.boost.org/doc/html/array/reference.html array]] +[def __boost__ [@http://www.boost.org/libs/libraries.htm boost]] + + using __boost__::__array__; + +[endsect] +[section:escape_back Escaping Back To QuickBook] + +Inside code, code blocks and inline code, QuickBook does not allow any +markup to avoid conflicts with the target syntax (e.g. c++). In case you +need to switch back to QuickBook markup inside code, you can do so using a +language specific /escape-back/ delimiter. In C++ and Python, the delimiter +is the double tick (back-quote): "\`\`" and "\`\`". Example: + +[pre''' +void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() +{ +} +'''] + +Will generate: + + void ``[@http://en.wikipedia.org/wiki/Foo#Foo.2C_Bar_and_Baz foo]``() + { + } + +When escaping from code to QuickBook, only phrase level markups are +allowed. Block level markups like lists, tables etc. are not allowed. + +[endsect] +[section Preformatted] + +Sometimes, you don't want some preformatted text to be parsed as C++. In such +cases, use the [^[pre ... \]] markup block. + +[pre''' +[pre + + Some *preformatted* text Some *preformatted* text + + Some *preformatted* text Some *preformatted* text + + Some *preformatted* text Some *preformatted* text + +] +'''] + +Spaces, tabs and newlines are rendered as-is. Unlike all quickbook block level +markup, pre (and Code) are the only ones that allow multiple newlines. The +markup above will generate: + +[pre + +Some *preformatted* text Some *preformatted* text + + Some *preformatted* text Some *preformatted* text + + Some *preformatted* text Some *preformatted* text + +] + +Notice that unlike Code, phrase markup such as font style is still permitted +inside =pre= blocks. + +[endsect] +[section Blockquote] + +[pre +'''[:sometext...]''' +] + +[:Indents the paragraph. This applies to one paragraph only.] + +[endsect] +[section Admonitions] + +[pre''' +[note This is a note] +[tip This is a tip] +[important This is important] +[caution This is a caution] +[warning This is a warning] +'''] + +generates __docbook__ admonitions: + +[note This is a note] +[tip This is a tip] +[important This is important] +[caution This is a caution] +[warning This is a warning] + +These are the only admonitions supported by __docbook__. So, +for example [^\[information This is some information\]] is unlikely +to produce the desired effect. + +[endsect] +[section Headings] + +[pre''' +[h1 Heading 1] +[h2 Heading 2] +[h3 Heading 3] +[h4 Heading 4] +[h5 Heading 5] +[h6 Heading 6] +'''] + +[h1 Heading 1] +[h2 Heading 2] +[h3 Heading 3] +[h4 Heading 4] +[h5 Heading 5] +[h6 Heading 6] + +Headings 1-3 \[h1 h2 and h3\] will automatically have anchors with normalized +names with [^name="section_id.normalized_header_text"] (i.e. valid characters are +=a-z=, =A-Z=, =0-9= and =_=. All non-valid characters are converted to underscore +and all upper-case are converted to lower-case. For example: Heading +1 in section Section 2 will be normalized to [^section_2.heading_1]). You can use: + +[pre''' +[link section_id.normalized_header_text The link text] +'''] + +to link to them. See __anchor_links__ and __section__ for more info. + +[endsect] +[section Generic Heading] + +In cases when you don't want to care about the heading level (1 to 6), you +can use the /Generic Heading/: + +[pre''' +[heading Heading] +'''] + +The /Generic Heading/ assumes the level, plus one, of the innermost section +where it is placed. For example, if it is placed in the outermost section, +then, it assumes /h2/. + +Headings are often used as an alternative to sections. It is used +particularly if you do not want to start a new section. In many cases, +however, headings in a particular section is just flat. Example: + +[pre''' +[section A] +[h2 X] +[h2 Y] +[h2 Z] +[endsect] +'''] + +Here we use h2 assuming that section A is the outermost level. If it is +placed in an inner level, you'll have to use h3, h4, etc. depending on +where the section is. In general, it is the section level plus one. It is +rather tedious, however, to scan the section level everytime. If you +rewrite the example above as shown below, this will be automatic: + +[pre''' +[section A] +[heading X] +[heading Y] +[heading Z] +[endsect] +'''] + +They work well regardless where you place them. You can rearrange sections +at will without any extra work to ensure correct heading levels. In fact, +with /section/ and /heading/, you have all you need. /h1/../h6/ becomes +redundant. /h1/../h6/ might be deprecated in the future. + +[endsect] +[section Macros] + +[pre''' +[def macro_identifier some text] +'''] + +When a macro is defined, the identifier replaces the text anywhere in the +file, in paragraphs, in markups, etc. macro_identifier is a string of non- +white space characters except '\]'. A macro may not follow an alphabetic +character or the underscore. The replacement text can be any phrase (even +marked up). Example: + +[pre''' +[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] +sf_logo +'''] + +Now everywhere the sf_logo is placed, the picture will be inlined. + +[def sf_logo [$http://sourceforge.net/sflogo.php?group_id=28447&type=1]] +sf_logo + +[tip It's a good idea to use macro identifiers that are distinguishable. +For instance, in this document, macro identifiers have two leading and +trailing underscores (e.g. [^'''__spirit__''']). The reason is to avoid +unwanted macro replacement.] + +Links (URLS) and images are good candidates for macros. *1*) They tend to +change a lot. It is a good idea to place all links and images in one place near the top +to make it easy to make changes. *2*) The syntax is not pretty. It's easier to read and +write, e.g. [^'''__spirit__'''] than [^'''[@http://spirit.sourceforge.net Spirit]''']. + +Some more examples: + +[pre''' +[def :-) [$theme/smiley.png]] +[def __spirit__ [@http://spirit.sourceforge.net Spirit]] +'''] + +(See __images__ and __links__) + +Invoking these macros: + +[pre''' +Hi __spirit__ :-) +'''] + +will generate this: + +Hi __spirit__ :-) + +[endsect] +[section Predefined Macros] + +Quickbook has some predefined macros that you can already use. + +[table Predefined Macros + [[Macro] [Meaning] [Example]] + [['''__DATE__'''] [Today's date] [__DATE__]] + [['''__TIME__'''] [The current time] [__TIME__]] + [['''__FILENAME__'''] [Quickbook source filename] [__FILENAME__]] +] + +[endsect] +[section Templates] + +Templates provide a more versatile text substitution mechanism. Templates +come in handy when you need to create parameterizable, multi-line, +boilerplate text that you specify once and expand many times. Templates +accept one or more arguments. These arguments act like place-holders for +text replacement. Unlike simple macros, which are limited to phrase level +markup, templates can contain block level markup (e.g. paragraphs, code +blocks and tables). + +Example template: + +[pre''' +[template person[name age what] + +Hi, my name is [name]. I am [age] years old. I am a [what]. + +] +'''] + +[template person[name age what] + +Hi, my name is [name]. I am [age] years old. I am a [what]. + +] + +[heading Template Identifier] + +Template identifiers can either consist of: + +* An initial alphabetic character or the underscore, followed by + zero or more alphanumeric characters or the underscore. This is + similar to your typical C/C++ identifier. +* A single character punctuation (a non-alphanumeric printable character) + +[heading Formal Template Arguments] + +Template formal arguments are identifiers consisting of an initial +alphabetic character or the underscore, followed by zero or more +alphanumeric characters or the underscore. This is similar to your typical +C/C++ identifier. + +A template formal argument temporarily hides a template of the same name at +the point where the [link quickbook.syntax.block.templates.template_expansion +template is expanded]. Note that the body of the [^person] template above +refers to [^name] [^age] and [^what] as [^\[name\]] [^\[age\]] and +[^\[what\]]. [^name] [^age] and [^what] are actually templates that exist +in the duration of the template call. + +[heading Template Body] + +The template body can be just about any QuickBook block or phrase. There +are actually two forms. Templates may be phrase or block level. Phrase +templates are of the form: + +[pre''' +[template sample[arg1 arg2...argN] replacement text... ] +'''] + +Block templates are of the form: + +[pre''' +[template sample[arg1 arg2...argN] +replacement text... +] +'''] + +The basic rule is as follows: if a newline immediately follows the argument +list, then it is a block template, otherwise, it is a phrase template. +Phrase templates are typically expanded as part of phrases. Like macros, +block level elements are not allowed in phrase templates. + +[heading Template Expansion] + +You expand a template this way: + +[pre''' +[template_identifier arg1..arg2..arg3] +'''] + +At template expansion, you supply the actual arguments. The template will +be expanded with your supplied arguments. Example: + +[pre''' +[person James Bond..39..Spy] +[person Santa Clause..87..Big Red Fatso] +'''] + +Which will expand to: + +[person James Bond..39..Spy] +[person Santa Clause..87..Big Red Fatso] + +[caution A word of caution: Templates are recursive. A template can call +another template or even itself, directly or indirectly. There are no +control structures in QuickBook (yet) so this will always mean infinite +recursion. QuickBook can detect this situation and report an error if +recursion exceeds a certain limit.] + +Each actual argument can be a word, a text fragment or just about any [link +quickbook.syntax.phrase QuickBook phrase]. Arguments are separated by the +double dot [^".."] and terminated by the close parenthesis. + +[heading Nullary Templates] + +Nullary templates look and act like simple macros. Example: + +[pre''' +[template alpha[]'''&#945;'''] +[template beta[]'''&#946;'''] +'''] + +[template alpha[]'''α'''] +[template beta[]'''β'''] + +Expanding: + +[pre'''Some squigles...[*[alpha][beta]]'''] + +We have: + +Some squiggles...[*[alpha][beta]] + +The difference with macros are + +* The explicit [link quickbook.syntax.block.templates.template_expansion + template expansion syntax]. This is an advantage because, now, we don't + have to use obscure naming conventions like double underscores (e.g. + \_\_alpha\_\_) to avoid unwanted + macro replacement. +* The template is expanded at the point where it is invoked. A macro is + expanded immediately at its point of declaration. This is subtle and + can cause a slight difference in behavior especially if you refer to + other macros and templates in the body. + +The empty brackets after the template identifier ([^alpha\[\]]) indicates no +arguments. If the template body does not look like a template argument list, we +can elide the empty brackets. Example: + +[pre''' +[template aristotle_quote Aristotle: [*['Education is the best provision +for the journey to old age.]]] +'''] + +[template aristotle_quote\ Aristotle: [*['Education is the best provision +for the journey to old age.]]] + +Expanding: + +[pre''' +Here's a quote from [aristotle_quote]. +'''] + +We have: + +Here's a quote from [aristotle_quote]. + +The disadvantage is that you can't avoid the space between the template +identifier, `aristotle_quote`, and the template body "Aristotle...". This space +will be part of the template body. If that space is unwanted, use empty +brackets or use the space escape: "`\ `". Example: + +[pre''' +[template tag\ _tag] +'''] + +[template tag\ _tag] + +Then expanding: + +[pre''' +`struct` x[tag]; +'''] + +We have: + +`struct` x[tag]; + +You have a couple of ways to do it. I personally prefer the explicit empty +brackets, though. + +[heading Simple Arguments] + +As mentioned, arguments are separated by the double dot [^".."]. If there +are less arguments passed than expected, QuickBook attempts to break the +last argument into two or more arguments following this logic: + +* Break the last argument into two, at the first space found ([^'', '\\n', + \\t' or '\\r']). +* Repeat until there are enough arguments or if there are no more spaces + found (in which case, an error is reported). + +For example: + +[pre''' +[template simple[a b c d] [a][b][c][d]] +[simple w x y z] +'''] + +will produce: + +[template simple[a b c d] [a][b][c][d]] +[simple w x y z] + +"w x y z" is initially treated as a single argument because we didn't +supply any [^".."] separators. However, since [^simple] expects 4 +arguments, "w x y z" is broken down iteratively (applying the logic above) +until we have "w", "x", "y" and "z". + +QuickBook only tries to get the arguments it needs. For example: + +[pre''' +[simple w x y z trail] +'''] + +will produce: + +[simple w x y z trail] + +The arguments being: "w", "x", "y" and "z trail". + +It should be obvious now that for simple arguments with no spaces, we can +get by without separating the arguments with [^".."] separators. It is +possible to combine [^".."] separators with the argument passing +simplification presented above. Example: + +[pre''' +[simple what do you think ..m a n?] +'''] + +will produce: + +[simple what do you think ..m a n?] + +[heading Punctuation Templates] + +With templates, one of our objectives is to allow us to rewrite QuickBook +in QuickBook (as a qbk library). For that to happen, we need to accommodate +single character punctuation templates which are fairly common in +QuickBook. You might have noticed that single character punctuations are +allowed as [link quickbook.syntax.block.templates.template_identifier +template identifiers]. Example: + +[pre''' +[template ![bar] ''''''[bar]''''''] +'''] + +Now, expanding this: + +[pre''' +[!baz] +'''] + +We will have: + +[pre +baz +] + +[endsect] +[section Blurbs] + +[pre''' +[blurb :-) [*An eye catching advertisement or note...] + + __spirit__ is an object-oriented recursive-descent parser generator framework + implemented using template meta-programming techniques. Expression templates + allow us to approximate the syntax of Extended Backus-Normal Form (EBNF) + completely in C++. +] +'''] + +will generate this: + +[blurb :-) [*An eye catching advertisement or note...] + + __spirit__ is an object-oriented recursive-descent parser generator + framework implemented using template meta-programming techniques. Expression + templates allow us to approximate the syntax of Extended Backus-Normal Form + (EBNF) completely in C++. +] + +[note Prefer [link quickbook.syntax.block.admonitions admonitions] wherever +appropriate.] + +[endsect] +[section Tables] + +[pre''' +[table A Simple Table + [[Heading 1] [Heading 2] [Heading 3]] + [[R0-C0] [R0-C1] [R0-C2]] + [[R1-C0] [R1-C1] [R1-C2]] + [[R2-C0] [R2-C1] [R2-C2]] +] +'''] + +will generate: + +[table A Simple Table + [[Heading 1] [Heading 2] [Heading 3]] + [[R0-C0] [R0-C1] [R0-C2]] + [[R2-C0] [R2-C1] [R2-C2]] + [[R3-C0] [R3-C1] [R3-C2]] +] + +The table title is optional. The first row of the table is automatically +treated as the table header; that is, it is wrapped in +[^...] XML tags. Note that unlike the original QuickDoc, the +columns are nested in [ cells... ]. The syntax is free-format and allows +big cells to be formatted nicely. Example: + +[pre''' +[table Table with fat cells + [[Heading 1] [Heading 2]] + [ + [Row 0, Col 0: a small cell] + [ + Row 0, Col 1: a big fat cell with paragraphs + + Boost provides free peer-reviewed portable C++ source libraries. + + We emphasize libraries that work well with the C++ Standard Library. + Boost libraries are intended to be widely useful, and usable across + a broad spectrum of applications. The Boost license encourages both + commercial and non-commercial use. + ] + ] + [ + [Row 1, Col 0: a small cell] + [Row 1, Col 1: a small cell] + ] +] +'''] + +and thus: + +[table Table with fat cells + [[Heading 1] [Heading 2]] + [ + [Row 0, Col 0: a small cell] + [ + Row 0, Col 1: a big fat cell with paragraphs + + Boost provides free peer-reviewed portable C++ source libraries. + + We emphasize libraries that work well with the C++ Standard Library. + Boost libraries are intended to be widely useful, and usable across + a broad spectrum of applications. The Boost license encourages both + commercial and non-commercial use. + ] + ] + [ + [Row 1, Col 0: a small cell] + [Row 1, Col 1: a small cell] + ] +] + +Here's how to have preformatted blocks of code in a table cell: + +[pre''' +[table Table with code + [[Comment] [Code]] + [ + [My first program] + ['''\`\` + #include + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } + \`\`'''] + ] +] +'''] + +[table Table with code + [[Comment] [Code]] + [ + [My first program] + [`` + #include + + int main() + { + std::cout << "Hello, World!" << std::endl; + return 0; + } + ``] + ] +] + +[endsect] +[section Variable Lists] + +[pre''' +[variablelist A Variable List + [[term 1] [The definition of term 1]] + [[term 2] [The definition of term 2]] + [[term 3] [The definition of term 3]] +] +'''] + +will generate: + +[variablelist A Variable List + [[term 1] [The definition of term 1]] + [[term 2] [The definition of term 2]] + [[term 3] [The definition of term 3]] +] + +The rules for variable lists are the same as for tables, except that +only 2 "columns" are allowed. The first column contains the terms, and +the second column contains the definitions. Those familiar with HTML +will recognize this as a "definition list". + +[endsect] +[section Include] + +You can include one QuickBook file from another. The syntax is simply: + +[pre''' +[include someother.qbk] +'''] + +The included file will be processed as if it had been cut and pasted +into the current document, with the following exceptions: + +* The '''__FILENAME__''' predefined macro will reflect the name of the + file currently being processed. +* Any macros defined in the included file are scoped to that file. + +The [^\[include\]] directive lets you specify a document id to use for the +included file. When this id is not explicitly specified, the id defaults to +the filename ("someother", in the example above). You can specify the id +like this: + +[pre''' +[include:someid someother.qbk] +'''] + +All auto-generated anchors will use the document id as a unique prefix. So +for instance, if there is a top section in someother.qbk named "Intro", the +named anchor for that section will be "someid.intro", and you can link to +it with [^\[link someid.intro The Intro\]]. + +[endsect] + +[section Import] + +When documenting code, you'd surely need to present code from actual source +files. While it is possible to copy some code and paste them in your QuickBook +file, doing so is error prone and the extracted code in the documentation tends +to get out of sync with the actual code as the code evolves. The problem, as +always, is that once documentation is written, the tendency is for the docs to +languish in the archives without maintenance. + +QuickBook's import facility provides a nice solution. + +[heading Example] + +You can effortlessly import code snippets from source code into your QuickBook. +The following illustrates how this is done: + +[pre''' +[import ../test/stub.cpp] +[foo] +[bar] +'''] + +The first line: + +[pre''' +[import ../test/stub.cpp] +'''] + +collects specially marked-up code snippets from [@../../test/stub.cpp stub.cpp] +and places them in your QuickBook file as virtual templates. Each of the +specially marked-up code snippets has a name (e.g. `foo` and `bar` in the +example above). This shall be the template identifier for that particular code +snippet. The second and third line above does the actual template expansion: + +[pre''' +[foo] +[bar] +'''] + +And the result is: + +[import ../test/stub.cpp] +[foo] +[bar] + +[heading Code Snippet Markup] + +Note how the code snippets in [@../../test/stub.cpp stub.cpp] get marked up. We +use distinguishable comments following the form: + + //[id + some code here + //] + +The first comment line above initiates a named code-snippet. This prefix will +not be visible in quickbook. The entire code-snippet in between `//[id` and +`//]` will be inserted as a template in quickbook with name ['/id/]. The comment +`//]` ends a code-snippet This too will not be visible in quickbook. + +[heading Special Comments] + +Special comments of the form: + + //` some [*quickbook] markup here + +and: + + /*` some [*quickbook] markup here */ + +will be parsed by QuickBook. This can contain quickbook /blocks/ (e.g. sections, +paragraphs, tables, etc). In the first case, the initial slash-slash, tick and +white-space shall be ignored. In the second, the initial slash-star-tick and the +final star-slash shall be ignored. + +[heading Callouts] + +Special comments of the form: + + /*< some [*quickbook] markup here >*/ + +will be regarded as callouts. These will be collected, numbered and +rendered as a "callout bug" (a small icon with a number). After the +whole snippet is parsed, the callout list is generated. See +[@http://www.docbook.org/tdg/en/html/callout.html Callouts] for details. +Example: + +[foo_bar] + +Checkout [@../../test/stub.cpp stub.cpp] to see the actual code. + +[endsect] + +[endsect] +[endsect] + +[section:install Installation and configuration] + +This section provides some guidelines on how to install and configure +BoostBook and Quickbook under several operating systems. + +Before continuing, it is very important that you keep this in mind: if you +try to build some documents and the process breaks due to misconfiguration, +be absolutely sure to delete any `bin` and `bin.v2` directories generated +by the build before trying again. Otherwise your configuration fixes will +not take any effect. + +[section:windows Windows 2000, XP, 2003, Vista] + +[python] + +[:['Section contributed by Julio M. Merino Vidal]] + +The following instructions apply to any Windows system based on Windows +2000, including Windows XP, Windows 2003 Server and Windows Vista. The +paths shown below are taken from a Windows Vista machine; you will need to +adjust them to match your system in case you are running an older version. + +# First of all you need to have a copy of `xsltproc` for Windows. There + are many ways to get this tool, but to keep things simple, use the + [@http://www.zlatkovic.com/pub/libxml/ binary packages] made by Igor + Zlatkovic. At the very least, you need to download the following + packages: `iconv`, `zlib`, `libxml2` and `libxslt`. + +# Unpack all these packages in the same directory so that you get unique + `bin`, `include` and `lib` directories within the hierarchy. These + instructions use `C:\Users\example\Documents\boost\xml` as the root for + all files. + +# From the command line, go to the `bin` directory and launch + `xsltproc.exe` to ensure it works. You should get usage information on + screen. + +# Download [@http://www.docbook.org/xml/4.2/docbook-xml-4.2.zip Docbook XML + 4.2] and unpack it in the same directory used above. That is: + `C:\Users\example\Documents\boost\xml\docbook-xml`. + +# Download the latest + [@http://sourceforge.net/project/showfiles.php?group_id=21935&package_id=16608 + Docbook XSL] version and unpack it, again in the same directory + used before. To make things easier, rename the directory created + during the extraction to `docbook-xsl` (bypassing the version name): + `C:\Users\example\Documents\boost\xml\docbook-xsl`. + +# Add the following to your `user-config.jam` file, which should live in + your home directory (`%HOMEDRIVE%%HOMEPATH%`). You must already have it + somewhere or otherwise you could not be building Boost (i.e. missing + tools configuration). + + using xsltproc + : "C:/Users/example/Documents/boost/xml/bin/xsltproc.exe" + ; + + using boostbook + : "C:/Users/example/Documents/boost/xml/docbook-xsl" + : "C:/Users/example/Documents/boost/xml/docbook-xml" + ; + +The above steps are enough to get a functional BoostBook setup. Quickbook +will be automatically built when needed. If you want to avoid these +rebuilds: + +# Go to Quickbook's source directory (`BOOST_ROOT\tools\quickbook`). + +# Build the utility by issuing `bjam --v2`. + +# Copy the resulting `quickbook.exe` binary (located under the + `BOOST_ROOT\bin.v2` hierarchy) to a safe place. Following our previous + example, you can install it into: + `C:\Users\example\Documents\boost\xml\bin`. + +# Add the following to your `user-config.jam` file: + + using quickbook + : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe" + ; + +[endsect] + +[section:linux Debian, Ubuntu] + +The following instructions apply to Debian and its derivatives. They are based +on a Ubuntu Edgy install but should work on other Debian based systems. + +First install the `bjam`, `xsltproc`, `docbook-xsl` and `docbook-xml` packages. +For example, using `apt-get`: + + sudo apt-get install xsltprc docbook-xsl docbook-xml + +If you're planning on building boost's documentation, you'll also need to +install the `doxygen` package as well. + +Next, we need to configure Boost Build to compile BoostBook files. Add the +following to your `user-config.jam` file, which should be in your home +directory. If you don't have one, create a file containing this text. For more +information on setting up `user-config.jam`, see the +[@http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html Boost +Build documentation]. + + using xsltproc ; + + using boostbook + : /usr/share/xml/docbook/stylesheet/nwalsh + : /usr/share/xml/docbook/schema/dtd/4.2 + ; + + # Remove this line if you're not using doxygen + using doxygen ; + +The above steps are enough to get a functional BoostBook setup. Quickbook +will be automatically built when needed. If you want to avoid these +rebuilds: + +# Go to Quickbook's source directory (`BOOST_ROOT/tools/quickbook`). + +# Build the utility by issuing `bjam --v2`. + +# Copy the resulting `quickbook` binary (located under the + `BOOST_ROOT/bin.v2` hierarchy) to a safe place. The traditional location is + `/usr/local/bin`. + +# Add the following to your `user-config.jam` file, using the full path of the + quickbook executable: + + using quickbook + : /usr/local/bin/quickbook + ; + +[endsect] +[endsect] [/Installation and configuration] + +[section:editors Editor Support] + +Editing quickbook files is usually done with text editors both simple and +powerful. The following sections list the settings for some editors which can +help make editing quickbook files a bit easier. + +[blurb __note__ You may submit your settings, tips, and suggestions to the +authors, or through the [@https://lists.sourceforge.net/lists/listinfo/boost- +docs Boost Docs mailing list].] + +[section:scite Scintilla Text Editor] + +[:['Section contributed by Dean Michael Berris]] + +The Scintilla Text Editor (SciTE) is a free source code editor for Win32 and X. +It uses the SCIntilla source code editing component. + +[blurb __tip__ SciTE can be downloaded from [@http://www.scintilla.org/SciTE.html]] + +You can use the following settings to highlight quickbook tags when +editing quickbook files. + +[pre''' +qbk=*.qbk +lexer.*.qbk=props +use.tabs.$(qbk)=0 +tab.size.$(qbk)=4 +indent.size.$(qbk)=4 +style.props.32=$(font.base) +comment.stream.start.props=[/ +comment.stream.end.props=] +comment.box.start.props=[/ +comment.box.middle.props= +comment.box.end.props=] +'''] + +[blurb __note__ Thanks to Rene Rivera for the above SciTE settings.] + +[endsect] [/scite] +[endsect] [/editors] + +[section:faq Frequently Asked Questions] + +[heading Can I use QuickBook for non-Boost documentation?] + +QuickBook can be used for non-Boost documentation with a little extra work. + +[:['Faq contributed by Michael Marcin]] + +When building HTML documentation with BoostBook a Boost C++ Libraries header +is added to the files. When using QuickBook to document projects outside of +Boost this is not desirable. This behavior can be overridden at the BoostBook +level by specifying some XSLT options. When using Boost Build version 2 (BBv2) +this can be achieved by adding parameters to the BoostBook target declaration. + +For example: +[pre +using quickbook ; + +xml my_doc : my_doc.qbk ; + +boostbook standalone + : + my_doc + : + boost.image.src=images/my_project_logo.png + boost.image.alt="\\"My Project\\"" + boost.image.w=100 + boost.image.h=50 + nav.layout=none + ; +] + +[endsect] [/faq] + +[section:ref Quick Reference] + +[cpp] + +[template ordered_list_sample[] +[pre''' +# one +# two +# three +'''] +] + +[template unordered_list_sample[] +[pre''' +* one +* two +* three +'''] +] + +[template table_sample[] +[pre''' +[table Title +[[a][b][c]] +[[a][b][c]] +] +'''] +] + +[template var_list_sample[] +[pre''' +[variablelist Title +[[a][b]] +[[a][b]] +] +'''] +] + + +[table Syntax Compendium + [[To do this...] [Use this...] [See this...]] + [[comment] [[^'''[/ some comment]''']] [__comments__]] + [[['italics]] [[^'''['italics] or /italics/''']] [__font_styles__ and __simple_formatting__]] + [[[*bold]] [[^'''[*bold] or *bold*''']] [__font_styles__ and __simple_formatting__]] + [[[_underline]] [[^'''[_underline] or _underline_''']] [__font_styles__ and __simple_formatting__]] + [[[^teletype]] [[^'''[^teletype] or =teletype=''']] [__font_styles__ and __simple_formatting__]] + [[[-strikethrough]] [[^'''[-strikethrough]''']] [__font_styles__ and __simple_formatting__]] + [[[~replaceable]] [[^'''[~replaceable]''']] [__replaceable__]] + [[source mode] [[^\[c++\]] or [^\[python\]]] [__source_mode__]] + [[inline code] [[^'''`int main();`''']] [__inline_code__]] + [[code block] [[^'''``int main();``''']] [__code__]] + [[code escape] [[^'''``from c++ to QuickBook``''']] [__escape_back__]] + [[line break] [[^'''[br] or \n''']] [__line_break__ *DEPRECATED*]] + [[anchor] [[^'''[#anchor]''']] [__anchors__]] + [[link] [[^'''[@http://www.boost.org Boost]''']] [__links__]] + [[anchor link] [[^'''[link section.anchor Link text]''']] [__anchor_links__]] + [[refentry link] [[^'''[link xml.refentry Link text]''']] [__refentry_links__]] + [[function link] [[^'''[funcref fully::qualified::function_name Link text]''']] [__code_links__]] + [[class link] [[^'''[classref fully::qualified::class_name Link text]''']] [__code_links__]] + [[member link] [[^'''[memberref fully::qualified::member_name Link text]''']] [__code_links__]] + [[enum link] [[^'''[enumref fully::qualified::enum_name Link text]''']] [__code_links__]] + [[macro link] [[^'''[macroref MACRO_NAME Link text]''']] [__code_links__]] + [[concept link] [[^'''[conceptref ConceptName Link text]''']] [__code_links__]] + [[header link] [[^'''[headerref path/to/header.hpp Link text]''']] [__code_links__]] + [[escape] [[^\'\'\'escaped text (no processing/formatting)\'\'\']] [__escape__]] + [[single char escape] [[^\\c]] [__single_char_escape__]] + [[images] [[^'''[$image.jpg]''']] [__images__]] + [[begin section] [[^'''[section The Section Title]''']] [__section__]] + [[end section] [[^'''[endsect]''']] [__section__]] + [[paragraph] [No markup. Paragraphs start left-flushed and are terminated by two or more newlines.] [__paragraphs__]] + [[ordered list] [[ordered_list_sample]] [__ordered_lists__]] + [[unordered list] [[unordered_list_sample]] [__unordered_lists__]] + [[code] [No markup. Preformatted code starts with a space or a tab.] [__code__]] + [[preformatted] [[^'''[pre preformatted]''']] [__preformatted__]] + [[block quote] [[^'''[:sometext...]''']] [__blockquote__]] + [[heading 1] [[^'''[h1 Heading 1]''']] [__heading__]] + [[heading 2] [[^'''[h2 Heading 2]''']] [__heading__]] + [[heading 3] [[^'''[h3 Heading 3]''']] [__heading__]] + [[heading 4] [[^'''[h4 Heading 4]''']] [__heading__]] + [[heading 5] [[^'''[h5 Heading 5]''']] [__heading__]] + [[heading 6] [[^'''[h6 Heading 6]''']] [__heading__]] + [[macro] [[^'''[def macro_identifier some text]''']] [__macros__]] + [[template] [[^'''[template[a b] [a] body [b]]''']] [__templates__]] + [[blurb] [[^'''[blurb advertisement or note...]''']] [__blurbs__]] + [[admonition] [[^'''[warning Warning text...]''']] [__admonitions__]] + [[table] [[table_sample]] [__tables__]] + [[variablelist] [[var_list_sample]] [__variable_lists__]] + [[include] [[^'''[include someother.qbk]''']] [__include__]] +] + +[endsect] From 1a46df1047380d8b40a31f44df003501cb7fccd5 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 14 Mar 2009 11:42:38 +0000 Subject: [PATCH 25/94] Merge most of the recent changes to quickbook and boostbook. Left out doxygen changes: [51323],[51324],[51680] And a quickbook change which might be a breaking change: [51403] Fixes #1977, #1170, #1213, #2701. Refs #2153, #2771. Merged revisions 51268-51269,51319-51321,51370-51372,51388-51389,51401-51402,51405-51406,51508,51647,51696 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r51268 | johnmaddock | 2009-02-16 10:39:18 +0000 (Mon, 16 Feb 2009) | 1 line Add default path for callouts. ........ r51269 | johnmaddock | 2009-02-16 10:40:26 +0000 (Mon, 16 Feb 2009) | 1 line Add preliminary HTMLHelp support. ........ r51319 | danieljames | 2009-02-18 21:22:37 +0000 (Wed, 18 Feb 2009) | 1 line Remove long out of date warning. ........ r51320 | danieljames | 2009-02-18 21:23:13 +0000 (Wed, 18 Feb 2009) | 1 line Write out the quickbook options when the file is missing. ........ r51321 | danieljames | 2009-02-18 21:23:35 +0000 (Wed, 18 Feb 2009) | 1 line Add default path for callouts to xhtml. ........ r51370 | danieljames | 2009-02-21 18:50:00 +0000 (Sat, 21 Feb 2009) | 4 lines Regenerate boostbook reference documentation and merge with existing documentation. Ref #2153 ........ r51371 | danieljames | 2009-02-21 18:50:14 +0000 (Sat, 21 Feb 2009) | 1 line Fix links in standalone boostbook documentation. ........ r51372 | danieljames | 2009-02-21 18:50:25 +0000 (Sat, 21 Feb 2009) | 3 lines Change license in boostbook docs to boost license. Douglas Gregor is listed in the blanket permissions file. ........ r51388 | danieljames | 2009-02-22 11:54:01 +0000 (Sun, 22 Feb 2009) | 1 line This DTD isn't stable, so I'm calling it a 'development' version. Which is probably wrong, but there you go. ........ r51389 | danieljames | 2009-02-22 11:54:18 +0000 (Sun, 22 Feb 2009) | 2 lines Support the alt tag in headername and macroname. Also make headername and macroname valid. Refs #1977 ........ r51401 | danieljames | 2009-02-22 23:47:51 +0000 (Sun, 22 Feb 2009) | 8 lines Add a purpose for macroname, headername, enumname, globalname. Ref #2153: There's still no documentation for methodname and classname. These are actually defined in the docbook DTD for a different purpose so I'm not sure how to deal with them. http://www.docbook.org/tdg/en/html/methodname.html http://www.docbook.org/tdg/en/html/classname.html ........ r51402 | danieljames | 2009-02-22 23:48:37 +0000 (Sun, 22 Feb 2009) | 7 lines Generate slightly more valid boostbook. For document types other than library: * Don't generate name or dirname for document types. * Put title before document info. Ref #2771 ........ r51405 | danieljames | 2009-02-22 23:49:21 +0000 (Sun, 22 Feb 2009) | 3 lines Print out unexpected characters as errors. Ref #1170 ........ r51406 | danieljames | 2009-02-22 23:49:36 +0000 (Sun, 22 Feb 2009) | 1 line Better handling of errors without line numbers. ........ r51508 | danieljames | 2009-03-01 14:16:44 +0000 (Sun, 01 Mar 2009) | 3 lines Try to make anchor and link usage a little clearer. Refs #1213, #2701 ........ r51647 | danieljames | 2009-03-08 09:45:51 +0000 (Sun, 08 Mar 2009) | 1 line Display text purposes in function reference. ........ r51696 | johnmaddock | 2009-03-11 10:22:42 +0000 (Wed, 11 Mar 2009) | 1 line Set margins to 0pt so they line up with surrounding text rather than appearing outside it - prevents margins from overlapping other content. ........ [SVN r51774] --- detail/actions.cpp | 90 +++++++++++++++-------- detail/post_process.cpp | 6 +- detail/quickbook.cpp | 15 +++- detail/utils.cpp | 2 +- detail/utils.hpp | 4 +- doc/quickbook.qbk | 20 +++-- test/code-block-1.gold | 4 +- test/code-block-2.gold | 4 +- test/code-snippet.gold | 4 +- test/escape.gold | 5 +- test/import.gold | 5 +- test/link-side-by-side.gold | 6 +- test/preformatted.gold | 4 +- test/quickbook-manual.gold | 5 +- test/stub.xml | 1 - test/templates.gold | 141 ++++++++++++++++++------------------ test/xinclude.gold | 17 ++--- 17 files changed, 188 insertions(+), 145 deletions(-) mode change 100755 => 100644 detail/utils.hpp delete mode 100644 test/stub.xml diff --git a/detail/actions.cpp b/detail/actions.cpp index dc230ee..8ebca57 100644 --- a/detail/actions.cpp +++ b/detail/actions.cpp @@ -251,7 +251,11 @@ namespace quickbook << ", unexpected character: " << std::string(first, last) << "\n"; - out << '#'; // print out an unexpected character + // print out an unexpected character + out << ""; + while (first != last) + detail::print_char(*first++, out.get()); + out << ""; } void anchor_action::operator()(iterator first, iterator last) const @@ -1212,6 +1216,9 @@ namespace quickbook out << " " << year << "\n"; } + static void write_document_title(collector& out, quickbook::actions& actions); + static void write_document_info(collector& out, quickbook::actions& actions); + void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo) { // The doc_info in the file has been parsed. Here's what we'll do @@ -1221,7 +1228,7 @@ namespace quickbook actions.doc_id = detail::make_identifier( actions.doc_title.begin(),actions.doc_title.end()); - if (actions.doc_dirname.empty()) + if (actions.doc_dirname.empty() && actions.doc_type == "library") actions.doc_dirname = actions.doc_id; if (actions.doc_last_revision.empty()) @@ -1264,12 +1271,58 @@ namespace quickbook << "\n" << '<' << actions.doc_type << "\n" - << " id=\"" << actions.doc_id << "\"\n" - << " name=\"" << actions.doc_title << "\"\n" - << " dirname=\"" << actions.doc_dirname << "\"\n" - << " last-revision=\"" << actions.doc_last_revision << "\" \n" - << " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n" - << " <" << actions.doc_type << "info>\n"; + << " id=\"" << actions.doc_id << "\"\n"; + + if(actions.doc_type == "library") + { + out << " name=\"" << actions.doc_title << "\"\n"; + } + + if(!actions.doc_dirname.empty()) + { + out << " dirname=\"" << actions.doc_dirname << "\"\n"; + } + + out << " last-revision=\"" << actions.doc_last_revision << "\" \n" + << " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n"; + + if(actions.doc_type == "library") { + write_document_info(out, actions); + write_document_title(out, actions); + } + else { + write_document_title(out, actions); + write_document_info(out, actions); + } + } + + void post(collector& out, quickbook::actions& actions, bool ignore_docinfo) + { + // if we're ignoring the document info, do nothing. + if (ignore_docinfo) + { + return; + } + + // We've finished generating our output. Here's what we'll do + // *after* everything else. + out << "\n\n\n"; + } + + void write_document_title(collector& out, quickbook::actions& actions) + { + if (!actions.doc_title.empty()) + { + out<< " " << actions.doc_title; + if (!actions.doc_version.empty()) + out << ' ' << actions.doc_version; + out<< "\n\n\n"; + } + } + + void write_document_info(collector& out, quickbook::actions& actions) + { + out << " <" << actions.doc_type << "info>\n"; if(!actions.doc_authors.empty()) { @@ -1328,27 +1381,6 @@ namespace quickbook out << " \n" << "\n" ; - - if (!actions.doc_title.empty()) - { - out << " " << actions.doc_title; - if (!actions.doc_version.empty()) - out << ' ' << actions.doc_version; - out << "\n\n\n"; - } - } - - void post(collector& out, quickbook::actions& actions, bool ignore_docinfo) - { - // if we're ignoring the document info, do nothing. - if (ignore_docinfo) - { - return; - } - - // We've finished generating our output. Here's what we'll do - // *after* everything else. - out << "\n\n\n"; } void phrase_to_string_action::operator()(iterator first, iterator last) const diff --git a/detail/post_process.cpp b/detail/post_process.cpp index d3fcf7c..ae9eb46 100644 --- a/detail/post_process.cpp +++ b/detail/post_process.cpp @@ -442,7 +442,7 @@ namespace quickbook else { // fallback! - ::quickbook::detail::outerr("",0) + ::quickbook::detail::outerr("") << "Warning: Post Processing Failed." << std::endl; out << in; @@ -453,8 +453,8 @@ namespace quickbook catch(...) { // fallback! - ::quickbook::detail::outerr("",0) - << "Warning: Post Processing Failed." + ::quickbook::detail::outerr("") + << "Post Processing Failed." << std::endl; out << in; return 1; diff --git a/detail/quickbook.cpp b/detail/quickbook.cpp index ece0154..f883722 100644 --- a/detail/quickbook.cpp +++ b/detail/quickbook.cpp @@ -88,6 +88,12 @@ namespace quickbook << "Syntax Error near column " << pos.column << ".\n"; ++actor.error_count; } + + if(actor.error_count) + { + detail::outerr(filein_) + << "Error count: " << actor.error_count << ".\n"; + } return actor.error_count ? 1 : 0; } @@ -98,7 +104,7 @@ namespace quickbook actions actor(filein_, outdir, out); bool r = parse(filein_, actor); if (actor.section_level != 0) - detail::outwarn(filein_,1) + detail::outwarn(filein_) << "Warning missing [endsect] detected at end of file." << std::endl; return r; @@ -264,20 +270,21 @@ main(int argc, char* argv[]) } else { - quickbook::detail::outerr("",0) << "Error: No filename given" << std::endl; + quickbook::detail::outerr("") << "Error: No filename given\n\n" + << desc << std::endl; return 1; } } catch(std::exception& e) { - quickbook::detail::outerr("",0) << "Error: " << e.what() << "\n"; + quickbook::detail::outerr("") << "Error: " << e.what() << "\n"; return 1; } catch(...) { - quickbook::detail::outerr("",0) << "Error: Exception of unknown type caught\n"; + quickbook::detail::outerr("") << "Error: Exception of unknown type caught\n"; return 1; } diff --git a/detail/utils.cpp b/detail/utils.cpp index a054539..a71f302 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -212,7 +212,7 @@ namespace quickbook { namespace detail if (!in) { - outerr(filename,-1) << "Could not open input file." << endl; + outerr(filename) << "Could not open input file." << endl; return 1; } diff --git a/detail/utils.hpp b/detail/utils.hpp old mode 100755 new mode 100644 index 57f0ad9..e48a94f --- a/detail/utils.hpp +++ b/detail/utils.hpp @@ -63,8 +63,8 @@ namespace quickbook { namespace detail // common IDEs. Uses the ms_errors global to determine if VS format // or GCC format. Returns the stream to continue ouput of the verbose // error message. - std::ostream & outerr(std::string const& file, int line); - std::ostream & outwarn(std::string const& file, int line); + std::ostream & outerr(std::string const& file, int line = -1); + std::ostream & outwarn(std::string const& file, int line = -1); // load file into memory with extra trailing newlines to eliminate // the need to check for end of file in the grammar. diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 6fffa65..85d95ac 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -461,6 +461,10 @@ A named anchor is a hook that can be referenced by a link elsewhere in the document. You can then reference an anchor with [^'''[link named_anchor Some link text]''']. See __anchor_links__, __section__ and __heading__. +These anchors are global and can be accessed from anywhere in the +quickbook documentation. Be careful to avoid clashes with anchors in +other sections. + [endsect] [section Links] @@ -494,7 +498,7 @@ see [@http://spirit.sourceforge.net/] You can link within a document using: [pre''' -[link section_id.normalized_header_text The link text] +[link document_id.section_id.normalized_header_text The link text] '''] See sections __section__ and __heading__ for more info. @@ -1053,14 +1057,16 @@ to produce the desired effect. [h5 Heading 5] [h6 Heading 6] -Headings 1-3 \[h1 h2 and h3\] will automatically have anchors with normalized -names with [^name="section_id.normalized_header_text"] (i.e. valid characters are -=a-z=, =A-Z=, =0-9= and =_=. All non-valid characters are converted to underscore -and all upper-case are converted to lower-case. For example: Heading -1 in section Section 2 will be normalized to [^section_2.heading_1]). You can use: +Headings 1-3 \[h1 h2 and h3\] will automatically have anchors with +normalized names with +[^name="document_id.section_id.normalized_header_text"] (i.e. valid +characters are =a-z=, =A-Z=, =0-9= and =_=. All non-valid characters are +converted to underscore and all upper-case are converted to lower-case. +For example: Heading 1 in section Section 2 will be normalized to +[^section_2.heading_1]). You can use: [pre''' -[link section_id.normalized_header_text The link text] +[link document_id.section_id.normalized_header_text The link text] '''] to link to them. See __anchor_links__ and __section__ for more info. diff --git a/test/code-block-1.gold b/test/code-block-1.gold index f610d68..96eb3ba 100644 --- a/test/code-block-1.gold +++ b/test/code-block-1.gold @@ -1,10 +1,10 @@ -
+ Code Block 1 - Code Block 1
A code block diff --git a/test/code-block-2.gold b/test/code-block-2.gold index 532cb9f..85330c0 100644 --- a/test/code-block-2.gold +++ b/test/code-block-2.gold @@ -1,10 +1,10 @@ -
+ Code Block 2 - Code Block 2
A code block diff --git a/test/code-snippet.gold b/test/code-snippet.gold index e3852ff..26de71d 100644 --- a/test/code-snippet.gold +++ b/test/code-snippet.gold @@ -1,10 +1,10 @@ -
+ Code Snippets - Code Snippets
A code snippet diff --git a/test/escape.gold b/test/escape.gold index cd04ea1..d7fbf21 100644 --- a/test/escape.gold +++ b/test/escape.gold @@ -1,10 +1,9 @@ -
+
+ Escape - Escape
Escape diff --git a/test/import.gold b/test/import.gold index e984259..4c4c4a7 100644 --- a/test/import.gold +++ b/test/import.gold @@ -1,10 +1,9 @@ -
+
+ Import - Import This is the foo function. diff --git a/test/link-side-by-side.gold b/test/link-side-by-side.gold index 887742c..0e79821 100644 --- a/test/link-side-by-side.gold +++ b/test/link-side-by-side.gold @@ -1,10 +1,10 @@ - diff --git a/test/templates_1_4.quickbook b/test/templates_1_4.quickbook index c99297f..5cedc76 100644 --- a/test/templates_1_4.quickbook +++ b/test/templates_1_4.quickbook @@ -13,4 +13,26 @@ [template y new] [template foo3[a y] [a]] -[foo3 [y] old] \ No newline at end of file +[foo3 [y] old] + +[/ 1.4 template arguments] + +[template binary[x y] {[x]-[y]}] +[binary 1..2] [/ {1-2} ] +[binary 1 2] [/ {1-2} ] +[binary 1..2 3 4] [/ {1-2 3 4} ] +[binary 1 2..3 4] [/ {1 2-3 4} ] +[binary 1 2 3..4] [/ {1 2 3-4} ] +[binary [1..2] [/ {(1-2} but with a square bracket ] +[binary 1.\.2..3] [/ {1..2-3} ] +[binary 1.\.2 3] [/ {1..2-3} ] + +[binary [binary 1 2..3] 4] [/ {[binary 1 2- {1 2-y}} 4] ] +[/ This is obviously wrong, but I don't feel up to fixing it at the moment.] + +[template ternary[x y z] {[x]-[y]-[z]}] +[ternary 1..2..3] [/ {1-2-3} ] +[ternary 1 2 3] [/ {1-2-3} ] +[ternary 1..2 3 4] [/ {1-2-3 4} ] +[ternary 1 2..3 4] [/ {1 2-3-4} ] +[ternary [1..2..3] [/ {(1-2-3} (but with a square bracket) ] \ No newline at end of file diff --git a/test/templates_1_5.gold b/test/templates_1_5.gold new file mode 100644 index 0000000..3ccf529 --- /dev/null +++ b/test/templates_1_5.gold @@ -0,0 +1,29 @@ + + +
+ Template 1.5 + + + + static scoping + + + new + + + foo foo + + + {1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {1..2-3} {1..2-3} + + + { {1 2-3}-4} { {1 2-3}-4} { {1-2 3}-4} + + + {[1-2] 3} {[1-2] 3} {[1-2} + + + {1-2-3} {1-2-3} + +
diff --git a/test/templates_1_5.quickbook b/test/templates_1_5.quickbook new file mode 100644 index 0000000..1032cd6 --- /dev/null +++ b/test/templates_1_5.quickbook @@ -0,0 +1,46 @@ +[article Template 1.5 + [quickbook 1.5] +] + +[/ 1.5 uses static scoping ] + +[template x static scoping] +[template foo1[] [x]] +[template foo2[x] [foo1]] +[foo2 dynamic scoping] + +[/ In 1.5 template arguments are scoped at the point they are defined] + +[template y new] +[template foo3[a y] [a]] +[foo3 [y] old] + +[/ From https://svn.boost.org/trac/boost/ticket/2034 ] + +[template same[x] [x]] +[template echo[a b] [a] [b]] +[template echo_twice[x] [echo [same [x]]..[same [x]]]] +[echo_twice foo] + +[/ 1.5 template arguments] + +[template binary[x y] {[x]-[y]}] +[binary 1..2] [/ {1-2} ] +[binary 1 2] [/ {1-2} ] +[binary 1..2 3 4] [/ {1-2 3 4} ] +[binary 1 2..3 4] [/ {1 2-3 4} ] +[binary 1 2 3..4] [/ {1 2 3-4} ] +[binary 1.\.2..3] [/ {1..2-3} ] +[binary 1.\.2 3] [/ {1..2-3} ] + +[binary [binary 1 2..3]..4] [/ { {1 2-3}-4} ] +[binary [binary 1 2..3] 4] [/ { {1 2-3}-4} ] +[binary [binary 1 2 3]..4] [/ { {1-2 3}-4} ] + +[binary \[1 2\] 3] [/ {[1-2] 3} ] +[binary \[1..2\] 3] [/ {[1-2] 3} ] +[binary \[1 2] [/ {(1-2} ] + +[template ternary[x y z] {[x]-[y]-[z]}] +[ternary 1..2..3] [/ {1-2-3} ] +[ternary 1 2 3] [/ {1-2-3} ] From 6977d5f96e8d612b38bc488ee9d993f1d84922fc Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 12 Oct 2009 20:18:43 +0000 Subject: [PATCH 38/94] Merge newline in quickbook.hpp [SVN r56754] --- detail/quickbook.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detail/quickbook.hpp b/detail/quickbook.hpp index 8455e90..aee576a 100644 --- a/detail/quickbook.hpp +++ b/detail/quickbook.hpp @@ -44,4 +44,4 @@ namespace quickbook } } -#endif \ No newline at end of file +#endif From 0f8c4eb5fb12d2a7ee76bcd181998d802b91bf28 Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 01:10:45 +0000 Subject: [PATCH 39/94] rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release. [SVN r56941] --- CMakeLists.txt | 62 -------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 4b86b1a..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_tool_project(Quickbook - DESCRIPTION "A WikiWiki style documentation tool geared towards C++ documentation" - AUTHORS "Joel de Guzman " - "Eric Niebler ") - -if (BUILD_QUICKBOOK) - if (MSVC) - add_definitions(/wd4511 /wd4512 /wd4701 /wd4702 /wd4244 /wd4267 /wd4800) - endif (MSVC) - -# -# TDS: this needs fixing... these are the modules that quickbook is -# dependent on. if boost is modularized, you need these, but -# they don't hurt if quickbook isn't modularized. -# -include_directories( - ${CMAKE_SOURCE_DIR}/libs/any/include - ${CMAKE_SOURCE_DIR}/libs/bind/include - ${CMAKE_SOURCE_DIR}/libs/concept/include - ${CMAKE_SOURCE_DIR}/libs/concept_check/include - ${CMAKE_SOURCE_DIR}/libs/config/include - ${CMAKE_SOURCE_DIR}/libs/detail/include - ${CMAKE_SOURCE_DIR}/libs/exception/include - ${CMAKE_SOURCE_DIR}/libs/filesystem/include - ${CMAKE_SOURCE_DIR}/libs/foreach/include - ${CMAKE_SOURCE_DIR}/libs/function/include - ${CMAKE_SOURCE_DIR}/libs/integer/include - ${CMAKE_SOURCE_DIR}/libs/iostreams/include - ${CMAKE_SOURCE_DIR}/libs/iterator/include - ${CMAKE_SOURCE_DIR}/libs/mpl/include - ${CMAKE_SOURCE_DIR}/libs/preprocessor/include - ${CMAKE_SOURCE_DIR}/libs/program_options/include - ${CMAKE_SOURCE_DIR}/libs/range/include - ${CMAKE_SOURCE_DIR}/libs/spirit/include - ${CMAKE_SOURCE_DIR}/libs/smart_ptr/include - ${CMAKE_SOURCE_DIR}/libs/static_assert/include - ${CMAKE_SOURCE_DIR}/libs/system/include - ${CMAKE_SOURCE_DIR}/libs/tuple/include - ${CMAKE_SOURCE_DIR}/libs/optional/include - ${CMAKE_SOURCE_DIR}/libs/type_traits/include - ${CMAKE_SOURCE_DIR}/libs/utility/include - ) - - boost_add_executable(quickbook - detail/quickbook.cpp - detail/actions.cpp - detail/actions_class.cpp - detail/utils.cpp - detail/post_process.cpp - detail/collector.cpp - detail/input_path.cpp - detail/template_stack.cpp - detail/markups.cpp - DEPENDS boost_program_options boost_filesystem - ) -endif (BUILD_QUICKBOOK) From eed93bcc1adfeac1891e08ed6029d0959e00c2b9 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 20 Oct 2009 23:13:33 +0000 Subject: [PATCH 40/94] Merge a couple of documentation changes. Merged revisions 56988-56989 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r56988 | danieljames | 2009-10-18 21:18:28 +0100 (Sun, 18 Oct 2009) | 1 line Add release notes for unordered. ........ r56989 | danieljames | 2009-10-18 21:18:43 +0100 (Sun, 18 Oct 2009) | 1 line Mention that image attributes are supported. ........ [SVN r57028] --- doc/quickbook.qbk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index ecec13b..ae2cba0 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -628,6 +628,14 @@ from the output. [$image.jpg] '''] +From version 1.5, you can also use +[@http://www.docbook.org/tdg/en/html/imagedata.html +DocBook imagedata attributes]: + +[pre''' +[$image.jpg [width 200in] [height 200in]] +'''] + [endsect] [section Footnotes] From 9bcdc85d232c2c0ea049c00680b985dac51c96d2 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Wed, 30 Dec 2009 03:38:56 +0000 Subject: [PATCH 41/94] Spirit: merging from trunk [SVN r58578] --- Jamfile.v2 | 8 ++++++++ code_snippet.hpp | 2 ++ detail/actions.cpp | 3 +++ detail/actions.hpp | 7 ++----- test/Jamfile.v2 | 2 +- test/heading.gold | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Jamfile.v2 b/Jamfile.v2 index a957c5b..9f93e6c 100644 --- a/Jamfile.v2 +++ b/Jamfile.v2 @@ -8,6 +8,14 @@ # http://www.boost.org/LICENSE_1_0.txt) #============================================================================== +project quickbook + : requirements + gcc:300 + darwin:300 + gcc:-g0 + darwin:-g0 + ; + exe quickbook : detail/quickbook.cpp diff --git a/code_snippet.hpp b/code_snippet.hpp index c3e8b0b..8eb84b0 100644 --- a/code_snippet.hpp +++ b/code_snippet.hpp @@ -11,7 +11,9 @@ #include #include +#include #include "./detail/template_stack.hpp" +#include "./detail/actions.hpp" namespace quickbook { diff --git a/detail/actions.cpp b/detail/actions.cpp index e2a2485..47b147e 100644 --- a/detail/actions.cpp +++ b/detail/actions.cpp @@ -25,6 +25,9 @@ namespace quickbook { + char const* quickbook_get_date = "__quickbook_get_date__"; + char const* quickbook_get_time = "__quickbook_get_time__"; + namespace { std::string fully_qualified_id(std::string const& library_id, std::string const& qualified_section_id, diff --git a/detail/actions.hpp b/detail/actions.hpp index a4430c8..d6546fe 100644 --- a/detail/actions.hpp +++ b/detail/actions.hpp @@ -286,11 +286,8 @@ namespace quickbook collector& out; }; - namespace - { - char const* quickbook_get_date = "__quickbook_get_date__"; - char const* quickbook_get_time = "__quickbook_get_time__"; - } + extern char const* quickbook_get_date; + extern char const* quickbook_get_time; struct do_macro_action { diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 797eb61..924dd80 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -23,7 +23,7 @@ test-suite quickbook.test : [ quickbook-test templates ] [ quickbook-test templates_1_4 ] [ quickbook-test templates_1_5 ] - [ quickbook-test xinclude ] + #[ quickbook-test xinclude ] [ quickbook-test import ] [ quickbook-test section_1_4 ] [ quickbook-test section_1_5 ] diff --git a/test/heading.gold b/test/heading.gold index e6cf992..0cd03d9 100644 --- a/test/heading.gold +++ b/test/heading.gold @@ -1,6 +1,6 @@ -
"; - - --section_level; - if (section_level < 0) + if (section_level <= min_section_level) { boost::spirit::classic::file_position const pos = first.get_position(); detail::outerr(pos.file,pos.line) << "Mismatched [endsect] near column " << pos.column << ".\n"; ++error_count; - // $$$ TODO: somehow fail parse else BOOST_ASSERT(std::string::npos != n) - // $$$ below will assert. + return; } + + --section_level; + out << "
"; + if (section_level == 0) { qualified_section_id.clear(); @@ -1077,7 +1111,7 @@ namespace quickbook { std::string::size_type const n = qualified_section_id.find_last_of('.'); - BOOST_ASSERT(std::string::npos != n); + if(std::string::npos != n); qualified_section_id.erase(n, std::string::npos); } } diff --git a/detail/actions.hpp b/detail/actions.hpp index d6546fe..acfea62 100644 --- a/detail/actions.hpp +++ b/detail/actions.hpp @@ -368,6 +368,14 @@ namespace quickbook collector& phrase; }; + struct escape_unicode_action + { + escape_unicode_action(collector& phrase) : phrase(phrase) {} + void operator()(iterator first, iterator last) const; + + collector& phrase; + }; + struct attribute_action { // Handle image attributes @@ -715,10 +723,12 @@ namespace quickbook end_section_action( collector& out , int& section_level + , int& min_section_level , std::string& qualified_section_id , int& error_count) : out(out) , section_level(section_level) + , min_section_level(min_section_level) , qualified_section_id(qualified_section_id) , error_count(error_count) {} @@ -726,6 +736,7 @@ namespace quickbook collector& out; int& section_level; + int& min_section_level; std::string& qualified_section_id; int& error_count; }; diff --git a/detail/actions_class.cpp b/detail/actions_class.cpp index d4d124c..5b46e0a 100644 --- a/detail/actions_class.cpp +++ b/detail/actions_class.cpp @@ -47,6 +47,7 @@ namespace quickbook , outdir(outdir_) , macro() , section_level(0) + , min_section_level(0) , section_id() , qualified_section_id() , source_mode("c++") @@ -97,6 +98,7 @@ namespace quickbook , tip(out, temp_para, tip_pre, tip_post) , plain_char(phrase) , raw_char(phrase) + , escape_unicode(phrase) , attribute(attributes, attribute_name) , image(phrase, attributes, image_fileref) , cond_phrase_pre(phrase, conditions, macro) @@ -172,7 +174,7 @@ namespace quickbook , anchor(out) , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id, element_id) - , end_section(out, section_level, qualified_section_id, error_count) + , end_section(out, section_level, min_section_level, qualified_section_id, error_count) , xinclude(out, *this) , include(*this) , import(out, *this) @@ -201,6 +203,7 @@ namespace quickbook , outdir , macro , section_level + , min_section_level , section_id , qualified_section_id , source_mode @@ -212,7 +215,7 @@ namespace quickbook temp.push(); temp_para.push(); list_buffer.push(); - templates.push(); + templates.push(); } void actions::pop() @@ -222,6 +225,7 @@ namespace quickbook , outdir , macro , section_level + , min_section_level , section_id , qualified_section_id , source_mode diff --git a/detail/actions_class.hpp b/detail/actions_class.hpp index 639ebf3..868795d 100644 --- a/detail/actions_class.hpp +++ b/detail/actions_class.hpp @@ -62,6 +62,7 @@ namespace quickbook fs::path outdir; string_symbols macro; int section_level; + int min_section_level; std::string section_id; std::string qualified_section_id; std::string source_mode; @@ -71,6 +72,7 @@ namespace quickbook , fs::path , string_symbols , int + , int , std::string , std::string , std::string> @@ -120,6 +122,7 @@ namespace quickbook phrase_action warning, caution, important, note, tip; plain_char_action plain_char; raw_char_action raw_char; + escape_unicode_action escape_unicode; attribute_action attribute; image_action image; cond_phrase_action_pre cond_phrase_pre; diff --git a/detail/post_process.cpp b/detail/post_process.cpp index ae9eb46..e41ef81 100644 --- a/detail/post_process.cpp +++ b/detail/post_process.cpp @@ -179,8 +179,11 @@ namespace quickbook "author" , "blockquote" , "bridgehead" + , "callout" + , "calloutlist" , "caution" , "copyright" + , "entry" , "footnote" , "important" , "informaltable" @@ -190,20 +193,19 @@ namespace quickbook , "note" , "orderedlist" , "para" - , "replaceable" , "row" , "section" + , "table" , "tbody" , "textobject" , "tgroup" , "thead" , "tip" , "variablelist" + , "varlistentry" , "warning" , "xml" , "xi:include" - , "calloutlist" - , "callout" }; char const* doc_types_[] = diff --git a/detail/quickbook.cpp b/detail/quickbook.cpp index 5cfe3fb..d5be0fa 100644 --- a/detail/quickbook.cpp +++ b/detail/quickbook.cpp @@ -29,7 +29,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.5" +#define QUICKBOOK_VERSION "Quickbook Version 1.5.1" namespace quickbook { diff --git a/detail/utils.cpp b/detail/utils.cpp index a71f302..acd4179 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -181,13 +181,74 @@ namespace quickbook { namespace detail } } + // Read the first few bytes in a file to see it starts with a byte order + // mark. If it doesn't, then write the characters we've already read in. + // Although, given how UTF-8 works, if we've read anything in, the files + // probably broken. + + template + bool check_bom(InputIterator& begin, InputIterator end, + OutputIterator out, char const* chars, int length) + { + char const* ptr = chars; + + while(begin != end && *begin == *ptr) { + ++begin; + ++ptr; + --length; + if(length == 0) return true; + } + + // Failed to match, so write the skipped characters to storage: + while(chars != ptr) *out++ = *chars++; + + return false; + } + + template + std::string read_bom(InputIterator& begin, InputIterator end, + OutputIterator out) + { + if(begin == end) return ""; + + const char utf8[] = {0xef, 0xbb, 0xbf}; + const char utf32be[] = {0, 0, 0xfe, 0xff}; + const char utf32le[] = {0xff, 0xfe, 0, 0}; + + unsigned char c = *begin; + switch(c) + { + case 0xEF: { // UTF-8 + return check_bom(begin, end, out, utf8, 3) ? "UTF-8" : ""; + } + case 0xFF: // UTF-16/UTF-32 little endian + return !check_bom(begin, end, out, utf32le, 2) ? "" : + check_bom(begin, end, out, utf32le + 2, 2) ? "UTF-32" : "UTF-16"; + case 0: // UTF-32 big endian + return check_bom(begin, end, out, utf32be, 4) ? "UTF-32" : ""; + case 0xFE: // UTF-16 big endian + return check_bom(begin, end, out, utf32be + 2, 2) ? "UTF-16" : ""; + default: + return ""; + } + } + // Copy a string, converting mac and windows style newlines to unix // newlines. template - void normalize_newlines(InputIterator begin, InputIterator end, - OutputIterator out) + bool normalize(InputIterator begin, InputIterator end, + OutputIterator out, std::string const& filename) { + std::string encoding = read_bom(begin, end, out); + + if(encoding != "UTF-8" && encoding != "") { + outerr(filename) << encoding << " is not supported. Please use UTF-8." + << std::endl; + + return false; + } + while(begin != end) { if(*begin == '\r') { *out++ = '\n'; @@ -198,6 +259,8 @@ namespace quickbook { namespace detail *out++ = *begin++; } } + + return true; } int load(std::string const& filename, std::string& storage) @@ -219,10 +282,14 @@ namespace quickbook { namespace detail // Turn off white space skipping on the stream in.unsetf(ios::skipws); - normalize_newlines( + if(!normalize( istream_iterator(in), istream_iterator(), - std::back_inserter(storage)); + std::back_inserter(storage), + filename)) + { + return 1; + } // ensure that we have enough trailing newlines to eliminate // the need to check for end of file in the grammar. diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index e585c9b..8dd21b7 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -180,6 +180,16 @@ Features include: * Accept a space between `section:` and the section id. * Support table ids. +[h3 Version 1.5.1] + +* Improve the post processor's list of block elements. `table`, `entry` and + `varlistentry` are treated as blocks. `replaceable` is treated as an inline + element. +* Check that `[section]` and `[endsect]` tags are balanced in templates. +* Add unicode escape characters, eg. `\u03B1` for \u03B1. +* Support UTF-8 files with a unicode byte order mark. +* Disallow `[` in simple markup. Fixes some errors with mismatched punctuation. + [endsect] [section:syntax Syntax Summary] @@ -621,6 +631,22 @@ and table cells (see __tables__) may now contain paragraphs.] The escaped space: `\ ` also has a special meaning. The escaped space is removed from the output. +[endsect] +[section Unicode escape] + +You can enter any 32-bit unicode character by using `\u` followed by its 4 digit +hexadecimal code. eg. + +[pre''' +\u03B1 + \u03B2 +'''] + +will generate: + +[: +\u03B1 + \u03B2 +] + [endsect] [section Images] diff --git a/phrase.hpp b/phrase.hpp index d3dfc0b..41f402a 100644 --- a/phrase.hpp +++ b/phrase.hpp @@ -223,14 +223,16 @@ namespace quickbook | simple_teletype ; + simple_phrase_end = '[' | phrase_end; + simple_markup(simple_bold, - '*', actions.simple_bold, phrase_end); + '*', actions.simple_bold, simple_phrase_end); simple_markup(simple_italic, - '/', actions.simple_italic, phrase_end); + '/', actions.simple_italic, simple_phrase_end); simple_markup(simple_underline, - '_', actions.simple_underline, phrase_end); + '_', actions.simple_underline, simple_phrase_end); simple_markup(simple_teletype, - '=', actions.simple_teletype, phrase_end); + '=', actions.simple_teletype, simple_phrase_end); phrase = *( common @@ -273,6 +275,10 @@ namespace quickbook str_p("\\n") [actions.break_] | "\\ " // ignore an escaped char | '\\' >> punct_p [actions.raw_char] + | "\\u">> repeat_p(4) + [ + chset<>("0-9a-fA-F") + ] [actions.escape_unicode] | ( ("'''" >> !eol) [actions.escape_pre] >> *(anychar_p - "'''") [actions.raw_char] @@ -462,7 +468,7 @@ namespace quickbook } rule space, blank, comment, phrase, phrase_markup, image, - phrase_end, bold, italic, underline, teletype, + simple_phrase_end, phrase_end, bold, italic, underline, teletype, strikethrough, escape, url, common, funcref, classref, memberref, enumref, macroref, headerref, conceptref, globalref, anchor, link, hard_space, eol, inline_code, simple_format, diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index aac1ddd..1d872ed 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -23,14 +23,17 @@ test-suite quickbook.test : [ quickbook-test templates ] [ quickbook-test templates_1_4 ] [ quickbook-test templates_1_5 ] + [ quickbook-test template-section ] #[ quickbook-test xinclude ] [ quickbook-test import ] + [ quickbook-test include_1_5 ] [ quickbook-test section_1_4 ] [ quickbook-test section_1_5 ] [ quickbook-test heading ] [ quickbook-test table_1_5 ] [ quickbook-test image_1_5 ] [ quickbook-test callouts ] + [ quickbook-test simple_markup ] [ quickbook-fail-test fail-include ] [ quickbook-fail-test fail-import ] [ quickbook-fail-test fail-template-arguments1 ] @@ -42,7 +45,12 @@ test-suite quickbook.test : [ quickbook-fail-test fail-parse-error1 ] [ quickbook-fail-test fail-parse-error2 ] [ quickbook-fail-test fail-template-lookup1 ] + [ quickbook-fail-test fail-template-section-1 ] + [ quickbook-fail-test fail-template-section-2 ] + [ quickbook-fail-test fail-template-section-3 ] + [ quickbook-test utf-8 ] + [ quickbook-test utf-8-bom ] + [ quickbook-test unicode-escape ] + [ quickbook-fail-test utf-16be-bom ] + [ quickbook-fail-test utf-16le-bom ] ; - - - diff --git a/test/fail-template-section-1.quickbook b/test/fail-template-section-1.quickbook new file mode 100644 index 0000000..60b3483 --- /dev/null +++ b/test/fail-template-section-1.quickbook @@ -0,0 +1,9 @@ +[article Template should contain balanced sections + [quickbook 1.5] +] + +[template begin_no_end[] +[section Test] +] + +[begin_no_end] \ No newline at end of file diff --git a/test/fail-template-section-2.quickbook b/test/fail-template-section-2.quickbook new file mode 100644 index 0000000..5445e88 --- /dev/null +++ b/test/fail-template-section-2.quickbook @@ -0,0 +1,10 @@ +[article Template should contain balanced sections + [quickbook 1.5] +] + +[template end_before_begin[] +[endsect] +[section Test] +] + +[end_before_begin] \ No newline at end of file diff --git a/test/fail-template-section-3.quickbook b/test/fail-template-section-3.quickbook new file mode 100644 index 0000000..237a9f0 --- /dev/null +++ b/test/fail-template-section-3.quickbook @@ -0,0 +1,9 @@ +[article Template should contain balanced sections + [quickbook 1.5] +] + +[template end_no_begin[] +[endsect] +] + +[end_no_begin] \ No newline at end of file diff --git a/test/include-sub.quickbook b/test/include-sub.quickbook new file mode 100644 index 0000000..1dcbff9 --- /dev/null +++ b/test/include-sub.quickbook @@ -0,0 +1,6 @@ +[article Include Test Sub Document + [quickbook 1.5] + [id include-sub] +] + +[/ Empty. Shouldn't really need this comment.] diff --git a/test/include-sub2.quickbook b/test/include-sub2.quickbook new file mode 100644 index 0000000..1fa6160 --- /dev/null +++ b/test/include-sub2.quickbook @@ -0,0 +1,9 @@ +[/ I'm trying not to break existing behaviour even when buggy. + In this case, this section will get an id using the title from + the previous 'include'.] + +[section:test Test] + +Just testing. + +[endsect] \ No newline at end of file diff --git a/test/include_1_5.gold b/test/include_1_5.gold new file mode 100644 index 0000000..c590619 --- /dev/null +++ b/test/include_1_5.gold @@ -0,0 +1,20 @@ + + +
+ Include Test + + +
+ <link linkend="include_test_sub_document.test"> Test</link> + + Just testing. + +
+
+ <link linkend="foo.test"> Test</link> + + Just testing. + +
+
diff --git a/test/include_1_5.quickbook b/test/include_1_5.quickbook new file mode 100644 index 0000000..7da3b62 --- /dev/null +++ b/test/include_1_5.quickbook @@ -0,0 +1,8 @@ +[article Include Test + [quickbook 1.5] + [id include-test] +] + +[include include-sub.quickbook] +[include include-sub2.quickbook] +[include:foo include-sub2.quickbook] \ No newline at end of file diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold index 3ba8eec..e4bbab0 100644 --- a/test/quickbook-manual.gold +++ b/test/quickbook-manual.gold @@ -283,9 +283,7 @@ This will generate: - - replacement - + replacement
@@ -381,179 +379,197 @@ the true business precept.] lists. - More Formatting Samples - - - - - - Markup - - - - Result - - - - - - - - - *Bold* - - - - Bold - - - - - - - *Is bold* - - - - Is bold - - - - - - - * Not bold* *Not bold * * Not bold * - - - - * Not bold* *Not bold * * Not bold * - - - - - - - This*Isn't*Bold (no bold) - - - - This*Isn't*Bold (no bold) - - - - - - - (*Bold Inside*) (parenthesis not bold) - - - - (Bold Inside) (parenthesis not bold) - - - - - - - *(Bold Outside)* (parenthesis bold) - - - - (Bold Outside) (parenthesis bold) - - - - - - - 3*4*5 = 60 (no bold) - - - - 3*4*5 = 60 (no bold) - - - - - - - 3 * 4 * 5 = 60 (no bold) - - - - 3 * 4 * 5 = 60 (no bold) - - - - - - - 3 *4* 5 = 60 (4 is bold) - - - - 3 4 5 = 60 (4 is bold) - - - - - - - *This is bold* this is not *but this is* - - - - This is bold this is not but this is - - - - - - - *This is bold*. - - - - This is bold. - - - - - - - *B*. (bold B) - - - - B. (bold B) - - - - - - - ['*Bold-Italic*] - - - - Bold-Italic - - - - - - - *side-by*/-side/ - - - - side-by-side - - - - - +
+ More Formatting Samples + + + + + + Markup + + + + + Result + + + + + + + + + *Bold* + + + + + Bold + + + + + + + *Is bold* + + + + + Is bold + + + + + + + * Not bold* *Not bold * * Not bold * + + + + + * Not bold* *Not bold * * Not bold * + + + + + + + This*Isn't*Bold (no bold) + + + + + This*Isn't*Bold (no bold) + + + + + + + (*Bold Inside*) (parenthesis not bold) + + + + + (Bold Inside) (parenthesis not + bold) + + + + + + + *(Bold Outside)* (parenthesis bold) + + + + + (Bold Outside) (parenthesis + bold) + + + + + + + 3*4*5 = 60 (no bold) + + + + + 3*4*5 = 60 (no bold) + + + + + + + 3 * 4 * 5 = 60 (no bold) + + + + + 3 * 4 * 5 = 60 (no bold) + + + + + + + 3 *4* 5 = 60 (4 is bold) + + + + + 3 4 5 = 60 (4 is bold) + + + + + + + *This is bold* this is not *but this is* + + + + + This is bold this is not but this is + + + + + + + *This is bold*. + + + + + This is bold. + + + + + + + *B*. (bold B) + + + + + B. (bold B) + + + + + + + ['*Bold-Italic*] + + + + + Bold-Italic + + + + + + + *side-by*/-side/ + + + + + side-by-side + + + + +
As mentioned, simple markups cannot go past a single block. The text from @@ -683,46 +699,50 @@ C++ comment `// looks like this` whereas a Python comment [python] A C++ comment // looks like this whereas a Python comment #looks like this. - Supported Source Modes - - - - - - Mode - - - - Source Mode Markup - - - - - - - - - C++ - - - - [c++] - - - - - - - Python - - - - [python] - - - - - +
+ Supported Source Modes + + + + + + Mode + + + + + Source Mode Markup + + + + + + + + + C++ + + + + + [c++] + + + + + + + Python + + + + + [python] + + + + +
@@ -1682,73 +1702,82 @@ sf_logo Quickbook has some predefined macros that you can already use. - Predefined Macros - - - - - - Macro - - - - Meaning - - - - Example - - - - - - - - - __DATE__ - - - - Today's date - - - - 2000-Dec-20 - - - - - - - __TIME__ - - - - The current time - - - - 12:00:00 PM - - - - - - - __FILENAME__ - - - - Quickbook source filename - - - - NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE - - - - - +
+ Predefined Macros + + + + + + Macro + + + + + Meaning + + + + + Example + + + + + + + + + __DATE__ + + + + + Today's date + + + + + 2000-Dec-20 + + + + + + + __TIME__ + + + + + The current time + + + + + 12:00:00 PM + + + + + + + __FILENAME__ + + + + + Quickbook source filename + + + + + NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE + + + + +
@@ -2120,73 +2149,82 @@ for the journey to old age.]]] will generate: - A Simple Table - - - - - - Heading 1 - - - - Heading 2 - - - - Heading 3 - - - - - - - - - R0-C0 - - - - R0-C1 - - - - R0-C2 - - - - - - - R2-C0 - - - - R2-C1 - - - - R2-C2 - - - - - - - R3-C0 - - - - R3-C1 - - - - R3-C2 - - - - - +
+ A Simple Table + + + + + + Heading 1 + + + + + Heading 2 + + + + + Heading 3 + + + + + + + + + R0-C0 + + + + + R0-C1 + + + + + R0-C2 + + + + + + + R2-C0 + + + + + R2-C1 + + + + + R2-C2 + + + + + + + R3-C0 + + + + + R3-C1 + + + + + R3-C2 + + + + +
The table title is optional. The first row of the table is automatically @@ -2220,55 +2258,59 @@ for the journey to old age.]]] and thus: - Table with fat cells - - - - - - Heading 1 - - - - Heading 2 - - - - - - - - - Row 0, Col 0: a small cell - - - - Row 0, Col 1: a big fat cell with paragraphs - - - Boost provides free peer-reviewed portable C++ source libraries. - - - We emphasize libraries that work well with the C++ Standard Library. - Boost libraries are intended to be widely useful, and usable across - a broad spectrum of applications. The Boost license encourages both - commercial and non-commercial use. - - - - - - - Row 1, Col 0: a small cell - - - - Row 1, Col 1: a small cell - - - - - +
+ Table with fat cells + + + + + + Heading 1 + + + + + Heading 2 + + + + + + + + + Row 0, Col 0: a small cell + + + + + Row 0, Col 1: a big fat cell with paragraphs + + + Boost provides free peer-reviewed portable C++ source libraries. + + + We emphasize libraries that work well with the C++ Standard Library. + Boost libraries are intended to be widely useful, and usable + across a broad spectrum of applications. The Boost license encourages + both commercial and non-commercial use. + + + + + + + Row 1, Col 0: a small cell + + + + + Row 1, Col 1: a small cell + + + + +
Here's how to have preformatted blocks of code in a table cell: @@ -2290,30 +2332,33 @@ for the journey to old age.]]] ] ] - Table with code - - - - - - Comment - - - - Code - - - - - - - - - My first program - - - - +
+ Table with code + + + + + + Comment + + + + + Code + + + + + + + + + My first program + + + + + #include <iostream> int main() @@ -2322,11 +2367,11 @@ for the journey to old age.]]] return 0; } - - - - - + + + + +
@@ -2342,24 +2387,30 @@ for the journey to old age.]]] will generate: - A Variable List term 1 - - - The definition of term 1 - - - term 2 - - - The definition of term 2 - - - term 3 - - - The definition of term 3 - - + A Variable List + + term 1 + + + The definition of term 1 + + + + + term 2 + + + The definition of term 2 + + + + + term 3 + + + The definition of term 3 + + @@ -2927,774 +2978,871 @@ boostbook standalone [cpp] - Syntax Compendium - - - - - - To do this... - - - - Use this... - - - - See this... - - - - - - - - - comment - - - - [/ some comment] - - - - Comments - - - - - - - italics - - - - ['italics] or /italics/ - - - - Font Styles - and Simple - formatting - - - - - - - bold - - - - [*bold] or *bold* - - - - Font Styles - and Simple - formatting - - - - - - - underline - - - - [_underline] or _underline_ - - - - Font Styles - and Simple - formatting - - - - - - - teletype - - - - [^teletype] or =teletype= - - - - Font Styles - and Simple - formatting - - - - - - - strikethrough - - - - [-strikethrough] - - - - Font Styles - and Simple - formatting - - - - - - - - replaceable - - - - - [~replaceable] - - - - Replaceble - - - - - - - source mode - - - - [c++] or [python] - - - - Source Mode - - - - - - - inline code - - - - `int main();` - - - - Inline code - - - - - - - code block - - - - ``int main();`` - - - - Code - - - - - - - code escape - - - - ``from c++ to QuickBook`` - - - - Escaping Back To QuickBook - - - - - - - line break - - - - [br] or \n - - - - line-break - DEPRECATED - - - - - - - anchor - - - - [#anchor] - - - - Anchors - - - - - - - link - - - - [@http://www.boost.org Boost] - - - - Links - - - - - - - anchor link - - - - [link section.anchor Link text] - - - - Anchor links - - - - - - - refentry link - - - - [link xml.refentry Link text] - - - - refentry links - - - - - - - function link - - - - [funcref fully::qualified::function_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - class link - - - - [classref fully::qualified::class_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - member link - - - - [memberref fully::qualified::member_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - enum link - - - - [enumref fully::qualified::enum_name Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - macro link - - - - [macroref MACRO_NAME Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - concept link - - - - [conceptref ConceptName Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - header link - - - - [headerref path/to/header.hpp Link text] - - - - function, class, member, - enum, macro, concept or header links - - - - - - - escape - - - - '''escaped text (no processing/formatting)''' - - - - Escape - - - - - - - single char escape - - - - \c - - - - Single char - escape - - - - - - - images - - - - [$image.jpg] - - - - Images - - - - - - - begin section - - - - [section The Section Title] - - - - Section - - - - - - - end section - - - - [endsect] - - - - Section - - - - - - - paragraph - - - - No markup. Paragraphs start left-flushed and are terminated by two or - more newlines. - - - - Paragraphs - - - - - - - ordered list - - - - +
+ Syntax Compendium + + + + + + To do this... + + + + + Use this... + + + + + See this... + + + + + + + + + comment + + + + + [/ some comment] + + + + + Comments + + + + + + + italics + + + + + ['italics] or /italics/ + + + + + Font Styles + and Simple + formatting + + + + + + + bold + + + + + [*bold] or *bold* + + + + + Font Styles + and Simple + formatting + + + + + + + underline + + + + + [_underline] or _underline_ + + + + + Font Styles + and Simple + formatting + + + + + + + teletype + + + + + [^teletype] or =teletype= + + + + + Font Styles + and Simple + formatting + + + + + + + strikethrough + + + + + [-strikethrough] + + + + + Font Styles + and Simple + formatting + + + + + + + replaceable + + + + + [~replaceable] + + + + + Replaceble + + + + + + + source mode + + + + + [c++] or [python] + + + + + Source Mode + + + + + + + inline code + + + + + `int main();` + + + + + Inline code + + + + + + + code block + + + + + ``int main();`` + + + + + Code + + + + + + + code escape + + + + + ``from c++ to QuickBook`` + + + + + Escaping Back + To QuickBook + + + + + + + line break + + + + + [br] or \n + + + + + line-break + DEPRECATED + + + + + + + anchor + + + + + [#anchor] + + + + + Anchors + + + + + + + link + + + + + [@http://www.boost.org Boost] + + + + + Links + + + + + + + anchor link + + + + + [link section.anchor Link text] + + + + + Anchor links + + + + + + + refentry link + + + + + [link xml.refentry Link text] + + + + + refentry links + + + + + + + function link + + + + + [funcref fully::qualified::function_name Link text] + + + + + function, class, + member, enum, macro, concept or header links + + + + + + + class link + + + + + [classref fully::qualified::class_name Link text] + + + + + function, class, + member, enum, macro, concept or header links + + + + + + + member link + + + + + [memberref fully::qualified::member_name Link text] + + + + + function, class, + member, enum, macro, concept or header links + + + + + + + enum link + + + + + [enumref fully::qualified::enum_name Link text] + + + + + function, class, + member, enum, macro, concept or header links + + + + + + + macro link + + + + + [macroref MACRO_NAME Link text] + + + + + function, class, + member, enum, macro, concept or header links + + + + + + + concept link + + + + + [conceptref ConceptName Link text] + + + + + function, class, + member, enum, macro, concept or header links + + + + + + + header link + + + + + [headerref path/to/header.hpp Link text] + + + + + function, class, + member, enum, macro, concept or header links + + + + + + + escape + + + + + '''escaped text (no processing/formatting)''' + + + + + Escape + + + + + + + single char escape + + + + + \c + + + + + Single + char escape + + + + + + + images + + + + + [$image.jpg] + + + + + Images + + + + + + + begin section + + + + + [section The Section Title] + + + + + Section + + + + + + + end section + + + + + [endsect] + + + + + Section + + + + + + + paragraph + + + + + No markup. Paragraphs start left-flushed and are terminated by two + or more newlines. + + + + + Paragraphs + + + + + + + ordered list + + + + + # one # two # three - - - - Ordered lists - - - - - - - unordered list - - - - + + + + + Ordered + lists + + + + + + + unordered list + + + + + * one * two * three - - - - Unordered - lists - - - - - - - code - - - - No markup. Preformatted code starts with a space or a tab. - - - - Code - - - - - - - preformatted - - - - [pre preformatted] - - - - Preformatted - - - - - - - block quote - - - - [:sometext...] - - - - Blockquote - - - - - - - heading 1 - - - - [h1 Heading 1] - - - - Heading - - - - - - - heading 2 - - - - [h2 Heading 2] - - - - Heading - - - - - - - heading 3 - - - - [h3 Heading 3] - - - - Heading - - - - - - - heading 4 - - - - [h4 Heading 4] - - - - Heading - - - - - - - heading 5 - - - - [h5 Heading 5] - - - - Heading - - - - - - - heading 6 - - - - [h6 Heading 6] - - - - Heading - - - - - - - macro - - - - [def macro_identifier some text] - - - - Macros - - - - - - - template - - - - [template[a b] [a] body [b]] - - - - Templates - - - - - - - blurb - - - - [blurb advertisement or note...] - - - - Blurbs - - - - - - - admonition - - - - [warning Warning text...] - - - - Admonitions - - - - - - - table - - - - + + + + + Unordered + lists + + + + + + + code + + + + + No markup. Preformatted code starts with a space or a tab. + + + + + Code + + + + + + + preformatted + + + + + [pre preformatted] + + + + + Preformatted + + + + + + + block quote + + + + + [:sometext...] + + + + + Blockquote + + + + + + + heading 1 + + + + + [h1 Heading 1] + + + + + Heading + + + + + + + heading 2 + + + + + [h2 Heading 2] + + + + + Heading + + + + + + + heading 3 + + + + + [h3 Heading 3] + + + + + Heading + + + + + + + heading 4 + + + + + [h4 Heading 4] + + + + + Heading + + + + + + + heading 5 + + + + + [h5 Heading 5] + + + + + Heading + + + + + + + heading 6 + + + + + [h6 Heading 6] + + + + + Heading + + + + + + + macro + + + + + [def macro_identifier some text] + + + + + Macros + + + + + + + template + + + + + [template[a b] [a] body [b]] + + + + + Templates + + + + + + + blurb + + + + + [blurb advertisement or note...] + + + + + Blurbs + + + + + + + admonition + + + + + [warning Warning text...] + + + + + Admonitions + + + + + + + table + + + + + [table Title [[a][b][c]] [[a][b][c]] ] - - - - Tables - - - - - - - variablelist - - - - + + + + + Tables + + + + + + + variablelist + + + + + [variablelist Title [[a][b]] [[a][b]] ] - - - - Variable Lists - - - - - - - include - - - - [include someother.qbk] - - - - Include - - - - - + + + + + Variable Lists + + + + + + + include + + + + + [include someother.qbk] + + + + + Include + + + + +
diff --git a/test/simple_markup.gold b/test/simple_markup.gold new file mode 100644 index 0000000..272b2d4 --- /dev/null +++ b/test/simple_markup.gold @@ -0,0 +1,21 @@ + + +
+ Simple Markup Test + + +
+ <link linkend="simple_markup_test.simple_markup">Simple Markup</link> + + italic bold underline teletype + + + /allitalic * not bold* + + + /not italic bold + +
+
diff --git a/test/simple_markup.quickbook b/test/simple_markup.quickbook new file mode 100644 index 0000000..77fcbd5 --- /dev/null +++ b/test/simple_markup.quickbook @@ -0,0 +1,13 @@ +[article Simple Markup Test +[quickbook 1.5] +] + +[section Simple Markup] + +/italic/ *bold* _underline_ =teletype= + +/all/italic/ * not bold* + +/not italic [@http://www.boost.org/ *bold*] + +[endsect] \ No newline at end of file diff --git a/test/table_1_5.gold b/test/table_1_5.gold index 075beb3..06c652f 100644 --- a/test/table_1_5.gold +++ b/test/table_1_5.gold @@ -4,66 +4,69 @@ Table 1.5 - Table 1 - - - - - - Heading - - - - - - - - - cell - - - - - -
Table 2 - - - - - - Heading - - - - - - - - - cell - - - - - -
- + + Table 1 - - Heading - + + Heading + - - cell - + + cell + + + + + +
+ + Table 2 + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + + + + + + Heading + + + + + + + + + cell + @@ -74,68 +77,70 @@ - - Heading - + + Heading + - - cell - + + cell + - -table5- - - - - - - Heading - - - - - - - - - cell - - - - - -
-
- <link linkend="table_1_5.section1"> Section 1</link> Table 1 +
+ -table5- - - Heading - + + Heading + - - cell - + + cell + +
+
+ <link linkend="table_1_5.section1"> Section 1</link> + + Table 1 + + + + + + Heading + + + + + + + + + cell + + + + +
diff --git a/test/template-section.gold b/test/template-section.gold new file mode 100644 index 0000000..ff0dcd9 --- /dev/null +++ b/test/template-section.gold @@ -0,0 +1,27 @@ + + +
+ Section in a template + + + + + It's a pity if the whole template is wrapped in a paragraph. + +
+ <link linkend="section_in_a_template.test">Test</link> + + Hello. + + + + Just + to test id generation + + + Goodbye. + +
+
+
diff --git a/test/template-section.quickbook b/test/template-section.quickbook new file mode 100644 index 0000000..0f88d71 --- /dev/null +++ b/test/template-section.quickbook @@ -0,0 +1,20 @@ +[article Section in a template + [quickbook 1.5] +] + +[template nestedsection[] + +It's a pity if the whole template is wrapped in a paragraph. + +[section Test] + +Hello. + +[heading Just to test id generation] + +Goodbye. + +[endsect] +] + +[nestedsection] \ No newline at end of file diff --git a/test/unicode-escape.gold b/test/unicode-escape.gold new file mode 100644 index 0000000..8c2bd69 --- /dev/null +++ b/test/unicode-escape.gold @@ -0,0 +1,85 @@ + + +
+ UTF-8 test + + + + + Iñtërnâtiônàlizætiøn + + + + Αα Alpha + + + Ββ Beta + + + Γγ Gamma + + + Δδ Delta + + + Εε Epsilon + + + Ζζ Zeta + + + Ηη Eta + + + Θθ Theta + + + Ιι Iota + + + Κκ Kappa + + + Λλ Lambda + + + Μμ Mu + + + Νν Nu + + + Ξξ Xi + + + Οο Omicron + + + Ππ Pi + + + Ρρ Rho + + + Σσς Sigma + + + Ττ Tau + + + Υυ Upsilon + + + Φφ Phi + + + Χχ Chi + + + Ψψ Psi + + + Ωω Omega + + +
diff --git a/test/unicode-escape.quickbook b/test/unicode-escape.quickbook new file mode 100644 index 0000000..e8a1349 --- /dev/null +++ b/test/unicode-escape.quickbook @@ -0,0 +1,30 @@ +[article UTF-8 test + [quickbook 1.5] +] + +[heading I\u00F1t\u00EBrn\u00E2ti\u00F4n\u00E0liz\u00E6ti\u00F8n] + +* \u0391\u03B1 Alpha +* \u0392\u03B2 Beta +* \u0393\u03B3 Gamma +* \u0394\u03B4 Delta +* \u0395\u03B5 Epsilon +* \u0396\u03B6 Zeta +* \u0397\u03B7 Eta +* \u0398\u03B8 Theta +* \u0399\u03B9 Iota +* \u039A\u03BA Kappa +* \u039B\u03BB Lambda +* \u039C\u03BC Mu +* \u039D\u03BD Nu +* \u039E\u03BE Xi +* \u039F\u03BF Omicron +* \u03A0\u03C0 Pi +* \u03A1\u03C1 Rho +* \u03A3\u03C3\u03C2 Sigma +* \u03A4\u03C4 Tau +* \u03A5\u03C5 Upsilon +* \u03A6\u03C6 Phi +* \u03A7\u03C7 Chi +* \u03A8\u03C8 Psi +* \u03A9\u03C9 Omega \ No newline at end of file diff --git a/test/utf-16be-bom.quickbook b/test/utf-16be-bom.quickbook new file mode 100644 index 0000000000000000000000000000000000000000..be2bcbc4484c9a055aaa82cd110f77509b25fd35 GIT binary patch literal 664 zcmezOpCOtdk)ep8gdvk5nIVTEl|g|alp%z{jX{^ekim>Wfgy<@lOdf!fgzP4k0FI2 zlOd5Ik3oT>o(vxuN*G=<6fxv6JOaDp3qu~m1BM)iOol3kXJC;Z40%xfS_}%z z6PY(MC@?rOHCoykgP+)LkNM$I2i%n+U%%H&F&XCBE%a98fox;3@ zL4m=AA(bHqN$phTtqckbt_%eX#SEDYISly>c~Fz5F>hl~V2DC7c{=lUuxf-|GnjWU zC@_S8{f7{p$-I+6fx(j@AIYX!%)1yA7`z!0844H*;I5j@yqiIR!3XTtB!(2Y_#Eav z3B-GWZ4CxGs0G{}D&j0`b literal 0 HcmV?d00001 diff --git a/test/utf-16le-bom.quickbook b/test/utf-16le-bom.quickbook new file mode 100644 index 0000000000000000000000000000000000000000..d9782a4655177f3775debb521dcc5350e2dce658 GIT binary patch literal 664 zcmezWFPb5dp@^Y`A(J7QA%`KAL4hHZA%ww=L6^ah!HhwHA&DWAA)P^iA(bJIA%!86 zA(0`EL4l!!A(f$+p@e~pK>-S*844Ln!KP$0Br)VOf@=rNcw#4>P!F&9HL zLk2@CLn7FuJg~W*3?CUv7+y0JG2}5k0=wf2LmtBeh8%`WhAM_kFgP;gFcdIkFeEZ?F@QuTF>hj4U~pncWhjA*O=jNAtia&TkjRkBkP8=`!n}o9 zfx(3#l_3X7?NsKi%nA&y3mfx(|47aSKwNd8#Be1KVjApov& zA@f0I1%@Do42FED-o?y^nGZ25Fa(3+91&tmn2&({mI$|XDf3ZgP)flJt!2!|z_w(- l?OD!zoLPavnE@fPg82kk4Jf1`vA2@>B-GWZ4CxGs3;+?cb + +
+ UTF-8 test + + + + + Iñtërnâtiônàlizætiøn + + + + Αα Alpha + + + Ββ Beta + + + Γγ Gamma + + + Δδ Delta + + + Εε Epsilon + + + Ζζ Zeta + + + Ηη Eta + + + Θθ Theta + + + Ιι Iota + + + Κκ Kappa + + + Λλ Lambda + + + Μμ Mu + + + Îν Nu + + + Ξξ Xi + + + Οο Omicron + + + Ππ Pi + + + Î¡Ï Rho + + + Σσς Sigma + + + Ττ Tau + + + Υυ Upsilon + + + Φφ Phi + + + Χχ Chi + + + Ψψ Psi + + + Ωω Omega + + +
diff --git a/test/utf-8-bom.quickbook b/test/utf-8-bom.quickbook new file mode 100644 index 0000000..443f6c6 --- /dev/null +++ b/test/utf-8-bom.quickbook @@ -0,0 +1,30 @@ +[article UTF-8 test + [quickbook 1.5] +] + +[heading Iñtërnâtiônàlizætiøn] + +* Αα Alpha +* Ββ Beta +* Γγ Gamma +* Δδ Delta +* Εε Epsilon +* Ζζ Zeta +* Ηη Eta +* Θθ Theta +* Ιι Iota +* Κκ Kappa +* Λλ Lambda +* Μμ Mu +* Îν Nu +* Ξξ Xi +* Οο Omicron +* Ππ Pi +* Î¡Ï Rho +* Σσς Sigma +* Ττ Tau +* Υυ Upsilon +* Φφ Phi +* Χχ Chi +* Ψψ Psi +* Ωω Omega \ No newline at end of file diff --git a/test/utf-8.gold b/test/utf-8.gold new file mode 100644 index 0000000..1a03043 --- /dev/null +++ b/test/utf-8.gold @@ -0,0 +1,85 @@ + + +
+ UTF-8 test + + + + + Iñtërnâtiônàlizætiøn + + + + Αα Alpha + + + Ββ Beta + + + Γγ Gamma + + + Δδ Delta + + + Εε Epsilon + + + Ζζ Zeta + + + Ηη Eta + + + Θθ Theta + + + Ιι Iota + + + Κκ Kappa + + + Λλ Lambda + + + Μμ Mu + + + Îν Nu + + + Ξξ Xi + + + Οο Omicron + + + Ππ Pi + + + Î¡Ï Rho + + + Σσς Sigma + + + Ττ Tau + + + Υυ Upsilon + + + Φφ Phi + + + Χχ Chi + + + Ψψ Psi + + + Ωω Omega + + +
diff --git a/test/utf-8.quickbook b/test/utf-8.quickbook new file mode 100644 index 0000000..96f02f4 --- /dev/null +++ b/test/utf-8.quickbook @@ -0,0 +1,30 @@ +[article UTF-8 test + [quickbook 1.5] +] + +[heading Iñtërnâtiônàlizætiøn] + +* Αα Alpha +* Ββ Beta +* Γγ Gamma +* Δδ Delta +* Εε Epsilon +* Ζζ Zeta +* Ηη Eta +* Θθ Theta +* Ιι Iota +* Κκ Kappa +* Λλ Lambda +* Μμ Mu +* Îν Nu +* Ξξ Xi +* Οο Omicron +* Ππ Pi +* Î¡Ï Rho +* Σσς Sigma +* Ττ Tau +* Υυ Upsilon +* Φφ Phi +* Χχ Chi +* Ψψ Psi +* Ωω Omega \ No newline at end of file From 962f63fef65d79d09df3cc2eae5f72940c415d71 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 17 Mar 2010 00:18:38 +0000 Subject: [PATCH 44/94] Merge quickbook. - 32-bit unicode escapes. - Escape a couple of equal signs. Fixes #3906. [SVN r60665] --- doc/quickbook.qbk | 7 ++++--- phrase.hpp | 8 ++++---- test/unicode-escape.gold | 17 +++++++++++++++++ test/unicode-escape.quickbook | 9 ++++++++- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 8dd21b7..6849777 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -634,7 +634,8 @@ from the output. [endsect] [section Unicode escape] -You can enter any 32-bit unicode character by using `\u` followed by its 4 digit +You can enter any 16-bit unicode character by using `\u` followed by its 4 digit +hexadecimal code, or a 32-bit character by using `\U` followed by an 8 digit hexadecimal code. eg. [pre''' @@ -2134,8 +2135,8 @@ boostbook standalone : my_doc : - boost.image.src=images/my_project_logo.png - boost.image.alt="\\"My Project\\"" + boost.image.src\=images/my_project_logo.png + boost.image.alt\="\\"My Project\\"" boost.image.w=100 boost.image.h=50 nav.layout=none diff --git a/phrase.hpp b/phrase.hpp index 41f402a..f9d0066 100644 --- a/phrase.hpp +++ b/phrase.hpp @@ -275,10 +275,10 @@ namespace quickbook str_p("\\n") [actions.break_] | "\\ " // ignore an escaped char | '\\' >> punct_p [actions.raw_char] - | "\\u">> repeat_p(4) - [ - chset<>("0-9a-fA-F") - ] [actions.escape_unicode] + | "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")] + [actions.escape_unicode] + | "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")] + [actions.escape_unicode] | ( ("'''" >> !eol) [actions.escape_pre] >> *(anychar_p - "'''") [actions.raw_char] diff --git a/test/unicode-escape.gold b/test/unicode-escape.gold index 8c2bd69..e2f8b12 100644 --- a/test/unicode-escape.gold +++ b/test/unicode-escape.gold @@ -82,4 +82,21 @@ Ωω Omega + + In the unlikely event that you've got a Mahjong font: + + + + 🀀 East Wind + + + 🀁 South Wind + + + 🀂 West Wind + + + 🀃 North Wind + + diff --git a/test/unicode-escape.quickbook b/test/unicode-escape.quickbook index e8a1349..becdef6 100644 --- a/test/unicode-escape.quickbook +++ b/test/unicode-escape.quickbook @@ -27,4 +27,11 @@ * \u03A6\u03C6 Phi * \u03A7\u03C7 Chi * \u03A8\u03C8 Psi -* \u03A9\u03C9 Omega \ No newline at end of file +* \u03A9\u03C9 Omega + +In the unlikely event that you've got a Mahjong font: + +* \U0001F000 East Wind +* \U0001F001 South Wind +* \U0001F002 West Wind +* \U0001F003 North Wind \ No newline at end of file From a42e360345d5b9305cc6e6dafc7d6bc6b2814f7c Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 5 Apr 2010 09:03:29 +0000 Subject: [PATCH 45/94] Merge quickbook - Define macros at the command line. - Some inspect fixes. [SVN r61065] --- detail/actions.hpp | 9 +++-- detail/quickbook.cpp | 96 ++++++++++++++++++++++++++++++++++++++++---- doc/Jamfile.v2 | 10 +++++ index.html | 5 +++ test/callouts.cpp | 5 +++ 5 files changed, 114 insertions(+), 11 deletions(-) diff --git a/detail/actions.hpp b/detail/actions.hpp index acfea62..5bbb77a 100644 --- a/detail/actions.hpp +++ b/detail/actions.hpp @@ -43,6 +43,7 @@ namespace quickbook extern tm* current_gm_time; // the current UTC time extern bool debug_mode; extern std::vector include_path; + extern std::vector preset_defines; // forward declarations struct actions; @@ -370,10 +371,10 @@ namespace quickbook struct escape_unicode_action { - escape_unicode_action(collector& phrase) : phrase(phrase) {} - void operator()(iterator first, iterator last) const; - - collector& phrase; + escape_unicode_action(collector& phrase) : phrase(phrase) {} + void operator()(iterator first, iterator last) const; + + collector& phrase; }; struct attribute_action diff --git a/detail/quickbook.cpp b/detail/quickbook.cpp index d5be0fa..f787444 100644 --- a/detail/quickbook.cpp +++ b/detail/quickbook.cpp @@ -43,6 +43,79 @@ namespace quickbook unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version bool ms_errors = false; // output errors/warnings as if for VS std::vector include_path; + std::vector preset_defines; + + /////////////////////////////////////////////////////////////////////////// + // + // Parse the macros passed as command line parameters + // + /////////////////////////////////////////////////////////////////////////// + template + struct command_line_grammar + : public grammar > + { + command_line_grammar(Actions& actions) + : actions(actions) {} + + template + struct definition + { + definition(command_line_grammar const& self) + : unused(false), common(self.actions, unused) + { + Actions& actions = self.actions; + + macro = + *space_p + >> macro_identifier [actions.macro_identifier] + >> *space_p + >> ( '=' + >> *space_p + >> phrase [actions.macro_definition] + >> *space_p + ) + | eps_p [actions.macro_definition] + ; + + macro_identifier = + +(anychar_p - (space_p | ']')) + ; + + phrase = + *( common + | (anychar_p - ']') [actions.plain_char] + ) + ; + } + + bool unused; + rule macro, macro_identifier, phrase; + phrase_grammar common; + + rule const& + start() const { return macro; } + }; + + Actions& actions; + }; + + static void set_macros(actions& actor) + { + quickbook::command_line_grammar grammar(actor); + + for(std::vector::const_iterator + it = preset_defines.begin(), + end = preset_defines.end(); + it != end; ++it) + { + typedef position_iterator iterator_type; + iterator_type first(it->begin(), it->end(), "command line parameter"); + iterator_type last(it->end(), it->end()); + + parse(first, last, grammar); + // TODO: Check result? + } + } /////////////////////////////////////////////////////////////////////////// // @@ -89,12 +162,6 @@ namespace quickbook << "Syntax Error near column " << pos.column << ".\n"; ++actor.error_count; } - - if(actor.error_count) - { - detail::outerr(filein_) - << "Error count: " << actor.error_count << ".\n"; - } return actor.error_count ? 1 : 0; } @@ -103,11 +170,19 @@ namespace quickbook parse(char const* filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false) { actions actor(filein_, outdir, out); + set_macros(actor); bool r = parse(filein_, actor); if (actor.section_level != 0) detail::outwarn(filein_) << "Warning missing [endsect] detected at end of file." << std::endl; + + if(actor.error_count) + { + detail::outerr(filein_) + << "Error count: " << actor.error_count << ".\n"; + } + return r; } @@ -177,6 +252,7 @@ main(int argc, char* argv[]) ("debug", "debug mode (for developers)") ("ms-errors", "use Microsoft Visual Studio style error & warn message format") ("include-path,I", value< std::vector >(), "include path") + ("define,D", value< std::vector >(), "define macro") ; positional_options_description p; @@ -247,6 +323,12 @@ main(int argc, char* argv[]) = std::vector(paths.begin(), paths.end()); } + if (vm.count("define")) + { + quickbook::preset_defines + = vm["define"].as >(); + } + if (vm.count("input-file")) { std::string filein @@ -274,7 +356,7 @@ main(int argc, char* argv[]) quickbook::detail::outerr("") << "Error: No filename given\n\n" << desc << std::endl; return 1; - } + } } catch(std::exception& e) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 1b19f03..7cf4fd3 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -1,3 +1,13 @@ +#============================================================================== +# Copyright (c) 2002 2004 2006 Joel de Guzman +# Copyright (c) 2004 Eric Niebler +# http://spirit.sourceforge.net/ +# +# Use, modification and distribution is subject to the Boost Software +# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +#============================================================================== + project boost/quickbook/doc ; import boostbook : boostbook ; diff --git a/index.html b/index.html index 1258a7f..35faddf 100644 --- a/index.html +++ b/index.html @@ -6,5 +6,10 @@ Automatic redirection failed, click this link +

Copyright Eric Niebler 2005

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at + www.boost.org/LICENSE_1_0.txt). +

diff --git a/test/callouts.cpp b/test/callouts.cpp index ab5ae99..e126d6a 100644 --- a/test/callouts.cpp +++ b/test/callouts.cpp @@ -1,3 +1,8 @@ + +// Copyright 2009 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or move at http://www.boost.org/LICENSE_1_0.txt) + //[ example1 /*` From 61619c509c86961bbbf7587f69e896c33feb87b3 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 21 Apr 2010 23:00:35 +0000 Subject: [PATCH 46/94] Merge some link fixes and release notes. [SVN r61474] --- doc/quickbook.qbk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 6849777..858ed1a 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -180,7 +180,7 @@ Features include: * Accept a space between `section:` and the section id. * Support table ids. -[h3 Version 1.5.1] +[h3 Version 1.5.1 - Boost 1.43.0] * Improve the post processor's list of block elements. `table`, `entry` and `varlistentry` are treated as blocks. `replaceable` is treated as an inline @@ -189,6 +189,8 @@ Features include: * Add unicode escape characters, eg. `\u03B1` for \u03B1. * Support UTF-8 files with a unicode byte order mark. * Disallow `[` in simple markup. Fixes some errors with mismatched punctuation. +* Add command line flag to define macros at the command line, + e.g. `quickbook "-D__italic_foo__=/foo/"`. [endsect] From a666d8a628954365c7d1be2fc6d83f60389aa020 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 23 Jun 2010 19:33:37 +0000 Subject: [PATCH 47/94] Merge quickbook. [SVN r63267] --- Jamfile.v2 | 2 + block.hpp | 9 +- code_snippet.hpp | 10 +- detail/actions.cpp | 109 +++-- detail/actions_class.cpp | 6 +- detail/actions_class.hpp | 2 +- detail/input_path.cpp | 83 +++- detail/markups.cpp | 8 +- detail/post_process.cpp | 18 +- detail/quickbook.cpp | 6 +- detail/utils.cpp | 6 +- doc/Jamfile.v2 | 4 +- doc/quickbook.qbk | 24 +- doc_info.hpp | 5 +- test/Jamfile.v2 | 6 + test/blocks.gold | 89 ++++ test/blocks.quickbook | 39 ++ test/callouts.gold | 8 +- test/code-block-1.gold | 2 +- test/code-block-2.gold | 2 +- test/code-block-3.gold | 2 +- test/code-block-teletype.gold | 2 +- test/code-snippet.gold | 6 +- test/code-snippet.quickbook | 2 + test/cond_phrase.gold | 11 + test/cond_phrase.quickbook | 8 + test/doc-info-1.gold | 11 + test/doc-info-1.quickbook | 9 + test/doc-info-2.gold | 15 + test/doc-info-2.quickbook | 9 + test/escape.gold | 2 +- test/heading.gold | 2 +- test/image_1_5.gold | 2 +- test/import.gold | 26 +- test/include_1_5.gold | 2 +- test/link-side-by-side.gold | 2 +- test/list_test.gold | 215 +++++++++ test/list_test.quickbook | 53 ++ test/para-test.gold | 77 +++ test/para-test.quickbook | 81 ++++ test/preformatted.gold | 2 +- test/quickbook-manual.gold | 877 +++++++++++++++++++++------------- test/section_1_4.gold | 2 +- test/section_1_5.gold | 2 +- test/simple_markup.gold | 2 +- test/table_1_5.gold | 2 +- test/template-section.gold | 2 +- test/templates.gold | 2 +- test/templates_1_4.gold | 2 +- test/templates_1_5.gold | 2 +- test/unicode-escape.gold | 114 +++-- test/utf-8-bom.gold | 98 +++- test/utf-8.gold | 98 +++- test/xinclude.gold | 2 +- 54 files changed, 1644 insertions(+), 538 deletions(-) create mode 100644 test/blocks.gold create mode 100644 test/blocks.quickbook create mode 100644 test/cond_phrase.gold create mode 100644 test/cond_phrase.quickbook create mode 100644 test/doc-info-1.gold create mode 100644 test/doc-info-1.quickbook create mode 100644 test/doc-info-2.gold create mode 100644 test/doc-info-2.quickbook create mode 100644 test/list_test.gold create mode 100644 test/list_test.quickbook create mode 100644 test/para-test.gold create mode 100644 test/para-test.quickbook diff --git a/Jamfile.v2 b/Jamfile.v2 index 9f93e6c..242edcc 100644 --- a/Jamfile.v2 +++ b/Jamfile.v2 @@ -30,6 +30,8 @@ exe quickbook /boost//program_options /boost//filesystem : #QUICKBOOK_NO_DATES + # Still using 'normalize' which has been deprecated. + #BOOST_FILESYSTEM_NO_DEPRECATED msvc:/wd4355 msvc:/wd4511 msvc:/wd4512 diff --git a/block.hpp b/block.hpp index e62c2a5..7126892 100644 --- a/block.hpp +++ b/block.hpp @@ -58,7 +58,7 @@ namespace quickbook | code | list [actions.list] | hr [actions.hr] - | comment >> *eol + | comment >> +eol | paragraph [actions.paragraph] | eol ) @@ -79,7 +79,8 @@ namespace quickbook ']' | if_p(var(no_eols)) [ - eol >> eol // Make sure that we don't go + eol >> *blank_p >> eol_p + // Make sure that we don't go ] // past a single block, except ; // when preformatted. @@ -173,7 +174,7 @@ namespace quickbook inside_paragraph = phrase [actions.inside_paragraph] >> *( - eol >> eol >> phrase [actions.inside_paragraph] + +eol >> phrase [actions.inside_paragraph] ) ; @@ -408,7 +409,7 @@ namespace quickbook ; paragraph_end = - '[' >> space >> paragraph_end_markups >> hard_space | eol >> eol + '[' >> space >> paragraph_end_markups >> hard_space | eol >> *blank_p >> eol_p ; paragraph = diff --git a/code_snippet.hpp b/code_snippet.hpp index 8eb84b0..66d3078 100644 --- a/code_snippet.hpp +++ b/code_snippet.hpp @@ -30,9 +30,7 @@ namespace quickbook void pass_thru(iterator first, iterator last); void escaped_comment(iterator first, iterator last); void compile(iterator first, iterator last); - void callout(iterator first, iterator last, char const* role); - void inline_callout(iterator first, iterator last); - void line_callout(iterator first, iterator last); + void callout(iterator first, iterator last); std::string code; std::string snippet; @@ -109,7 +107,7 @@ namespace quickbook rule start_, snippet, identifier, code_elements, escaped_comment, - inline_callout, line_callout, ignore; + ignore; rule const& start() const { return start_; } @@ -168,13 +166,13 @@ namespace quickbook inline_callout = "/*<" - >> (*(anychar_p - ">*/")) [boost::bind(&actions_type::inline_callout, &actions, _1, _2)] + >> (*(anychar_p - ">*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] >> ">*/" ; line_callout = "/*<<" - >> (*(anychar_p - ">>*/")) [boost::bind(&actions_type::line_callout, &actions, _1, _2)] + >> (*(anychar_p - ">>*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] >> ">>*/" >> *space_p ; diff --git a/detail/actions.cpp b/detail/actions.cpp index 6a7e751..d4aaaca 100644 --- a/detail/actions.cpp +++ b/detail/actions.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "./quickbook.hpp" #include "./actions.hpp" #include "./utils.hpp" @@ -171,7 +172,7 @@ namespace quickbook list_marks.pop(); out << std::string((mark == '#') ? "\n" : "\n"); if (list_marks.size() >= 1) - out << std::string("\n"); + out << list_item_post; } list_indent = -1; // reset @@ -211,12 +212,12 @@ namespace quickbook { // Make this new list a child of the previous list. // The previous listelem has already ended so we erase - // to accomodate this sub-list. We'll close + // list_item_post to accomodate this sub-list. We'll close // the listelem later. std::string str; out.swap(str); - std::string::size_type pos = str.rfind("\n"); + std::string::size_type pos = str.rfind(list_item_post); BOOST_ASSERT(pos <= str.size()); str.erase(str.begin()+pos, str.end()); out << str; @@ -235,7 +236,7 @@ namespace quickbook list_marks.pop(); out << std::string((mark == '#') ? "\n" : "\n"); if (list_marks.size() >= 1) - out << std::string("\n"); + out << list_item_post; } } @@ -452,12 +453,12 @@ namespace quickbook fs::path const img_path(image_fileref); attribute_map::iterator it = attributes.find("alt"); - std::string alt_text = it != attributes.end() ? it->second : fs::basename(img_path); + std::string alt_text = it != attributes.end() ? it->second : img_path.stem(); attributes.erase("alt"); attributes.insert(attribute_map::value_type("fileref", image_fileref)); - if(fs::extension(img_path) == ".svg") + if(img_path.extension() == ".svg") { // // SVG's need special handling: @@ -754,7 +755,7 @@ namespace quickbook else if (!is_block) { // do a phrase level parse - iterator first(body.begin(), body.end(), actions.filename.native_file_string().c_str()); + iterator first(body.begin(), body.end(), actions.filename.file_string().c_str()); first.set_position(template_pos); iterator last(body.end(), body.end()); r = boost::spirit::classic::parse(first, last, phrase_p).full; @@ -769,7 +770,7 @@ namespace quickbook body.push_back('\n'); while (iter != body.end() && ((*iter == '\r') || (*iter == '\n'))) ++iter; // skip initial newlines - iterator first(iter, body.end(), actions.filename.native_file_string().c_str()); + iterator first(iter, body.end(), actions.filename.file_string().c_str()); first.set_position(template_pos); iterator last(body.end(), body.end()); r = boost::spirit::classic::parse(first, last, block_p).full; @@ -1111,7 +1112,6 @@ namespace quickbook { std::string::size_type const n = qualified_section_id.find_last_of('.'); - if(std::string::npos != n); qualified_section_id.erase(n, std::string::npos); } } @@ -1149,7 +1149,7 @@ namespace quickbook if (!path.is_complete()) { fs::path infile = fs::complete(actions.filename).normalize(); - path = (infile.branch_path() / path).normalize(); + path = (infile.parent_path() / path).normalize(); fs::path outdir = fs::complete(actions.outdir).normalize(); path = path_difference(outdir, path); } @@ -1174,31 +1174,19 @@ namespace quickbook int callout_id = 0; } - void code_snippet_actions::callout(iterator first, iterator last, char const* role) + void code_snippet_actions::callout(iterator first, iterator last) { using detail::callout_id; code += "``'''"; - code += std::string(""; code += "(callout_id + callouts.size()) + "co\" "; code += "linkends=\""; code += doc_id + boost::lexical_cast(callout_id + callouts.size()) + "\" />"; - code += ""; code += "'''``"; callouts.push_back(std::string(first, last)); } - void code_snippet_actions::inline_callout(iterator first, iterator last) - { - callout(first, last, "callout_bug"); - } - - void code_snippet_actions::line_callout(iterator first, iterator last) - { - callout(first, last, "line_callout_bug"); - } - void code_snippet_actions::escaped_comment(iterator first, iterator last) { if (!code.empty()) @@ -1301,7 +1289,7 @@ namespace quickbook { fs::path include_search(fs::path const & current, std::string const & name) { - fs::path path(name,fs::native); + fs::path path(name); // If the path is relative, try and resolve it. if (!path.is_complete()) @@ -1315,7 +1303,7 @@ namespace quickbook // Search in each of the include path locations. BOOST_FOREACH(std::string const & p, include_path) { - fs::path full(p,fs::native); + fs::path full(p); full /= path; if (fs::exists(full)) { @@ -1330,8 +1318,8 @@ namespace quickbook void import_action::operator()(iterator first, iterator last) const { - fs::path path = include_search(actions.filename.branch_path(), std::string(first,last)); - std::string ext = fs::extension(path); + fs::path path = include_search(actions.filename.parent_path(), std::string(first,last)); + std::string ext = path.extension(); std::vector storage; actions.error_count += load_snippets(path.string(), storage, ext, actions.doc_id); @@ -1355,7 +1343,7 @@ namespace quickbook void include_action::operator()(iterator first, iterator last) const { - fs::path filein = include_search(actions.filename.branch_path(), std::string(first,last)); + fs::path filein = include_search(actions.filename.parent_path(), std::string(first,last)); std::string doc_type, doc_id, doc_dirname, doc_last_revision; // swap the filenames @@ -1381,10 +1369,10 @@ namespace quickbook } // update the __FILENAME__ macro - *boost::spirit::classic::find(actions.macro, "__FILENAME__") = actions.filename.native_file_string(); + *boost::spirit::classic::find(actions.macro, "__FILENAME__") = actions.filename.file_string(); // parse the file - quickbook::parse(actions.filename.native_file_string().c_str(), actions, true); + quickbook::parse(actions.filename.file_string().c_str(), actions, true); // restore the values std::swap(actions.filename, filein); @@ -1470,7 +1458,7 @@ namespace quickbook qbk_major_version = 1; qbk_minor_version = 1; qbk_version_n = 101; - detail::outwarn(actions.filename.native_file_string(),1) + detail::outwarn(actions.filename.file_string(),1) << "Warning: Quickbook version undefined. " "Version 1.1 is assumed" << std::endl; } @@ -1480,7 +1468,9 @@ namespace quickbook } out << "\n" - << "\n" << '<' << actions.doc_type << "\n" << " id=\"" << actions.doc_id << "\"\n"; @@ -1534,6 +1524,8 @@ namespace quickbook void write_document_info(collector& out, quickbook::actions& actions) { + std::vector invalid_attributes; + out << " <" << actions.doc_type << "info>\n"; if(!actions.doc_authors.empty()) @@ -1574,25 +1566,56 @@ namespace quickbook if (!actions.doc_purpose.empty()) { - out << " <" << actions.doc_type << "purpose>\n" - << " " << actions.doc_purpose - << " \n" - << "\n" - ; + if (actions.doc_type == "library") + { + out << " <" << actions.doc_type << "purpose>\n" + << " " << actions.doc_purpose + << " \n" + << "\n" + ; + } + else + { + invalid_attributes.push_back("purpose"); + } } - if (!actions.doc_category.empty()) + if (!actions.doc_categories.empty()) { - out << " <" << actions.doc_type << "category name=\"category:" - << actions.doc_category - << "\">\n" - << "\n" - ; + if (actions.doc_type == "library") + { + for(actions::string_list::const_iterator + it = actions.doc_categories.begin(), + end = actions.doc_categories.end(); + it != end; ++it) + { + out << " <" << actions.doc_type << "category name=\"category:" + << *it + << "\">\n" + << "\n" + ; + } + } + else + { + invalid_attributes.push_back("category"); + } } out << " \n" << "\n" ; + + if(!invalid_attributes.empty()) + { + detail::outwarn(actions.filename.file_string(),1) + << (invalid_attributes.size() > 1 ? + "Invalid attributes" : "Invalid attribute") + << " for '" << actions.doc_type << "': " + << boost::algorithm::join(invalid_attributes, ", ") + << "\n" + ; + } } void phrase_to_string_action::operator()(iterator first, iterator last) const diff --git a/detail/actions_class.cpp b/detail/actions_class.cpp index 5b46e0a..a3adb7e 100644 --- a/detail/actions_class.cpp +++ b/detail/actions_class.cpp @@ -26,7 +26,7 @@ namespace quickbook , doc_dirname() , doc_copyrights() , doc_purpose() - , doc_category() + , doc_categories() , doc_authors() , doc_license() , doc_last_revision() @@ -43,7 +43,7 @@ namespace quickbook , list_buffer() // state - , filename(fs::complete(fs::path(filein_, fs::native))) + , filename(fs::complete(fs::path(filein_))) , outdir(outdir_) , macro() , section_level(0) @@ -185,7 +185,7 @@ namespace quickbook // turn off __FILENAME__ macro on debug mode = true std::string filename_str = debug_mode ? std::string("NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE") : - filename.native_file_string(); + filename.file_string(); // add the predefined macros macro.add diff --git a/detail/actions_class.hpp b/detail/actions_class.hpp index 868795d..52ecbc9 100644 --- a/detail/actions_class.hpp +++ b/detail/actions_class.hpp @@ -40,7 +40,7 @@ namespace quickbook std::string doc_dirname; copyright_list doc_copyrights; std::string doc_purpose; - std::string doc_category; + string_list doc_categories; author_list doc_authors; std::string doc_license; std::string doc_last_revision; diff --git a/detail/input_path.cpp b/detail/input_path.cpp index 63563ad..d984936 100644 --- a/detail/input_path.cpp +++ b/detail/input_path.cpp @@ -9,12 +9,9 @@ #include #include "./input_path.hpp" -#if defined(__cygwin__) || defined(__CYGWIN__) -#include -#include -#include -#endif +#if !(defined(__cygwin__) || defined(__CYGWIN__)) +// Everything but cygwin namespace quickbook { namespace detail { @@ -25,18 +22,84 @@ namespace quickbook { namespace detail std::string path = boost::program_options::validators::get_single_string(values); -#if !(defined(__cygwin__) || defined(__CYGWIN__)) v = input_path(path); -#elif defined(BOOST_WINDOWS_PATH) + } +}} + +#elif defined(QUICKBOOK_CYGWIN_1_5) + +// Cygwin 1.5.x + +#include +#include +#include + +namespace quickbook { namespace detail +{ + void validate(boost::any& v, + const std::vector& values, + input_path*, int) + { + std::string path + = boost::program_options::validators::get_single_string(values); + char result[MAX_PATH + 1]; + +#if defined(BOOST_WINDOWS_PATH) cygwin_conv_to_win32_path(path.c_str(), result); - v = input_path(result); #elif defined(BOOST_POSIX_PATH) - char result[MAX_PATH + 1]; cygwin_conv_to_posix_path(path.c_str(), result); - v = input_path(result); #else # error "Bosot filesystem path type doesn't seem to be set." #endif + + v = input_path(result); } }} + +#else + +// Cygwin 1.7.x + +#include +#include +#include +#include +#include + +namespace quickbook { namespace detail +{ + void validate(boost::any& v, + const std::vector& values, + input_path*, int) + { + std::string path + = boost::program_options::validators::get_single_string(values); + +#if defined(BOOST_WINDOWS_PATH) + cygwin_conv_path_t flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE; +#elif defined(BOOST_POSIX_PATH) + cygwin_conv_path_t flags = CCP_WIN_A_TO_POSIX | CCP_RELATIVE; +#else +# error "Bosot filesystem path type doesn't seem to be set." +#endif + + ssize_t size = cygwin_conv_path(flags, path.c_str(), NULL, 0); + + if (size < 0) { + throw boost::program_options::validation_error( + boost::program_options::validation_error::invalid_option_value); + } + + boost::scoped_array result(new char[size]); + + if(cygwin_conv_path(flags, path.c_str(), result.get(), size)) { + throw boost::program_options::validation_error( + boost::program_options::validation_error::invalid_option_value); + } + + v = input_path(result.get()); + } +}} + +#endif diff --git a/detail/markups.cpp b/detail/markups.cpp index 7ed6bfb..1ae2dc0 100644 --- a/detail/markups.cpp +++ b/detail/markups.cpp @@ -31,8 +31,8 @@ namespace quickbook const char* hr_ = ""; const char* blurb_pre = "\n"; const char* blurb_post = "\n"; - const char* blockquote_pre = "
"; - const char* blockquote_post = "
"; + const char* blockquote_pre = "
"; + const char* blockquote_post = "
"; const char* preformatted_pre = ""; const char* preformatted_post = ""; const char* warning_pre = ""; @@ -45,8 +45,8 @@ namespace quickbook const char* note_post = ""; const char* tip_pre = ""; const char* tip_post = ""; - const char* list_item_pre = "\n"; - const char* list_item_post = "\n"; + const char* list_item_pre = "\n"; + const char* list_item_post = "\n"; const char* bold_pre_ = ""; const char* bold_post_ = ""; const char* italic_pre_ = ""; diff --git a/detail/post_process.cpp b/detail/post_process.cpp index e41ef81..84306d1 100644 --- a/detail/post_process.cpp +++ b/detail/post_process.cpp @@ -184,7 +184,6 @@ namespace quickbook , "caution" , "copyright" , "entry" - , "footnote" , "important" , "informaltable" , "itemizedlist" @@ -195,6 +194,7 @@ namespace quickbook , "para" , "row" , "section" + , "simpara" , "table" , "tbody" , "textobject" @@ -266,7 +266,7 @@ namespace quickbook { definition(tidy_grammar const& self) { - tag = (lexeme_d[+(alpha_p | '_' | ':')]) [bind(&tidy_grammar::do_tag, &self, _1, _2)]; + tag = (lexeme_d[+(alpha_p | '_' | ':')]) [boost::bind(&tidy_grammar::do_tag, &self, _1, _2)]; code = "" @@ -282,14 +282,14 @@ namespace quickbook str_p("") >> (*(anychar_p - str_p(""))) [ - bind(&tidy_grammar::do_escape, &self, _1, _2) + boost::bind(&tidy_grammar::do_escape, &self, _1, _2) ] >> lexeme_d [ str_p("") >> (*space_p) [ - bind(&tidy_grammar::do_escape_post, &self, _1, _2) + boost::bind(&tidy_grammar::do_escape_post, &self, _1, _2) ] ] ; @@ -306,11 +306,11 @@ namespace quickbook markup = escape - | code [bind(&tidy_grammar::do_code, &self, _1, _2)] - | start_end_tag [bind(&tidy_grammar::do_start_end_tag, &self, _1, _2)] - | start_tag [bind(&tidy_grammar::do_start_tag, &self, _1, _2)] - | end_tag [bind(&tidy_grammar::do_end_tag, &self, _1, _2)] - | content [bind(&tidy_grammar::do_content, &self, _1, _2)] + | code [boost::bind(&tidy_grammar::do_code, &self, _1, _2)] + | start_end_tag [boost::bind(&tidy_grammar::do_start_end_tag, &self, _1, _2)] + | start_tag [boost::bind(&tidy_grammar::do_start_tag, &self, _1, _2)] + | end_tag [boost::bind(&tidy_grammar::do_end_tag, &self, _1, _2)] + | content [boost::bind(&tidy_grammar::do_content, &self, _1, _2)] ; tidy = +markup; diff --git a/detail/quickbook.cpp b/detail/quickbook.cpp index f787444..479aaad 100644 --- a/detail/quickbook.cpp +++ b/detail/quickbook.cpp @@ -29,7 +29,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.5.1" +#define QUICKBOOK_VERSION "Quickbook Version 1.5.2" namespace quickbook { @@ -196,7 +196,7 @@ namespace quickbook { int result = 0; std::ofstream fileout(fileout_); - fs::path outdir = fs::path(fileout_, fs::native).branch_path(); + fs::path outdir = fs::path(fileout_).parent_path(); if (outdir.empty()) outdir = "."; if (pretty_print) @@ -238,7 +238,7 @@ main(int argc, char* argv[]) using boost::program_options::positional_options_description; // First thing, the filesystem should record the current working directory. - boost::filesystem::initial_path(); + boost::filesystem::initial_path(); options_description desc("Allowed options"); desc.add_options() diff --git a/detail/utils.cpp b/detail/utils.cpp index acd4179..5856572 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -211,9 +211,9 @@ namespace quickbook { namespace detail { if(begin == end) return ""; - const char utf8[] = {0xef, 0xbb, 0xbf}; - const char utf32be[] = {0, 0, 0xfe, 0xff}; - const char utf32le[] = {0xff, 0xfe, 0, 0}; + const char* utf8 = "\xef\xbb\xbf" ; + const char* utf32be = "\0\0\xfe\xff"; + const char* utf32le = "\xff\xfe\0\0"; unsigned char c = *begin; switch(c) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 7cf4fd3..08b9f4f 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -15,15 +15,13 @@ using quickbook ; xml quickbook : quickbook.qbk ; -path-constant images : ../../../doc/html ; +path-constant images : ../../../doc/src ; boostbook standalone : quickbook : boost.root=../../../.. - boost.libraries=../../../../libs/libraries.htm - html.stylesheet=../../../../doc/html/boostbook.css generate.section.toc.level=3 chunk.section.depth=2 chunk.first.sections=1 diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 858ed1a..3016fbe 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -19,10 +19,7 @@ [/ Some links] -[def __note__ [$images/note.png]] -[def __alert__ [$images/alert.png]] -[def __tip__ [$images/tip.png]] -[def :-) [$images/smiley.png]] +[def :-) [$../src/images/smiley.png]] [def __spirit__ [@http://spirit.sourceforge.net Spirit]] [def __boostbook__ [@http://www.boost.org/doc/html/boostbook.html BoostBook]] [def __docbook__ [@http://www.docbook.org/ DocBook]] @@ -192,6 +189,19 @@ Features include: * Add command line flag to define macros at the command line, e.g. `quickbook "-D__italic_foo__=/foo/"`. +[h3 Version 1.5.2 - Boost 1.44.0] + +* Generate more valid boostbook (still invalid in a few places). +* Warn about invalid doc_info members. +* Support multiple categories in library doc_info. +* Use the cygwin 1.7 API for better path handling. +* Fix some corner cases for paragraph detection: + * A line containing only a comment is no longer interpreted as a + paragraph break. + * If a line starts with a comment, interpret it as a paragraph even if it's + followed by whitespace or a list character. + * Don't treat 4+ consecutive blank lines as multiple paragraph breaks. + [endsect] [section:syntax Syntax Summary] @@ -2074,7 +2084,7 @@ Editing quickbook files is usually done with text editors both simple and powerful. The following sections list the settings for some editors which can help make editing quickbook files a bit easier. -[blurb __note__ You may submit your settings, tips, and suggestions to the +[note You may submit your settings, tips, and suggestions to the authors, or through the [@https://lists.sourceforge.net/lists/listinfo/boost- docs Boost Docs mailing list].] @@ -2085,7 +2095,7 @@ docs Boost Docs mailing list].] The Scintilla Text Editor (SciTE) is a free source code editor for Win32 and X. It uses the SCIntilla source code editing component. -[blurb __tip__ SciTE can be downloaded from [@http://www.scintilla.org/SciTE.html]] +[tip SciTE can be downloaded from [@http://www.scintilla.org/SciTE.html]] You can use the following settings to highlight quickbook tags when editing quickbook files. @@ -2104,7 +2114,7 @@ comment.box.middle.props= comment.box.end.props=] '''] -[blurb __note__ Thanks to Rene Rivera for the above SciTE settings.] +[note Thanks to Rene Rivera for the above SciTE settings.] [endsect] [/scite] diff --git a/doc_info.hpp b/doc_info.hpp index 7bab42c..f6279b2 100644 --- a/doc_info.hpp +++ b/doc_info.hpp @@ -117,7 +117,7 @@ namespace quickbook doc_category = "category" >> hard_space - >> (*(anychar_p - ']')) [assign_a(actions.doc_category)] + >> (*(anychar_p - ']')) [push_back_a(actions.doc_categories)] ; doc_author = @@ -179,8 +179,9 @@ namespace quickbook bool unused; std::pair name; std::pair, std::string> copyright; + std::string category; rule doc_info, doc_title, doc_version, doc_id, doc_dirname, - doc_copyright, doc_purpose,doc_category, doc_authors, + doc_copyright, doc_purpose, doc_category, doc_authors, doc_author, comment, space, hard_space, doc_license, doc_last_revision, doc_source_mode, phrase, quickbook_version; phrase_grammar common; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1d872ed..bdbfb46 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -30,10 +30,16 @@ test-suite quickbook.test : [ quickbook-test section_1_4 ] [ quickbook-test section_1_5 ] [ quickbook-test heading ] + [ quickbook-test para-test ] [ quickbook-test table_1_5 ] [ quickbook-test image_1_5 ] + [ quickbook-test list_test ] + [ quickbook-test cond_phrase ] + [ quickbook-test doc-info-1 ] + [ quickbook-test doc-info-2 ] [ quickbook-test callouts ] [ quickbook-test simple_markup ] + [ quickbook-test blocks ] [ quickbook-fail-test fail-include ] [ quickbook-fail-test fail-import ] [ quickbook-fail-test fail-template-arguments1 ] diff --git a/test/blocks.gold b/test/blocks.gold new file mode 100644 index 0000000..da0132c --- /dev/null +++ b/test/blocks.gold @@ -0,0 +1,89 @@ + + +
+ Various blocks + + + + + Blockquotes + + + Here's a blockquote: + +
+ + Blockquote. + +
+ + And another: + +
+ + Blockquote first paragraph. + + + Blockquote second paragraph. + +
+ + + Admonitions + + + + Warning + + + + + Caution + + + + + Important + + + + + Note + + + + + Tip + + + + + Warning first paragraph. + + + Warning second paragraph. + + + + + Blurb + + + + Blurb + + + + Inline blocks + +
+ + Blockquote containing a footnote + + Here it is! + + . + +
+
diff --git a/test/blocks.quickbook b/test/blocks.quickbook new file mode 100644 index 0000000..9b4736e --- /dev/null +++ b/test/blocks.quickbook @@ -0,0 +1,39 @@ +[article Various blocks +[quickbook 1.5] +] + +[heading Blockquotes] + +Here's a blockquote: + +[:Blockquote.] + +And another: + +[: +Blockquote first paragraph. + +Blockquote second paragraph. +] + +[heading Admonitions] + +[warning Warning] +[caution Caution] +[important Important] +[note Note] +[tip Tip] + +[warning Warning first paragraph. + +Warning second paragraph.] + +[heading Blurb] + +[blurb Blurb] + +[heading Inline blocks] + +[: Blockquote containing a footnote[footnote Here it is!].] + +[/ Unfortunately footnotes currently can't contain blocks.] \ No newline at end of file diff --git a/test/callouts.gold b/test/callouts.gold index 2ecccd4..a96ffcf 100644 --- a/test/callouts.gold +++ b/test/callouts.gold @@ -1,5 +1,5 @@ - +
Callout Tests @@ -15,7 +15,7 @@ int roll_die() { - boost::uniform_int<> dist(1, 6); + boost::uniform_int<> dist(1, 6); } @@ -31,7 +31,7 @@ int roll_die() { - boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); + boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } @@ -55,7 +55,7 @@ int roll_die() { - boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); + boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } diff --git a/test/code-block-1.gold b/test/code-block-1.gold index 96eb3ba..ddcca15 100644 --- a/test/code-block-1.gold +++ b/test/code-block-1.gold @@ -1,5 +1,5 @@ - +
Code Block 1 diff --git a/test/code-block-2.gold b/test/code-block-2.gold index 85330c0..471f025 100644 --- a/test/code-block-2.gold +++ b/test/code-block-2.gold @@ -1,5 +1,5 @@ - +
Code Block 2 diff --git a/test/code-block-3.gold b/test/code-block-3.gold index 34b7a20..f81b793 100644 --- a/test/code-block-3.gold +++ b/test/code-block-3.gold @@ -1,5 +1,5 @@ - +
Code Block 3 diff --git a/test/code-block-teletype.gold b/test/code-block-teletype.gold index 821b9a0..ffa7b2a 100644 --- a/test/code-block-teletype.gold +++ b/test/code-block-teletype.gold @@ -1,5 +1,5 @@ - +
Code Block Teletype 1 diff --git a/test/code-snippet.gold b/test/code-snippet.gold index 26de71d..bea46bc 100644 --- a/test/code-snippet.gold +++ b/test/code-snippet.gold @@ -1,5 +1,5 @@ - +
Code Snippets @@ -16,5 +16,9 @@ }, should be properly formatted and not glued to the surrounding text. + + There shoud be no spacees around (this), + and spaces around this code. +
diff --git a/test/code-snippet.quickbook b/test/code-snippet.quickbook index 8c4e94c..8751627 100644 --- a/test/code-snippet.quickbook +++ b/test/code-snippet.quickbook @@ -7,4 +7,6 @@ Code snippets inlined in text, as in `namespace quickbook { static const int value = 0; }`, should be properly formatted and not glued to the surrounding text. +There shoud be no spacees around (`this`), and spaces around `this` code. + [endsect] diff --git a/test/cond_phrase.gold b/test/cond_phrase.gold new file mode 100644 index 0000000..3b4ca63 --- /dev/null +++ b/test/cond_phrase.gold @@ -0,0 +1,11 @@ + + +
+ Coniditional Phrase Test + + + + This should show + +
diff --git a/test/cond_phrase.quickbook b/test/cond_phrase.quickbook new file mode 100644 index 0000000..a00422d --- /dev/null +++ b/test/cond_phrase.quickbook @@ -0,0 +1,8 @@ +[article Coniditional Phrase Test + [quickbook 1.5] +] + +[def defined] + +[?defined This should show] +[?undefined This should not show] \ No newline at end of file diff --git a/test/doc-info-1.gold b/test/doc-info-1.gold new file mode 100644 index 0000000..020edce --- /dev/null +++ b/test/doc-info-1.gold @@ -0,0 +1,11 @@ + + +
+ Document Information 1 + + + + The body is largely irrelevant. + +
diff --git a/test/doc-info-1.quickbook b/test/doc-info-1.quickbook new file mode 100644 index 0000000..5ad3dbe --- /dev/null +++ b/test/doc-info-1.quickbook @@ -0,0 +1,9 @@ +[article Document Information 1 +[quickbook 1.5] +[source-mode teletype] +[purpose Inline code test: `1 + 2`] +[category tests] +[category irrelevance] +] + +The body is largely irrelevant. \ No newline at end of file diff --git a/test/doc-info-2.gold b/test/doc-info-2.gold new file mode 100644 index 0000000..399cde4 --- /dev/null +++ b/test/doc-info-2.gold @@ -0,0 +1,15 @@ + + + + + + Inline code test: 1 + 2 + + + + Document Information 1 + + The body is largely irrelevant. + + diff --git a/test/doc-info-2.quickbook b/test/doc-info-2.quickbook new file mode 100644 index 0000000..2d56e86 --- /dev/null +++ b/test/doc-info-2.quickbook @@ -0,0 +1,9 @@ +[library Document Information 1 +[quickbook 1.5] +[source-mode teletype] +[purpose Inline code test: `1 + 2`] +[category tests] +[category irrelevance] +] + +The body is largely irrelevant. \ No newline at end of file diff --git a/test/escape.gold b/test/escape.gold index d7fbf21..0664d90 100644 --- a/test/escape.gold +++ b/test/escape.gold @@ -1,5 +1,5 @@ - +
Escape diff --git a/test/heading.gold b/test/heading.gold index 0cd03d9..3195f4e 100644 --- a/test/heading.gold +++ b/test/heading.gold @@ -1,5 +1,5 @@ - + diff --git a/test/table_1_5.quickbook b/test/table_1_5.quickbook index 3719a4b..867a6bb 100644 --- a/test/table_1_5.quickbook +++ b/test/table_1_5.quickbook @@ -40,4 +40,33 @@ [[a][b]] ] +[table Empty Table +] + +[table Table with an empty cell +[[x]]] + +[table Indentation + [ + [ + Header 1. Paragraph 1 + + Header 1. Paragraph 2 + ] + [ + Header 2 + ] + ] + [ + [ + Row 1. Cell 1. + ] + [ + Row 1. Cell 2. + + Row 1. Cell 2. Paragraph 2. + ] + ] +] + [endsect] \ No newline at end of file From 6d7475344de4c04955164437f6d024a1827f01d2 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 13 Jan 2011 18:18:18 +0000 Subject: [PATCH 58/94] Merge quickbook from trunk. - Use a single symbol table for all elements. - Fix filesystem use on windows. Fixes #5055. [SVN r68115] --- src/actions.cpp | 6 +-- src/actions_class.cpp | 2 +- src/block_element_grammar.cpp | 74 +++++++++++++++---------------- src/doc_info_actions.cpp | 8 ++-- src/grammar_impl.hpp | 31 +++++++++---- src/main_grammar.cpp | 79 +++++++++++++++++++++++----------- src/phrase_element_grammar.cpp | 66 ++++++++++++++-------------- src/utils.hpp | 25 ----------- test/cond_phrase.gold | 3 ++ test/cond_phrase.quickbook | 4 +- 10 files changed, 159 insertions(+), 139 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index 4585d7f..f50baea 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -157,7 +157,7 @@ namespace quickbook if(actions.suppress) return; int level_ = section_level + 2; // section_level is zero-based. We need to use a - // 0ne-based heading which is one greater + // one-based heading which is one greater // than the current. Thus: section_level + 2. if (level_ > 6) // The max is h6, clip it if it goes level_ = 6; // further than that @@ -1414,10 +1414,10 @@ namespace quickbook } // update the __FILENAME__ macro - *boost::spirit::classic::find(actions.macro, "__FILENAME__") = actions.filename.native(); + *boost::spirit::classic::find(actions.macro, "__FILENAME__") = actions.filename.string(); // parse the file - quickbook::parse_file(actions.filename.native().c_str(), actions, true); + quickbook::parse_file(actions.filename.string().c_str(), actions, true); // restore the values std::swap(actions.filename, filein); diff --git a/src/actions_class.cpp b/src/actions_class.cpp index e2f2f75..82c92db 100644 --- a/src/actions_class.cpp +++ b/src/actions_class.cpp @@ -206,7 +206,7 @@ namespace quickbook // turn off __FILENAME__ macro on debug mode = true std::string filename_str = debug_mode ? std::string("NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE") : - filename.native(); + filename.string(); // add the predefined macros macro.add diff --git a/src/block_element_grammar.cpp b/src/block_element_grammar.cpp index 6cb99e2..41cda70 100644 --- a/src/block_element_grammar.cpp +++ b/src/block_element_grammar.cpp @@ -70,9 +70,9 @@ namespace quickbook ] ; - block_keyword_rules.add - ("section", &local.begin_section) - ("endsect", &local.end_section) + elements.add + ("section", element_info(element_info::block, &local.begin_section)) + ("endsect", element_info(element_info::block, &local.end_section)) ; local.begin_section = @@ -86,14 +86,14 @@ namespace quickbook cl::eps_p [actions.end_section] ; - block_keyword_rules.add - ("heading", &local.h) - ("h1", &local.h1) - ("h2", &local.h2) - ("h3", &local.h3) - ("h4", &local.h4) - ("h5", &local.h5) - ("h6", &local.h6) + elements.add + ("heading", element_info(element_info::block, &local.h)) + ("h1", element_info(element_info::block, &local.h1)) + ("h2", element_info(element_info::block, &local.h2)) + ("h3", element_info(element_info::block, &local.h3)) + ("h4", element_info(element_info::block, &local.h4)) + ("h5", element_info(element_info::block, &local.h5)) + ("h6", element_info(element_info::block, &local.h6)) ; local.h = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h]; @@ -107,15 +107,15 @@ namespace quickbook static const bool true_ = true; static const bool false_ = false; - block_keyword_rules.add("blurb", &local.blurb); + elements.add("blurb", element_info(element_info::block, &local.blurb)); local.blurb = actions.scoped_block[inside_paragraph] [actions.blurb] ; - block_symbol_rules.add - (":", &local.blockquote) + elements.add + (":", element_info(element_info::block, &local.blockquote)) ; local.blockquote = @@ -123,12 +123,12 @@ namespace quickbook [actions.blockquote] ; - block_keyword_rules.add - ("warning", &local.warning) - ("caution", &local.caution) - ("important", &local.important) - ("note", &local.note) - ("tip", &local.tip) + elements.add + ("warning", element_info(element_info::block, &local.warning)) + ("caution", element_info(element_info::block, &local.caution)) + ("important", element_info(element_info::block, &local.important)) + ("note", element_info(element_info::block, &local.note)) + ("tip", element_info(element_info::block, &local.tip)) ; local.warning = @@ -156,8 +156,8 @@ namespace quickbook [actions.tip] ; - block_keyword_rules.add - ("pre", &local.preformatted) + elements.add + ("pre", element_info(element_info::block, &local.preformatted)) ; local.preformatted = @@ -166,8 +166,8 @@ namespace quickbook >> actions.set_no_eols[phrase] [actions.preformatted] ; - block_keyword_rules.add - ("def", &local.def_macro) + elements.add + ("def", element_info(element_info::block, &local.def_macro)) ; local.def_macro = @@ -184,8 +184,8 @@ namespace quickbook local.identifier | (cl::punct_p - (cl::ch_p('[') | ']')) ; - block_keyword_rules.add - ("template", &local.template_) + elements.add + ("template", element_info(element_info::block, &local.template_)) ; local.template_ = @@ -214,8 +214,8 @@ namespace quickbook >> space ; - block_keyword_rules.add - ("variablelist", &local.variablelist) + elements.add + ("variablelist", element_info(element_info::block, &local.variablelist)) ; local.variablelist = @@ -272,8 +272,8 @@ namespace quickbook ) ; - block_keyword_rules.add - ("table", &local.table) + elements.add + ("table", element_info(element_info::block, &local.table)) ; local.table = @@ -312,16 +312,10 @@ namespace quickbook ) ; - block_keyword_rules.add - ("xinclude", &local.xinclude) - ("import", &local.import) - ("include", &local.include) - ; - - extended_phrase_keyword_rules.add - ("xinclude", &local.xinclude) - ("import", &local.import) - ("include", &local.include) + elements.add + ("xinclude", element_info(element_info::conditional_or_block, &local.xinclude)) + ("import", element_info(element_info::conditional_or_block, &local.import)) + ("include", element_info(element_info::conditional_or_block, &local.include)) ; local.xinclude = diff --git a/src/doc_info_actions.cpp b/src/doc_info_actions.cpp index 1ff1f2d..2a4c81e 100644 --- a/src/doc_info_actions.cpp +++ b/src/doc_info_actions.cpp @@ -77,7 +77,7 @@ namespace quickbook qbk_major_version = 1; qbk_minor_version = 1; qbk_version_n = 101; - detail::outwarn(actions.filename.native(),1) + detail::outwarn(actions.filename.string(),1) << "Warning: Quickbook version undefined. " "Version 1.1 is assumed" << std::endl; } @@ -89,13 +89,13 @@ namespace quickbook if (qbk_version_n == 106) { - detail::outwarn(actions.filename.native(),1) + detail::outwarn(actions.filename.string(),1) << "Quickbook 1.6 is still under development and is " "likely to change in the future." << std::endl; } else if(qbk_version_n < 100 || qbk_version_n > 106) { - detail::outerr(actions.filename.native(),1) + detail::outerr(actions.filename.string(),1) << "Unknown version of quickbook: quickbook " << qbk_major_version << "." @@ -121,7 +121,7 @@ namespace quickbook if(!invalid_attributes.empty()) { - detail::outwarn(actions.filename.native(),1) + detail::outwarn(actions.filename.string(),1) << (invalid_attributes.size() > 1 ? "Invalid attributes" : "Invalid attribute") << " for '" << actions.doc_type << " document info': " diff --git a/src/grammar_impl.hpp b/src/grammar_impl.hpp index 3c12271..12d5553 100644 --- a/src/grammar_impl.hpp +++ b/src/grammar_impl.hpp @@ -19,6 +19,27 @@ namespace quickbook { namespace cl = boost::spirit::classic; + struct element_info + { + enum context { + in_block = 1, + in_phrase = 2, + in_conditional = 4, + }; + + enum type_enum { + block = 1, + phrase = 2, + conditional_or_block = 5 + }; + + element_info(type_enum t, cl::rule* r) + : type(t), rule(r) {} + + type_enum type; + cl::rule* rule; + }; + struct quickbook_grammar::impl { quickbook::actions& actions; @@ -43,14 +64,8 @@ namespace quickbook cl::rule comment; cl::rule macro_identifier; - // Markup Symbols - cl::symbols*> phrase_keyword_rules; - cl::symbols*> phrase_symbol_rules; - - cl::symbols*> block_keyword_rules; - cl::symbols*> block_symbol_rules; - - cl::symbols*> extended_phrase_keyword_rules; + // Element Symbols + cl::symbols elements; // Doc Info cl::rule doc_info_details; diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index fb20c8e..7276f9e 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -60,10 +60,10 @@ namespace quickbook { cl::rule top_level, blocks, paragraph_separator, - block_element, block_element_start, + block_element, code, code_line, blank_line, hr, list, ordered_list, list_item, - phrase_element, extended_phrase_element, + phrase_element, extended_phrase_element, element, simple_phrase_end, escape, inline_code, simple_format, @@ -79,8 +79,39 @@ namespace quickbook dummy_block ; - cl::rule block_keyword_rule; - cl::rule phrase_keyword_rule; + struct assign_element_type { + assign_element_type(main_grammar_local& l) : l(l) {} + + void operator()(element_info& t) const { + l.element_type = t.type; + l.element_rule = *t.rule; + } + + main_grammar_local& l; + }; + + struct check_element_type { + check_element_type(main_grammar_local const& l, element_info::context t) + : l(l), t(t) {} + + bool operator()() const { + return l.element_type & t; + } + + main_grammar_local const& l; + element_info::context t; + }; + + element_info::type_enum element_type; + cl::rule element_rule; + assign_element_type assign_element; + + main_grammar_local() + : assign_element(*this) {} + + check_element_type check_element(element_info::context t) const { + return check_element_type(*this, t); + } }; void quickbook_grammar::impl::init_main() @@ -128,22 +159,17 @@ namespace quickbook ; local.block_element - = local.block_element_start [actions.inside_paragraph] - >> ( local.block_keyword_rule + = '[' >> space + >> local.element + >> cl::eps_p(local.check_element(element_info::in_block)) + [actions.inside_paragraph] + >> ( local.element_rule >> ( (space >> ']') | cl::eps_p [actions.error] ) | cl::eps_p [actions.error] ) ; - - local.block_element_start - = '[' >> space - >> ( block_keyword_rules [detail::assign_rule(local.block_keyword_rule)] - >> (cl::eps_p - (cl::alnum_p | '_')) - | block_symbol_rules [detail::assign_rule(local.block_keyword_rule)] - ) - ; local.code = ( @@ -344,11 +370,9 @@ namespace quickbook local.phrase_element = '[' >> space - >> ( phrase_keyword_rules [detail::assign_rule(local.phrase_keyword_rule)] - >> (cl::eps_p - (cl::alnum_p | '_')) - >> local.phrase_keyword_rule - | phrase_symbol_rules [detail::assign_rule(local.phrase_keyword_rule)] - >> local.phrase_keyword_rule + >> ( local.element + >> cl::eps_p(local.check_element(element_info::in_phrase)) + >> local.element_rule | local.template_ [actions.do_template] | cl::str_p("br") [actions.break_] ) @@ -356,12 +380,11 @@ namespace quickbook ; local.extended_phrase_element - = '[' - >> space - >> extended_phrase_keyword_rules [detail::assign_rule(local.block_keyword_rule)] - >> (cl::eps_p - (cl::alnum_p | '_')) + = '[' >> space + >> local.element + >> cl::eps_p(local.check_element(element_info::in_conditional)) [actions.inside_paragraph] - >> ( local.block_keyword_rule + >> ( local.element_rule >> ( (space >> ']') | cl::eps_p [actions.error] ) @@ -369,6 +392,14 @@ namespace quickbook ) ; + + local.element + = cl::eps_p(cl::punct_p) + >> elements [local.assign_element] + | elements [local.assign_element] + >> (cl::eps_p - (cl::alnum_p | '_')) + ; + local.escape = cl::str_p("\\n") [actions.break_] | cl::str_p("\\ ") // ignore an escaped space diff --git a/src/phrase_element_grammar.cpp b/src/phrase_element_grammar.cpp index 1bab398..1656a6e 100644 --- a/src/phrase_element_grammar.cpp +++ b/src/phrase_element_grammar.cpp @@ -40,8 +40,8 @@ namespace quickbook phrase_element_grammar_local& local = store_.create(); - phrase_symbol_rules.add - ("?", &local.cond_phrase) + elements.add + ("?", element_info(element_info::phrase, &local.cond_phrase)) ; local.cond_phrase = @@ -50,8 +50,8 @@ namespace quickbook >> actions.scoped_cond_phrase[extended_phrase] ; - phrase_symbol_rules.add - ("$", &local.image) + elements.add + ("$", element_info(element_info::phrase, &local.image)) ; local.image = @@ -78,8 +78,8 @@ namespace quickbook >> cl::eps_p(']') [actions.image] ; - phrase_symbol_rules.add - ("@", &local.url) + elements.add + ("@", element_info(element_info::phrase, &local.url)) ; local.url = @@ -89,8 +89,8 @@ namespace quickbook >> phrase [actions.url_post] ; - phrase_keyword_rules.add - ("link", &local.link) + elements.add + ("link", element_info(element_info::phrase, &local.link)) ; local.link = @@ -101,8 +101,8 @@ namespace quickbook >> phrase [actions.link_post] ; - phrase_symbol_rules.add - ("#", &local.anchor) + elements.add + ("#", element_info(element_info::phrase, &local.anchor)) ; local.anchor = @@ -110,15 +110,15 @@ namespace quickbook >> (*(cl::anychar_p - phrase_end)) [actions.anchor] ; - phrase_keyword_rules.add - ("funcref", &local.funcref) - ("classref", &local.classref) - ("memberref", &local.memberref) - ("enumref", &local.enumref) - ("macroref", &local.macroref) - ("headerref", &local.headerref) - ("conceptref", &local.conceptref) - ("globalref", &local.globalref) + elements.add + ("funcref", element_info(element_info::phrase, &local.funcref)) + ("classref", element_info(element_info::phrase, &local.classref)) + ("memberref", element_info(element_info::phrase, &local.memberref)) + ("enumref", element_info(element_info::phrase, &local.enumref)) + ("macroref", element_info(element_info::phrase, &local.macroref)) + ("headerref", element_info(element_info::phrase, &local.headerref)) + ("conceptref", element_info(element_info::phrase, &local.conceptref)) + ("globalref", element_info(element_info::phrase, &local.globalref)) ; local.funcref = @@ -185,14 +185,14 @@ namespace quickbook >> phrase [actions.globalref_post] ; - phrase_symbol_rules.add - ("*", &local.bold) - ("'", &local.italic) - ("_", &local.underline) - ("^", &local.teletype) - ("-", &local.strikethrough) - ("\"", &local.quote) - ("~", &local.replaceable) + elements.add + ("*", element_info(element_info::phrase, &local.bold)) + ("'", element_info(element_info::phrase, &local.italic)) + ("_", element_info(element_info::phrase, &local.underline)) + ("^", element_info(element_info::phrase, &local.teletype)) + ("-", element_info(element_info::phrase, &local.strikethrough)) + ("\"", element_info(element_info::phrase, &local.quote)) + ("~", element_info(element_info::phrase, &local.replaceable)) ; local.bold = @@ -230,18 +230,18 @@ namespace quickbook >> phrase [actions.replaceable_post] ; - phrase_keyword_rules.add - ("c++", &local.source_mode_cpp) - ("python", &local.source_mode_python) - ("teletype", &local.source_mode_teletype) + elements.add + ("c++", element_info(element_info::phrase, &local.source_mode_cpp)) + ("python", element_info(element_info::phrase, &local.source_mode_python)) + ("teletype", element_info(element_info::phrase, &local.source_mode_teletype)) ; local.source_mode_cpp = cl::eps_p [cl::assign_a(actions.source_mode, "c++")]; local.source_mode_python = cl::eps_p [cl::assign_a(actions.source_mode, "python")]; local.source_mode_teletype = cl::eps_p [cl::assign_a(actions.source_mode, "teletype")]; - phrase_keyword_rules.add - ("footnote", &local.footnote) + elements.add + ("footnote", element_info(element_info::phrase, &local.footnote)) ; local.footnote = diff --git a/src/utils.hpp b/src/utils.hpp index 95c2a36..e48a94f 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -51,31 +51,6 @@ namespace quickbook { namespace detail return var_wrapper(t); } - template - struct assign_rule_impl - { - assign_rule_impl(Rule& the_rule) - : m_the_rule(the_rule) - { - } - - void operator()(Rule* new_rule) const - { - m_the_rule = *new_rule; - } - - private: - - Rule& m_the_rule; - }; - - template - assign_rule_impl assign_rule(Rule& the_rule) - { - return assign_rule_impl(the_rule); - } - - // un-indent a code segment void unindent(std::string& program); diff --git a/test/cond_phrase.gold b/test/cond_phrase.gold index bc29619..95a1d35 100644 --- a/test/cond_phrase.gold +++ b/test/cond_phrase.gold @@ -9,4 +9,7 @@ The should be no space inserted. + + Bold text +
diff --git a/test/cond_phrase.quickbook b/test/cond_phrase.quickbook index 689150f..e158a25 100644 --- a/test/cond_phrase.quickbook +++ b/test/cond_phrase.quickbook @@ -7,4 +7,6 @@ [? __defined__ This should show] [? __undefined__ This should not show] -The should be no sp[?__undefined__ just some junk]ace inserted. \ No newline at end of file +The should be no sp[?__undefined__ just some junk]ace inserted. + +[? __defined__ [*Bold text]] \ No newline at end of file From 06fe0ae76e4f2831360563aac94e0464b3833f1f Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 21 Jan 2011 00:24:42 +0000 Subject: [PATCH 59/94] Merge xinclude fix for windows. [SVN r68330] --- src/actions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions.cpp b/src/actions.cpp index f50baea..0f1645a 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1310,7 +1310,7 @@ namespace quickbook fs::path path = calculate_relative_path(first, last, actions); out << "\n\n"; } From df80728f5ec6e46d45d018cf473129d863cba862 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 30 Jan 2011 13:02:37 +0000 Subject: [PATCH 60/94] Merge quickbook documentation changes. [SVN r68568] --- doc/quickbook.qbk | 154 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 127 insertions(+), 27 deletions(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 1e215a3..d608f77 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -9,6 +9,7 @@ (See accompanying file LICENSE_1_0.txt or copy at [@http://www.boost.org/LICENSE_1_0.txt]) ] + [source-mode teletype] ] [/ QuickBook Document version 1.5 ] @@ -238,6 +239,18 @@ Features include: * XML escape documentation fields, with escapes to allow encoding unicode in ASCII. +[heading Version 1.5.4 - Boost 1.46.0] + +* Add support for `lang` attribute in documentation info. +* Improved anchor implementation. Especially for using an anchor + before a section or heading. +* Fixed some more issues where lines containing comments were treated + as blank lines. +* Allow import, include and xinclude in conditional phrases. Will + allow more block elements in a future version. +* Rearrange the structure of the grammar. +* Use filesystem 3. Remove cygwin support. + [endsect] [/Change log] [section:syntax Syntax Summary] @@ -509,6 +522,8 @@ Python's [python] `import` is rather like C++'s [c++] `#include`. A C++ comment `// looks like this` whereas a Python comment [python] `#looks like this`. +[teletype] + [table Supported Source Modes [[Mode] [Source Mode Markup]] [[C++] [[^\[c++\]]]] @@ -1063,7 +1078,7 @@ syntax highlighted according to the current __source_mode__: return cgi.escape(text) -[c++] +[teletype] Macros that are already defined are expanded in source code. Example: @@ -1936,23 +1951,87 @@ See the actual code here: [@boost:/tools/quickbook/test/stub.cpp] [section:install Installation and configuration] This section provides some guidelines on how to install and configure -BoostBook and Quickbook under several operating systems. +BoostBook and Quickbook under several operating systems. Before installing +you'll need a local copy of boost, and to install the version of `bjam` +which comes with it (or a later version). +[/ I don't think this is needed any more] +[/ Before continuing, it is very important that you keep this in mind: if you try to build some documents and the process breaks due to misconfiguration, be absolutely sure to delete any `bin` and `bin.v2` directories generated by the build before trying again. Otherwise your configuration fixes will not take any effect. +] [section:macosx Mac OS X] -[:['Section contributed by Julio M. Merino Vidal]] +The simplest way to install on OS X is to use macports. +If you don't want to use macports and are using Snow Leopard or later, +there are instructions [link quickbook.install.macosx.native later]. +Earlier versions of OS X need to use something like macports to install +`xsltproc` because the version they come with is very old, and doesn't have +good enough XSL support for boostbook's stylesheets. -The following instructions explain how to install Docbook XML, Docbook XSL -and Doxygen in a Mac OS X system, how to configure Boost.Build v2 to -recognize them and how to build and install Quickbook. They were taken -from a 10.4 (Tiger) machine so it is likely that they also apply to future -versions; they may not work with older ones, though. +[section:macports Mac OS X, using macports] + +First install the `libxslt`, `docbook-xsl` and `docbook-xml-4.2` +packages: + + sudo port install libxslt docbook-xsl docbook-xml-4.2 + +Next, we need to configure Boost Build to compile BoostBook files. Add the +following to your `user-config.jam` file, which should be in your home +directory. If you don't have one, create a file containing this text. For more +information on setting up `user-config.jam`, see the +[@http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html Boost +Build documentation]. + + using xsltproc + : /opt/local/bin/xsltproc + ; + + using boostbook + : /opt/local/share/xsl/docbook-xsl/ + : /opt/local/share/xml/docbook/4.2 + ; + +The above steps are enough to get a functional BoostBook setup. Quickbook +will be automatically built when needed. If you want to avoid these +rebuilds: + +# Go to Quickbook's source directory (`BOOST_ROOT/tools/quickbook`). + +# Build the utility by issuing `bjam`. + +# Copy the resulting `quickbook` binary (located at + `BOOST_ROOT/dist/bin`) to a safe place. The traditional location is + `/usr/local/bin`. + +# Add the following to your `user-config.jam` file, using the full path of the + quickbook executable: + ``` + using quickbook + : /usr/local/bin/quickbook + ; + ``` + +If you need to build documentation that uses Doxygen, you will need to install it as well: + + sudo port install doxygen + +And then add to your `user-config.jam`: + + using doxygen ; + +Alternatively, you can install from the official doxygen `dmg`. +This is described at [link osx-prebuilt-doxygen the end of the next section]. + +[endsect] [/ macports] + +[section:native Mac OS X, Snow Leopard (or later)] + +[:['Section contributed by Julio M. Merino Vidal]] The text below assumes you want to install all the necessary utilities in a system-wide location, allowing any user in the machine to have access to @@ -1960,7 +2039,7 @@ them. Therefore, all files will be put in the `/usr/local` hierarchy. If you do not want this, you can choose any other prefix such as `~/Applications` for a single-user installation. -Mac OS X comes with `xsltproc` and all related libraries preinstalled, so +Snow Leopard comes with `xsltproc` and all related libraries preinstalled, so you do not need to take any extra steps to set them up. It is probable that future versions will include them too, but these instructions may not apply to older versions. @@ -1972,7 +2051,12 @@ To get started: # Download the latest [@http://sourceforge.net/project/showfiles.php?group_id=21935&package_id=16608 - Docbook XSL] version and unpack it. Put the results in + Docbook XSL] version and unpack it. Be careful that you download the correct + file, sometimes the 'looking for the latest version' link often links to + another file. The name should be of the form + '''docbook-xsl-1.nn.n.tar.bz2''', + with no suffix such as `-ns.tar.bz2` or `-doc.tar.bz2`. + Put the results in `/usr/local/share/xsl/docbook`, thus effectively removing the version number from the directory name (for simplicity). @@ -1980,13 +2064,14 @@ To get started: your home directory (`/Users/`). You must already have it somewhere or otherwise you could not be building Boost (i.e. missing tools configuration). - + ``` using xsltproc ; using boostbook : "/usr/local/share/xsl/docbook" : "/usr/local/share/xml/docbook/4.2" ; + ``` The above steps are enough to get a functional BoostBook setup. Quickbook will be automatically built when needed. If you want to avoid these @@ -1996,16 +2081,18 @@ rebuilds and install a system-wide Quickbook instead: # Build the utility by issuing `bjam`. -# Copy the resulting `quickbook` binary (located under the - `BOOST_ROOT/bin.v2` hierarchy) to a safe place. Following our previous +# Copy the resulting `quickbook` binary (located at + `BOOST_ROOT/dist/bin`) to a safe place. Following our previous example, you can install it into: `/usr/local/bin`. # Add the following to your `user-config.jam` file: - + ``` using quickbook : "/usr/local/bin/quickbook" ; ; + ``` +[# osx-prebuilt-doxygen] Additionally, if you need to build documentation that uses [@http://www.doxygen.org Doxygen], you will need to install it too: @@ -2016,21 +2103,26 @@ Additionally, if you need to build documentation that uses `Applications` folder to install it. # Add the following to your `user-config.jam` file: - + ``` using doxygen : /Applications/Doxygen.app/Contents/Resources/doxygen ; + ``` +[/ Removed this, since there are macports based instructions earlier. + Instructions for pkgsrc welcome] +[/ Alternatively, you may want to install all the prerequistes through a package system to avoid manual management of the installations. In that case, check out [@http://www.pkgsrc.org pkgsrc]. +] -[endsect] [/Mac OS X] +[endsect] [/ native] + +[endsect] [/ macosx] [section:windows Windows 2000, XP, 2003, Vista] -[python] - [:['Section contributed by Julio M. Merino Vidal]] The following instructions apply to any Windows system based on Windows @@ -2060,7 +2152,12 @@ adjust them to match your system in case you are running an older version. # Download the latest [@http://sourceforge.net/project/showfiles.php?group_id=21935&package_id=16608 Docbook XSL] version and unpack it, again in the same directory - used before. To make things easier, rename the directory created + used before. Be careful that you download the correct + file, sometimes the 'looking for the latest version' link often links to + another file. The name should be of the form + '''docbook-xsl-1.nn.n.tar.bz2''', + with no suffix such as `-ns.tar.bz2` or `-doc.tar.bz2`. + To make things easier, rename the directory created during the extraction to `docbook-xsl` (bypassing the version name): `C:\Users\example\Documents\boost\xml\docbook-xsl`. @@ -2086,25 +2183,28 @@ rebuilds: # Build the utility by issuing `bjam`. -# Copy the resulting `quickbook.exe` binary (located under the - `BOOST_ROOT\bin.v2` hierarchy) to a safe place. Following our previous +# Copy the resulting `quickbook.exe` binary (located at + `BOOST_ROOT\dist\bin`) to a safe place. Following our previous example, you can install it into: `C:\Users\example\Documents\boost\xml\bin`. # Add the following to your `user-config.jam` file: - + ``` using quickbook : "C:/Users/example/Documents/boost/xml/bin/quickbook.exe" ; + ``` [endsect] [/Windows] [section:linux Debian, Ubuntu] The following instructions apply to Debian and its derivatives. They are based -on a Ubuntu Edgy install but should work on other Debian based systems. +on a Ubuntu Edgy install but should work on other Debian based systems. They +assume you've already installed an appropriate version of `bjam` for your +copy of boost. -First install the `bjam`, `xsltproc`, `docbook-xsl` and `docbook-xml` packages. +First install the `xsltproc`, `docbook-xsl` and `docbook-xml` packages. For example, using `apt-get`: sudo apt-get install xsltproc docbook-xsl docbook-xml @@ -2137,8 +2237,8 @@ rebuilds: # Build the utility by issuing `bjam`. -# Copy the resulting `quickbook` binary (located under the - `BOOST_ROOT/bin.v2` hierarchy) to a safe place. The traditional location is +# Copy the resulting `quickbook` binary (located at + `BOOST_ROOT/dist/bin`) to a safe place. The traditional location is `/usr/local/bin`. # Add the following to your `user-config.jam` file, using the full path of the @@ -2243,7 +2343,7 @@ QuickBook (which IMO is a whole lot easier to edit and maintain). [section:ref Quick Reference] -[c++] +[teletype] [template ordered_list_sample[] [pre''' From 8cec89bb23dcb8f0bab20807f3302c6a677d9021 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 2 Mar 2011 08:51:20 +0000 Subject: [PATCH 61/94] Merge quickbook workaround for g++ 4.4 optimization bug. [SVN r69470] --- src/actions.cpp | 2 ++ src/actions.hpp | 8 ++++++++ src/doc_info_grammar.cpp | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index 0f1645a..0770c95 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -30,6 +30,8 @@ namespace quickbook int qbk_minor_version = -1; unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version + void assign_qbk_version::operator()(int value) const { v_ = value; } + namespace { std::string fully_qualified_id(std::string const& library_id, std::string const& qualified_section_id, diff --git a/src/actions.hpp b/src/actions.hpp index d8b2f4e..ebe3a60 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -37,6 +37,14 @@ namespace quickbook extern int qbk_major_version; extern int qbk_minor_version; extern unsigned qbk_version_n; // qbk_major_version * 100 + qbk_minor_version + + // This struct is used to avoid an optimization bug + // in g++ 4.4 on 64-bit linux. + struct assign_qbk_version { + assign_qbk_version(int& v) : v_(v) {} + void operator()(int value) const; + int& v_; + }; struct quickbook_range { template diff --git a/src/doc_info_grammar.cpp b/src/doc_info_grammar.cpp index eaef6b5..6e2d476 100644 --- a/src/doc_info_grammar.cpp +++ b/src/doc_info_grammar.cpp @@ -80,9 +80,9 @@ namespace quickbook local.quickbook_version = "quickbook" >> hard_space - >> ( cl::uint_p [cl::assign_a(qbk_major_version)] + >> ( cl::uint_p [assign_qbk_version(qbk_major_version)] >> '.' - >> uint2_t() [cl::assign_a(qbk_minor_version)] + >> uint2_t() [assign_qbk_version(qbk_minor_version)] ) ; From 729c4f3142d4531f33720a522645357f7631f26e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 3 Apr 2011 11:57:03 +0000 Subject: [PATCH 62/94] Quickbook: Delete file missed in merge. [SVN r70931] --- test/snippets/pass_thru.xml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 test/snippets/pass_thru.xml diff --git a/test/snippets/pass_thru.xml b/test/snippets/pass_thru.xml deleted file mode 100644 index c647d11..0000000 --- a/test/snippets/pass_thru.xml +++ /dev/null @@ -1,21 +0,0 @@ - - -
- Pass thru test - - -struct Foo{ - - Foo()//=; - -}; - - - - -def foo: - #= print('foo') - - -
From 387e473e01a2860f9c8c9704e062d8d0e27955fb Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 10 May 2011 18:39:38 +0000 Subject: [PATCH 63/94] Quickbook: merge to release. Includes: - Detemplate syntax highlighter. - Allow escaped markup in comments in highlighter. - Remove whitespace hat was inserted after anchors. - Use fs::path in a couple more places. - Handle blocks inside phrases better (can happen with templates). [SVN r71862] --- doc/quickbook.qbk | 1 + src/Jamfile.v2 | 1 - src/actions.cpp | 40 ++- src/actions.hpp | 31 ++- src/actions_class.cpp | 3 +- src/actions_class.hpp | 3 +- src/block_element_grammar.cpp | 2 +- src/code_snippet.cpp | 4 +- src/main_grammar.cpp | 6 +- src/phrase_element_grammar.cpp | 2 +- src/syntax_highlight.cpp | 422 ++++++++++++++++++++++++++++--- src/syntax_highlight.hpp | 417 ------------------------------ test/Jamfile.v2 | 2 + test/anchor.gold | 18 +- test/code-block-cpp.gold | 29 +++ test/code-block-cpp.quickbook | 22 ++ test/code-block-python.gold | 10 + test/code-block-python.quickbook | 8 + test/import.gold | 12 +- test/link.gold | 2 +- test/quickbook-manual.gold | 28 +- test/simple_markup.gold | 3 + test/simple_markup.quickbook | 2 + test/table_1_5.gold | 2 +- test/templates.gold | 90 ++++++- test/templates.quickbook | 42 ++- test/variablelist.gold | 4 +- test/variablelist.quickbook | 10 +- 28 files changed, 695 insertions(+), 521 deletions(-) delete mode 100644 src/syntax_highlight.hpp create mode 100644 test/code-block-cpp.gold create mode 100644 test/code-block-cpp.quickbook create mode 100644 test/code-block-python.gold create mode 100644 test/code-block-python.quickbook diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 9b5f3c1..16c656f 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -287,6 +287,7 @@ Boost 1.46.1: * Use relative paths for `__FILENAME__` macro. * Rewrite xinclude path generator so that it doesn't use deprecated filesystem functions. +* Allow quickbook escapes inside comments in syntax highlighted code. * Quickbook 1.6: * Scope source mode changes to the file they're made in. * Explicit markup for lists. e.g. diff --git a/src/Jamfile.v2 b/src/Jamfile.v2 index e7ead94..736c19f 100644 --- a/src/Jamfile.v2 +++ b/src/Jamfile.v2 @@ -14,7 +14,6 @@ project quickbook darwin:300 gcc:-g0 darwin:-g0 - all msvc:/wd4709 ; diff --git a/src/actions.cpp b/src/actions.cpp index 856949f..bd10a7f 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -59,7 +59,7 @@ namespace quickbook { tgt << "\n"; + tgt << "\"/>"; } actions.anchors.clear(); @@ -522,12 +522,26 @@ namespace quickbook } // TODO: No need to check suppress since this is only used in the syntax - // highlighter. I should moved this or something. + // highlighter. I should move this or something. void span::operator()(iterator first, iterator last) const + { + if (name) out << ""; + while (first != last) + detail::print_char(*first++, out.get()); + if (name) out << ""; + } + + void span_start::operator()(iterator first, iterator last) const { out << ""; while (first != last) detail::print_char(*first++, out.get()); + } + + void span_end::operator()(iterator first, iterator last) const + { + while (first != last) + detail::print_char(*first++, out.get()); out << ""; } @@ -1341,6 +1355,7 @@ namespace quickbook actions.paragraph(); // For paragraphs before the template call. actions.out << block; actions.phrase << phrase; + actions.paragraph(); } else { actions.phrase << phrase; @@ -1777,7 +1792,7 @@ namespace quickbook std::string ext = paths.filename.extension().generic_string(); std::vector storage; actions.error_count += - load_snippets(paths.filename.string(), storage, ext, actions.doc_id); + load_snippets(paths.filename, storage, ext, actions.doc_id); BOOST_FOREACH(template_symbol& ts, storage) { @@ -1842,7 +1857,7 @@ namespace quickbook actions.values.builder.save(); // parse the file - quickbook::parse_file(actions.filename.string().c_str(), actions, true); + quickbook::parse_file(actions.filename, actions, true); // restore the values actions.values.builder.restore(); @@ -1884,13 +1899,24 @@ namespace quickbook return (*this)(first, last, value::default_tag); } - void collector_to_value_action::operator()(iterator, iterator) const + void to_value_action::operator()(iterator, iterator) const { if (actions.suppress) return; - write_anchors(actions, output); std::string value; - output.swap(value); + + if (!actions.out.str().empty()) + { + actions.paragraph(); + write_anchors(actions, actions.out); + actions.out.swap(value); + } + else + { + write_anchors(actions, actions.phrase); + actions.phrase.swap(value); + } + actions.values.builder.insert(bbk_value(value, value::default_tag)); } diff --git a/src/actions.hpp b/src/actions.hpp index b3769e3..27a39c1 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -53,8 +53,9 @@ namespace quickbook typedef cl::symbols string_symbols; - int load_snippets(std::string const& file, std::vector& storage, + int load_snippets(fs::path const& file, std::vector& storage, std::string const& extension, std::string const& doc_id); + std::string syntax_highlight( iterator first, iterator last, actions& escape_actions, @@ -161,6 +162,27 @@ namespace quickbook collector& out; }; + struct span_start + { + span_start(char const* name, collector& out) + : name(name), out(out) {} + + void operator()(iterator first, iterator last) const; + + char const* name; + collector& out; + }; + + struct span_end + { + span_end(collector& out) + : out(out) {} + + void operator()(iterator first, iterator last) const; + + collector& out; + }; + struct unexpected_char { // Handles unexpected chars in c++ syntax @@ -356,15 +378,14 @@ namespace quickbook typedef phoenix::function phrase_to_docinfo_action; - struct collector_to_value_action + struct to_value_action { - collector_to_value_action(quickbook::actions& actions, collector& output) - : actions(actions), output(output) {} + to_value_action(quickbook::actions& actions) + : actions(actions) {} void operator()(iterator first, iterator last) const; quickbook::actions& actions; - collector& output; }; struct scoped_output_push : scoped_action_base diff --git a/src/actions_class.cpp b/src/actions_class.cpp index 9ebd75b..7487a66 100644 --- a/src/actions_class.cpp +++ b/src/actions_class.cpp @@ -35,8 +35,7 @@ namespace quickbook // value actions , values() - , phrase_value(*this, phrase) - , out_value(*this, out) + , to_value(*this) , docinfo_value(*this) , scoped_cond_phrase(*this) , scoped_output(*this) diff --git a/src/actions_class.hpp b/src/actions_class.hpp index 27f7c4e..0759a08 100644 --- a/src/actions_class.hpp +++ b/src/actions_class.hpp @@ -51,8 +51,7 @@ namespace quickbook // value actions value_parser values; - collector_to_value_action phrase_value; - collector_to_value_action out_value; + to_value_action to_value; phrase_to_docinfo_action docinfo_value; scoped_parser diff --git a/src/block_element_grammar.cpp b/src/block_element_grammar.cpp index 6a3c9ff..6732979 100644 --- a/src/block_element_grammar.cpp +++ b/src/block_element_grammar.cpp @@ -281,7 +281,7 @@ namespace quickbook local.inner_block = actions.scoped_output() [ - inside_paragraph [actions.out_value] + inside_paragraph [actions.to_value] ] ; diff --git a/src/code_snippet.cpp b/src/code_snippet.cpp index a88ee77..fcedf70 100644 --- a/src/code_snippet.cpp +++ b/src/code_snippet.cpp @@ -24,7 +24,7 @@ namespace quickbook struct code_snippet_actions { code_snippet_actions(std::vector& storage, - std::string const& filename, + fs::path const& filename, std::string const& doc_id, char const* source_type) : callout_id(0) @@ -312,7 +312,7 @@ namespace quickbook }; int load_snippets( - std::string const& file + fs::path const& file , std::vector& storage // snippets are stored in a // vector of template_symbols , std::string const& extension diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index 6e3ee74..69d374b 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -221,7 +221,7 @@ namespace quickbook >> (cl::ch_p('*') | '#') [actions.values.entry(ph::arg1, ph::arg2, general_tags::list_mark)] >> *cl::blank_p - >> local.list_item [actions.phrase_value] + >> local.list_item [actions.to_value] ] ] ] [actions.element] @@ -384,7 +384,7 @@ namespace quickbook [ actions.scoped_output() [ - (*( ~cl::eps_p(local.simple_markup_end) + (+( ~cl::eps_p(local.simple_markup_end) >> local.nested_char )) [actions.docinfo_value(ph::arg1, ph::arg2)] ] @@ -508,7 +508,7 @@ namespace quickbook >> local.command_line_phrase >> *cl::space_p | cl::eps_p - ) [actions.phrase_value] + ) [actions.to_value] ] [actions.element] ; diff --git a/src/phrase_element_grammar.cpp b/src/phrase_element_grammar.cpp index 4b22af6..ab5de65 100644 --- a/src/phrase_element_grammar.cpp +++ b/src/phrase_element_grammar.cpp @@ -127,7 +127,7 @@ namespace quickbook local.inner_phrase = blank >> actions.scoped_output() - [ phrase [actions.phrase_value] + [ phrase [actions.to_value] ] ; } diff --git a/src/syntax_highlight.cpp b/src/syntax_highlight.cpp index 98fa4bb..bacb23f 100644 --- a/src/syntax_highlight.cpp +++ b/src/syntax_highlight.cpp @@ -7,42 +7,394 @@ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ -#include "syntax_highlight.hpp" +#include +#include +#include +#include +#include +#include "grammar.hpp" +#include "grammar_impl.hpp" // Just for context stuff. Should move? #include "actions_class.hpp" namespace quickbook -{ - typedef cpp_highlight< - span - , space - , string_symbols - , do_macro_action - , pre_escape_back - , post_escape_back - , unexpected_char - , collector> - cpp_p_type; +{ + namespace cl = boost::spirit::classic; + + // Grammar for C++ highlighting + struct cpp_highlight + : public cl::grammar + { + cpp_highlight(collector& out, actions& escape_actions) + : out(out), escape_actions(escape_actions) {} + + template + struct definition + { + definition(cpp_highlight const& self) + : g(self.escape_actions.grammar()) + { + program + = + *( (+cl::space_p) [space(self.out)] + | macro + | escape + | preprocessor [span("preprocessor", self.out)] + | comment + | keyword [span("keyword", self.out)] + | identifier [span("identifier", self.out)] + | special [span("special", self.out)] + | string_ [span("string", self.out)] + | char_ [span("char", self.out)] + | number [span("number", self.out)] + | cl::repeat_p(1)[cl::anychar_p] + [unexpected_char(self.out, self.escape_actions)] + ) + ; + + macro = + // must not be followed by alpha or underscore + cl::eps_p(self.escape_actions.macro + >> (cl::eps_p - (cl::alpha_p | '_'))) + >> self.escape_actions.macro [do_macro_action(self.out, self.escape_actions)] + ; + + qbk_phrase = + self.escape_actions.scoped_context(element_info::in_phrase) + [ *( g.common + | (cl::anychar_p - cl::str_p("``")) + [self.escape_actions.plain_char] + ) + ] + ; + + escape = + cl::str_p("``") [pre_escape_back(self.escape_actions, save)] + >> + ( + ( + ( + (+(cl::anychar_p - "``") >> cl::eps_p("``")) + & qbk_phrase + ) + >> cl::str_p("``") + ) + | + ( + cl::eps_p [self.escape_actions.error] + >> *cl::anychar_p + ) + ) [post_escape_back(self.out, self.escape_actions, save)] + ; + + preprocessor + = '#' >> *cl::space_p >> ((cl::alpha_p | '_') >> *(cl::alnum_p | '_')) + ; + + comment + = cl::str_p("//") [span_start("comment", self.out)] + >> *( escape + | (+(cl::anychar_p - (cl::eol_p | "``"))) + [span(0, self.out)] + ) + >> cl::eps_p [span_end(self.out)] + | cl::str_p("/*") [span_start("comment", self.out)] + >> *( escape + | (+(cl::anychar_p - (cl::str_p("*/") | "``"))) + [span(0, self.out)] + ) + >> (!cl::str_p("*/")) [span_end(self.out)] + ; + + keyword + = keyword_ >> (cl::eps_p - (cl::alnum_p | '_')) + ; // make sure we recognize whole words only + + keyword_ + = "and_eq", "and", "asm", "auto", "bitand", "bitor", + "bool", "break", "case", "catch", "char", "class", + "compl", "const_cast", "const", "continue", "default", + "delete", "do", "double", "dynamic_cast", "else", + "enum", "explicit", "export", "extern", "false", + "float", "for", "friend", "goto", "if", "inline", + "int", "long", "mutable", "namespace", "new", "not_eq", + "not", "operator", "or_eq", "or", "private", + "protected", "public", "register", "reinterpret_cast", + "return", "short", "signed", "sizeof", "static", + "static_cast", "struct", "switch", "template", "this", + "throw", "true", "try", "typedef", "typeid", + "typename", "union", "unsigned", "using", "virtual", + "void", "volatile", "wchar_t", "while", "xor_eq", "xor" + ; + + special + = +cl::chset_p("~!%^&*()+={[}]:;,<.>?/|\\-") + ; + + string_char = ('\\' >> cl::anychar_p) | (cl::anychar_p - '\\'); + + string_ + = !cl::as_lower_d['l'] >> cl::confix_p('"', *string_char, '"') + ; + + char_ + = !cl::as_lower_d['l'] >> cl::confix_p('\'', *string_char, '\'') + ; + + number + = ( + cl::as_lower_d["0x"] >> cl::hex_p + | '0' >> cl::oct_p + | cl::real_p + ) + >> *cl::as_lower_d[cl::chset_p("ldfu")] + ; + + identifier + = (cl::alpha_p | '_') >> *(cl::alnum_p | '_') + ; + } + + cl::rule + program, macro, preprocessor, comment, special, string_, + char_, number, identifier, keyword, qbk_phrase, escape, + string_char; + + cl::symbols<> keyword_; + quickbook_grammar& g; + std::string save; + + cl::rule const& + start() const { return program; } + }; + + collector& out; + actions& escape_actions; + }; + + // Grammar for Python highlighting + // See also: The Python Reference Manual + // http://docs.python.org/ref/ref.html + struct python_highlight + : public cl::grammar + { + python_highlight(collector& out, actions& escape_actions) + : out(out), escape_actions(escape_actions) {} + + template + struct definition + { + definition(python_highlight const& self) + : g(self.escape_actions.grammar()) + { + program + = + *( (+cl::space_p) [space(self.out)] + | macro + | escape + | comment + | keyword [span("keyword", self.out)] + | identifier [span("identifier", self.out)] + | special [span("special", self.out)] + | string_ [span("string", self.out)] + | number [span("number", self.out)] + | cl::repeat_p(1)[cl::anychar_p] + [unexpected_char(self.out, self.escape_actions)] + ) + ; + + macro = + // must not be followed by alpha or underscore + cl::eps_p(self.escape_actions.macro + >> (cl::eps_p - (cl::alpha_p | '_'))) + >> self.escape_actions.macro [do_macro_action(self.out, self.escape_actions)] + ; + + qbk_phrase = + self.escape_actions.scoped_context(element_info::in_phrase) + [ + *( g.common + | (cl::anychar_p - cl::str_p("``")) + [self.escape_actions.plain_char] + ) + ] + ; + + escape = + cl::str_p("``") [pre_escape_back(self.escape_actions, save)] + >> + ( + ( + ( + (+(cl::anychar_p - "``") >> cl::eps_p("``")) + & qbk_phrase + ) + >> cl::str_p("``") + ) + | + ( + cl::eps_p [self.escape_actions.error] + >> *cl::anychar_p + ) + ) [post_escape_back(self.out, self.escape_actions, save)] + ; + + comment + = cl::str_p("#") [span_start("comment", self.out)] + >> *( escape + | (+(cl::anychar_p - (cl::eol_p | "``"))) + [span(0, self.out)] + ) + >> cl::eps_p [span_end(self.out)] + ; + + keyword + = keyword_ >> (cl::eps_p - (cl::alnum_p | '_')) + ; // make sure we recognize whole words only + + keyword_ + = + "and", "del", "for", "is", "raise", + "assert", "elif", "from", "lambda", "return", + "break", "else", "global", "not", "try", + "class", "except", "if", "or", "while", + "continue", "exec", "import", "pass", "yield", + "def", "finally", "in", "print", + + // Technically "as" and "None" are not yet keywords (at Python + // 2.4). They are destined to become keywords, and we treat them + // as such for syntax highlighting purposes. + + "as", "None" + ; + + special + = +cl::chset_p("~!%^&*()+={[}]:;,<.>/|\\-") + ; + + string_prefix + = cl::as_lower_d[cl::str_p("u") >> ! cl::str_p("r")] + ; + + string_ + = ! string_prefix >> (long_string | short_string) + ; + + string_char = ('\\' >> cl::anychar_p) | (cl::anychar_p - '\\'); + + short_string + = cl::confix_p('\'', * string_char, '\'') | + cl::confix_p('"', * string_char, '"') + ; + + long_string + // Note: the "cl::str_p" on the next two lines work around + // an INTERNAL COMPILER ERROR when using VC7.1 + = cl::confix_p(cl::str_p("'''"), * string_char, "'''") | + cl::confix_p(cl::str_p("\"\"\""), * string_char, "\"\"\"") + ; + + number + = ( + cl::as_lower_d["0x"] >> cl::hex_p + | '0' >> cl::oct_p + | cl::real_p + ) + >> *cl::as_lower_d[cl::chset_p("lj")] + ; + + identifier + = (cl::alpha_p | '_') >> *(cl::alnum_p | '_') + ; + } + + cl::rule + program, macro, comment, special, string_, string_prefix, + short_string, long_string, number, identifier, keyword, + qbk_phrase, escape, string_char; + + cl::symbols<> keyword_; + quickbook_grammar& g; + std::string save; + + cl::rule const& + start() const { return program; } + }; + + collector& out; + actions& escape_actions; + }; + + // Grammar for plain text (no actual highlighting) + struct teletype_highlight + : public cl::grammar + { + teletype_highlight(collector& out, actions& escape_actions) + : out(out), escape_actions(escape_actions) {} + + template + struct definition + { + definition(teletype_highlight const& self) + : g(self.escape_actions.grammar()) + { + program + = + *( macro + | escape + | cl::repeat_p(1)[cl::anychar_p] [plain_char_action(self.out, self.escape_actions)] + ) + ; + + macro = + // must not be followed by alpha or underscore + cl::eps_p(self.escape_actions.macro + >> (cl::eps_p - (cl::alpha_p | '_'))) + >> self.escape_actions.macro [do_macro_action(self.out, self.escape_actions)] + ; + + qbk_phrase = + self.escape_actions.scoped_context(element_info::in_phrase) + [ + *( g.common + | (cl::anychar_p - cl::str_p("``")) + [self.escape_actions.plain_char] + ) + ] + ; + + escape = + cl::str_p("``") [pre_escape_back(self.escape_actions, save)] + >> + ( + ( + ( + (+(cl::anychar_p - "``") >> cl::eps_p("``")) + & qbk_phrase + ) + >> cl::str_p("``") + ) + | + ( + cl::eps_p [self.escape_actions.error] + >> *cl::anychar_p + ) + ) [post_escape_back(self.out, self.escape_actions, save)] + ; + } + + cl::rule program, macro, qbk_phrase, escape; + + quickbook_grammar& g; + std::string save; + + cl::rule const& + start() const { return program; } + }; + + collector& out; + actions& escape_actions; + }; - typedef python_highlight< - span - , space - , string_symbols - , do_macro_action - , pre_escape_back - , post_escape_back - , unexpected_char - , collector> - python_p_type; - - typedef teletype_highlight< - plain_char_action - , string_symbols - , do_macro_action - , pre_escape_back - , post_escape_back - , collector> - teletype_p_type; - std::string syntax_highlight( iterator first, iterator last, actions& escape_actions, @@ -53,17 +405,17 @@ namespace quickbook // print the code with syntax coloring if (source_mode == "c++") { - cpp_p_type cpp_p(temp, escape_actions.macro, do_macro_action(temp, escape_actions), escape_actions); + cpp_highlight cpp_p(temp, escape_actions); boost::spirit::classic::parse(first, last, cpp_p); } else if (source_mode == "python") { - python_p_type python_p(temp, escape_actions.macro, do_macro_action(temp, escape_actions), escape_actions); + python_highlight python_p(temp, escape_actions); boost::spirit::classic::parse(first, last, python_p); } else if (source_mode == "teletype") { - teletype_p_type teletype_p(temp, escape_actions.macro, do_macro_action(temp, escape_actions), escape_actions); + teletype_highlight teletype_p(temp, escape_actions); boost::spirit::classic::parse(first, last, teletype_p); } else diff --git a/src/syntax_highlight.hpp b/src/syntax_highlight.hpp deleted file mode 100644 index 3a16c99..0000000 --- a/src/syntax_highlight.hpp +++ /dev/null @@ -1,417 +0,0 @@ -/*============================================================================= - Copyright (c) 2002 2004 2006 Joel de Guzman - Copyright (c) 2004 Eric Niebler - http://spirit.sourceforge.net/ - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ -#if !defined(BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP) -#define BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP - -#include -#include -#include -#include -#include -#include "grammar.hpp" -#include "grammar_impl.hpp" // Just for context stuff. Should move? - -namespace quickbook -{ - namespace cl = boost::spirit::classic; - - // Grammar for C++ highlighting - template < - typename Process - , typename Space - , typename Macro - , typename DoMacro - , typename PreEscape - , typename PostEscape - , typename Unexpected - , typename Out> - struct cpp_highlight - : public cl::grammar > - { - cpp_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions) - : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {} - - template - struct definition - { - definition(cpp_highlight const& self) - : g(self.escape_actions.grammar()) - { - program - = - *( (+cl::space_p) [Space(self.out)] - | macro - | escape - | preprocessor [Process("preprocessor", self.out)] - | comment [Process("comment", self.out)] - | keyword [Process("keyword", self.out)] - | identifier [Process("identifier", self.out)] - | special [Process("special", self.out)] - | string_ [Process("string", self.out)] - | char_ [Process("char", self.out)] - | number [Process("number", self.out)] - | cl::repeat_p(1)[cl::anychar_p] - [Unexpected(self.out, self.escape_actions)] - ) - ; - - macro = - // must not be followed by alpha or underscore - cl::eps_p(self.macro - >> (cl::eps_p - (cl::alpha_p | '_'))) - >> self.macro [self.do_macro] - ; - - qbk_phrase = - self.escape_actions.scoped_context(element_info::in_phrase) - [ *( g.common - | (cl::anychar_p - cl::str_p("``")) - [self.escape_actions.plain_char] - ) - ] - ; - - escape = - cl::str_p("``") [PreEscape(self.escape_actions, save)] - >> - ( - ( - ( - (+(cl::anychar_p - "``") >> cl::eps_p("``")) - & qbk_phrase - ) - >> cl::str_p("``") - ) - | - ( - cl::eps_p [self.escape_actions.error] - >> *cl::anychar_p - ) - ) [PostEscape(self.out, self.escape_actions, save)] - ; - - preprocessor - = '#' >> *cl::space_p >> ((cl::alpha_p | '_') >> *(cl::alnum_p | '_')) - ; - - comment - = cl::comment_p("//") | cl::comment_p("/*", "*/") - ; - - keyword - = keyword_ >> (cl::eps_p - (cl::alnum_p | '_')) - ; // make sure we recognize whole words only - - keyword_ - = "and_eq", "and", "asm", "auto", "bitand", "bitor", - "bool", "break", "case", "catch", "char", "class", - "compl", "const_cast", "const", "continue", "default", - "delete", "do", "double", "dynamic_cast", "else", - "enum", "explicit", "export", "extern", "false", - "float", "for", "friend", "goto", "if", "inline", - "int", "long", "mutable", "namespace", "new", "not_eq", - "not", "operator", "or_eq", "or", "private", - "protected", "public", "register", "reinterpret_cast", - "return", "short", "signed", "sizeof", "static", - "static_cast", "struct", "switch", "template", "this", - "throw", "true", "try", "typedef", "typeid", - "typename", "union", "unsigned", "using", "virtual", - "void", "volatile", "wchar_t", "while", "xor_eq", "xor" - ; - - special - = +cl::chset_p("~!%^&*()+={[}]:;,<.>?/|\\-") - ; - - string_char = ('\\' >> cl::anychar_p) | (cl::anychar_p - '\\'); - - string_ - = !cl::as_lower_d['l'] >> cl::confix_p('"', *string_char, '"') - ; - - char_ - = !cl::as_lower_d['l'] >> cl::confix_p('\'', *string_char, '\'') - ; - - number - = ( - cl::as_lower_d["0x"] >> cl::hex_p - | '0' >> cl::oct_p - | cl::real_p - ) - >> *cl::as_lower_d[cl::chset_p("ldfu")] - ; - - identifier - = (cl::alpha_p | '_') >> *(cl::alnum_p | '_') - ; - } - - cl::rule - program, macro, preprocessor, comment, special, string_, - char_, number, identifier, keyword, qbk_phrase, escape, - string_char; - - cl::symbols<> keyword_; - quickbook_grammar& g; - std::string save; - - cl::rule const& - start() const { return program; } - }; - - Out& out; - Macro const& macro; - DoMacro do_macro; - actions& escape_actions; - }; - - // Grammar for Python highlighting - // See also: The Python Reference Manual - // http://docs.python.org/ref/ref.html - template < - typename Process - , typename Space - , typename Macro - , typename DoMacro - , typename PreEscape - , typename PostEscape - , typename Unexpected - , typename Out> - struct python_highlight - : public cl::grammar > - { - python_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions) - : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {} - - template - struct definition - { - definition(python_highlight const& self) - : g(self.escape_actions.grammar()) - { - program - = - *( (+cl::space_p) [Space(self.out)] - | macro - | escape - | comment [Process("comment", self.out)] - | keyword [Process("keyword", self.out)] - | identifier [Process("identifier", self.out)] - | special [Process("special", self.out)] - | string_ [Process("string", self.out)] - | number [Process("number", self.out)] - | cl::repeat_p(1)[cl::anychar_p] - [Unexpected(self.out, self.escape_actions)] - ) - ; - - macro = - // must not be followed by alpha or underscore - cl::eps_p(self.macro - >> (cl::eps_p - (cl::alpha_p | '_'))) - >> self.macro [self.do_macro] - ; - - qbk_phrase = - self.escape_actions.scoped_context(element_info::in_phrase) - [ - *( g.common - | (cl::anychar_p - cl::str_p("``")) - [self.escape_actions.plain_char] - ) - ] - ; - - escape = - cl::str_p("``") [PreEscape(self.escape_actions, save)] - >> - ( - ( - ( - (+(cl::anychar_p - "``") >> cl::eps_p("``")) - & qbk_phrase - ) - >> cl::str_p("``") - ) - | - ( - cl::eps_p [self.escape_actions.error] - >> *cl::anychar_p - ) - ) [PostEscape(self.out, self.escape_actions, save)] - ; - - comment - = cl::comment_p("#") - ; - - keyword - = keyword_ >> (cl::eps_p - (cl::alnum_p | '_')) - ; // make sure we recognize whole words only - - keyword_ - = - "and", "del", "for", "is", "raise", - "assert", "elif", "from", "lambda", "return", - "break", "else", "global", "not", "try", - "class", "except", "if", "or", "while", - "continue", "exec", "import", "pass", "yield", - "def", "finally", "in", "print", - - // Technically "as" and "None" are not yet keywords (at Python - // 2.4). They are destined to become keywords, and we treat them - // as such for syntax highlighting purposes. - - "as", "None" - ; - - special - = +cl::chset_p("~!%^&*()+={[}]:;,<.>/|\\-") - ; - - string_prefix - = cl::as_lower_d[cl::str_p("u") >> ! cl::str_p("r")] - ; - - string_ - = ! string_prefix >> (long_string | short_string) - ; - - string_char = ('\\' >> cl::anychar_p) | (cl::anychar_p - '\\'); - - short_string - = cl::confix_p('\'', * string_char, '\'') | - cl::confix_p('"', * string_char, '"') - ; - - long_string - // Note: the "cl::str_p" on the next two lines work around - // an INTERNAL COMPILER ERROR when using VC7.1 - = cl::confix_p(cl::str_p("'''"), * string_char, "'''") | - cl::confix_p(cl::str_p("\"\"\""), * string_char, "\"\"\"") - ; - - number - = ( - cl::as_lower_d["0x"] >> cl::hex_p - | '0' >> cl::oct_p - | cl::real_p - ) - >> *cl::as_lower_d[cl::chset_p("lj")] - ; - - identifier - = (cl::alpha_p | '_') >> *(cl::alnum_p | '_') - ; - } - - cl::rule - program, macro, comment, special, string_, string_prefix, - short_string, long_string, number, identifier, keyword, - qbk_phrase, escape, string_char; - - cl::symbols<> keyword_; - quickbook_grammar& g; - std::string save; - - cl::rule const& - start() const { return program; } - }; - - Out& out; - Macro const& macro; - DoMacro do_macro; - actions& escape_actions; - }; - - // Grammar for plain text (no actual highlighting) - template < - typename CharProcess - , typename Macro - , typename DoMacro - , typename PreEscape - , typename PostEscape - , typename Out> - struct teletype_highlight - : public cl::grammar > - { - teletype_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions) - : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {} - - template - struct definition - { - definition(teletype_highlight const& self) - : g(self.escape_actions.grammar()) - { - program - = - *( macro - | escape - | cl::repeat_p(1)[cl::anychar_p] [CharProcess(self.out, self.escape_actions)] - ) - ; - - macro = - // must not be followed by alpha or underscore - cl::eps_p(self.macro - >> (cl::eps_p - (cl::alpha_p | '_'))) - >> self.macro [self.do_macro] - ; - - qbk_phrase = - self.escape_actions.scoped_context(element_info::in_phrase) - [ - *( g.common - | (cl::anychar_p - cl::str_p("``")) - [self.escape_actions.plain_char] - ) - ] - ; - - escape = - cl::str_p("``") [PreEscape(self.escape_actions, save)] - >> - ( - ( - ( - (+(cl::anychar_p - "``") >> cl::eps_p("``")) - & qbk_phrase - ) - >> cl::str_p("``") - ) - | - ( - cl::eps_p [self.escape_actions.error] - >> *cl::anychar_p - ) - ) [PostEscape(self.out, self.escape_actions, save)] - ; - } - - cl::rule program, macro, qbk_phrase, escape; - - quickbook_grammar& g; - std::string save; - - cl::rule const& - start() const { return program; } - }; - - Out& out; - Macro const& macro; - DoMacro do_macro; - actions& escape_actions; - }; - -} - -#endif // BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d07e83c..86c8c4d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -26,6 +26,8 @@ test-suite quickbook.test : [ quickbook-test code-block-2 ] [ quickbook-test code-block-3 ] [ quickbook-test code-block-teletype ] + [ quickbook-test code-block-cpp ] + [ quickbook-test code-block-python ] [ quickbook-test code-snippet ] [ quickbook-test preformatted ] [ quickbook-test link ] diff --git a/test/anchor.gold b/test/anchor.gold index 1aca95b..03f35ce 100644 --- a/test/anchor.gold +++ b/test/anchor.gold @@ -6,42 +6,42 @@
Anchors - A paragraph containing several anchors. - We want to make sure they appear in the correct place. + A paragraph containing several anchors. We + want to make sure they appear in the correct place. This heading shouldn't pick up the previous anchor - + This heading should pick up the previous anchor - + And this one - + Also this one - + Finally this
- <anchor id="a9"/> Section Anchor + <anchor id="a9"/>Section Anchor
- <anchor id="a10"/> Nested Section + <anchor id="a10"/>Nested Section
- <anchor id="a12"/> Conditional Section Anchor + <anchor id="a12"/>Conditional Section Anchor
Lists diff --git a/test/code-block-cpp.gold b/test/code-block-cpp.gold new file mode 100644 index 0000000..793bf65 --- /dev/null +++ b/test/code-block-cpp.gold @@ -0,0 +1,29 @@ + + +
+ C++ Code Blocks +// No escape +/* No escape */ +/* No escape + * with newlines + */ +// In Header: <boost/optional/optional.hpp> +/* In Header: <boost/optional/optional.hpp> */ +/* Multiple escapes: italic + * underlinebold + */ + + + A badly formed comment: + + +/* Oh dear + + + A badly formed comment with an escape: + + +/* Oh dear bold + +
diff --git a/test/code-block-cpp.quickbook b/test/code-block-cpp.quickbook new file mode 100644 index 0000000..be8043a --- /dev/null +++ b/test/code-block-cpp.quickbook @@ -0,0 +1,22 @@ +[article C++ Code Blocks +[quickbook 1.5] +] + + // No escape + /* No escape */ + /* No escape + * with newlines + */ + // In Header: <``[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]``> + /* In Header: <``[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]``> */ + /* Multiple escapes: ``/italic/`` + * ``_underline_````*bold*`` + */ + +A badly formed comment: + + /* Oh dear + +A badly formed comment with an escape: + + /* Oh dear ``*bold*`` diff --git a/test/code-block-python.gold b/test/code-block-python.gold new file mode 100644 index 0000000..ec6c845 --- /dev/null +++ b/test/code-block-python.gold @@ -0,0 +1,10 @@ + + +
+ Python Code Blocks +# No escape +# Escape: bold +# Escape: underlineitalic + +
diff --git a/test/code-block-python.quickbook b/test/code-block-python.quickbook new file mode 100644 index 0000000..45e700e --- /dev/null +++ b/test/code-block-python.quickbook @@ -0,0 +1,8 @@ +[article Python Code Blocks +[quickbook 1.5] +[source-mode python] +] + + # No escape + # Escape: ``*bold*`` + # Escape: ``_underline_````/italic/`` diff --git a/test/import.gold b/test/import.gold index 88083ee..5da7949 100644 --- a/test/import.gold +++ b/test/import.gold @@ -27,8 +27,8 @@ std::string foo() { - // return 'em, foo man! - return "foo"; + // return 'em, foo man! + return "foo"; } @@ -57,8 +57,8 @@ def foo(): - # return 'em, foo man! - return "foo" + # return 'em, foo man! + return "foo" @@ -87,8 +87,8 @@ char* foo() { - // return 'em, foo man! - return "foo"; + // return 'em, foo man! + return "foo"; } diff --git a/test/link.gold b/test/link.gold index 3b3e2a1..8a64fcf 100644 --- a/test/link.gold +++ b/test/link.gold @@ -7,7 +7,7 @@ http://www.boost.org/ Boost link-id Link Text - foo foo link text foo link text foo link text foo int main() { - // Sample code - std::cout << "Hello, World\n"; + // Sample code + std::cout << "Hello, World\n"; return 0; } @@ -2714,8 +2714,8 @@ for the journey to old age.]]] std::string foo() { - // return 'em, foo man! - return "foo"; + // return 'em, foo man! + return "foo"; } @@ -2726,8 +2726,8 @@ for the journey to old age.]]] std::string bar() { - // return 'em, bar man! - return "bar"; + // return 'em, bar man! + return "bar"; } @@ -2743,10 +2743,10 @@ for the journey to old age.]]] get marked up. We use distinguishable comments following the form: -//[id -some code here -//] - +//[id +some code here +//] + The first comment line above initiates a named code-snippet. This prefix will not be visible in quickbook. The entire code-snippet in between -//` some [*quickbook] markup here - +//` some [*quickbook] markup here + and: @@ -3029,8 +3029,8 @@ for the journey to old age.]]] : /usr/share/xml/docbook/schema/dtd/4.2 ; -# Remove this line if you're not using doxygen -using doxygen ; +# Remove this line if you're not using doxygen +using doxygen ; The above steps are enough to get a functional BoostBook setup. Quickbook diff --git a/test/simple_markup.gold b/test/simple_markup.gold index 2cb0481..7acaa98 100644 --- a/test/simple_markup.gold +++ b/test/simple_markup.gold @@ -46,5 +46,8 @@ /not italic/ + + These shouldn't be interepted as markup: == // ** +
diff --git a/test/simple_markup.quickbook b/test/simple_markup.quickbook index 9f4268f..b2f6c7a 100644 --- a/test/simple_markup.quickbook +++ b/test/simple_markup.quickbook @@ -33,4 +33,6 @@ __macro__ /not italic\/ +These shouldn't be interepted as markup: == // ** + [endsect] \ No newline at end of file diff --git a/test/table_1_5.gold b/test/table_1_5.gold index 86c1c67..a15b2d4 100644 --- a/test/table_1_5.gold +++ b/test/table_1_5.gold @@ -306,7 +306,7 @@ - a + a diff --git a/test/templates.gold b/test/templates.gold index 1ddb72d..9a40d34 100644 --- a/test/templates.gold +++ b/test/templates.gold @@ -66,6 +66,9 @@
<link linkend="templates.nested_templates">Nested Templates</link> + + Pre + Start block template. @@ -81,6 +84,12 @@ End block template. + + Post + + + Pre + Start block template. @@ -90,6 +99,12 @@ End block template. + + Post + + + Pre + Start phrase template. @@ -103,8 +118,79 @@ End block template. - End phrase template. Start phrase template. Start phrase template. Hello! End - phrase template. End phrase template. + End phrase template. + + + Post + + + Pre Start phrase template. Start phrase template. Hello! End phrase template. + End phrase template. Post
+
+ <link linkend="templates.block_markup">Block Markup</link> + + + + a + + + + + b + + + + + +int main() {} + + + Paragraphs 1 + + + Paragraphs 2 + + + + + + + + a + + + + + b + + + + + + + + + + + + + +int main() {} + + + + + + + Paragraphs 1 + + + Paragraphs 2 + + + + +
diff --git a/test/templates.quickbook b/test/templates.quickbook index 586caf6..457cd15 100644 --- a/test/templates.quickbook +++ b/test/templates.quickbook @@ -160,9 +160,41 @@ End block template. [template phrase[content] Start phrase template. [content] End phrase template.] -[block [block Hello!]] -[block [phrase Hello!]] -[phrase [block Hello!]] -[phrase [phrase Hello!]] +Pre [block [block Hello!]] Post -[endsect] \ No newline at end of file +Pre [block [phrase Hello!]] Post + +Pre [phrase [block Hello!]] Post + +Pre [phrase [phrase Hello!]] Post + +[endsect] + +[/----------------------------------- Block Markup ] + +[section Block Markup] + +[template list +* a +* b] + +[template horizontal +----] + +[template codeblock + int main() {}] + +[template paragraphs +Paragraphs 1 + +Paragraphs 2 +] + +[list][horizontal][codeblock][paragraphs] + +* [list] +* [horizontal] +* [codeblock] +* [paragraphs] + +[endsect] diff --git a/test/variablelist.gold b/test/variablelist.gold index 8bd1ec1..08d6613 100644 --- a/test/variablelist.gold +++ b/test/variablelist.gold @@ -96,10 +96,10 @@ Variable List with anchors - a + a - b + b diff --git a/test/variablelist.quickbook b/test/variablelist.quickbook index 484e8af..0aed118 100644 --- a/test/variablelist.quickbook +++ b/test/variablelist.quickbook @@ -23,9 +23,9 @@ [#id1] [variablelist Variable List with anchors - [ - [[#id2]a[#id3]] - [[#id4]b[#id5]] - ] + [ + [[#id2]a[#id3]] + [[#id4]b[#id5]] + ] ] - + From a7af466135d27f4f33600550569bc4ddbac8df74 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 11 Jun 2011 16:57:01 +0000 Subject: [PATCH 64/94] Quickbook: Don't match double marks in simple markup. [SVN r72545] --- src/actions.cpp | 14 +++----------- src/actions.hpp | 3 --- src/actions_class.cpp | 2 +- src/main_grammar.cpp | 23 +++++++++++++++-------- test/simple_markup.gold | 6 ++++-- test/simple_markup.quickbook | 6 ++++-- test/snippets/pass_thru.cpp | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index bd10a7f..e32515d 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -193,9 +193,8 @@ namespace quickbook if(!actions.warned_about_breaks) { detail::outwarn(actions.filename, pos.line) - << "line breaks generate invalid boostbook" - << " (will only note first occurrence)." - << "\n"; + << "line breaks generate invalid boostbook " + "(will only note first occurrence).\n"; actions.warned_about_breaks = true; } @@ -380,14 +379,7 @@ namespace quickbook values.finish(); out << markup.pre; - if (std::string const* ptr = find(macro, content.get_quickbook().c_str())) - { - out << *ptr; - } - else - { - out << content.get_boostbook(); - } + out << content.get_boostbook(); out << markup.post; } diff --git a/src/actions.hpp b/src/actions.hpp index 27a39c1..7fc0e8e 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -124,16 +124,13 @@ namespace quickbook simple_phrase_action( collector& out - , string_symbols const& macro , quickbook::actions& actions) : out(out) - , macro(macro) , actions(actions) {} void operator()(char) const; collector& out; - string_symbols const& macro; quickbook::actions& actions; }; diff --git a/src/actions_class.cpp b/src/actions_class.cpp index 7487a66..48f1602 100644 --- a/src/actions_class.cpp +++ b/src/actions_class.cpp @@ -75,7 +75,7 @@ namespace quickbook , raw_char(phrase, *this) , escape_unicode(phrase, *this) - , simple_markup(phrase, macro, *this) + , simple_markup(phrase, *this) , break_(phrase, *this) , do_macro(phrase, *this) diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index 69d374b..b38e4c3 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -368,10 +368,10 @@ namespace quickbook ; local.simple_markup = - cl::chset<>("*/_=") [local.simple_markup.mark = ph::arg1] - >> cl::eps_p(cl::graph_p) // graph_p must follow first mark + cl::chset<>("*/_=") [local.simple_markup.mark = ph::arg1] + >> cl::eps_p(cl::graph_p) // graph_p must follow first mark >> lookback - [ cl::anychar_p + [ cl::anychar_p // skip back over the markup >> ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark)) // first mark not be preceeded by // the same character. @@ -384,11 +384,18 @@ namespace quickbook [ actions.scoped_output() [ - (+( ~cl::eps_p(local.simple_markup_end) - >> local.nested_char - )) [actions.docinfo_value(ph::arg1, ph::arg2)] - ] - >> cl::f_ch_p(local.simple_markup.mark) + ( cl::eps_p(actions.macro >> local.simple_markup_end) + >> actions.macro [actions.do_macro] + | ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark)) + >> +( ~cl::eps_p + ( lookback [~cl::f_ch_p(local.simple_markup.mark)] + >> local.simple_markup_end + ) + >> local.nested_char + ) + ) [actions.to_value] + ] + >> cl::f_ch_p(local.simple_markup.mark) [actions.simple_markup] ] ; diff --git a/test/simple_markup.gold b/test/simple_markup.gold index 7acaa98..8408400 100644 --- a/test/simple_markup.gold +++ b/test/simple_markup.gold @@ -10,8 +10,10 @@ role="underline">underline teletype - /italic/ *bold* _underline_ =teletype= + //not italic// **not bold** __not underline__ ==not teletype== + + + odd__ edge case not__underlined__hopefully diff --git a/test/simple_markup.quickbook b/test/simple_markup.quickbook index b2f6c7a..8849b02 100644 --- a/test/simple_markup.quickbook +++ b/test/simple_markup.quickbook @@ -8,7 +8,9 @@ /italic/ *bold* _underline_ =teletype= -//italic// **bold** __underline__ ==teletype== +//not italic// **not bold** __not underline__ ==not teletype== + +_odd__ edge case_ not__underlined__hopefully @@ -35,4 +37,4 @@ __macro__ These shouldn't be interepted as markup: == // ** -[endsect] \ No newline at end of file +[endsect] diff --git a/test/snippets/pass_thru.cpp b/test/snippets/pass_thru.cpp index 96a962e..bdd9b79 100644 --- a/test/snippets/pass_thru.cpp +++ b/test/snippets/pass_thru.cpp @@ -19,4 +19,4 @@ struct Foo{ int x; //-> }; -//] \ No newline at end of file +//] From 4e631c623776f5ab6f2405ca986ec472ca1ee9b8 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 27 Jun 2011 14:02:28 +0000 Subject: [PATCH 65/94] Quickbook: remove escape character support from simple markup. Authorized by Beman Dawes. [SVN r72775] --- src/main_grammar.cpp | 17 ++--------------- test/simple_markup.gold | 9 ++++++--- test/simple_markup.quickbook | 2 ++ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index b38e4c3..af4cc05 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -89,7 +89,7 @@ namespace quickbook top_level, blocks, paragraph_separator, code, code_line, blank_line, hr, list, list_item, - nested_char, escape, + escape, inline_code, template_, code_block, macro, @@ -391,7 +391,7 @@ namespace quickbook ( lookback [~cl::f_ch_p(local.simple_markup.mark)] >> local.simple_markup_end ) - >> local.nested_char + >> cl::anychar_p [actions.plain_char] ) ) [actions.to_value] ] @@ -454,19 +454,6 @@ namespace quickbook ] ; - local.nested_char = - cl::str_p("\\n") [actions.break_] - | "\\ " // ignore an escaped space - | '\\' >> cl::punct_p [actions.raw_char] - | "\\u" >> cl::repeat_p(4) - [cl::chset<>("0-9a-fA-F")] - [actions.escape_unicode] - | "\\U" >> cl::repeat_p(8) - [cl::chset<>("0-9a-fA-F")] - [actions.escape_unicode] - | cl::anychar_p [actions.plain_char] - ; - local.escape = cl::str_p("\\n") [actions.break_] | cl::str_p("\\ ") // ignore an escaped space diff --git a/test/simple_markup.gold b/test/simple_markup.gold index 8408400..e08f596 100644 --- a/test/simple_markup.gold +++ b/test/simple_markup.gold @@ -34,7 +34,7 @@ _Should not underline escaped markup_. _or this escaped_ markup form. - Matti Meikäläinen + Matti Meik\u00E4l\u00E4inen replaced @@ -43,13 +43,16 @@ replaced - _macro_ + _mac\ ro_ - /not italic/ + not italic\ These shouldn't be interepted as markup: == // ** + + < \< \\< +
diff --git a/test/simple_markup.quickbook b/test/simple_markup.quickbook index 8849b02..61da0ab 100644 --- a/test/simple_markup.quickbook +++ b/test/simple_markup.quickbook @@ -37,4 +37,6 @@ __macro__ These shouldn't be interepted as markup: == // ** +=<= =\<= =\\<= + [endsect] From d41b4c398df0eeadfa52b8010b4f8ee0daf868df Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 2 Jul 2011 20:25:10 +0000 Subject: [PATCH 66/94] Quickbook: Merge documentation fix. Authorized by Beman. [SVN r72860] --- doc/quickbook.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 16c656f..f23e936 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -284,7 +284,7 @@ Boost 1.46.1: * Go back to using invalid markup for lists. It generates better html. * Better anchor placement for lists. * Pass-thru comments in code snippets. -* Use relative paths for `__FILENAME__` macro. +* Use relative paths for '''__FILENAME__''' macro. * Rewrite xinclude path generator so that it doesn't use deprecated filesystem functions. * Allow quickbook escapes inside comments in syntax highlighted code. From 34d6ee0da06720960121ad24b669f271bd9c4326 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 14 Jul 2011 19:22:57 +0000 Subject: [PATCH 67/94] Quickbook: XML encode escaped punctuation. [SVN r73110] --- doc/quickbook.qbk | 4 ++++ src/actions.cpp | 16 ---------------- src/actions.hpp | 16 ---------------- src/actions_class.cpp | 1 - src/actions_class.hpp | 1 - src/doc_info_grammar.cpp | 2 +- src/main_grammar.cpp | 2 +- src/quickbook.cpp | 2 +- test/escape.gold | 3 +++ test/escape.quickbook | 2 ++ test/simple_markup.gold | 2 +- test/simple_markup.quickbook | 2 +- 12 files changed, 14 insertions(+), 39 deletions(-) diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index f23e936..7b9184d 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -294,6 +294,10 @@ Boost 1.46.1: `[ordered_list [item1][item2]]` or `[itemized_list [item1][item2]]`. +[heading Version 1.5.6 - Boost 1.48] + +* Xml encode escaped punctuation (eg. `\<` is correctly encodes to \<). + [endsect] [/Change log] [section:syntax Syntax Summary] diff --git a/src/actions.cpp b/src/actions.cpp index e32515d..76f4d07 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -664,22 +664,6 @@ namespace quickbook out << ""; } - void raw_char_action::operator()(char ch) const - { - if (actions.suppress) return; - write_anchors(actions, phrase); - - phrase << ch; - } - - void raw_char_action::operator()(iterator first, iterator /*last*/) const - { - if (actions.suppress) return; - write_anchors(actions, phrase); - - phrase << *first; - } - void plain_char_action::operator()(char ch) const { if (actions.suppress) return; diff --git a/src/actions.hpp b/src/actions.hpp index 7fc0e8e..4ac2203 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -252,22 +252,6 @@ namespace quickbook std::string& save; }; - struct raw_char_action - { - // Prints a single raw (unprocessed) char. - // Allows '<', '>'... etc. - - raw_char_action(collector& phrase, quickbook::actions& actions) - : phrase(phrase) - , actions(actions) {} - - void operator()(char ch) const; - void operator()(iterator first, iterator /*last*/) const; - - collector& phrase; - quickbook::actions& actions; - }; - struct plain_char_action { // Prints a single plain char. diff --git a/src/actions_class.cpp b/src/actions_class.cpp index 48f1602..e1fcc12 100644 --- a/src/actions_class.cpp +++ b/src/actions_class.cpp @@ -72,7 +72,6 @@ namespace quickbook , paragraph(*this) , space_char(phrase) , plain_char(phrase, *this) - , raw_char(phrase, *this) , escape_unicode(phrase, *this) , simple_markup(phrase, *this) diff --git a/src/actions_class.hpp b/src/actions_class.hpp index 0759a08..1414c7f 100644 --- a/src/actions_class.hpp +++ b/src/actions_class.hpp @@ -121,7 +121,6 @@ namespace quickbook paragraph_action paragraph; space space_char; plain_char_action plain_char; - raw_char_action raw_char; escape_unicode_action escape_unicode; simple_phrase_action simple_markup; diff --git a/src/doc_info_grammar.cpp b/src/doc_info_grammar.cpp index 4656373..145628c 100644 --- a/src/doc_info_grammar.cpp +++ b/src/doc_info_grammar.cpp @@ -240,7 +240,7 @@ namespace quickbook local.char_ = cl::str_p("\\n") [actions.break_] | "\\ " // ignore an escaped space - | '\\' >> cl::punct_p [actions.raw_char] + | '\\' >> cl::punct_p [actions.plain_char] | "\\u" >> cl::repeat_p(4) [cl::chset<>("0-9a-fA-F")] [actions.escape_unicode] diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index af4cc05..098abb0 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -457,7 +457,7 @@ namespace quickbook local.escape = cl::str_p("\\n") [actions.break_] | cl::str_p("\\ ") // ignore an escaped space - | '\\' >> cl::punct_p [actions.raw_char] + | '\\' >> cl::punct_p [actions.plain_char] | "\\u" >> cl::repeat_p(4) [cl::chset<>("0-9a-fA-F")] [actions.escape_unicode] | "\\U" >> cl::repeat_p(8) [cl::chset<>("0-9a-fA-F")] diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 6c9dc1e..2be1d9a 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -34,7 +34,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.5.5" +#define QUICKBOOK_VERSION "Quickbook Version 1.5.6 (release)" namespace quickbook { diff --git a/test/escape.gold b/test/escape.gold index ea6267d..e08ebe4 100644 --- a/test/escape.gold +++ b/test/escape.gold @@ -10,5 +10,8 @@ This letter α should have a space either side of it. + + These should be properly encoded: > < " +
diff --git a/test/escape.quickbook b/test/escape.quickbook index 82b8d33..8dae7ed 100644 --- a/test/escape.quickbook +++ b/test/escape.quickbook @@ -9,5 +9,7 @@ This letter '''α''' should have a space either side of it. +These should be properly encoded: \> \< \" + [endsect] diff --git a/test/simple_markup.gold b/test/simple_markup.gold index e08f596..4d044ce 100644 --- a/test/simple_markup.gold +++ b/test/simple_markup.gold @@ -46,7 +46,7 @@ _mac\ ro_ - not italic\ + italic\ These shouldn't be interepted as markup: == // ** diff --git a/test/simple_markup.quickbook b/test/simple_markup.quickbook index 61da0ab..c8277fb 100644 --- a/test/simple_markup.quickbook +++ b/test/simple_markup.quickbook @@ -33,7 +33,7 @@ __macro__ =_mac\ ro_= -/not italic\/ +/italic\/ These shouldn't be interepted as markup: == // ** From a8862fe8a54a6e6e9d31e2030d6669bb07a07b99 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 30 Jul 2011 16:45:08 +0000 Subject: [PATCH 68/94] Quickbook: Merge from trunk. - Add ids to more elements. - Try to avoid generating duplicate ids. - Simplify the grammar a little to avoid what I assume are optimization bugs in older versions of gcc. [SVN r73445] --- Jamfile.v2 | 10 + src/Jamfile.v2 | 1 + src/actions.cpp | 157 ++++++++----- src/actions_class.cpp | 5 +- src/actions_class.hpp | 4 +- src/block_element_grammar.cpp | 21 +- src/doc_info_actions.cpp | 8 +- src/fwd.hpp | 1 + src/id_generator.cpp | 344 ++++++++++++++++++++++++++++ src/id_generator.hpp | 70 ++++++ src/main_grammar.cpp | 13 +- src/markups.cpp | 1 - src/phrase_element_grammar.cpp | 40 ++-- src/post_process.hpp | 2 +- src/quickbook.cpp | 24 +- src/template_stack.cpp | 5 +- src/template_stack.hpp | 20 +- src/utils.cpp | 6 +- src/values.hpp | 40 ++-- test/Jamfile.v2 | 1 + test/anchor.gold | 10 +- test/blocks.gold | 10 +- test/callouts.gold | 32 +-- test/code-block.gold | 2 +- test/doc-info/duplicates-1.1.gold | 2 +- test/doc-info/duplicates-1.5.gold | 2 +- test/doc-info/source-mode-1.4.gold | 2 +- test/doc-info/source-mode-1.5.gold | 2 +- test/doc-info/source-mode-1.6.gold | 2 +- test/escape.gold | 9 + test/escape.quickbook | 13 ++ test/heading.gold | 6 +- test/heading_1_6.gold | 6 +- test/identifier_1_5.gold | 2 +- test/identifier_1_6.gold | 2 +- test/list_test.gold | 2 +- test/quickbook-manual.gold | 66 +++--- test/table_1_3.gold | 350 +++++++++++++++++++++++++++++ test/table_1_3.quickbook | 113 ++++++++++ test/table_1_3.xml | 350 +++++++++++++++++++++++++++++ test/table_1_5.gold | 115 ++++++++++ test/table_1_5.quickbook | 32 +++ test/template-section.gold | 2 +- test/unicode-escape.gold | 2 +- test/unit/Jamfile.v2 | 2 +- test/utf-8-bom.gold | 2 +- test/utf-8.gold | 2 +- test/xml-escape_1_2.gold | 2 +- test/xml-escape_1_5.gold | 2 +- 49 files changed, 1699 insertions(+), 218 deletions(-) create mode 100644 src/id_generator.cpp create mode 100644 src/id_generator.hpp create mode 100644 test/table_1_3.gold create mode 100644 test/table_1_3.quickbook create mode 100644 test/table_1_3.xml diff --git a/Jamfile.v2 b/Jamfile.v2 index 0df2fa9..64a0ab0 100644 --- a/Jamfile.v2 +++ b/Jamfile.v2 @@ -33,3 +33,13 @@ install dist-lib : release ; + +# Target for quickbook toolset's auto build. + +alias quickbook-auto + : quickbook + : release + ; + +explicit quickbook-auto + ; diff --git a/src/Jamfile.v2 b/src/Jamfile.v2 index 736c19f..7b6460c 100644 --- a/src/Jamfile.v2 +++ b/src/Jamfile.v2 @@ -28,6 +28,7 @@ exe quickbook utils.cpp input_path.cpp values.cpp + id_generator.cpp post_process.cpp collector.cpp template_stack.cpp diff --git a/src/actions.cpp b/src/actions.cpp index 76f4d07..00ef141 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -29,6 +29,7 @@ #include "input_path.hpp" #include "block_tags.hpp" #include "phrase_tags.hpp" +#include "id_generator.hpp" namespace quickbook { @@ -58,12 +59,23 @@ namespace quickbook it != end; ++it) { tgt << ""; } actions.anchors.clear(); - } + } + + std::string add_anchor(quickbook::actions& actions, + std::string const& id, + id_generator::categories category = id_generator::explicit_id) + { + std::string placeholder = actions.ids.add(id, category); + actions.anchors.push_back(placeholder); + return placeholder; + } } void list_action(quickbook::actions&, value); @@ -84,6 +96,7 @@ namespace quickbook void anchor_action(quickbook::actions&, value); void link_action(quickbook::actions&, value); void phrase_action(quickbook::actions&, value); + void footnote_action(quickbook::actions&, value); void raw_phrase_action(quickbook::actions&, value); void source_mode_action(quickbook::actions&, value); void do_template_action(quickbook::actions&, value, file_position); @@ -161,8 +174,9 @@ namespace quickbook case phrase_tags::strikethrough: case phrase_tags::quote: case phrase_tags::replaceable: - case phrase_tags::footnote: return phrase_action(actions, v); + case phrase_tags::footnote: + return footnote_action(actions, v); case phrase_tags::escape: return raw_phrase_action(actions, v); case source_mode_tags::cpp: @@ -258,6 +272,21 @@ namespace quickbook values.finish(); } + void footnote_action(quickbook::actions& actions, value phrase) + { + if (actions.suppress) return; + write_anchors(actions, actions.phrase); + + value_consumer values = phrase; + actions.phrase + << "" + << values.consume().get_boostbook() + << ""; + values.finish(); + } + void raw_phrase_action(quickbook::actions& actions, value phrase) { if (actions.suppress) return; @@ -329,16 +358,22 @@ namespace quickbook level = heading_list.get_tag() - block_tags::heading1 + 1; } - std::string anchor; std::string linkend; if (!generic && qbk_version_n < 103) // version 1.2 and below { - anchor = actions.section_id + '.' + - detail::make_identifier(content.get_boostbook()); + add_anchor(actions, + actions.section_id + '.' + + detail::make_identifier(content.get_boostbook()), + id_generator::generated); } else { + id_generator::categories category = + !element_id.empty() ? + id_generator::explicit_id : + id_generator::generated; + std::string id = !element_id.empty() ? element_id.get_quickbook() : @@ -348,15 +383,20 @@ namespace quickbook content.get_boostbook() ); - linkend = anchor = - fully_qualified_id(actions.doc_id, actions.qualified_section_id, id); + linkend = add_anchor(actions, + fully_qualified_id(actions.doc_id, + actions.qualified_section_id, id), + category); } - actions.anchors.push_back(anchor); - write_anchors(actions, actions.out); - + write_anchors(actions, actions.out); write_bridgehead(actions.out, level, - content.get_boostbook(), anchor + "-heading", linkend); + content.get_boostbook(), + actions.ids.add( + fully_qualified_id(actions.doc_id, + actions.qualified_section_id, "h"), + id_generator::numbered), + linkend); } void simple_phrase_action::operator()(char mark) const @@ -558,7 +598,7 @@ namespace quickbook if(actions.suppress) return; value_consumer values = anchor; - actions.anchors.push_back(values.consume().get_quickbook()); + add_anchor(actions, values.consume().get_quickbook()); values.finish(); } @@ -1070,8 +1110,7 @@ namespace quickbook while (arg != args.end()) { if (!actions.templates.add( - template_symbol(*tpl, empty_params, arg->content, - arg->filename, &scope))) + template_symbol(*tpl, empty_params, *arg, &scope))) { detail::outerr(actions.filename, pos.line) << "Duplicate Symbol Found" << std::endl; @@ -1096,7 +1135,8 @@ namespace quickbook // // Note: this is now done in the grammar. - if (escape) + // TODO: For escape, should this be surrounded in escape comments? + if (body.type == template_body::raw_output || escape) { // escape the body of the template // we just copy out the literal body @@ -1131,11 +1171,6 @@ namespace quickbook } } - namespace detail - { - int callout_id = 0; - } - void do_template_action(quickbook::actions& actions, value template_list, file_position pos) { @@ -1149,6 +1184,7 @@ namespace quickbook std::string identifier = values.consume(template_tags::identifier).get_quickbook(); + std::vector callout_ids; std::vector args; BOOST_FOREACH(value arg, values) @@ -1225,18 +1261,25 @@ namespace quickbook for(unsigned int i = 0; i < size; ++i) { - std::string callout_id = actions.doc_id + - boost::lexical_cast(detail::callout_id + i); + std::string callout_id1 = + actions.ids.add( + actions.doc_id + ".c", + id_generator::numbered); + std::string callout_id2 = + actions.ids.add( + actions.doc_id + ".c", + id_generator::numbered); std::string code; - code += "'''"; - code += ""; - code += "'''"; + code += ""; + // TODO: This isn't a qbk_value... args.push_back(template_body( qbk_value(code, pos, template_tags::phrase), - actions.filename)); + actions.filename, template_body::raw_output)); + callout_ids.push_back(callout_id1); + callout_ids.push_back(callout_id2); } } @@ -1294,10 +1337,11 @@ namespace quickbook { BOOST_ASSERT(phrase.empty()); block += ""; + int i = 0; BOOST_FOREACH(value c, symbol->callouts) { - std::string callout_id = actions.doc_id + - boost::lexical_cast(detail::callout_id++); + std::string callout_id1 = callout_ids[i++]; + std::string callout_id2 = callout_ids[i++]; std::string callout_value; actions.push(); @@ -1319,8 +1363,8 @@ namespace quickbook return; } - block += ""; + block += ""; block += callout_value; block += ""; } @@ -1417,15 +1461,26 @@ namespace quickbook std::string table_id; if(qbk_version_n >= 105) { if(!element_id.empty()) { - table_id = fully_qualified_id(actions.doc_id, - actions.qualified_section_id, element_id); + table_id = actions.ids.add( + fully_qualified_id(actions.doc_id, + actions.qualified_section_id, element_id), + id_generator::explicit_id); } else if(has_title) { - table_id = fully_qualified_id(actions.doc_id, - actions.qualified_section_id, - detail::make_identifier(title)); + table_id = actions.ids.add( + fully_qualified_id(actions.doc_id, + actions.qualified_section_id, + detail::make_identifier(title)), + id_generator::generated); } } + else if (has_title) + { + table_id = actions.ids.add( + fully_qualified_id(actions.doc_id, + actions.qualified_section_id, "t"), + id_generator::numbered); + } // Emulating the old behaviour which used the width of the final // row for span_count. @@ -1515,23 +1570,18 @@ namespace quickbook actions.qualified_section_id += actions.section_id; ++actions.section_level; - actions::string_list saved_anchors; - saved_anchors.swap(actions.anchors); - - if (qbk_version_n < 103) // version 1.2 and below - { - actions.out << "\n
\n"; - } - else // version 1.3 and above - { - actions.out << "\n
\n"; - } + // TODO: This could be awkward if there's a clash, possibly + // needs another category, between explicit and generated. + std::string full_id = actions.ids.add( + qbk_version_n < 103 ? + actions.doc_id + "." + actions.section_id : + actions.doc_id + "." + actions.qualified_section_id, + !element_id.empty() ? + id_generator::explicit_id : + id_generator::generated); + actions.out << "\n
\n"; actions.out << ""; - - actions.anchors.swap(saved_anchors); write_anchors(actions, actions.out); if (qbk_version_n < 103) // version 1.2 and below @@ -1540,8 +1590,7 @@ namespace quickbook } else // version 1.3 and above { - actions.out << "<link linkend=\"" << actions.doc_id - << "." << actions.qualified_section_id << "\">" + actions.out << "<link linkend=\"" << full_id << "\">" << content.get_boostbook() << "</link>" ; diff --git a/src/actions_class.cpp b/src/actions_class.cpp index e1fcc12..b3b09a9 100644 --- a/src/actions_class.cpp +++ b/src/actions_class.cpp @@ -19,7 +19,8 @@ namespace quickbook { - actions::actions(fs::path const& filein_, fs::path const& xinclude_base_, string_stream& out_) + actions::actions(fs::path const& filein_, fs::path const& xinclude_base_, + string_stream& out_, id_generator& ids) : grammar_() // header info @@ -62,6 +63,8 @@ namespace quickbook , no_eols(true) , suppress(false) , warned_about_breaks(false) + , context(0) + , ids(ids) // actions , element(*this) diff --git a/src/actions_class.hpp b/src/actions_class.hpp index 1414c7f..ccaba00 100644 --- a/src/actions_class.hpp +++ b/src/actions_class.hpp @@ -24,7 +24,8 @@ namespace quickbook struct actions { - actions(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_); + actions(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_, + id_generator&); private: boost::scoped_ptr<quickbook_grammar> grammar_; @@ -101,6 +102,7 @@ namespace quickbook bool suppress; bool warned_about_breaks; int context; + id_generator& ids; // push/pop the states and the streams void copy_macros_for_write(); diff --git a/src/block_element_grammar.cpp b/src/block_element_grammar.cpp index 6732979..8bbddfc 100644 --- a/src/block_element_grammar.cpp +++ b/src/block_element_grammar.cpp @@ -34,7 +34,8 @@ namespace quickbook xinclude, include, template_, template_id, template_formal_arg, template_body, identifier, import, - element_id, element_id_1_5, element_id_1_6; + element_id, element_id_1_5, element_id_1_6, + same_line; }; void quickbook_grammar::impl::init_block_elements() @@ -44,7 +45,7 @@ namespace quickbook local.element_id = !( ':' - >> ( cl::if_p(qbk_since(105u)) [space] + >> ( !(cl::eps_p(qbk_since(105u)) >> space) >> (+(cl::alnum_p | '_')) [actions.values.entry(ph::arg1, ph::arg2, general_tags::element_id)] | cl::eps_p [actions.element_id_warning] ) @@ -52,16 +53,10 @@ namespace quickbook ; local.element_id_1_5 = - cl::if_p(qbk_since(105u)) [ - local.element_id - ] - ; + !(cl::eps_p(qbk_since(105u)) >> local.element_id); local.element_id_1_6 = - cl::if_p(qbk_since(106u)) [ - local.element_id - ] - ; + !(cl::eps_p(qbk_since(106u)) >> local.element_id); elements.add ("section", element_info(element_info::block, &local.begin_section, block_tags::begin_section)) @@ -208,10 +203,12 @@ namespace quickbook ("table", element_info(element_info::nested_block, &local.table, block_tags::table)) ; + local.same_line = *cl::blank_p >> !(comment >> space); + local.table = - (cl::eps_p(*cl::blank_p >> cl::eol_p) | space) + local.same_line >> local.element_id_1_5 - >> (cl::eps_p(*cl::blank_p >> cl::eol_p) | space) + >> local.same_line >> (*(cl::anychar_p - eol)) [actions.values.entry(ph::arg1, ph::arg2, table_tags::title)] >> (+eol) >> *local.table_row diff --git a/src/doc_info_actions.cpp b/src/doc_info_actions.cpp index 97b5c58..fca9bca 100644 --- a/src/doc_info_actions.cpp +++ b/src/doc_info_actions.cpp @@ -17,6 +17,7 @@ #include "input_path.hpp" #include "actions_class.hpp" #include "doc_info_tags.hpp" +#include "id_generator.hpp" namespace quickbook { @@ -232,7 +233,7 @@ namespace quickbook << " \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">\n" << '<' << actions.doc_type << "\n" << " id=\"" - << actions.doc_id + << actions.ids.add(actions.doc_id, id_generator::explicit_id) << "\"\n"; if(!lang.empty()) @@ -325,7 +326,10 @@ namespace quickbook if (!license.empty()) { - tmp << " <legalnotice>\n" + tmp << " <legalnotice id=\"" + << actions.ids.add(actions.doc_id + ".legal", + id_generator::generated) + << "\">\n" << " <para>\n" << " " << doc_info_output(license, 103) << "\n" << " </para>\n" diff --git a/src/fwd.hpp b/src/fwd.hpp index 60d246d..1b63611 100644 --- a/src/fwd.hpp +++ b/src/fwd.hpp @@ -18,6 +18,7 @@ namespace quickbook struct actions; struct quickbook_grammar; struct collector; + struct id_generator; typedef position_iterator<std::string::const_iterator> iterator; diff --git a/src/id_generator.cpp b/src/id_generator.cpp new file mode 100644 index 0000000..473f6b1 --- /dev/null +++ b/src/id_generator.cpp @@ -0,0 +1,344 @@ +/*============================================================================= + Copyright (c) 2011 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include "id_generator.hpp" +#include "markups.hpp" +#include "phrase_tags.hpp" +#include <boost/lexical_cast.hpp> +#include <algorithm> +#include <vector> + +namespace quickbook +{ + // string_ref + + struct string_ref + { + public: + typedef std::string::const_iterator iterator; + + private: + iterator begin_, end_; + + public: + string_ref() : begin_(), end_() {} + + explicit string_ref(iterator b, iterator e) + : begin_(b), end_(e) {} + + explicit string_ref(std::string const& x) + : begin_(x.begin()), end_(x.end()) {} + + iterator begin() const { return begin_; } + iterator end() const { return end_; } + + std::size_t size() const + { + return static_cast<std::size_t>(end_ - begin_); + } + }; + + bool operator==(string_ref const& x, string_ref const& y); + bool operator<(string_ref const& x, string_ref const& y); + + inline bool operator==(string_ref const& x, std::string const& y) + { + return x == string_ref(y); + } + + inline bool operator==(std::string const& x, string_ref const& y) + { + return string_ref(x) == y; + } + + inline bool operator<(string_ref const& x, std::string const& y) + { + return x < string_ref(y); + } + + inline bool operator<(std::string const& x, string_ref const& y) + { + return string_ref(x) < y; + } + + bool operator==(string_ref const& x, string_ref const& y) + { + return x.size() == y.size() && + std::equal(x.begin(), x.end(), y.begin()); + } + + bool operator<(string_ref const& x, string_ref const& y) + { + return std::lexicographical_compare( + x.begin(), x.end(), y.begin(), y.end()); + } + + // id_generator + + struct id_generator::id + { + id() + : category(id_generator::default_category), + used(false), + count(0) {} + + id_generator::categories category; + + // These are updated when generating ids + bool used; + int count; + }; + + id_generator::id_generator() + { + } + + id_generator::~id_generator() + { + } + + std::string id_generator::add( + std::string const& value, + id_generator::categories category) + { + std::string result; + id_generator::id& id = ids_[value]; + + // Doesn't check if explicit ids collide, could probably be a warning. + if (category == explicit_id) + { + id.category = category; + id.used = true; + result = value; + } + else + { + if (category < id.category) id.category = category; + + // '$' can't appear in quickbook ids, so use it indicate a + // placeholder id. + result = "$" + + boost::lexical_cast<std::string>(placeholders_.size()); + placeholders_.push_back( + id_generator::placeholder(category, *ids_.find(value))); + } + + return result; + } + + string_ref id_generator::get(string_ref value) + { + // If this isn't a placeholder id. + if (value.size() <= 1 || *value.begin() != '$') + return value; + + id_generator::placeholder& placeholder = placeholders_.at( + boost::lexical_cast<int>(std::string( + value.begin() + 1, value.end()))); + + if (placeholder.final_id.empty()) + { + if (placeholder.category < id_generator::numbered && + !placeholder.id.second.used && + placeholder.id.second.category == placeholder.category) + { + placeholder.id.second.used = true; + placeholder.final_id = placeholder.id.first; + } + else while(true) + { + int count = placeholder.id.second.count++; + placeholder.final_id = placeholder.id.first + + boost::lexical_cast<std::string>(count); + // TODO: Should add final_id to ids_, there are some + // edges cases where it could collide. + if (ids_.find(placeholder.final_id) == ids_.end()) + break; + } + } + + return string_ref(placeholder.final_id); + } + + // Very simple xml subset parser which replaces id values. + // + // I originally tried to integrate this into the post processor + // but that proved tricky. Alternatively it could use a proper + // xml parser, but I want this to be able to survive badly + // marked up escapes. + + struct xml_processor + { + xml_processor(); + + std::string escape_prefix; + std::string escape_postfix; + std::string processing_instruction_postfix; + std::string comment_postfix; + std::string whitespace; + std::string tag_end; + std::string name_end; + std::string attribute_assign; + std::vector<std::string> id_attributes; + + std::string replace(std::string const&, id_generator&); + }; + + std::string id_generator::replace_placeholders(std::string const& source) + { + xml_processor processor; + return processor.replace(source, *this); + } + + namespace + { + char const* id_attributes_[] = + { + "id", + "linkend", + "linkends", + "arearefs" + }; + } + + xml_processor::xml_processor() + : escape_prefix("<!--quickbook-escape-prefix-->") + , escape_postfix("<!--quickbook-escape-postfix-->") + , processing_instruction_postfix("?>") + , comment_postfix("-->") + , whitespace(" \t\n\r") + , tag_end(" \t\n\r>") + , name_end("= \t\n\r>") + , attribute_assign("= \t\n\r") + { + static int const n_id_attributes = sizeof(id_attributes_)/sizeof(char const*); + for (int i = 0; i != n_id_attributes; ++i) + { + id_attributes.push_back(id_attributes_[i]); + } + + std::sort(id_attributes.begin(), id_attributes.end()); + } + + std::string xml_processor::replace(std::string const& source, id_generator& ids) + { + std::string result; + + typedef std::string::const_iterator iterator; + + // copied is the point up to which the source has been copied, or + // replaced, to result. + iterator copied = source.begin(); + + iterator end = source.end(); + + for(iterator it = copied; it != end; it = std::find(it, end, '<')) + { + assert(copied <= it && it <= end); + + if (static_cast<std::size_t>(end - it) > escape_prefix.size() && + std::equal(escape_prefix.begin(), escape_prefix.end(), it)) + { + it = std::search(it + escape_prefix.size(), end, + escape_postfix.begin(), escape_postfix.end()); + + if (it == end) break; + + it += escape_postfix.size(); + continue; + } + + ++it; + if (it == end) break; + + switch(*it) + { + case '?': + it = std::search(it, end, + processing_instruction_postfix.begin(), + processing_instruction_postfix.end()); + break; + + case '!': + if (end - it > 3 && it[1] == '-' && it[2] == '-') + { + it = std::search(it + 3, end, + comment_postfix. begin(), comment_postfix.end()); + if (it != end) it += comment_postfix.size(); + } + else + { + it = std::find(it, end, '>'); + } + break; + + default: + if ((*it >= 'a' && *it <= 'z') || + (*it >= 'A' && *it <= 'Z') || + *it == '_' || *it == ':') + { + it = std::find_first_of( + it + 1, end, tag_end.begin(), tag_end.end()); + + while (true) { + while(it != end && + std::find(whitespace.begin(), + whitespace.end(), *it) + != whitespace.end()) + ++it; + + iterator name_start = it; + + it = std::find_first_of( + it, end, name_end.begin(), name_end.end()); + + if (it == end || *it == '>') break; + + string_ref name(name_start, it); + ++it; + + while (it != end && + std::find(attribute_assign.begin(), + attribute_assign.end(), *it) + != attribute_assign.end()) + ++it; + + if (it == end || (*it != '"' && *it != '\'')) break; + + char delim = *it; + ++it; + + iterator value_start = it; + + it = std::find(it, end, delim); + string_ref value(value_start, it); + if (it == end) break; + ++it; + + if (std::find(id_attributes.begin(), id_attributes.end(), + name) + != id_attributes.end()) + { + result.append(copied, value.begin()); + string_ref x = ids.get(value); + result.append(x.begin(), x.end()); + copied = value.end(); + } + } + } + else + { + it = std::find(it, end, '>'); + } + } + } + + result.append(copied, source.end()); + return result; + } +} diff --git a/src/id_generator.hpp b/src/id_generator.hpp new file mode 100644 index 0000000..f57d1a3 --- /dev/null +++ b/src/id_generator.hpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2011 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#if !defined(BOOST_QUICKBOOK_ID_GENERATOR_HPP) +#define BOOST_QUICKBOOK_ID_GENERATOR_HPP + +#include "fwd.hpp" +#include <boost/unordered/unordered_map.hpp> +#include <deque> +#include <string> + +namespace quickbook +{ + struct string_ref; + + struct id_generator + { + public: + + enum categories + { + explicit_id = 0, // Explicitly given by user + generated, // Generated from source, e.g. table title + numbered, // Just used to avoid random docbook ids + default_category + }; + + private: + + struct id; + typedef boost::unordered_map<std::string, id> placeholder_map; + + struct placeholder + { + typedef std::pair<std::string const, id_generator::id> id_pair; + + placeholder(id_generator::categories category, id_pair& id) + : category(category), + id(id), + final_id() {} + + id_generator::categories category; + id_pair& id; + std::string final_id; // Set in the second pass. + }; + + placeholder_map ids_; + std::deque<placeholder> placeholders_; + + public: + id_generator(); + ~id_generator(); + + std::string add(std::string const& id, categories priority); + + std::string replace_placeholders(std::string const&); + string_ref get(string_ref placeholder); + + private: + id_generator(id_generator const&); + id_generator& operator=(id_generator const&); + }; +} + +#endif \ No newline at end of file diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index 098abb0..215f4b1 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -145,9 +145,7 @@ namespace quickbook actions.scoped_context(element_info::in_block) [ local.blocks >> *( local.element - >> cl::if_p(local.is_block) - [ !(+eol >> local.blocks) - ] + >> !(cl::eps_p(local.is_block) >> +eol >> local.blocks) | local.paragraph_separator >> local.blocks | common | cl::space_p [actions.space_char] @@ -281,11 +279,10 @@ namespace quickbook ; local.template_args = - cl::if_p(qbk_since(105u)) [ - local.template_args_1_5 - ].else_p [ - local.template_args_1_4 - ] + cl::eps_p(qbk_since(105u)) + >> local.template_args_1_5 + | cl::eps_p(qbk_before(105u)) + >> local.template_args_1_4 ; local.template_args_1_4 = local.template_arg_1_4 >> *(".." >> local.template_arg_1_4); diff --git a/src/markups.cpp b/src/markups.cpp index c12e731..a10ba2c 100644 --- a/src/markups.cpp +++ b/src/markups.cpp @@ -54,7 +54,6 @@ namespace quickbook { phrase_tags::strikethrough, "<emphasis role=\"strikethrough\">", "</emphasis>" }, { phrase_tags::quote, "<quote>", "</quote>" }, { phrase_tags::replaceable, "<replaceable>", "</replaceable>" }, - { phrase_tags::footnote, "<footnote><para>", "</para></footnote>" }, { phrase_tags::escape, "<!--quickbook-escape-prefix-->", "<!--quickbook-escape-postfix-->" }, { phrase_tags::break_mark, "<sbr/>\n", 0 } }; diff --git a/src/phrase_element_grammar.cpp b/src/phrase_element_grammar.cpp index ab5de65..b2e4821 100644 --- a/src/phrase_element_grammar.cpp +++ b/src/phrase_element_grammar.cpp @@ -51,28 +51,28 @@ namespace quickbook ; local.image = - blank - >> cl::if_p(qbk_since(105u)) [ - (+( - *cl::space_p - >> +(cl::anychar_p - (cl::space_p | phrase_end | '[')) - )) [actions.values.entry(ph::arg1, ph::arg2)] - >> hard_space - >> *actions.values.list() - [ '[' - >> (*(cl::alnum_p | '_')) - [actions.values.entry(ph::arg1, ph::arg2)] - >> space - >> (*(cl::anychar_p - (phrase_end | '['))) - [actions.values.entry(ph::arg1, ph::arg2)] - >> ']' - >> space - ] - ].else_p [ - (*(cl::anychar_p - phrase_end)) - [actions.values.entry(ph::arg1, ph::arg2)] + cl::eps_p(qbk_since(105u)) + >> blank + >> (+( + *cl::space_p + >> +(cl::anychar_p - (cl::space_p | phrase_end | '[')) + )) [actions.values.entry(ph::arg1, ph::arg2)] + >> hard_space + >> *actions.values.list() + [ '[' + >> (*(cl::alnum_p | '_')) + [actions.values.entry(ph::arg1, ph::arg2)] + >> space + >> (*(cl::anychar_p - (phrase_end | '['))) + [actions.values.entry(ph::arg1, ph::arg2)] + >> ']' + >> space ] >> cl::eps_p(']') + | cl::eps_p(qbk_before(105u)) + >> blank + >> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)] + >> cl::eps_p(']') ; elements.add diff --git a/src/post_process.hpp b/src/post_process.hpp index 75b6b9a..81f282b 100644 --- a/src/post_process.hpp +++ b/src/post_process.hpp @@ -19,7 +19,7 @@ namespace quickbook , int indent = -1 , int linewidth = -1); - class post_process_failure : public std::runtime_error + struct post_process_failure : public std::runtime_error { public: explicit post_process_failure(std::string const& error) diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 2be1d9a..73c311c 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -13,6 +13,7 @@ #include "post_process.hpp" #include "utils.hpp" #include "input_path.hpp" +#include "id_generator.hpp" #include <boost/program_options.hpp> #include <boost/filesystem/v3/path.hpp> #include <boost/filesystem/v3/operations.hpp> @@ -112,12 +113,8 @@ namespace quickbook static int parse_document( fs::path const& filein_, - fs::path const& xinclude_base, - string_stream& out) - { - actions actor(filein_, xinclude_base, out); - - set_macros(actor); + actions& actor) + { bool r = parse_file(filein_, actor); if (actor.section_level != 0) detail::outwarn(filein_) @@ -142,9 +139,14 @@ namespace quickbook , int linewidth , bool pretty_print) { - int result = 0; string_stream buffer; - result = parse_document(filein_, xinclude_base_, buffer); + id_generator ids; + actions actor(filein_, xinclude_base_, buffer, ids); + set_macros(actor); + + int result = parse_document(filein_, actor); + + std::string stage2 = ids.replace_placeholders(buffer.str()); if (result == 0) { @@ -154,7 +156,7 @@ namespace quickbook { try { - fileout << post_process(buffer.str(), indent, linewidth); + fileout << post_process(stage2, indent, linewidth); } catch (quickbook::post_process_failure&) { @@ -162,13 +164,13 @@ namespace quickbook ::quickbook::detail::outerr() << "Post Processing Failed." << std::endl; - fileout << buffer.str(); + fileout << stage2; return 1; } } else { - fileout << buffer.str(); + fileout << stage2; } } return result; diff --git a/src/template_stack.cpp b/src/template_stack.cpp index a2059c3..e6d916a 100644 --- a/src/template_stack.cpp +++ b/src/template_stack.cpp @@ -18,10 +18,12 @@ namespace quickbook { template_body::template_body( value const& content, - fs::path const& filename + fs::path const& filename, + content_type type ) : content(content) , filename(filename) + , type(type) { assert(content.get_tag() == template_tags::block || content.get_tag() == template_tags::phrase); @@ -32,7 +34,6 @@ namespace quickbook return content.get_tag() == template_tags::block; } - template_stack::template_stack() : scope(template_stack::parser(*this)) , scopes() diff --git a/src/template_stack.hpp b/src/template_stack.hpp index c053c71..eedee15 100644 --- a/src/template_stack.hpp +++ b/src/template_stack.hpp @@ -28,11 +28,18 @@ namespace quickbook struct template_body { - template_body(value const&, fs::path const&); + enum content_type + { + quickbook, + raw_output + }; + + template_body(value const&, fs::path const&, content_type = quickbook); bool is_block() const; stored_value content; fs::path filename; + content_type type; }; struct template_scope; @@ -40,6 +47,17 @@ namespace quickbook struct template_symbol { template_symbol( + std::string const& identifier, + std::vector<std::string> const& params, + template_body const& body, + template_scope const* parent = 0) + : identifier(identifier) + , params(params) + , body(body) + , parent(parent) + , callouts() {} + + template_symbol( std::string const& identifier, std::vector<std::string> const& params, value const& content, diff --git a/src/utils.cpp b/src/utils.cpp index bf8f064..ee60276 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -139,7 +139,7 @@ namespace quickbook { namespace detail // Although, given how UTF-8 works, if we've read anything in, the files // probably broken. - template <class InputIterator, class OutputIterator> + template <typename InputIterator, typename OutputIterator> bool check_bom(InputIterator& begin, InputIterator end, OutputIterator out, char const* chars, int length) { @@ -158,7 +158,7 @@ namespace quickbook { namespace detail return false; } - template <class InputIterator, class OutputIterator> + template <typename InputIterator, typename OutputIterator> std::string read_bom(InputIterator& begin, InputIterator end, OutputIterator out) { @@ -189,7 +189,7 @@ namespace quickbook { namespace detail // Copy a string, converting mac and windows style newlines to unix // newlines. - template <class InputIterator, class OutputIterator> + template <typename InputIterator, typename OutputIterator> bool normalize(InputIterator begin, InputIterator end, OutputIterator out, fs::path const& filename) { diff --git a/src/values.hpp b/src/values.hpp index 3becb36..e24c98e 100644 --- a/src/values.hpp +++ b/src/values.hpp @@ -22,17 +22,17 @@ namespace quickbook { - class value; - class stored_value; - class value_builder; - class value_error; + struct value; + struct stored_value; + struct value_builder; + struct value_error; namespace detail { //////////////////////////////////////////////////////////////////////// // Node - class value_node + struct value_node { private: value_node(value_node const&); @@ -81,10 +81,10 @@ namespace quickbook // This defines most of the public methods for value. // 'begin' and 'end' are defined with the iterators later. - class value_base + struct value_base { public: - class iterator; + struct iterator; typedef iterator const_iterator; typedef value_node::tag_type tag_type; @@ -133,20 +133,20 @@ namespace quickbook // value_builder needs to access 'value_' to get the node // from a value. - friend class quickbook::value_builder; - friend class quickbook::stored_value; + friend struct quickbook::value_builder; + friend struct quickbook::stored_value; }; //////////////////////////////////////////////////////////////////////// // Reference and proxy values for use in iterators - class value_ref : public value_base + struct value_ref : public value_base { public: explicit value_ref(value_node* base) : value_base(base) {} }; - class value_proxy : public value_base + struct value_proxy : public value_base { public: explicit value_proxy(value_node* base) : value_base(base) {} @@ -157,7 +157,7 @@ namespace quickbook //////////////////////////////////////////////////////////////////////// // Iterators - class value_base::iterator + struct value_base::iterator : public boost::forward_iterator_helper< iterator, value, int, value_proxy, value_ref> { @@ -186,7 +186,7 @@ namespace quickbook //////////////////////////////////////////////////////////////////////// // Reference counting for values - class value_counted : public value_base + struct value_counted : public value_base { value_counted& operator=(value_counted const&); protected: @@ -203,7 +203,7 @@ namespace quickbook // Values are immutable, so this class is used to build a list of // value nodes before constructing the value. - class value_list_builder { + struct value_list_builder { value_list_builder(value_list_builder const&); value_list_builder& operator=(value_list_builder const&); public: @@ -226,7 +226,7 @@ namespace quickbook // // Most of the methods are in value_base. - class value : public detail::value_counted + struct value : public detail::value_counted { public: value(); @@ -237,7 +237,7 @@ namespace quickbook void swap(value& x) { detail::value_counted::swap(x); } }; - class stored_value : public detail::value_counted + struct stored_value : public detail::value_counted { public: stored_value(); @@ -269,7 +269,7 @@ namespace quickbook // // Used to incrementally build a valueeter tree. - class value_builder { + struct value_builder { public: value_builder(); void swap(value_builder& b); @@ -299,7 +299,7 @@ namespace quickbook // Value Error // - class value_error : public std::logic_error + struct value_error : public std::logic_error { public: explicit value_error(std::string const&); @@ -310,9 +310,9 @@ namespace quickbook // // Convenience class for unpacking value values. - class value_consumer { + struct value_consumer { public: - class iterator + struct iterator : public boost::input_iterator_helper<iterator, boost::iterator_value<value::iterator>::type, boost::iterator_difference<value::iterator>::type, diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 86c8c4d..733b541 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -52,6 +52,7 @@ test-suite quickbook.test : [ quickbook-test identifier_1_6 ] [ quickbook-test para-test ] [ quickbook-test variablelist ] + [ quickbook-test table_1_3 ] [ quickbook-test table_1_5 ] [ quickbook-test image_1_5 ] [ quickbook-test list_test ] diff --git a/test/anchor.gold b/test/anchor.gold index 03f35ce..18ef867 100644 --- a/test/anchor.gold +++ b/test/anchor.gold @@ -10,25 +10,25 @@ want to make sure they appear in the correct place. <anchor id="a3"/> </para> <anchor id="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor"/> - <bridgehead renderas="sect3" id="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor-heading"> + <bridgehead renderas="sect3" id="anchor_test.anchors.h0"> <link linkend="anchor_test.anchors.this_heading_shouldn_t_pick_up_the_previous_anchor">This heading shouldn't pick up the previous anchor</link> </bridgehead> <anchor id="a4"/><anchor id="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor"/> - <bridgehead renderas="sect3" id="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor-heading"> + <bridgehead renderas="sect3" id="anchor_test.anchors.h1"> <link linkend="anchor_test.anchors.this_heading_should_pick_up_the_previous_anchor">This heading should pick up the previous anchor</link> </bridgehead> <anchor id="a5"/><anchor id="anchor_test.anchors.and_this_one"/> - <bridgehead renderas="sect3" id="anchor_test.anchors.and_this_one-heading"> + <bridgehead renderas="sect3" id="anchor_test.anchors.h2"> <link linkend="anchor_test.anchors.and_this_one">And this one</link> </bridgehead> <anchor id="a6"/><anchor id="anchor_test.anchors.also_this_one"/> - <bridgehead renderas="sect3" id="anchor_test.anchors.also_this_one-heading"> + <bridgehead renderas="sect3" id="anchor_test.anchors.h3"> <link linkend="anchor_test.anchors.also_this_one">Also this one</link> </bridgehead> <anchor id="a7"/><anchor id="anchors.finally_this"/> - <bridgehead renderas="sect3" id="anchors.finally_this-heading"> + <bridgehead renderas="sect3" id="anchor_test.anchors.h4"> Finally this </bridgehead> <anchor id="a8"/> diff --git a/test/blocks.gold b/test/blocks.gold index c01de12..cae4d70 100644 --- a/test/blocks.gold +++ b/test/blocks.gold @@ -3,7 +3,7 @@ <article id="various_blocks" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude"> <title>Various blocks - + Blockquotes @@ -26,7 +26,7 @@ - + Admonitions @@ -63,7 +63,7 @@ - + Blurb @@ -71,12 +71,12 @@ Blurb - + Inline blocks
- Blockquote containing a footnote + Blockquote containing a footnote Here it is! diff --git a/test/callouts.gold b/test/callouts.gold index 403c7e0..f816ed0 100644 --- a/test/callouts.gold +++ b/test/callouts.gold @@ -12,13 +12,13 @@ int roll_die() { - boost::uniform_int<> dist(1, 6); + boost::uniform_int<> dist(1, 6); } - + create a uniform_int distribution @@ -30,13 +30,13 @@ int roll_die() { - boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); + boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } - + test @@ -50,13 +50,13 @@ int roll_die() { - boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); + boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } - + test @@ -70,13 +70,13 @@ int roll_die() { - boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); + boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); } - + test @@ -90,24 +90,24 @@ int roll_die() { - boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); -boost::uniform_int<> dist(1, 6); + boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist); +boost::uniform_int<> dist(1, 6); } - + callout 1 - + callout 2 - + create a uniform_int distribution @@ -115,16 +115,16 @@ -boost::uniform_int<> dist(1, 6); +boost::uniform_int<> dist(1, 6); - + callout 2 - + create a uniform_int distribution diff --git a/test/code-block.gold b/test/code-block.gold index b91794a..2f10c0d 100644 --- a/test/code-block.gold +++ b/test/code-block.gold @@ -27,7 +27,7 @@ Code block line 2. Paragraph. - + Code blocks separated by comment diff --git a/test/doc-info/duplicates-1.1.gold b/test/doc-info/duplicates-1.1.gold index 4a14213..7ff1fa4 100644 --- a/test/doc-info/duplicates-1.1.gold +++ b/test/doc-info/duplicates-1.1.gold @@ -17,7 +17,7 @@ 1963 Jane Doe - + Public Domain diff --git a/test/doc-info/duplicates-1.5.gold b/test/doc-info/duplicates-1.5.gold index 469c090..71a58a8 100644 --- a/test/doc-info/duplicates-1.5.gold +++ b/test/doc-info/duplicates-1.5.gold @@ -17,7 +17,7 @@ 1963 Jane Doe - + Public Domain diff --git a/test/doc-info/source-mode-1.4.gold b/test/doc-info/source-mode-1.4.gold index 1e104a3..c105559 100644 --- a/test/doc-info/source-mode-1.4.gold +++ b/test/doc-info/source-mode-1.4.gold @@ -3,7 +3,7 @@
C++ test - + def foo(x): diff --git a/test/doc-info/source-mode-1.5.gold b/test/doc-info/source-mode-1.5.gold index cee815a..e10aee2 100644 --- a/test/doc-info/source-mode-1.5.gold +++ b/test/doc-info/source-mode-1.5.gold @@ -3,7 +3,7 @@
C++ test - + def foo(x): diff --git a/test/doc-info/source-mode-1.6.gold b/test/doc-info/source-mode-1.6.gold index 50764b8..05ae525 100644 --- a/test/doc-info/source-mode-1.6.gold +++ b/test/doc-info/source-mode-1.6.gold @@ -3,7 +3,7 @@
C++ test - + def foo(x): diff --git a/test/escape.gold b/test/escape.gold index e08ebe4..7846127 100644 --- a/test/escape.gold +++ b/test/escape.gold @@ -13,5 +13,14 @@ These should be properly encoded: > < " + + This link shouldn't be changed. + + + Some other problematic links: +one, +two, +three. +
diff --git a/test/escape.quickbook b/test/escape.quickbook index 8dae7ed..9cd786f 100644 --- a/test/escape.quickbook +++ b/test/escape.quickbook @@ -11,5 +11,18 @@ This letter '''α''' should have a space either side of it. These should be properly encoded: \> \< \" +[/ The following tests are based on internal knowledge of + how quickbook's id generator works. They make sure it + doesn't mess up escaped docbook. ] + +'''This link shouldn't be changed.''' + +''' +Some other problematic links: +one, +two, +three. +''' + [endsect] diff --git a/test/heading.gold b/test/heading.gold index 7af5adc..f6fc2c3 100644 --- a/test/heading.gold +++ b/test/heading.gold @@ -2,21 +2,21 @@ diff --git a/test/doc-info/source-mode-1.6.gold b/test/doc-info/source-mode-1.6.gold index 05ae525..6e28096 100644 --- a/test/doc-info/source-mode-1.6.gold +++ b/test/doc-info/source-mode-1.6.gold @@ -15,31 +15,24 @@ - This shouldn't be highlighted. - int main() {} - This shouldn't be highlighted. - def foo(): - This shouldn't be highlighted. - This shouldn't be highlighted - This shouldn't be highlighted. diff --git a/test/heading_1_1.gold b/test/heading_1_1.gold index bee638f..b920b37 100644 --- a/test/heading_1_1.gold +++ b/test/heading_1_1.gold @@ -2,13 +2,13 @@
- Heading 1.1 - + Heading 1.1 + First heading
- Section - + Section + Second heading
diff --git a/test/heading_1_3.gold b/test/heading_1_3.gold index f6fc2c3..f883a60 100644 --- a/test/heading_1_3.gold +++ b/test/heading_1_3.gold @@ -1,23 +1,22 @@
diff --git a/test/list_test-1_5.quickbook b/test/list_test-1_5.quickbook index ab78e6f..64b391a 100644 --- a/test/list_test-1_5.quickbook +++ b/test/list_test-1_5.quickbook @@ -98,3 +98,11 @@ Don't end list with comment 2: * Three [endsect] + +[section List immediately following markup 2] +* One +[section Nested section] +* Two +[endsect] + +[endsect] diff --git a/test/list_test-1_6.gold b/test/list_test-1_6.gold index 223509a..f005525 100644 --- a/test/list_test-1_6.gold +++ b/test/list_test-1_6.gold @@ -420,6 +420,28 @@ +
+ <link linkend="list_test.list_immediately_following_mark0">List immediately + following markup 2</link> + + + + One + + + +
+ <link linkend="list_test.list_immediately_following_mark0.nested_section">Nested + section</link> + + + + Two + + + +
+
<link linkend="list_test.paragraphs_in_list_items">Paragraphs in list items</link> @@ -473,4 +495,32 @@
+
+ <link linkend="list_test.indented_code_blocks_in_lists">Indented code + blocks in lists</link> + + + + A +B + + + C + + + + + + D +E + + + + + + F + + + +
diff --git a/test/list_test-1_6.quickbook b/test/list_test-1_6.quickbook index fd01b38..dbba742 100644 --- a/test/list_test-1_6.quickbook +++ b/test/list_test-1_6.quickbook @@ -103,6 +103,13 @@ Don't end list with comment 2: [endsect] +[section List immediately following markup 2] +* One +[section Nested section] +* Two +[endsect] +[endsect] + [section Paragraphs in list items] * A1 @@ -125,4 +132,16 @@ Don't end list with comment 2: D2 -[endsect] \ No newline at end of file +[endsect] + +[section Indented code blocks in lists] + +* A + + B + C +* D + + E +* F +[endsect] From 27e796024a8cef9bd53f457e1e699538e7799513 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 7 Jun 2012 17:59:01 +0000 Subject: [PATCH 79/94] Quickbook: Merge documentation fix + version number for release. [SVN r78850] --- doc/structure.qbk | 1 - src/quickbook.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/structure.qbk b/doc/structure.qbk index 0c76c97..c9a4be9 100644 --- a/doc/structure.qbk +++ b/doc/structure.qbk @@ -7,7 +7,6 @@ [@http://www.boost.org/LICENSE_1_0.txt]) ] -[#quickbook.ref.structure] [chapter Document Structure [quickbook 1.6] [id quickbook.syntax.structure] diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 57fb766..5a359ed 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -38,7 +38,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.5.8 (dev)" +#define QUICKBOOK_VERSION "Quickbook Version 1.5.8" namespace quickbook { From 24474c11caa1926c76992065f515878492fea157 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 21 Jan 2013 07:44:33 +0000 Subject: [PATCH 80/94] Quickbook: Merge old changelog entries from trunk. [SVN r82576] --- doc/change_log.qbk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/change_log.qbk b/doc/change_log.qbk index 96fa45d..fc49b86 100644 --- a/doc/change_log.qbk +++ b/doc/change_log.qbk @@ -248,3 +248,29 @@ Boost 1.46.1: block (`quickbook`, `compatibility-mode`, `source-mode`). * Only add explicit alt text to images. * Don't put 'inline' code blocks inside paragraphs. + +[heading Version 1.5.8 - Boost 1.50] + +* Write dependencies to a file, using `--output-deps` + ([@https://svn.boost.org/trac/boost/ticket/6691 #6691]). +* Fix handling of section tags in lists. +* Fix indented code blocks in lists. +* Fix handling UTF-8 code points in the syntax highlighter. + Was treating each individual byte as a character. + Still doesn't deal with combining code points. +* Internal changes: + * A lot of restructuring. + * Stop using 'v3' filesystem paths and namespaces, it's now + the default version. + * Remove awkward intrusive reference counting implementation, + avoids a gcc internal compiler error + ([@http://svn.boost.org/trac/boost/ticket/6794 #6794]), + but is also a cleaner implementation. +* 1.6 changes: + * Better handling of brackets in link values. + * Improved handling of escaped characters in include paths. +* Starting to develop 1.7: + * Source mode for single entities. + * Callouts in code blocks. + * Escaped docbook in docinfo blocks. + * Starting to implement calling templates from link values. From dbb843095c40539d5fe2fce98a01dec3fcc0d895 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 24 Feb 2013 14:53:38 +0000 Subject: [PATCH 81/94] Merge quickbook to release. - Use `boost::string_ref`. - Improved source map handling, unindent for code blocks. [SVN r83133] --- doc/1_6.qbk | 58 ++++++- doc/change_log.qbk | 9 + src/Jamfile.v2 | 2 +- src/actions.cpp | 52 +++--- src/code_snippet.cpp | 47 +++-- src/dependency_tracker.cpp | 83 +++++++++ src/dependency_tracker.hpp | 37 ++++ src/doc_info_actions.cpp | 8 +- src/files.cpp | 237 +++++++++++++------------ src/files.hpp | 34 ++-- src/fwd.hpp | 3 +- src/id_manager.cpp | 140 +++++++-------- src/id_manager.hpp | 21 +-- src/input_path.cpp | 18 +- src/input_path.hpp | 8 +- src/main_grammar.cpp | 2 +- src/quickbook.cpp | 28 +-- src/state.cpp | 38 ---- src/state.hpp | 8 +- src/string_ref.cpp | 37 ---- src/string_ref.hpp | 89 ---------- src/syntax_highlight.cpp | 4 +- src/utils.cpp | 4 +- src/utils.hpp | 10 +- src/values.cpp | 14 +- src/values.hpp | 6 +- test/unit/Jamfile.v2 | 3 +- test/unit/source_map_test.cpp | 316 ++++++++++++++++++++++++++++++++++ test/unit/values_test.cpp | 6 +- 29 files changed, 843 insertions(+), 479 deletions(-) create mode 100644 src/dependency_tracker.cpp create mode 100644 src/dependency_tracker.hpp delete mode 100644 src/string_ref.cpp delete mode 100644 src/string_ref.hpp create mode 100644 test/unit/source_map_test.cpp diff --git a/doc/1_6.qbk b/doc/1_6.qbk index 89c41f2..e9ce035 100644 --- a/doc/1_6.qbk +++ b/doc/1_6.qbk @@ -235,12 +235,60 @@ if you're totally sure that you will need it. [section:elements New Elements] -New elements in 1.6 (to be documented later): +[section:block `block`] -* `block` -* `ordered_list` -* `itemized_list` -* `role` +`block` is a block element that just marks its contents as a block, +so that they aren't wrapped in paragraph tags. The main use is +for escaped docbook block tags, such as: + + [template chapter[title] [block''''''[title]'''''']] + [template chapterend [block'''''']] + + [chapter An example chapter] + + Content + + [chapterend] + +Without the `block` element, the `chapter` and `chapterend` templates +would be wrapped in paragraph tags. + +[endsect] + +[section:lists `ordered_list` and `itemized_list`] + +These are used as an alternative to the normal wiki-style markup for +lists. They make it easier to nest lists inside other elements, and +nest elements inside lists. The markup is similar to a single level +table: + + [ordered_list [item1][item2]] + +is equivalent to: + + # item1 + # item2 + +[endsect] + +[section:role `role`] + +`role` is a phrase element used to mark up the text in the eventual html +with an a class. For example: + + [role red Text content] + +Will generate the docbook: + + Text content + +Which will generate html along the lines of: + + Text content + +And then you can use css to style this however you wish. + +[endsect] [endsect] diff --git a/doc/change_log.qbk b/doc/change_log.qbk index fc49b86..aacd813 100644 --- a/doc/change_log.qbk +++ b/doc/change_log.qbk @@ -274,3 +274,12 @@ Boost 1.46.1: * Callouts in code blocks. * Escaped docbook in docinfo blocks. * Starting to implement calling templates from link values. + +[heading Version 1.5.9 - Boost 1.54] + +* When code blocks are indented using a mixture of tabs and spaces, + convert indentation to spaces. +* Internal changes: + * Convert to use `boost::string_ref`. + * Clean up the source map implementation (used to get the correct + location for error messages in things like templates and snippets). diff --git a/src/Jamfile.v2 b/src/Jamfile.v2 index 0c55c7a..e699cd9 100644 --- a/src/Jamfile.v2 +++ b/src/Jamfile.v2 @@ -27,9 +27,9 @@ exe quickbook actions.cpp doc_info_actions.cpp state.cpp + dependency_tracker.cpp utils.cpp files.cpp - string_ref.cpp input_path.cpp values.cpp id_manager.cpp diff --git a/src/actions.cpp b/src/actions.cpp index 304663f..fdfa5eb 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -63,7 +63,7 @@ namespace quickbook } std::string add_anchor(quickbook::state& state, - std::string const& id, + boost::string_ref id, id_category::categories category = id_category::explicit_anchor_id) { @@ -474,7 +474,7 @@ namespace quickbook if (saved_conditional) { - string_ref macro1 = values.consume().get_quickbook(); + boost::string_ref macro1 = values.consume().get_quickbook(); std::string macro(macro1.begin(), macro1.end()); state.conditional = find(state.macro, macro.c_str()); @@ -702,7 +702,7 @@ namespace quickbook int code_tag = code_block.get_tag(); value_consumer values = code_block; - string_ref code_value = values.consume().get_quickbook(); + boost::string_ref code_value = values.consume().get_quickbook(); values.finish(); bool inline_code = code_tag == code_tags::inline_code || @@ -710,7 +710,7 @@ namespace quickbook bool block = code_tag != code_tags::inline_code; std::string source_mode = state.source_mode_next.empty() ? - state.source_mode : state.source_mode_next.get_quickbook(); + state.source_mode : detail::to_s(state.source_mode_next.get_quickbook()); state.source_mode_next = value(); if (inline_code) { @@ -726,17 +726,17 @@ namespace quickbook // preprocess the code section to remove the initial indentation mapped_file_builder mapped; mapped.start(state.current_file); - mapped.unindent_and_add(code_value.begin(), code_value.end()); + mapped.unindent_and_add(code_value); file_ptr f = mapped.release(); - if (f->source.empty()) + if (f->source().empty()) return; // Nothing left to do here. The program is empty. if (qbk_version_n >= 107u) state.start_callouts(); - parse_iterator first_(f->source.begin()); - parse_iterator last_(f->source.end()); + parse_iterator first_(f->source().begin()); + parse_iterator last_(f->source().end()); file_ptr saved_file = f; boost::swap(state.current_file, saved_file); @@ -813,8 +813,8 @@ namespace quickbook detail::print_string(v.get_encoded(), out); } else { - std::string value = v.get_quickbook(); - for(std::string::const_iterator + boost::string_ref value = v.get_quickbook(); + for(boost::string_ref::const_iterator first = value.begin(), last = value.end(); first != last; ++first) { @@ -841,8 +841,10 @@ namespace quickbook value_consumer pair = pair_; value name = pair.consume(); value value = pair.consume(); + std::string name_str(name.get_quickbook().begin(), + name.get_quickbook().end()); pair.finish(); - if(!attributes.insert(std::make_pair(name.get_quickbook(), value)).second) + if(!attributes.insert(std::make_pair(name_str, value)).second) { detail::outwarn(name.get_file(), name.get_position()) << "Duplicate image attribute: " @@ -860,7 +862,7 @@ namespace quickbook std::string fileref = attributes["fileref"].is_encoded() ? attributes["fileref"].get_encoded() : - attributes["fileref"].get_quickbook(); + detail::to_s(attributes["fileref"].get_quickbook()); // Check for windows paths, then convert. // A bit crude, but there you go. @@ -937,7 +939,7 @@ namespace quickbook // Now load the SVG file: // std::string svg_text; - if (state.add_dependency(img)) { + if (state.dependencies.add_dependency(img)) { fs::ifstream fs(img); std::stringstream buffer; buffer << fs.rdbuf(); @@ -1006,7 +1008,7 @@ namespace quickbook void macro_definition_action(quickbook::state& state, quickbook::value macro_definition) { value_consumer values = macro_definition; - std::string macro_id = values.consume().get_quickbook(); + std::string macro_id = detail::to_s(values.consume().get_quickbook()); value phrase_value = values.optional_consume(); std::string phrase; if (phrase_value.check()) phrase = phrase_value.get_encoded(); @@ -1035,11 +1037,11 @@ namespace quickbook void template_body_action(quickbook::state& state, quickbook::value template_definition) { value_consumer values = template_definition; - std::string identifier = values.consume().get_quickbook(); + std::string identifier = detail::to_s(values.consume().get_quickbook()); std::vector template_values; BOOST_FOREACH(value const& p, values.consume()) { - template_values.push_back(p.get_quickbook()); + template_values.push_back(detail::to_s(p.get_quickbook())); } BOOST_ASSERT(values.check(template_tags::block) || values.check(template_tags::phrase)); @@ -1207,7 +1209,7 @@ namespace quickbook file_ptr saved_current_file = state.current_file; state.current_file = content.get_file(); - string_ref source = content.get_quickbook(); + boost::string_ref source = content.get_quickbook(); parse_iterator first(source.begin()); parse_iterator last(source.end()); @@ -1363,7 +1365,7 @@ namespace quickbook bool template_escape = values.check(template_tags::escape); if(template_escape) values.consume(); - std::string identifier = values.consume(template_tags::identifier).get_quickbook(); + std::string identifier = detail::to_s(values.consume(template_tags::identifier).get_quickbook()); std::vector args; @@ -1480,7 +1482,7 @@ namespace quickbook // Note: dst is never actually encoded as boostbook, which // is why the result is called with 'print_string' later. std::string dst = dst_value.is_encoded() ? - dst_value.get_encoded() : dst_value.get_quickbook(); + dst_value.get_encoded() : detail::to_s(dst_value.get_quickbook()); state.phrase << markup.pre; detail::print_string(dst, state.phrase.get()); @@ -1499,7 +1501,7 @@ namespace quickbook write_anchors(state, state.out); value_consumer values = variable_list; - std::string title = values.consume(table_tags::title).get_quickbook(); + std::string title = detail::to_s(values.consume(table_tags::title).get_quickbook()); state.out << "\n"; @@ -1538,7 +1540,7 @@ namespace quickbook std::string element_id; if(values.check(general_tags::element_id)) - element_id = values.consume().get_quickbook(); + element_id = detail::to_s(values.consume().get_quickbook()); value title = values.consume(table_tags::title); bool has_title = !title.empty(); @@ -1785,7 +1787,7 @@ namespace quickbook // Counter-intuitively: encoded == plain text here. std::string path_text = qbk_version_n >= 106u || path.is_encoded() ? - path.get_encoded() : path.get_quickbook(); + path.get_encoded() : detail::to_s(path.get_quickbook()); if(path_text.find('\\') != std::string::npos) { @@ -1875,7 +1877,7 @@ namespace quickbook state.current_file->path.parent_path() / path; // See if it can be found locally first. - if (state.add_dependency(local_path)) + if (state.dependencies.add_dependency(local_path)) { result.insert(include_search_return( local_path, @@ -1887,7 +1889,7 @@ namespace quickbook { full /= path; - if (state.add_dependency(full)) + if (state.dependencies.add_dependency(full)) { result.insert(include_search_return(full, path)); return result; @@ -1896,7 +1898,7 @@ namespace quickbook } else { - if (state.add_dependency(path)) { + if (state.dependencies.add_dependency(path)) { result.insert(include_search_return(path, path)); return result; } diff --git a/src/code_snippet.cpp b/src/code_snippet.cpp index 4c63a3b..e8334dd 100644 --- a/src/code_snippet.cpp +++ b/src/code_snippet.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include "block_tags.hpp" #include "template_stack.hpp" #include "actions.hpp" @@ -30,7 +29,7 @@ namespace quickbook code_snippet_actions(std::vector& storage, file_ptr source_file, char const* source_type) - : last_code_pos(source_file->source.begin()) + : last_code_pos(source_file->source().begin()) , in_code(false) , snippet_stack() , storage(storage) @@ -63,13 +62,13 @@ namespace quickbook std::string id; bool start_code; - std::string::const_iterator source_pos; + string_iterator source_pos; mapped_file_builder::pos start_pos; boost::shared_ptr next; }; void push_snippet_data(std::string const& id, - std::string::const_iterator pos) + string_iterator pos) { boost::shared_ptr new_snippet(new snippet_data(id)); new_snippet->next = snippet_stack; @@ -88,8 +87,8 @@ namespace quickbook } mapped_file_builder content; - std::string::const_iterator mark_begin, mark_end; - std::string::const_iterator last_code_pos; + boost::string_ref::const_iterator mark_begin, mark_end; + boost::string_ref::const_iterator last_code_pos; bool in_code; boost::shared_ptr snippet_stack; std::vector& storage; @@ -352,8 +351,8 @@ namespace quickbook bool is_python = extension == ".py"; code_snippet_actions a(storage, load(filename, qbk_version_n), is_python ? "[python]" : "[c++]"); - string_iterator first(a.source_file->source.begin()); - string_iterator last(a.source_file->source.end()); + string_iterator first(a.source_file->source().begin()); + string_iterator last(a.source_file->source().end()); cl::parse_info info; @@ -376,14 +375,14 @@ namespace quickbook if (last_code_pos != first) { if (!in_code) { - content.add("\n\n", last_code_pos); - content.add(source_type, last_code_pos); - content.add("```\n", last_code_pos); + content.add_at_pos("\n\n", last_code_pos); + content.add_at_pos(source_type, last_code_pos); + content.add_at_pos("```\n", last_code_pos); in_code = true; } - content.add(last_code_pos, first); + content.add(boost::string_ref(last_code_pos, first - last_code_pos)); } } @@ -396,7 +395,7 @@ namespace quickbook if (in_code) { - content.add("\n```\n\n", last_code_pos); + content.add_at_pos("\n```\n\n", last_code_pos); in_code = false; } } @@ -414,13 +413,13 @@ namespace quickbook if (!in_code) { - content.add("\n\n", first); - content.add(source_type, first); - content.add("```\n", first); + content.add_at_pos("\n\n", first); + content.add_at_pos(source_type, first); + content.add_at_pos("```\n", first); in_code = true; } - content.add(mark_begin, mark_end); + content.add(boost::string_ref(mark_begin, mark_end - mark_begin)); } void code_snippet_actions::escaped_comment(string_iterator first, string_iterator last) @@ -437,8 +436,8 @@ namespace quickbook snippet_data& snippet = *snippet_stack; - content.add("\n", mark_begin); - content.unindent_and_add(mark_begin, mark_end); + content.add_at_pos("\n", mark_begin); + content.unindent_and_add(boost::string_ref(mark_begin, mark_end - mark_begin)); if (snippet.id == "!") { @@ -516,13 +515,13 @@ namespace quickbook mapped_file_builder f; f.start(source_file); if (snippet->start_code) { - f.add("\n\n", snippet->source_pos); - f.add(source_type, snippet->source_pos); - f.add("```\n", snippet->source_pos); + f.add_at_pos("\n\n", snippet->source_pos); + f.add_at_pos(source_type, snippet->source_pos); + f.add_at_pos("```\n", snippet->source_pos); } f.add(content, snippet->start_pos, content.get_pos()); if (in_code) { - f.add("\n```\n\n", position); + f.add_at_pos("\n```\n\n", position); } std::vector params; @@ -530,7 +529,7 @@ namespace quickbook file_ptr body = f.release(); storage.push_back(template_symbol(snippet->id, params, - qbk_value(body, body->source.begin(), body->source.end(), + qbk_value(body, body->source().begin(), body->source().end(), template_tags::snippet))); } } diff --git a/src/dependency_tracker.cpp b/src/dependency_tracker.cpp new file mode 100644 index 0000000..53d24d2 --- /dev/null +++ b/src/dependency_tracker.cpp @@ -0,0 +1,83 @@ +/*============================================================================= + Copyright (c) 2013 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include "dependency_tracker.hpp" +#include "input_path.hpp" +#include +#include + +namespace quickbook +{ + // Convert the path to its canonical representation if it exists. + // Or something close if it doesn't. + static fs::path normalize_path(fs::path const& path) + { + fs::path p = fs::absolute(path); // The base of the path. + fs::path extra; // The non-existant part of the path. + int parent_count = 0; // Number of active '..' sections + + // Invariant: path is equivalent to: p / ('..' * parent_count) / extra + // i.e. if parent_count == 0: p/extra + // if parent_count == 2: p/../../extra + + // Pop path sections from path until we find an existing + // path, adjusting for any dot path sections. + while (!fs::exists(fs::status(p))) { + fs::path name = p.filename(); + p = p.parent_path(); + if (name == "..") { + ++parent_count; + } + else if (name == ".") { + } + else if (parent_count) { + --parent_count; + } + else { + extra = name / extra; + } + } + + // If there are any left over ".." sections, then add them + // on to the end of the real path, and trust Boost.Filesystem + // to sort them out. + while (parent_count) { + p = p / ".."; + --parent_count; + } + + // Cannoicalize the existing part of the path, and add 'extra' back to + // the end. + return fs::canonical(p) / extra; + } + + bool dependency_tracker::add_dependency(fs::path const& f) { + bool found = fs::exists(fs::status(f)); + dependencies[normalize_path(f)] |= found; + return found; + } + + void dependency_tracker::write_dependencies(std::ostream& out) + { + BOOST_FOREACH(dependency_list::value_type const& d, dependencies) + { + if (d.second) { + out << detail::path_to_generic(d.first) << std::endl; + } + } + } + + void dependency_tracker::write_checked_locations(std::ostream& out) + { + BOOST_FOREACH(dependency_list::value_type const& d, dependencies) + { + out << (d.second ? "+ " : "- ") + << detail::path_to_generic(d.first) << std::endl; + } + } +} diff --git a/src/dependency_tracker.hpp b/src/dependency_tracker.hpp new file mode 100644 index 0000000..bbf991c --- /dev/null +++ b/src/dependency_tracker.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2013 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#if !defined(QUICKBOOK_DEPENDENCY_TRACKER_HPP) +#define QUICKBOOK_DEPENDENCY_TRACKER_HPP + +#include +#include +#include + +namespace quickbook +{ + namespace fs = boost::filesystem; + + struct dependency_tracker { + private: + + typedef std::map dependency_list; + dependency_list dependencies; + + public: + + // Call this before loading any file so that it will be included in the + // list of dependencies. Returns true if file exists. + bool add_dependency(fs::path const&); + + void write_dependencies(std::ostream&); + void write_checked_locations(std::ostream&); + }; +} + +#endif diff --git a/src/doc_info_actions.cpp b/src/doc_info_actions.cpp index 42ee961..8ceac6c 100644 --- a/src/doc_info_actions.cpp +++ b/src/doc_info_actions.cpp @@ -29,7 +29,7 @@ namespace quickbook static std::string doc_info_output(value const& p, unsigned version) { if (qbk_version_n < version) { - std::string value = p.get_quickbook(); + std::string value = detail::to_s(p.get_quickbook()); value.erase(value.find_last_not_of(" \t") + 1); return value; } @@ -141,7 +141,7 @@ namespace quickbook if (values.check(doc_info_tags::type)) { - doc_type = values.consume(doc_info_tags::type).get_quickbook(); + doc_type = detail::to_s(values.consume(doc_info_tags::type).get_quickbook()); doc_title = values.consume(doc_info_tags::title); use_doc_info = !nested_file || qbk_version_n >= 106u; } @@ -200,9 +200,9 @@ namespace quickbook std::string include_doc_id_, id_; if (!include_doc_id.empty()) - include_doc_id_ = include_doc_id.get_quickbook(); + include_doc_id_ = detail::to_s(include_doc_id.get_quickbook()); if (!id.empty()) - id_ = id.get_quickbook(); + id_ = detail::to_s(id.get_quickbook()); // Quickbook version diff --git a/src/files.cpp b/src/files.cpp index f85b611..fddd3b1 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -135,12 +135,17 @@ namespace quickbook return pos->second; } + std::ostream& operator<<(std::ostream& out, file_position const& x) + { + return out << "line: " << x.line << ", column: " << x.column; + } + file_position relative_position( - std::string::const_iterator begin, - std::string::const_iterator iterator) + boost::string_ref::const_iterator begin, + boost::string_ref::const_iterator iterator) { file_position pos; - std::string::const_iterator line_begin = begin; + boost::string_ref::const_iterator line_begin = begin; while (begin != iterator) { @@ -172,9 +177,9 @@ namespace quickbook return pos; } - file_position file::position_of(std::string::const_iterator iterator) const + file_position file::position_of(boost::string_ref::const_iterator iterator) const { - return relative_position(source.begin(), iterator); + return relative_position(source().begin(), iterator); } // Mapped files. @@ -190,55 +195,15 @@ namespace quickbook std::string::size_type original_pos; std::string::size_type our_pos; section_types section_type; + int indentation; mapped_file_section( std::string::size_type original_pos, std::string::size_type our_pos, - section_types section_type = normal) : - original_pos(original_pos), our_pos(our_pos), section_type(section_type) {} - - std::string::size_type to_original_pos(std::string::size_type pos) - { - switch (section_type) { - case normal: - return pos - our_pos + original_pos; - case empty: - return original_pos; - case indented: - // Indented doesn't really work, but that's okay because we - // currently don't break up indented code. - assert(pos == our_pos); - return pos - our_pos + original_pos; - default: - assert(false); - return original_pos; - } - } - - // If 'to_original_pos' worked for indented blocks, this wouldn't - // be necessary. - file_position calculate_position( - file_position const& original, - file_position const& relative) const - { - switch (section_type) { - case normal: - return file_position( - original.line + relative.line - 1, - relative.line == 1 ? - original.column + relative.column - 1 : - relative.column); - case empty: - return original; - case indented: - return file_position( - original.line + relative.line - 1, - original.column + relative.column - 1); - default: - assert(false); - return file_position(); - } - } + section_types section_type = normal, + int indentation = 0) : + original_pos(original_pos), our_pos(our_pos), + section_type(section_type), indentation(indentation) {} }; struct mapped_section_original_cmp @@ -293,9 +258,9 @@ namespace quickbook file_ptr original; std::vector mapped_sections; - void add_empty_mapped_file_section(std::string::const_iterator pos) { + void add_empty_mapped_file_section(boost::string_ref::const_iterator pos) { std::string::size_type original_pos = - pos - original->source.begin(); + pos - original->source().begin(); if (mapped_sections.empty() || mapped_sections.back().section_type != @@ -303,23 +268,91 @@ namespace quickbook mapped_sections.back().original_pos != original_pos) { mapped_sections.push_back(mapped_file_section( - original_pos, source.size(), + original_pos, source().size(), mapped_file_section::empty)); } } - void add_mapped_file_section(std::string::const_iterator pos) { + void add_mapped_file_section(boost::string_ref::const_iterator pos) { mapped_sections.push_back(mapped_file_section( - pos - original->source.begin(), source.size())); + pos - original->source().begin(), source().size())); } - void add_indented_mapped_file_section(std::string::const_iterator pos) { + void add_indented_mapped_file_section(boost::string_ref::const_iterator pos, + int indentation) + { mapped_sections.push_back(mapped_file_section( - pos - original->source.begin(), source.size(), - mapped_file_section::indented)); + pos - original->source().begin(), source().size(), + mapped_file_section::indented, indentation)); } - virtual file_position position_of(std::string::const_iterator) const; + std::string::size_type to_original_pos( + std::vector::const_iterator section, + std::string::size_type pos) const + { + switch (section->section_type) { + case mapped_file_section::normal: + return pos - section->our_pos + section->original_pos; + case mapped_file_section::empty: + return section->original_pos; + case mapped_file_section::indented: { + boost::string_ref::size_type our_line = section->our_pos; + unsigned newline_count = 0; + + for(boost::string_ref::size_type i = section->our_pos; + i != pos; ++i) + { + if (source()[i] == '\n') { + our_line = i + 1; + ++newline_count; + } + } + + if (newline_count == 0) + return pos - section->our_pos + section->original_pos; + + boost::string_ref::size_type original_line = + section->original_pos; + + while(newline_count > 0) { + if (original->source()[original_line] == '\n') + --newline_count; + ++original_line; + } + + for(unsigned i = section->indentation; i > 0; --i) { + if (original->source()[original_line] == '\n' || + original->source()[original_line] == '\0') break; + assert(original->source()[original_line] == ' ' || + original->source()[original_line] == '\t'); + ++original_line; + } + + assert(original->source()[original_line] == + source()[our_line]); + + return original_line + (pos - our_line); + } + default: + assert(false); + return section->original_pos; + } + } + + std::vector::const_iterator find_section( + boost::string_ref::const_iterator pos) const + { + std::vector::const_iterator section = + boost::upper_bound(mapped_sections, + std::string::size_type(pos - source().begin()), + mapped_section_pos_cmp()); + assert(section != mapped_sections.begin()); + --section; + + return section; + } + + virtual file_position position_of(boost::string_ref::const_iterator) const; }; namespace { @@ -361,88 +394,80 @@ namespace quickbook bool mapped_file_builder::empty() const { - return data->new_file->source.empty(); + return data->new_file->source().empty(); } mapped_file_builder::pos mapped_file_builder::get_pos() const { - return data->new_file->source.size(); + return data->new_file->source().size(); } - void mapped_file_builder::add(char const* x, iterator pos) + void mapped_file_builder::add_at_pos(boost::string_ref x, iterator pos) { data->new_file->add_empty_mapped_file_section(pos); - data->new_file->source.append(x); + data->new_file->source_.append(x.begin(), x.end()); } - void mapped_file_builder::add(std::string const& x, iterator pos) + void mapped_file_builder::add(boost::string_ref x) { - data->new_file->add_empty_mapped_file_section(pos); - data->new_file->source.append(x); - } - - void mapped_file_builder::add(iterator begin, iterator end) - { - data->new_file->add_mapped_file_section(begin); - data->new_file->source.append(begin, end); + data->new_file->add_mapped_file_section(x.begin()); + data->new_file->source_.append(x.begin(), x.end()); } void mapped_file_builder::add(mapped_file_builder const& x) { - add(x, 0, x.data->new_file->source.size()); + add(x, 0, x.data->new_file->source_.size()); } void mapped_file_builder::add(mapped_file_builder const& x, pos begin, pos end) { assert(data->new_file->original == x.data->new_file->original); - assert(begin <= x.data->new_file->source.size()); - assert(end <= x.data->new_file->source.size()); + assert(begin <= x.data->new_file->source_.size()); + assert(end <= x.data->new_file->source_.size()); if (begin != end) { - std::vector::iterator start = - boost::upper_bound(x.data->new_file->mapped_sections, - begin, mapped_section_pos_cmp()); - assert(start != x.data->new_file->mapped_sections.begin()); - --start; + std::vector::const_iterator start = + x.data->new_file->find_section( + x.data->new_file->source().begin() + begin); - std::string::size_type size = data->new_file->source.size(); + std::string::size_type size = data->new_file->source_.size(); data->new_file->mapped_sections.push_back(mapped_file_section( - start->to_original_pos(begin), size, - start->section_type)); + x.data->new_file->to_original_pos(start, begin), + size, start->section_type, start->indentation)); for (++start; start != x.data->new_file->mapped_sections.end() && start->our_pos < end; ++start) { data->new_file->mapped_sections.push_back(mapped_file_section( start->original_pos, start->our_pos - begin + size, - start->section_type)); + start->section_type, start->indentation)); } - data->new_file->source.append( - x.data->new_file->source.begin() + begin, - x.data->new_file->source.begin() + end); + data->new_file->source_.append( + x.data->new_file->source_.begin() + begin, + x.data->new_file->source_.begin() + end); } } - void mapped_file_builder::unindent_and_add(iterator begin, iterator end) + void mapped_file_builder::unindent_and_add(boost::string_ref x) { - std::string program(begin, end); + std::string program(x.begin(), x.end()); // Erase leading blank lines and newlines: - std::string::size_type start = program.find_first_not_of(" \t"); - if (start != std::string::npos && - (program[start] == '\r' || program[start] == '\n')) + std::string::size_type start = program.find_first_not_of(" \t\r\n"); + if (start == std::string::npos) return; + + start = program.find_last_of("\r\n", start); + if (start != std::string::npos) { + ++start; program.erase(0, start); } - start = program.find_first_not_of("\r\n"); - program.erase(0, start); - if (program.size() == 0) - return; // nothing left to do + assert(program.size() != 0); // Get the first line indent std::string::size_type indent = program.find_first_not_of(" \t"); @@ -487,23 +512,13 @@ namespace quickbook program.erase(pos, (std::min)(indent, next-pos)); } - data->new_file->add_indented_mapped_file_section(begin + indent); - data->new_file->source.append(program); + data->new_file->add_indented_mapped_file_section(x.begin() + indent, indent); + data->new_file->source_.append(program); } - file_position mapped_file::position_of(std::string::const_iterator pos) const + file_position mapped_file::position_of(boost::string_ref::const_iterator pos) const { - std::vector::const_iterator section = - boost::upper_bound(mapped_sections, - std::string::size_type(pos - source.begin()), - mapped_section_pos_cmp()); - assert(section != mapped_sections.begin()); - --section; - - return section->calculate_position( - original->position_of( - original->source.begin() + section->original_pos), - relative_position(source.begin() + section->our_pos, pos) - ); + return original->position_of(original->source().begin() + + to_original_pos(find_section(pos), pos - source().begin())); } } diff --git a/src/files.hpp b/src/files.hpp index 4f217e7..0a2e530 100644 --- a/src/files.hpp +++ b/src/files.hpp @@ -14,8 +14,10 @@ #include #include #include +#include #include #include +#include namespace quickbook { @@ -31,6 +33,13 @@ namespace quickbook { int line; int column; + + bool operator==(file_position const& other) const + { + return line == other.line && column == other.column; + } + + friend std::ostream& operator<<(std::ostream&, file_position const&); }; struct file @@ -41,21 +50,23 @@ namespace quickbook { file(file const&); public: fs::path const path; - std::string source; + std::string source_; bool is_code_snippets; private: unsigned qbk_version; unsigned ref_count; public: + boost::string_ref source() const { return source_; } - file(fs::path const& path, std::string const& source, + file(fs::path const& path, boost::string_ref source, unsigned qbk_version) : - path(path), source(source), is_code_snippets(false), + path(path), source_(source.begin(), source.end()), is_code_snippets(false), qbk_version(qbk_version), ref_count(0) {} - file(file const& f, std::string const& source) : - path(f.path), source(source), is_code_snippets(f.is_code_snippets), + file(file const& f, boost::string_ref source) : + path(f.path), source_(source.begin(), source.end()), + is_code_snippets(f.is_code_snippets), qbk_version(f.qbk_version), ref_count(0) {} @@ -76,7 +87,7 @@ namespace quickbook { qbk_version = v; } - virtual file_position position_of(std::string::const_iterator) const; + virtual file_position position_of(boost::string_ref::const_iterator) const; friend void intrusive_ptr_add_ref(file* ptr) { ++ptr->ref_count; } @@ -101,8 +112,8 @@ namespace quickbook { struct mapped_file_builder { - typedef std::string::const_iterator iterator; - typedef std::string::size_type pos; + typedef boost::string_ref::const_iterator iterator; + typedef boost::string_ref::size_type pos; mapped_file_builder(); ~mapped_file_builder(); @@ -114,12 +125,11 @@ namespace quickbook { bool empty() const; pos get_pos() const; - void add(char const*, iterator); - void add(std::string const&, iterator); - void add(iterator, iterator); + void add_at_pos(boost::string_ref, iterator); + void add(boost::string_ref); void add(mapped_file_builder const&); void add(mapped_file_builder const&, pos, pos); - void unindent_and_add(iterator, iterator); + void unindent_and_add(boost::string_ref); private: mapped_file_builder_data* data; diff --git a/src/fwd.hpp b/src/fwd.hpp index 7cccde8..2fce3ee 100644 --- a/src/fwd.hpp +++ b/src/fwd.hpp @@ -13,6 +13,7 @@ #include "iterator.hpp" #include +#include namespace quickbook { @@ -25,7 +26,7 @@ namespace quickbook struct template_symbol; typedef boost::intrusive_ptr file_ptr; - typedef std::string::const_iterator string_iterator; + typedef boost::string_ref::const_iterator string_iterator; typedef lookback_iterator parse_iterator; inline void ignore_variable(void const*) {} diff --git a/src/id_manager.cpp b/src/id_manager.cpp index 3b2f601..1f84ad1 100644 --- a/src/id_manager.cpp +++ b/src/id_manager.cpp @@ -8,7 +8,7 @@ #include "id_manager.hpp" #include "utils.hpp" -#include "string_ref.hpp" +#include #include #include #include @@ -29,9 +29,9 @@ namespace quickbook struct id_placeholder; struct id_data; - std::string replace_ids(id_state& state, std::string const& xml, + std::string replace_ids(id_state& state, boost::string_ref xml, bool use_resolved_ids = true); - std::string process_ids(id_state&, std::string const&); + std::string process_ids(id_state&, boost::string_ref); static const std::size_t max_size = 32; @@ -68,13 +68,15 @@ namespace quickbook id_placeholder( unsigned index, - std::string const& id, + boost::string_ref id, id_category category, id_placeholder* parent_ = 0) : index(index), generation_state(parent_ ? child : unresolved), - unresolved_id(parent_ ? parent_->unresolved_id + '.' + id : id), - id(id), + unresolved_id(parent_ ? + parent_->unresolved_id + '.' + detail::to_s(id) : + detail::to_s(id)), + id(id.begin(), id.end()), parent(parent_), category(category), num_dots(boost::range::count(id, '.') + @@ -118,39 +120,39 @@ namespace quickbook // Placeholder methods id_placeholder* add_placeholder( - std::string const&, id_category, id_placeholder* parent = 0); + boost::string_ref, id_category, id_placeholder* parent = 0); - id_placeholder* get_placeholder(string_ref); + id_placeholder* get_placeholder(boost::string_ref); // Events id_placeholder* start_file( unsigned compatibility_version, bool document_root, - std::string const& include_doc_id, - std::string const& id, + boost::string_ref include_doc_id, + boost::string_ref id, value const& title); void end_file(); id_placeholder* add_id( - std::string const& id, + boost::string_ref id, id_category category); id_placeholder* old_style_id( - std::string const& id, + boost::string_ref id, id_category category); id_placeholder* begin_section( - std::string const& id, + boost::string_ref id, id_category category); void end_section(); private: id_placeholder* add_id_to_section( - std::string const& id, + boost::string_ref id, id_category category, boost::shared_ptr const& section); id_placeholder* create_new_section( - std::string const& id, + boost::string_ref id, id_category category); void switch_section(id_placeholder*); @@ -210,7 +212,7 @@ private: id_placeholder* placeholder_1_6; section_info(boost::shared_ptr const& parent, - unsigned compatibility_version, std::string const& id) : + unsigned compatibility_version, boost::string_ref id) : parent(parent), compatibility_version(compatibility_version), level(parent ? parent->level + 1 : 1), id_1_1(), placeholder_1_6(0) @@ -219,7 +221,7 @@ private: id_1_1 = parent->id_1_1; if (!id_1_1.empty() && !id.empty()) id_1_1 += "."; - id_1_1 += id; + id_1_1.append(id.begin(), id.end()); } } }; @@ -237,8 +239,8 @@ private: void id_manager::start_file( unsigned compatibility_version, - std::string const& include_doc_id, - std::string const& id, + boost::string_ref include_doc_id, + boost::string_ref id, value const& title) { state->start_file(compatibility_version, false, include_doc_id, id, title); @@ -246,8 +248,8 @@ private: std::string id_manager::start_file_with_docinfo( unsigned compatibility_version, - std::string const& include_doc_id, - std::string const& id, + boost::string_ref include_doc_id, + boost::string_ref id, value const& title) { return state->start_file(compatibility_version, true, include_doc_id, @@ -259,7 +261,7 @@ private: state->end_file(); } - std::string id_manager::begin_section(std::string const& id, + std::string id_manager::begin_section(boost::string_ref id, id_category category) { return state->begin_section(id, category)->to_string(); @@ -275,28 +277,28 @@ private: return state->current_file->document->current_section->level; } - std::string id_manager::old_style_id(std::string const& id, id_category category) + std::string id_manager::old_style_id(boost::string_ref id, id_category category) { return state->old_style_id(id, category)->to_string(); } - std::string id_manager::add_id(std::string const& id, id_category category) + std::string id_manager::add_id(boost::string_ref id, id_category category) { return state->add_id(id, category)->to_string(); } - std::string id_manager::add_anchor(std::string const& id, id_category category) + std::string id_manager::add_anchor(boost::string_ref id, id_category category) { return state->add_placeholder(id, category)->to_string(); } std::string id_manager::replace_placeholders_with_unresolved_ids( - std::string const& xml) const + boost::string_ref xml) const { return replace_ids(*state, xml, false); } - std::string id_manager::replace_placeholders(std::string const& xml) const + std::string id_manager::replace_placeholders(boost::string_ref xml) const { assert(!state->current_file); return process_ids(*state, xml); @@ -316,12 +318,11 @@ private: namespace { std::string normalize_id( - std::string src_id, + boost::string_ref src_id, std::size_t prefix = 0, std::size_t size = max_size) { - std::string id; - id.swap(src_id); + std::string id(src_id.begin(), src_id.end()); std::size_t src = prefix; std::size_t dst = prefix; @@ -364,7 +365,7 @@ private: // id_placeholder* id_state::add_placeholder( - std::string const& id, id_category category, + boost::string_ref id, id_category category, id_placeholder* parent) { placeholders.push_back(id_placeholder( @@ -372,7 +373,7 @@ private: return &placeholders.back(); } - id_placeholder* id_state::get_placeholder(string_ref value) + id_placeholder* id_state::get_placeholder(boost::string_ref value) { // If this isn't a placeholder id. if (value.size() <= 1 || *value.begin() != '$') @@ -429,8 +430,8 @@ private: id_placeholder* id_state::start_file( unsigned compatibility_version, bool document_root, - std::string const& include_doc_id, - std::string const& id, + boost::string_ref include_doc_id, + boost::string_ref id, value const& title) { // Create new file @@ -451,7 +452,7 @@ private: // specified in an 'include' element) unless backwards compatibility // is required. - std::string initial_doc_id; + boost::string_ref initial_doc_id; if (document_root || compatibility_version >= 106u || @@ -471,9 +472,9 @@ private: if (title.check()) current_file->document->last_title_1_1 = - title.get_quickbook(); + detail::to_s(title.get_quickbook()); - current_file->doc_id_1_1 = !initial_doc_id.empty() ? initial_doc_id : + current_file->doc_id_1_1 = !initial_doc_id.empty() ? detail::to_s(initial_doc_id) : detail::make_identifier(current_file->document->last_title_1_1); } else if (parent) { @@ -519,7 +520,7 @@ private: } id_placeholder* id_state::add_id( - std::string const& id, + boost::string_ref id, id_category category) { return add_id_to_section(id, category, @@ -527,11 +528,11 @@ private: } id_placeholder* id_state::add_id_to_section( - std::string const& id, + boost::string_ref id, id_category category, boost::shared_ptr const& section) { - std::string id_part = id; + std::string id_part(id.begin(), id.end()); // Note: Normalizing id according to file compatibility version, but // adding to section according to section compatibility version. @@ -562,25 +563,25 @@ private: } id_placeholder* id_state::old_style_id( - std::string const& id, + boost::string_ref id, id_category category) { return current_file->compatibility_version < 103u ? add_placeholder( - current_file->document->section_id_1_1 + "." + id, category) : + current_file->document->section_id_1_1 + "." + detail::to_s(id), category) : add_id(id, category); } id_placeholder* id_state::begin_section( - std::string const& id, + boost::string_ref id, id_category category) { - current_file->document->section_id_1_1 = id; + current_file->document->section_id_1_1 = detail::to_s(id); return create_new_section(id, category); } id_placeholder* id_state::create_new_section( - std::string const& id, + boost::string_ref id, id_category category) { boost::shared_ptr parent = @@ -618,7 +619,7 @@ private: if (parent && !new_section->placeholder_1_6) new_id = current_file->doc_id_1_1 + '.'; - new_id += id; + new_id += detail::to_s(id); p = add_placeholder(new_id, category, new_section->placeholder_1_6); @@ -654,13 +655,13 @@ private: std::vector id_attributes; struct callback { - virtual void start(string_ref) {} - virtual void id_value(string_ref) {} - virtual void finish(string_ref) {} + virtual void start(boost::string_ref) {} + virtual void id_value(boost::string_ref) {} + virtual void finish(boost::string_ref) {} virtual ~callback() {} }; - void parse(std::string const&, callback&); + void parse(boost::string_ref, callback&); }; namespace @@ -724,14 +725,13 @@ private: while(it != end && !find_char(text, *it)) ++it; } - void xml_processor::parse(std::string const& source, callback& c) + void xml_processor::parse(boost::string_ref source, callback& c) { - typedef std::string::const_iterator iterator; + typedef boost::string_ref::const_iterator iterator; - string_ref source_ref(source.begin(), source.end()); - c.start(source_ref); + c.start(source); - iterator it = source_ref.begin(), end = source_ref.end(); + iterator it = source.begin(), end = source.end(); for(;;) { @@ -770,7 +770,7 @@ private: iterator name_start = it; read_to_one_of(it, end, "= \t\n\r>"); if (it == end || *it == '>') break; - string_ref name(name_start, it); + boost::string_ref name(name_start, it - name_start); ++it; read_some_of(it, end, "= \t\n\r"); @@ -783,10 +783,10 @@ private: it = std::find(it, end, delim); if (it == end) break; - string_ref value(value_start, it); + boost::string_ref value(value_start, it - value_start); ++it; - if (boost::find(id_attributes, name) + if (boost::find(id_attributes, detail::to_s(name)) != id_attributes.end()) { c.id_value(value); @@ -800,7 +800,7 @@ private: } } - c.finish(source_ref); + c.finish(source); } // @@ -813,7 +813,7 @@ private: struct id_generation_data { - id_generation_data(std::string const& src_id) + id_generation_data(boost::string_ref src_id) : child_start(src_id.rfind('.') + 1), id(normalize_id(src_id, child_start, max_size - 1)), // 'max_size - 1' leaves a character to append @@ -878,11 +878,11 @@ private: typedef boost::unordered_map allocated_ids; typedef std::vector placeholder_index; - placeholder_index index_placeholders(id_state&, std::string const& xml); + placeholder_index index_placeholders(id_state&, boost::string_ref xml); void resolve_id(id_placeholder&, allocated_ids&); void generate_id(id_placeholder&, allocated_ids&); - std::string process_ids(id_state& state, std::string const& xml) + std::string process_ids(id_state& state, boost::string_ref xml) { placeholder_index placeholders = index_placeholders(state, xml); @@ -947,7 +947,7 @@ private: count(0) {} - void id_value(string_ref value) + void id_value(boost::string_ref value) { id_placeholder* p = state.get_placeholder(value); number(p); @@ -964,7 +964,7 @@ private: placeholder_index index_placeholders( id_state& state, - std::string const& xml) + boost::string_ref xml) { xml_processor processor; number_placeholders_callback callback(state); @@ -1095,7 +1095,7 @@ private: { id_state& state; bool use_resolved_ids; - std::string::const_iterator source_pos; + boost::string_ref::const_iterator source_pos; std::string result; replace_ids_callback(id_state& state, bool resolved) @@ -1105,18 +1105,18 @@ private: result() {} - void start(string_ref xml) + void start(boost::string_ref xml) { source_pos = xml.begin(); } - void id_value(string_ref value) + void id_value(boost::string_ref value) { if (id_placeholder* p = state.get_placeholder(value)) { assert(!use_resolved_ids || p->check_state(id_placeholder::generated)); - std::string const& id = use_resolved_ids ? + boost::string_ref id = use_resolved_ids ? p->id : p->unresolved_id; result.append(source_pos, value.begin()); @@ -1125,14 +1125,14 @@ private: } } - void finish(string_ref xml) + void finish(boost::string_ref xml) { result.append(source_pos, xml.end()); source_pos = xml.end(); } }; - std::string replace_ids(id_state& state, std::string const& xml, + std::string replace_ids(id_state& state, boost::string_ref xml, bool use_unresolved_ids) { xml_processor processor; diff --git a/src/id_manager.hpp b/src/id_manager.hpp index e071241..9410d23 100644 --- a/src/id_manager.hpp +++ b/src/id_manager.hpp @@ -10,6 +10,7 @@ #define BOOST_QUICKBOOK_ID_MANAGER_HPP #include +#include #include #include "values.hpp" @@ -53,29 +54,29 @@ namespace quickbook std::string start_file_with_docinfo( unsigned compatibility_version, - std::string const& include_doc_id, - std::string const& id, + boost::string_ref include_doc_id, + boost::string_ref id, value const& title); void start_file( unsigned compatibility_version, - std::string const& include_doc_id, - std::string const& id, + boost::string_ref include_doc_id, + boost::string_ref id, value const& title); void end_file(); - std::string begin_section(std::string const&, id_category); + std::string begin_section(boost::string_ref, id_category); void end_section(); int section_level() const; - std::string old_style_id(std::string const&, id_category); - std::string add_id(std::string const&, id_category); - std::string add_anchor(std::string const&, id_category); + std::string old_style_id(boost::string_ref, id_category); + std::string add_id(boost::string_ref, id_category); + std::string add_anchor(boost::string_ref, id_category); std::string replace_placeholders_with_unresolved_ids( - std::string const&) const; - std::string replace_placeholders(std::string const&) const; + boost::string_ref) const; + std::string replace_placeholders(boost::string_ref) const; unsigned compatibility_version() const; private: diff --git a/src/input_path.cpp b/src/input_path.cpp index 9b6a877..3fa8717 100644 --- a/src/input_path.cpp +++ b/src/input_path.cpp @@ -51,8 +51,9 @@ namespace detail { return std::string(buffer.get()); } - std::wstring from_utf8(std::string const& x) + std::wstring from_utf8(boost::string_ref text) { + std::string x(text.begin(), text.end()); int buffer_count = MultiByteToWideChar(CP_UTF8, 0, x.c_str(), -1, 0, 0); if (!buffer_count) @@ -81,7 +82,7 @@ namespace detail { #endif #if QUICKBOOK_WIDE_PATHS - fs::path generic_to_path(std::string const& x) + fs::path generic_to_path(boost::string_ref x) { return fs::path(from_utf8(x)); } @@ -91,9 +92,9 @@ namespace detail { return to_utf8(x.generic_wstring()); } #else - fs::path generic_to_path(std::string const& x) + fs::path generic_to_path(boost::string_ref x) { - return fs::path(x); + return fs::path(x.begin(), x.end()); } std::string path_to_generic(fs::path const& x) @@ -166,7 +167,7 @@ namespace detail { if (_isatty(_fileno(stderr))) _setmode(_fileno(stderr), _O_U16TEXT); } - void write_utf8(ostream::base_ostream& out, std::string const& x) + void write_utf8(ostream::base_ostream& out, boost::string_ref x) { out << from_utf8(x); } @@ -192,7 +193,7 @@ namespace detail { { } - void write_utf8(ostream::base_ostream& out, std::string const& x) + void write_utf8(ostream::base_ostream& out, boost::string_ref x) { out << x; } @@ -281,6 +282,11 @@ namespace detail { return *this; } + ostream& ostream::operator<<(boost::string_ref x) { + write_utf8(base, x); + return *this; + } + ostream& ostream::operator<<(int x) { base << x; return *this; diff --git a/src/input_path.hpp b/src/input_path.hpp index a9b55f6..6529514 100644 --- a/src/input_path.hpp +++ b/src/input_path.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -62,8 +63,10 @@ namespace quickbook #if QUICKBOOK_WIDE_PATHS typedef std::wstring input_string; + typedef boost::wstring_ref input_string_ref; #else typedef std::string input_string; + typedef boost::string_ref input_string_ref; #endif // A light wrapper around C++'s streams that gets things right @@ -76,10 +79,12 @@ namespace quickbook typedef std::wostream base_ostream; typedef std::wios base_ios; typedef std::wstring string; + typedef boost::wstring_ref string_ref; #else typedef std::ostream base_ostream; typedef std::ios base_ios; typedef std::string string; + typedef boost::string_ref string_ref; #endif base_ostream& base; @@ -91,6 +96,7 @@ namespace quickbook // std::string should be UTF-8 (what a mess!) ostream& operator<<(std::string const&); + ostream& operator<<(boost::string_ref); // Other value types. ostream& operator<<(int x); @@ -109,7 +115,7 @@ namespace quickbook fs::path input_to_path(input_string const&); std::string path_to_generic(fs::path const&); - fs::path generic_to_path(std::string const&); + fs::path generic_to_path(boost::string_ref); void initialise_output(); diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index 74dbece..c494350 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -224,7 +224,7 @@ namespace quickbook info_.type != element_info::maybe_block) { l.state_.source_mode.swap(saved_source_mode_); - l.state_.source_mode = l.state_.source_mode_next.get_quickbook(); + l.state_.source_mode = detail::to_s(l.state_.source_mode_next.get_quickbook()); l.state_.source_mode_next = value(); } diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 5a359ed..8890dcb 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -38,7 +38,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.5.8" +#define QUICKBOOK_VERSION "Quickbook Version 1.5.9 (dev)" namespace quickbook { @@ -61,8 +61,9 @@ namespace quickbook end = preset_defines.end(); it != end; ++it) { - parse_iterator first(it->begin()); - parse_iterator last(it->end()); + boost::string_ref val(*it); + parse_iterator first(val.begin()); + parse_iterator last(val.end()); cl::parse_info info = cl::parse(first, last, state.grammar().command_line_macro); @@ -85,8 +86,8 @@ namespace quickbook /////////////////////////////////////////////////////////////////////////// void parse_file(quickbook::state& state, value include_doc_id, bool nested_file) { - parse_iterator first(state.current_file->source.begin()); - parse_iterator last(state.current_file->source.end()); + parse_iterator first(state.current_file->source().begin()); + parse_iterator last(state.current_file->source().end()); cl::parse_info info = cl::parse(first, last, state.grammar().doc_info); assert(info.hit); @@ -131,7 +132,7 @@ namespace quickbook set_macros(state); if (state.error_count == 0) { - state.add_dependency(filein_); + state.dependencies.add_dependency(filein_); state.current_file = load(filein_); // Throws load_error parse_file(state); @@ -147,24 +148,13 @@ namespace quickbook if (!deps_out_.empty()) { fs::ofstream out(deps_out_); - BOOST_FOREACH(quickbook::state::dependency_list::value_type - const& d, state.dependencies) - { - if (d.second) { - out << detail::path_to_generic(d.first) << std::endl; - } - } + state.dependencies.write_dependencies(out); } if (!locations_out_.empty()) { fs::ofstream out(locations_out_); - BOOST_FOREACH(quickbook::state::dependency_list::value_type - const& d, state.dependencies) - { - out << (d.second ? "+ " : "- ") - << detail::path_to_generic(d.first) << std::endl; - } + state.dependencies.write_checked_locations(out); } } catch (load_error& e) { diff --git a/src/state.cpp b/src/state.cpp index d16200d..9f2168a 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -13,7 +13,6 @@ #include "quickbook.hpp" #include "grammar.hpp" #include "input_path.hpp" -#include #if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310)) #pragma warning(disable:4355) @@ -71,43 +70,6 @@ namespace quickbook return *grammar_; } - bool state::add_dependency(fs::path const& f) { - fs::path p = fs::absolute(f); - bool found = fs::exists(fs::status(p)); - - // Pop path sections from path until we find an existing - // path, adjusting for any dot path sections. - fs::path extra; - int parent_count = 0; - while (!fs::exists(fs::status(p))) { - fs::path name = p.filename(); - p = p.parent_path(); - if (name == "..") { - ++parent_count; - } - else if (name == ".") { - } - else if (parent_count) { - --parent_count; - } - else { - extra = name / extra; - } - } - - // If there are any left over ".." sections, then add them - // on to the end of the real path, and trust Boost.Filesystem - // to sort them out. - while (parent_count) { - p = p / ".."; - --parent_count; - } - - p = fs::canonical(p) / extra; - dependencies[p] |= found; - return found; - } - file_state::file_state(quickbook::state& state, scope_flags scope) : state(state) , scope(scope) diff --git a/src/state.hpp b/src/state.hpp index b750904..8d5f389 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -17,6 +17,7 @@ #include "collector.hpp" #include "template_stack.hpp" #include "symbols.hpp" +#include "dependency_tracker.hpp" namespace quickbook { @@ -37,7 +38,6 @@ namespace quickbook /////////////////////////////////////////////////////////////////////////// typedef std::vector string_list; - typedef std::map dependency_list; static int const max_template_depth = 100; @@ -51,7 +51,7 @@ namespace quickbook id_manager& ids; value_builder callouts; // callouts are global as int callout_depth; // they don't nest. - dependency_list dependencies; + dependency_tracker dependencies; // state saved for files and templates. bool imported; @@ -78,10 +78,6 @@ namespace quickbook // actions /////////////////////////////////////////////////////////////////////////// - // Call this before loading any file so that it will be included in the - // list of dependencies. Returns true if file exists. - bool add_dependency(fs::path const&); - void start_list(char mark); void end_list(char mark); void start_list_item(); diff --git a/src/string_ref.cpp b/src/string_ref.cpp deleted file mode 100644 index 6c33df1..0000000 --- a/src/string_ref.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================= - Copyright (c) 2011 Daniel James - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ - -#include "string_ref.hpp" -#include -#include -#include -#include - -namespace quickbook -{ - void string_ref::swap(string_ref& x) - { - boost::swap(begin_, x.begin_); - boost::swap(end_, x.end_); - } - - bool operator==(string_ref const& x, string_ref const& y) - { - return boost::equal(x, y); - } - - bool operator<(string_ref const& x, string_ref const& y) - { - return boost::lexicographical_compare(x, y); - } - - std::ostream& operator<<(std::ostream& out, string_ref const& x) - { - return out.write(&*x.begin(), x.end() - x.begin()); - } -} diff --git a/src/string_ref.hpp b/src/string_ref.hpp deleted file mode 100644 index ffb95bf..0000000 --- a/src/string_ref.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/*============================================================================= - Copyright (c) 2011 Daniel James - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ - -#if !defined(BOOST_QUICKBOOK_STRING_REF_HPP) -#define BOOST_QUICKBOOK_STRING_REF_HPP - -#include -#include -#include - -namespace quickbook -{ - struct string_ref - : boost::less_than_comparable > > > - { - public: - typedef std::string::const_iterator iterator; - typedef std::string::const_iterator const_iterator; - - private: - iterator begin_, end_; - - public: - string_ref() : begin_(), end_() {} - - explicit string_ref(iterator b, iterator e) - : begin_(b), end_(e) {} - - explicit string_ref(std::string const& x) - : begin_(x.begin()), end_(x.end()) {} - - void swap(string_ref&); - - void clear() { - begin_ = end_ = iterator(); - } - - operator std::string() const { - return std::string(begin_, end_); - } - - iterator begin() const { return begin_; } - iterator end() const { return end_; } - - std::size_t size() const - { - return static_cast(end_ - begin_); - } - - bool empty() const - { - return begin_ == end_; - } - }; - - bool operator==(string_ref const& x, string_ref const& y); - bool operator<(string_ref const& x, string_ref const& y); - std::ostream& operator<<(std::ostream&, string_ref const& x); - - inline bool operator==(string_ref const& x, std::string const& y) - { - return x == string_ref(y); - } - - inline bool operator<(string_ref const& x, std::string const& y) - { - return x < string_ref(y); - } - - inline bool operator>(string_ref const& x, std::string const& y) - { - return x > string_ref(y); - } - - inline void swap(string_ref& x, string_ref& y) - { - x.swap(y); - } -} - -#endif diff --git a/src/syntax_highlight.cpp b/src/syntax_highlight.cpp index e618c07..bb164c5 100644 --- a/src/syntax_highlight.cpp +++ b/src/syntax_highlight.cpp @@ -93,7 +93,7 @@ namespace quickbook // State bool support_callouts; - string_ref marked_text; + boost::string_ref marked_text; syntax_highlight_actions(quickbook::state& state, bool is_block) : out(), state(state), @@ -186,7 +186,7 @@ namespace quickbook void syntax_highlight_actions::mark_text(parse_iterator first, parse_iterator last) { - marked_text = string_ref(first.base(), last.base()); + marked_text = boost::string_ref(first.base(), last.base() - first.base()); } void syntax_highlight_actions::callout(parse_iterator, parse_iterator) diff --git a/src/utils.cpp b/src/utils.cpp index 3a5ee42..9bd0bee 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -29,9 +29,9 @@ namespace quickbook { namespace detail } } - void print_string(std::basic_string const& str, std::ostream& out) + void print_string(boost::string_ref const& str, std::ostream& out) { - for (std::string::const_iterator cur = str.begin(); + for (boost::string_ref::const_iterator cur = str.begin(); cur != str.end(); ++cur) { print_char(*cur, out); diff --git a/src/utils.hpp b/src/utils.hpp index 9170f81..d867747 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -14,10 +14,11 @@ #include #include #include +#include namespace quickbook { namespace detail { void print_char(char ch, std::ostream& out); - void print_string(std::basic_string const& str, std::ostream& out); + void print_string(boost::string_ref const& str, std::ostream& out); char filter_identifier_char(char ch); template @@ -33,6 +34,13 @@ namespace quickbook { namespace detail { } std::string escape_uri(std::string uri); + inline std::string escape_uri(boost::string_ref const& uri) { + return escape_uri(std::string(uri.begin(), uri.end())); + } + + inline std::string to_s(boost::string_ref x) { + return std::string(x.begin(), x.end()); + } }} #endif // BOOST_SPIRIT_QUICKBOOK_UTILS_HPP diff --git a/src/values.cpp b/src/values.cpp index 904cc8b..59c11cf 100644 --- a/src/values.cpp +++ b/src/values.cpp @@ -50,7 +50,7 @@ namespace quickbook file_ptr value_node::get_file() const { UNDEFINED_ERROR(); } string_iterator value_node::get_position() const { UNDEFINED_ERROR(); } int value_node::get_int() const { UNDEFINED_ERROR(); } - string_ref value_node::get_quickbook() const { UNDEFINED_ERROR(); } + boost::string_ref value_node::get_quickbook() const { UNDEFINED_ERROR(); } std::string value_node::get_encoded() const { UNDEFINED_ERROR(); } value_node* value_node::get_list() const { UNDEFINED_ERROR(); } @@ -332,7 +332,7 @@ namespace quickbook virtual value_node* clone() const; virtual file_ptr get_file() const; virtual string_iterator get_position() const; - virtual string_ref get_quickbook() const; + virtual boost::string_ref get_quickbook() const; virtual bool empty() const; virtual bool equals(value_node*) const; @@ -354,7 +354,7 @@ namespace quickbook virtual value_node* clone() const; virtual file_ptr get_file() const; virtual string_iterator get_position() const; - virtual string_ref get_quickbook() const; + virtual boost::string_ref get_quickbook() const; virtual std::string get_encoded() const; virtual bool empty() const; virtual bool is_encoded() const; @@ -433,8 +433,8 @@ namespace quickbook string_iterator qbk_value_impl::get_position() const { return begin_; } - string_ref qbk_value_impl::get_quickbook() const - { return string_ref(begin_, end_); } + boost::string_ref qbk_value_impl::get_quickbook() const + { return boost::string_ref(begin_, end_ - begin_); } bool qbk_value_impl::empty() const { return begin_ == end_; } @@ -481,8 +481,8 @@ namespace quickbook string_iterator encoded_qbk_value_impl::get_position() const { return begin_; } - string_ref encoded_qbk_value_impl::get_quickbook() const - { return string_ref(begin_, end_); } + boost::string_ref encoded_qbk_value_impl::get_quickbook() const + { return boost::string_ref(begin_, end_ - begin_); } std::string encoded_qbk_value_impl::get_encoded() const { return encoded_value_; } diff --git a/src/values.hpp b/src/values.hpp index d637ea2..e681c8a 100644 --- a/src/values.hpp +++ b/src/values.hpp @@ -16,9 +16,9 @@ #include #include #include +#include #include #include "fwd.hpp" -#include "string_ref.hpp" #include "files.hpp" namespace quickbook @@ -51,7 +51,7 @@ namespace quickbook virtual file_ptr get_file() const; virtual string_iterator get_position() const; - virtual string_ref get_quickbook() const; + virtual boost::string_ref get_quickbook() const; virtual std::string get_encoded() const; virtual int get_int() const; @@ -113,7 +113,7 @@ namespace quickbook { return value_->get_file(); } string_iterator get_position() const { return value_->get_position(); } - string_ref get_quickbook() const + boost::string_ref get_quickbook() const { return value_->get_quickbook(); } std::string get_encoded() const { return value_->get_encoded(); } diff --git a/test/unit/Jamfile.v2 b/test/unit/Jamfile.v2 index 0b583b7..2dca669 100644 --- a/test/unit/Jamfile.v2 +++ b/test/unit/Jamfile.v2 @@ -20,8 +20,9 @@ project quickbook-unit-tests darwin:BOOST_DETAIL_CONTAINER_FWD ; -run values_test.cpp ../../src/values.cpp ../../src/files.cpp ../../src/string_ref.cpp ; +run values_test.cpp ../../src/values.cpp ../../src/files.cpp ; run post_process_test.cpp ../../src/post_process.cpp ; +run source_map_test.cpp ../../src/files.cpp ; # Copied from spirit run symbols_tests.cpp ; diff --git a/test/unit/source_map_test.cpp b/test/unit/source_map_test.cpp new file mode 100644 index 0000000..ead5b5f --- /dev/null +++ b/test/unit/source_map_test.cpp @@ -0,0 +1,316 @@ +/*============================================================================= + Copyright (c) 2012 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include "fwd.hpp" +#include "files.hpp" +#include +#include +#include + +void simple_map_tests() +{ + boost::string_ref source("First Line\nSecond Line"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + + quickbook::string_iterator line1 = fake_file->source().begin(); + quickbook::string_iterator line1_end = boost::find(fake_file->source(), '\n'); + quickbook::string_iterator line2 = line1_end + 1; + quickbook::string_iterator line2_end = fake_file->source().end(); + + quickbook::mapped_file_builder builder; + + { // Empty test + builder.start(fake_file); + BOOST_TEST(builder.empty()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST(f1->source().empty()); + } + + { // Add full text + builder.start(fake_file); + builder.add(boost::string_ref(line1, line2_end - line1)); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), source); + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(1,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), + quickbook::file_position(1,3)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line1_end - line1)), + quickbook::file_position(1,line1_end - line1 + 1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line2 - line1)), + quickbook::file_position(2,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + fake_file->position_of(fake_file->source().end())); + } + + { // Add first line + builder.start(fake_file); + builder.add(boost::string_ref(line1, line1_end - line1)); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref(source.begin(), line1_end - line1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(1,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), + quickbook::file_position(1,3)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(1,line1_end - line1 + 1)); + } + + { // Add second line + builder.start(fake_file); + builder.add(boost::string_ref(line2, line2_end - line2)); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), boost::string_ref("Second Line")); + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(2,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), + quickbook::file_position(2,3)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(2,line2_end - line2 + 1)); + } + + { // Out of order + builder.start(fake_file); + builder.add(boost::string_ref(line2, line2_end - line2)); + builder.add(boost::string_ref(line1_end, 1)); + builder.add(boost::string_ref(line1, line1_end - line1)); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Second Line\nFirst Line")); + + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(2,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), + quickbook::file_position(2,3)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line2_end - line2 - 1)), + quickbook::file_position(2,line2_end - line2)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line2_end - line2)), + quickbook::file_position(1,(line1_end - line1 + 1))); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line2_end - line2 + 1)), + quickbook::file_position(1,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(1,line1_end - line1 + 1)); + } + + { // Repeated text + builder.start(fake_file); + builder.add(boost::string_ref(line2, line2_end - line2)); + builder.add(boost::string_ref(line1_end, 1)); + builder.add(boost::string_ref(line2, line2_end - line2)); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Second Line\nSecond Line")); + + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(2,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), + quickbook::file_position(2,3)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line2_end - line2 - 1)), + quickbook::file_position(2,line2_end - line2)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line2_end - line2)), + quickbook::file_position(1,(line1_end - line1 + 1))); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + (line2_end - line2 + 1)), + quickbook::file_position(2,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(2,line2_end - line2 + 1)); + } + + + { // Generated text + builder.start(fake_file); + builder.add_at_pos("------\n", line1); + builder.add(boost::string_ref(line1, line1_end - line1)); + builder.add_at_pos("\n------\n", line1_end); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("------\nFirst Line\n------\n")); + + quickbook::string_iterator newline = boost::find(f1->source(), '\n'); + + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(1,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), + quickbook::file_position(1,1)); + BOOST_TEST_EQ(f1->position_of(newline), + quickbook::file_position(1,1)); + BOOST_TEST_EQ(f1->position_of(newline + 1), + quickbook::file_position(1,1)); + BOOST_TEST_EQ(f1->position_of(newline + 2), + quickbook::file_position(1,2)); + BOOST_TEST_EQ(f1->position_of(newline + (line1_end - line1)), + quickbook::file_position(1,line1_end - line1)); + BOOST_TEST_EQ(f1->position_of(newline + (line1_end - line1 + 1)), + quickbook::file_position(1,line1_end - line1 + 1)); + BOOST_TEST_EQ(f1->position_of(newline + (line1_end - line1 + 2)), + quickbook::file_position(1,line1_end - line1 + 1)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(1,line1_end - line1 + 1)); + } +} + +void indented_map_tests() +{ + boost::string_ref source( + " Code line1\n" + " Code line2\n"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + + quickbook::mapped_file_builder builder; + + { + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\nCode line2\n")); + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(1,4)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), + quickbook::file_position(1,5)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 5), + quickbook::file_position(1,9)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 10), + quickbook::file_position(1,14)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 11), + quickbook::file_position(2,4)); + // TODO: Shouldn't this be (3,1)? Does it matter? + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(3,1)); + } + + { + builder.start(fake_file); + { + quickbook::mapped_file_builder builder2; + builder2.start(fake_file); + builder2.unindent_and_add(fake_file->source()); + builder.add(builder2); + } + quickbook::file_ptr f1 = builder.release(); + + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\nCode line2\n")); + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(1,4)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), + quickbook::file_position(1,5)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 5), + quickbook::file_position(1,9)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 10), + quickbook::file_position(1,14)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 11), + quickbook::file_position(2,4)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(3,1)); + } + + { + builder.start(fake_file); + builder.unindent_and_add(boost::string_ref( + fake_file->source().begin() + 3, + fake_file->source().end() - (fake_file->source().begin() + 3))); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n Code line2\n")); + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(1,4)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), + quickbook::file_position(1,5)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 5), + quickbook::file_position(1,9)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 10), + quickbook::file_position(1,14)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 11), + quickbook::file_position(2,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().end()), + quickbook::file_position(3,1)); + } +} + +void indented_map_tests2() +{ + boost::string_ref source( + " Code line1\n" + "\n" + " Code line2\n"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + + quickbook::mapped_file_builder builder; + + { + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n\nCode line2\n")); + BOOST_TEST_EQ(f1->position_of(f1->source().begin()), + quickbook::file_position(1,4)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), + quickbook::file_position(1,5)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 5), + quickbook::file_position(1,9)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 10), + quickbook::file_position(1,14)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 11), + quickbook::file_position(2,1)); + BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 12), + quickbook::file_position(3,4)); + } +} + +void indented_map_leading_blanks_test() +{ + quickbook::mapped_file_builder builder; + + { + boost::string_ref source("\n\n Code line1\n"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n")); + } + + { + boost::string_ref source(" \n \n Code line1\n"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n")); + } + + { + boost::string_ref source(" Code line1\n \n Code line2"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n\nCode line2")); + } + +} + +int main() +{ + simple_map_tests(); + indented_map_tests(); + indented_map_tests2(); + indented_map_leading_blanks_test(); + return boost::report_errors(); +} diff --git a/test/unit/values_test.cpp b/test/unit/values_test.cpp index b6d186c..d3da4a8 100644 --- a/test/unit/values_test.cpp +++ b/test/unit/values_test.cpp @@ -32,10 +32,10 @@ void qbk_tests() "(fake file)", source, 105u); q = quickbook::qbk_value( fake_file, - fake_file->source.begin(), - fake_file->source.end()); + fake_file->source().begin(), + fake_file->source().end()); } - BOOST_TEST_EQ(q.get_quickbook(), source); + BOOST_TEST_EQ(q.get_quickbook(), boost::string_ref(source)); } void sort_test() From d8b487499beb8a854ce36d8b6b044de7d361edb4 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 16 May 2013 21:30:01 +0000 Subject: [PATCH 82/94] Merge quickbook to release. [SVN r84300] --- doc/1_6.qbk | 25 ++- doc/change_log.qbk | 13 ++ src/block_element_grammar.cpp | 5 +- src/dependency_tracker.cpp | 65 +++++- src/dependency_tracker.hpp | 9 +- src/doc_info_grammar.cpp | 20 +- src/files.cpp | 210 ++++++++++++------ src/grammar_impl.hpp | 1 + src/main_grammar.cpp | 90 +++++++- src/quickbook.cpp | 134 ++++++++--- src/syntax_highlight.cpp | 54 +++-- test/code_cpp-1_5.gold | 15 +- test/code_cpp-1_5.quickbook | 12 + test/doc-info/Jamfile.v2 | 2 + test/doc-info/macros1-1_5.gold | 11 + test/doc-info/macros1-1_5.quickbook | 6 + test/doc-info/macros1-1_6.gold | 8 + test/doc-info/macros1-1_6.quickbook | 7 + test/doc-info/macros1-inc_1_6.quickbook | 4 + test/{empty.qbk => empty-inc.quickbook} | 0 test/include-1_5.quickbook | 14 +- test/include-1_6.quickbook | 10 +- ..._sub-1_5.qbk => include-inc-1_5.quickbook} | 0 ...{include_sub.qbk => include-inc.quickbook} | 0 test/include/compatibility-1_1.quickbook | 8 +- test/include/compatibility-1_5.quickbook | 8 +- test/include/compatibility-1_6.quickbook | 8 +- ...ty-inc.qbk => compatibility-inc.quickbook} | 0 ..._1.qbk => compatibility-inc_1_1.quickbook} | 0 ..._5.qbk => compatibility-inc_1_5.quickbook} | 0 ..._6.qbk => compatibility-inc_1_6.quickbook} | 0 test/include/in_section-1_5.quickbook | 12 +- test/include/in_section-1_6.quickbook | 12 +- ...include1.qbk => in_section-inc1.quickbook} | 0 ...include2.qbk => in_section-inc2.quickbook} | 0 .../include_id_unbalanced-1_6.quickbook | 4 +- ...k => include_id_unbalanced-inc1.quickbook} | 2 +- ... => include_id_unbalanced-inc1a.quickbook} | 0 ...k => include_id_unbalanced-inc2.quickbook} | 2 +- ... => include_id_unbalanced-inc2a.quickbook} | 0 .../nested_compatibility-1_5.quickbook | 8 +- .../nested_compatibility-1_6.quickbook | 8 +- ...=> nested_compatibility-inc-1_5.quickbook} | 0 ...=> nested_compatibility-inc-1_6.quickbook} | 0 test/include/source_mode-1_5.quickbook | 2 +- test/include/source_mode-1_6.quickbook | 2 +- ...de-inc1.qbk => source_mode-inc1.quickbook} | 0 test/include2-1_6.quickbook | 6 +- test/include_win_path-1_6-fail.quickbook | 2 +- test/python/include_path.qbk | 8 + test/python/missing_relative.qbk | 8 + test/python/sub1/a.qbk | 8 + test/python/sub2/b.qbk | 8 + test/python/svg_missing.qbk | 8 + test/snippets/unbalanced_snippet1.cpp | 2 +- test/snippets/unbalanced_snippet2.cpp | 2 +- test/unit/source_map_test.cpp | 79 +++++++ test/versions/invalid_macro-1_6.quickbook | 4 +- ..._1.qbk => invalid_macro-inc-1_1.quickbook} | 0 ...es-1_1.qbk => templates-inc-1_1.quickbook} | 0 ...es-1_4.qbk => templates-inc-1_4.quickbook} | 0 ...es-1_5.qbk => templates-inc-1_5.quickbook} | 0 test/versions/versions-1_6.quickbook | 12 +- 63 files changed, 726 insertions(+), 212 deletions(-) create mode 100644 test/doc-info/macros1-1_5.gold create mode 100644 test/doc-info/macros1-1_5.quickbook create mode 100644 test/doc-info/macros1-1_6.gold create mode 100644 test/doc-info/macros1-1_6.quickbook create mode 100644 test/doc-info/macros1-inc_1_6.quickbook rename test/{empty.qbk => empty-inc.quickbook} (100%) rename test/{include_sub-1_5.qbk => include-inc-1_5.quickbook} (100%) rename test/{include_sub.qbk => include-inc.quickbook} (100%) rename test/include/{compatibility-inc.qbk => compatibility-inc.quickbook} (100%) rename test/include/{compatibility-inc_1_1.qbk => compatibility-inc_1_1.quickbook} (100%) rename test/include/{compatibility-inc_1_5.qbk => compatibility-inc_1_5.quickbook} (100%) rename test/include/{compatibility-inc_1_6.qbk => compatibility-inc_1_6.quickbook} (100%) rename test/include/{in_section-include1.qbk => in_section-inc1.quickbook} (100%) rename test/include/{in_section-include2.qbk => in_section-inc2.quickbook} (100%) rename test/include/{include_id_unbalanced-inc1.qbk => include_id_unbalanced-inc1.quickbook} (57%) rename test/include/{include_id_unbalanced-inc1a.qbk => include_id_unbalanced-inc1a.quickbook} (100%) rename test/include/{include_id_unbalanced-inc2.qbk => include_id_unbalanced-inc2.quickbook} (61%) rename test/include/{include_id_unbalanced-inc2a.qbk => include_id_unbalanced-inc2a.quickbook} (100%) rename test/include/{nested_compatibility_inc-1_5.qbk => nested_compatibility-inc-1_5.quickbook} (100%) rename test/include/{nested_compatibility_inc-1_6.qbk => nested_compatibility-inc-1_6.quickbook} (100%) rename test/include/{source_mode-inc1.qbk => source_mode-inc1.quickbook} (100%) rename test/versions/{invalid_macro-inc-1_1.qbk => invalid_macro-inc-1_1.quickbook} (100%) rename test/versions/{templates-1_1.qbk => templates-inc-1_1.quickbook} (100%) rename test/versions/{templates-1_4.qbk => templates-inc-1_4.quickbook} (100%) rename test/versions/{templates-1_5.qbk => templates-inc-1_5.quickbook} (100%) diff --git a/doc/1_6.qbk b/doc/1_6.qbk index e9ce035..eac1ea2 100644 --- a/doc/1_6.qbk +++ b/doc/1_6.qbk @@ -70,6 +70,19 @@ before. [endsect] [/docinfo] +[section:doc-info-macros Macros in docinfo block] + +You can now expand macros in text fields in the docinfo block. In the top +docinfo block only the predefined macros are available, but in nested documents +macros defined in the parent document are also available. + +There's a small bug here - this leaks into older versions for the `license` +and `purpose` fields, but since only the predefined macros are available, it's +unlikely to break any existing documents. So I'd rather not complicate the code +further by fixing that. + +[endsect] + [section:scope Scoping templates and macros] A long standing quickbook bug is that macros are scoped by file, but templates @@ -241,8 +254,13 @@ if you're totally sure that you will need it. so that they aren't wrapped in paragraph tags. The main use is for escaped docbook block tags, such as: - [template chapter[title] [block''''''[title]'''''']] - [template chapterend [block'''''']] + [template chapter[title] + [block''''''[title]''''''] + ] + + [template chapterend + [block''''''] + ] [chapter An example chapter] @@ -253,6 +271,9 @@ for escaped docbook block tags, such as: Without the `block` element, the `chapter` and `chapterend` templates would be wrapped in paragraph tags. +[note In this example, the template body has to start with a newline so that +the template will be interpreted in block mode.] + [endsect] [section:lists `ordered_list` and `itemized_list`] diff --git a/doc/change_log.qbk b/doc/change_log.qbk index aacd813..77413eb 100644 --- a/doc/change_log.qbk +++ b/doc/change_log.qbk @@ -279,6 +279,19 @@ Boost 1.46.1: * When code blocks are indented using a mixture of tabs and spaces, convert indentation to spaces. +* In the C++ systax highlighter, fix syntax highlighting for `#`, so that it's + used for preprocessor statements at the start of a line, and as a 'special' + character elsewhere + ([@https://svn.boost.org/trac/boost/ticket/8510 #8510], + [@https://svn.boost.org/trac/boost/ticket/8511 #8511]). +* Add C++11 keywords to syntax highlighter + ([@https://svn.boost.org/trac/boost/ticket/8541 #8541]). +* Hidden options for formatting of `--output-deps`. Not really for public use +* yet. +* 1.6 changes: + * Better template argument parsing, so that it understands things + like escaped markup. + * Support for using macros in the doc info block. * Internal changes: * Convert to use `boost::string_ref`. * Clean up the source map implementation (used to get the correct diff --git a/src/block_element_grammar.cpp b/src/block_element_grammar.cpp index 1f5d5da..1d998b9 100644 --- a/src/block_element_grammar.cpp +++ b/src/block_element_grammar.cpp @@ -169,7 +169,10 @@ namespace quickbook ; local.template_body = - *(('[' >> local.template_body >> ']') | (cl::anychar_p - ']')) + qbk_ver(106u) + >> *(~cl::eps_p(']') >> skip_entity) + | qbk_ver(0,106u) + >> *(('[' >> local.template_body >> ']') | (cl::anychar_p - ']')) >> cl::eps_p(space >> ']') >> space ; diff --git a/src/dependency_tracker.cpp b/src/dependency_tracker.cpp index 53d24d2..ff28198 100644 --- a/src/dependency_tracker.cpp +++ b/src/dependency_tracker.cpp @@ -56,28 +56,69 @@ namespace quickbook return fs::canonical(p) / extra; } + static char const* control_escapes[16] = { + "\\000", "\\001", "\\002", "\\003", + "\\004", "\\005", "\\006", "\\a", + "\\b", "\\t", "\\n", "\\v", + "\\f", "\\r", "\\016", "\\017" + }; + + static std::string escaped_path(std::string const& generic) + { + std::string result; + result.reserve(generic.size()); + + BOOST_FOREACH(char c, generic) + { + if (c >= 0 && c < 16) { + result += control_escapes[(unsigned int) c]; + } + else if (c == '\\') { + result += "\\\\"; + } + else if (c == 127) { + result += "\\177"; + } + else { + result += c; + } + } + + return result; + } + + static std::string get_path(fs::path const& path, + dependency_tracker::flags f) + { + std::string generic = detail::path_to_generic(path); + + if (f & dependency_tracker::escaped) { + generic = escaped_path(generic); + } + + return generic; + } + bool dependency_tracker::add_dependency(fs::path const& f) { bool found = fs::exists(fs::status(f)); dependencies[normalize_path(f)] |= found; return found; } - void dependency_tracker::write_dependencies(std::ostream& out) + void dependency_tracker::write_dependencies(std::ostream& out, + flags f) { BOOST_FOREACH(dependency_list::value_type const& d, dependencies) { - if (d.second) { - out << detail::path_to_generic(d.first) << std::endl; + if (f & checked) { + out << (d.second ? "+ " : "- ") + << get_path(d.first, f) << std::endl; + } + else { + if (d.second) { + out << get_path(d.first, f) << std::endl; + } } } } - - void dependency_tracker::write_checked_locations(std::ostream& out) - { - BOOST_FOREACH(dependency_list::value_type const& d, dependencies) - { - out << (d.second ? "+ " : "- ") - << detail::path_to_generic(d.first) << std::endl; - } - } } diff --git a/src/dependency_tracker.hpp b/src/dependency_tracker.hpp index bbf991c..6b477b9 100644 --- a/src/dependency_tracker.hpp +++ b/src/dependency_tracker.hpp @@ -25,12 +25,17 @@ namespace quickbook public: + enum flags { + default_ = 0, + checked = 1, + escaped = 2 + }; + // Call this before loading any file so that it will be included in the // list of dependencies. Returns true if file exists. bool add_dependency(fs::path const&); - void write_dependencies(std::ostream&); - void write_checked_locations(std::ostream&); + void write_dependencies(std::ostream&, flags = default_); }; } diff --git a/src/doc_info_grammar.cpp b/src/doc_info_grammar.cpp index 862d0ce..563efc3 100644 --- a/src/doc_info_grammar.cpp +++ b/src/doc_info_grammar.cpp @@ -75,7 +75,7 @@ namespace quickbook doc_authors, doc_author, doc_copyright, doc_copyright_holder, doc_source_mode, doc_biblioid, doc_compatibility_mode, - quickbook_version, char_; + quickbook_version, macro, char_; cl::uint_parser doc_copyright_year; cl::symbols<> doc_types; cl::symbols doc_info_attributes; @@ -119,6 +119,7 @@ namespace quickbook // Actions error_action error(state); plain_char_action plain_char(state.phrase, state); + do_macro_action do_macro(state.phrase, state); scoped_parser to_value(state); doc_info_details = @@ -302,6 +303,21 @@ namespace quickbook local.attribute_rules[doc_info_attributes::biblioid] = &local.doc_biblioid; - local.char_ = escape | cl::anychar_p[plain_char]; + local.char_ = + escape + | local.macro + | cl::anychar_p[plain_char]; + ; + + local.macro = + cl::eps_p + ( ( state.macro + >> ~cl::eps_p(cl::alpha_p | '_') + // must not be followed by alpha or underscore + ) + & macro_identifier // must be a valid macro for the current version + ) + >> state.macro [do_macro] + ; } } diff --git a/src/files.cpp b/src/files.cpp index fddd3b1..97c67c2 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -195,15 +195,13 @@ namespace quickbook std::string::size_type original_pos; std::string::size_type our_pos; section_types section_type; - int indentation; mapped_file_section( std::string::size_type original_pos, std::string::size_type our_pos, - section_types section_type = normal, - int indentation = 0) : + section_types section_type = normal) : original_pos(original_pos), our_pos(our_pos), - section_type(section_type), indentation(indentation) {} + section_type(section_type) {} }; struct mapped_section_original_cmp @@ -278,12 +276,11 @@ namespace quickbook pos - original->source().begin(), source().size())); } - void add_indented_mapped_file_section(boost::string_ref::const_iterator pos, - int indentation) + void add_indented_mapped_file_section(boost::string_ref::const_iterator pos) { mapped_sections.push_back(mapped_file_section( pos - original->source().begin(), source().size(), - mapped_file_section::indented, indentation)); + mapped_file_section::indented)); } std::string::size_type to_original_pos( @@ -293,10 +290,16 @@ namespace quickbook switch (section->section_type) { case mapped_file_section::normal: return pos - section->our_pos + section->original_pos; + case mapped_file_section::empty: return section->original_pos; + case mapped_file_section::indented: { + // Will contain the start of the current line. boost::string_ref::size_type our_line = section->our_pos; + + // Will contain the number of lines in the block before + // the current line. unsigned newline_count = 0; for(boost::string_ref::size_type i = section->our_pos; @@ -307,10 +310,8 @@ namespace quickbook ++newline_count; } } - - if (newline_count == 0) - return pos - section->our_pos + section->original_pos; + // The start of the line in the original source. boost::string_ref::size_type original_line = section->original_pos; @@ -319,18 +320,23 @@ namespace quickbook --newline_count; ++original_line; } - - for(unsigned i = section->indentation; i > 0; --i) { - if (original->source()[original_line] == '\n' || - original->source()[original_line] == '\0') break; - assert(original->source()[original_line] == ' ' || - original->source()[original_line] == '\t'); - ++original_line; - } - + + // The start of line content (i.e. after indentation). + our_line = skip_indentation(source(), our_line); + + // The position is in the middle of indentation, so + // just return the start of the whitespace, which should + // be good enough. + if (our_line > pos) return original_line; + + original_line = + skip_indentation(original->source(), original_line); + + // Confirm that we are actually in the same position. assert(original->source()[original_line] == source()[our_line]); + // Calculate the position return original_line + (pos - our_line); } default: @@ -353,6 +359,16 @@ namespace quickbook } virtual file_position position_of(boost::string_ref::const_iterator) const; + + private: + + static std::string::size_type skip_indentation( + boost::string_ref src, std::string::size_type i) + { + while (i != src.size() && (src[i] == ' ' || src[i] == '\t')) ++i; + return i; + } + }; namespace { @@ -436,14 +452,14 @@ namespace quickbook data->new_file->mapped_sections.push_back(mapped_file_section( x.data->new_file->to_original_pos(start, begin), - size, start->section_type, start->indentation)); + size, start->section_type)); for (++start; start != x.data->new_file->mapped_sections.end() && start->our_pos < end; ++start) { data->new_file->mapped_sections.push_back(mapped_file_section( start->original_pos, start->our_pos - begin + size, - start->section_type, start->indentation)); + start->section_type)); } data->new_file->source_.append( @@ -452,68 +468,130 @@ namespace quickbook } } + boost::string_ref::size_type indentation_count(boost::string_ref x) + { + unsigned count = 0; + + for(boost::string_ref::const_iterator begin = x.begin(), end = x.end(); + begin != end; ++begin) + { + switch(*begin) + { + case ' ': + ++count; + break; + case '\t': + // hardcoded tab to 4 for now + count = count - (count % 4) + 4; + break; + default: + assert(false); + } + } + + return count; + } + void mapped_file_builder::unindent_and_add(boost::string_ref x) { - std::string program(x.begin(), x.end()); + // I wanted to do everything using a string_ref, but unfortunately + // they don't have all the overloads used in here. So... + std::string const program(x.begin(), x.end()); // Erase leading blank lines and newlines: std::string::size_type start = program.find_first_not_of(" \t\r\n"); if (start == std::string::npos) return; start = program.find_last_of("\r\n", start); - if (start != std::string::npos) - { - ++start; - program.erase(0, start); - } + start = start == std::string::npos ? 0 : start + 1; - assert(program.size() != 0); + assert(start < program.size()); - // Get the first line indent - std::string::size_type indent = program.find_first_not_of(" \t"); - std::string::size_type pos = 0; - if (std::string::npos == indent) - { - // Nothing left to do here. The code is empty (just spaces). - // We clear the program to signal the caller that it is empty - // and return early. - program.clear(); - return; - } + // Get the first line indentation + std::string::size_type indent = program.find_first_not_of(" \t", start) - start; + boost::string_ref::size_type full_indent = indentation_count( + boost::string_ref(&program[start], indent)); + + std::string::size_type pos = start; // Calculate the minimum indent from the rest of the lines - do - { - pos = program.find_first_not_of("\r\n", pos); - if (std::string::npos == pos) - break; - - std::string::size_type n = program.find_first_not_of(" \t", pos); - if (n != std::string::npos) - { - char ch = program[n]; - if (ch != '\r' && ch != '\n') // ignore empty lines - indent = (std::min)(indent, n-pos); - } - } - while (std::string::npos != (pos = program.find_first_of("\r\n", pos))); - - // Trim white spaces from column 0..indent - pos = 0; - program.erase(0, indent); + // Detecting a mix of spaces and tabs. while (std::string::npos != (pos = program.find_first_of("\r\n", pos))) { - if (std::string::npos == (pos = program.find_first_not_of("\r\n", pos))) - { - break; - } + pos = program.find_first_not_of("\r\n", pos); + if (std::string::npos == pos) break; - std::string::size_type next = program.find_first_of("\r\n", pos); - program.erase(pos, (std::min)(indent, next-pos)); + std::string::size_type n = program.find_first_not_of(" \t", pos); + if (n == std::string::npos) break; + + char ch = program[n]; + if (ch == '\r' || ch == '\n') continue; // ignore empty lines + + indent = (std::min)(indent, n-pos); + full_indent = (std::min)(full_indent, indentation_count( + boost::string_ref(&program[pos], n-pos))); } - data->new_file->add_indented_mapped_file_section(x.begin() + indent, indent); - data->new_file->source_.append(program); + // Detect if indentation is mixed. + bool mixed_indentation = false; + boost::string_ref first_indent(&program[start], indent); + pos = start; + + while (std::string::npos != (pos = program.find_first_of("\r\n", pos))) + { + pos = program.find_first_not_of("\r\n", pos); + if (std::string::npos == pos) break; + + std::string::size_type n = program.find_first_not_of(" \t", pos); + if (n == std::string::npos || n-pos < indent) continue; + + if (boost::string_ref(&program[pos], indent) != first_indent) { + mixed_indentation = true; + break; + } + } + + // Trim white spaces from column 0..indent + std::string unindented_program; + std::string::size_type copy_start = start; + pos = start; + + do { + if (std::string::npos == (pos = program.find_first_not_of("\r\n", pos))) + break; + + unindented_program.append(program.begin() + copy_start, program.begin() + pos); + copy_start = pos; + + // Find the end of the indentation. + std::string::size_type next = program.find_first_not_of(" \t", pos); + if (next == std::string::npos) next = program.size(); + + if (mixed_indentation) + { + unsigned length = indentation_count(boost::string_ref( + &program[pos], next - pos)); + + if (length > full_indent) { + std::string new_indentation(length - full_indent, ' '); + unindented_program.append(new_indentation); + } + + copy_start = next; + } + else + { + copy_start = (std::min)(pos + indent, next); + } + + pos = next; + } while (std::string::npos != + (pos = program.find_first_of("\r\n", pos))); + + unindented_program.append(program.begin() + copy_start, program.end()); + + data->new_file->add_indented_mapped_file_section(x.begin()); + data->new_file->source_.append(unindented_program); } file_position mapped_file::position_of(boost::string_ref::const_iterator pos) const diff --git a/src/grammar_impl.hpp b/src/grammar_impl.hpp index 090b399..800e9f8 100644 --- a/src/grammar_impl.hpp +++ b/src/grammar_impl.hpp @@ -77,6 +77,7 @@ namespace quickbook cl::rule attribute_value_1_7; cl::rule escape; cl::rule raw_escape; + cl::rule skip_entity; // Miscellaneous stuff cl::rule hard_space; diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index c494350..a01c00a 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -128,17 +128,19 @@ namespace quickbook top_level, indent_check, paragraph_separator, code, code_line, blank_line, hr, - inline_code, + inline_code, skip_inline_code, template_, - code_block, macro, + code_block, skip_code_block, macro, template_args, template_args_1_4, template_arg_1_4, template_inner_arg_1_4, brackets_1_4, template_args_1_5, template_arg_1_5, template_arg_1_5_content, template_inner_arg_1_5, brackets_1_5, + template_args_1_6, template_arg_1_6, template_arg_1_6_content, break_, command_line_macro_identifier, - dummy_block, line_dummy_block, square_brackets + dummy_block, line_dummy_block, square_brackets, + skip_escape ; struct simple_markup_closure @@ -540,6 +542,17 @@ namespace quickbook | cl::anychar_p [plain_char] ; + skip_entity = + '[' + >> *(~cl::eps_p(']') >> skip_entity) + >> !cl::ch_p(']') + | local.skip_code_block + | local.skip_inline_code + | local.skip_escape + | comment + | (cl::anychar_p - '[' - ']') + ; + local.square_brackets = ( cl::ch_p('[') [plain_char] >> paragraph_phrase @@ -580,7 +593,8 @@ namespace quickbook ; local.template_args = - qbk_ver(105u) >> local.template_args_1_5 + qbk_ver(106u) >> local.template_args_1_6 + | qbk_ver(105u, 106u) >> local.template_args_1_5 | qbk_ver(0, 105u) >> local.template_args_1_4 ; @@ -622,6 +636,19 @@ namespace quickbook '[' >> local.template_inner_arg_1_5 >> ']' ; + local.template_args_1_6 = local.template_arg_1_6 >> *(".." >> local.template_arg_1_6); + + local.template_arg_1_6 = + ( cl::eps_p(*cl::blank_p >> cl::eol_p) + >> local.template_arg_1_6_content [state.values.entry(ph::arg1, ph::arg2, template_tags::block)] + | local.template_arg_1_6_content [state.values.entry(ph::arg1, ph::arg2, template_tags::phrase)] + ) + ; + + local.template_arg_1_6_content = + + ( ~cl::eps_p("..") >> skip_entity ) + ; + local.break_ = ( '[' >> space @@ -645,6 +672,48 @@ namespace quickbook ] [element] ; + local.skip_inline_code = + '`' + >> *(cl::anychar_p - + ( '`' + | (cl::eol_p >> *cl::blank_p >> cl::eol_p) + // Make sure that we don't go + ) // past a single block + ) + >> !cl::ch_p('`') + ; + + local.skip_code_block = + "```" + >> ~cl::eps_p("`") + >> ( !( *(*cl::blank_p >> cl::eol_p) + >> ( *( "````" >> *cl::ch_p('`') + | ( cl::anychar_p + - (*cl::space_p >> "```" >> ~cl::eps_p("`")) + ) + ) + >> !(*cl::blank_p >> cl::eol_p) + ) + >> (*cl::space_p >> "```") + ) + | *cl::anychar_p + ) + | "``" + >> ~cl::eps_p("`") + >> ( ( *(*cl::blank_p >> cl::eol_p) + >> ( *( "```" >> *cl::ch_p('`') + | ( cl::anychar_p + - (*cl::space_p >> "``" >> ~cl::eps_p("`")) + ) + ) + >> !(*cl::blank_p >> cl::eol_p) + ) + >> (*cl::space_p >> "``") + ) + | *cl::anychar_p + ) + ; + local.code_block = "```" >> ~cl::eps_p("`") @@ -746,6 +815,19 @@ namespace quickbook ] ; + local.skip_escape = + cl::str_p("\\n") + | cl::str_p("\\ ") + | '\\' >> cl::punct_p + | "\\u" >> cl::repeat_p(4) [cl::chset<>("0-9a-fA-F")] + | "\\U" >> cl::repeat_p(8) [cl::chset<>("0-9a-fA-F")] + | ("'''" >> !eol) + >> (*(cl::anychar_p - "'''")) + >> ( cl::str_p("'''") + | cl::eps_p + ) + ; + raw_escape = cl::str_p("\\n") [error("Newlines invalid here.")] | cl::str_p("\\ ") // ignore an escaped space diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 8890dcb..2af638c 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include @@ -111,16 +113,29 @@ namespace quickbook } } + struct parse_document_options + { + parse_document_options() : + indent(-1), + linewidth(-1), + pretty_print(true), + deps_out_flags(quickbook::dependency_tracker::default_) + {} + + int indent; + int linewidth; + bool pretty_print; + fs::path deps_out; + quickbook::dependency_tracker::flags deps_out_flags; + fs::path locations_out; + fs::path xinclude_base; + }; + static int parse_document( fs::path const& filein_ , fs::path const& fileout_ - , fs::path const& deps_out_ - , fs::path const& locations_out_ - , fs::path const& xinclude_base_ - , int indent - , int linewidth - , bool pretty_print) + , parse_document_options const& options_) { string_stream buffer; id_manager ids; @@ -128,7 +143,7 @@ namespace quickbook int result = 0; try { - quickbook::state state(filein_, xinclude_base_, buffer, ids); + quickbook::state state(filein_, options_.xinclude_base, buffer, ids); set_macros(state); if (state.error_count == 0) { @@ -145,16 +160,18 @@ namespace quickbook result = state.error_count ? 1 : 0; - if (!deps_out_.empty()) + if (!options_.deps_out.empty()) { - fs::ofstream out(deps_out_); - state.dependencies.write_dependencies(out); + fs::ofstream out(options_.deps_out); + state.dependencies.write_dependencies(out, + options_.deps_out_flags); } - if (!locations_out_.empty()) + if (!options_.locations_out.empty()) { - fs::ofstream out(locations_out_); - state.dependencies.write_checked_locations(out); + fs::ofstream out(options_.locations_out); + state.dependencies.write_dependencies(out, + dependency_tracker::checked); } } catch (load_error& e) { @@ -177,11 +194,12 @@ namespace quickbook return 1; } - if (pretty_print) + if (options_.pretty_print) { try { - fileout << post_process(stage2, indent, linewidth); + fileout << post_process(stage2, options_.indent, + options_.linewidth); } catch (quickbook::post_process_failure&) { @@ -243,6 +261,8 @@ main(int argc, char* argv[]) quickbook::detail::initialise_output(); quickbook::detail::initialise_markups(); + // Declare the program options + options_description desc("Allowed options"); options_description hidden("Hidden options"); options_description all("All options"); @@ -277,10 +297,15 @@ main(int argc, char* argv[]) ("xinclude-base", PO_VALUE(), "Generate xincludes as if generating for this target " "directory.") + ("output-deps-format", PO_VALUE(), + "Comma separated list of formatting options for output-deps, " + "options are: escaped, checked") ("output-checked-locations", PO_VALUE(), "Writes a file listing all the file locations that were " "checked, starting with '+' if they were found, or '-' " - "if they weren't.") + "if they weren't.\n" + "This is deprecated, use 'output-deps-format=checked' to " + "write the deps file in this format.") ; all.add(desc).add(hidden); @@ -288,10 +313,9 @@ main(int argc, char* argv[]) positional_options_description p; p.add("input-file", -1); + // Read option from the command line + variables_map vm; - int indent = -1; - int linewidth = -1; - bool pretty_print = true; #if QUICKBOOK_WIDE_PATHS quickbook::ignore_variable(&argc); @@ -321,6 +345,9 @@ main(int argc, char* argv[]) notify(vm); + // Process the command line options + + quickbook::parse_document_options parse_document_options; bool expect_errors = vm.count("expect-errors"); int error_count = 0; @@ -352,15 +379,15 @@ main(int argc, char* argv[]) quickbook::ms_errors = true; if (vm.count("no-pretty-print")) - pretty_print = false; + parse_document_options.pretty_print = false; quickbook::self_linked_headers = !vm.count("no-self-link-headers"); if (vm.count("indent")) - indent = vm["indent"].as(); + parse_document_options.indent = vm["indent"].as(); if (vm.count("linewidth")) - linewidth = vm["linewidth"].as(); + parse_document_options.linewidth = vm["linewidth"].as(); if (vm.count("debug")) { @@ -410,22 +437,56 @@ main(int argc, char* argv[]) fs::path filein = quickbook::detail::input_to_path( vm["input-file"].as()); fs::path fileout; - fs::path deps_out; - fs::path locations_out; bool default_output = true; if (vm.count("output-deps")) { - deps_out = quickbook::detail::input_to_path( - vm["output-deps"].as()); + parse_document_options.deps_out = + quickbook::detail::input_to_path( + vm["output-deps"].as()); default_output = false; } + if (vm.count("output-deps-format")) + { + std::string format_flags = + quickbook::detail::input_to_utf8( + vm["output-deps-format"].as()); + + std::vector flag_names; + boost::algorithm::split(flag_names, format_flags, + boost::algorithm::is_any_of(", "), + boost::algorithm::token_compress_on); + + unsigned flags = 0; + + BOOST_FOREACH(std::string const& flag, flag_names) { + if (flag == "checked") { + flags |= quickbook::dependency_tracker::checked; + } + else if (flag == "escaped") { + flags |= quickbook::dependency_tracker::escaped; + } + else if (!flag.empty()) { + quickbook::detail::outerr() + << "Unknown dependency format flag: " + << flag + <()); + parse_document_options.locations_out = + quickbook::detail::input_to_path( + vm["output-checked-locations"].as()); default_output = false; } @@ -440,20 +501,20 @@ main(int argc, char* argv[]) fileout.replace_extension(".xml"); } - fs::path xinclude_base; if (vm.count("xinclude-base")) { - xinclude_base = quickbook::detail::input_to_path( - vm["xinclude-base"].as()); + parse_document_options.xinclude_base = + quickbook::detail::input_to_path( + vm["xinclude-base"].as()); } else { - xinclude_base = fileout.parent_path(); - if (xinclude_base.empty()) - xinclude_base = "."; + parse_document_options.xinclude_base = fileout.parent_path(); + if (parse_document_options.xinclude_base.empty()) + parse_document_options.xinclude_base = "."; } - if (!fs::is_directory(xinclude_base)) + if (!fs::is_directory(parse_document_options.xinclude_base)) { quickbook::detail::outerr() << (vm.count("xinclude-base") ? @@ -480,8 +541,7 @@ main(int argc, char* argv[]) if (!error_count) error_count += quickbook::parse_document( - filein, fileout, deps_out, locations_out, - xinclude_base, indent, linewidth, pretty_print); + filein, fileout, parse_document_options); if (expect_errors) { diff --git a/src/syntax_highlight.cpp b/src/syntax_highlight.cpp index bb164c5..fdeaef5 100644 --- a/src/syntax_highlight.cpp +++ b/src/syntax_highlight.cpp @@ -205,20 +205,23 @@ namespace quickbook keywords_holder() { cpp - = "and_eq", "and", "asm", "auto", "bitand", "bitor", - "bool", "break", "case", "catch", "char", "class", - "compl", "const_cast", "const", "continue", "default", - "delete", "do", "double", "dynamic_cast", "else", - "enum", "explicit", "export", "extern", "false", - "float", "for", "friend", "goto", "if", "inline", - "int", "long", "mutable", "namespace", "new", "not_eq", - "not", "operator", "or_eq", "or", "private", - "protected", "public", "register", "reinterpret_cast", - "return", "short", "signed", "sizeof", "static", + = "alignas", "alignof", "and_eq", "and", "asm", "auto", + "bitand", "bitor", "bool", "break", "case", "catch", + "char", "char16_t", "char32_t", "class", "compl", + "const", "const_cast", "constexpr", "continue", + "decltype", "default", "delete", "do", "double", + "dynamic_cast", "else", "enum", "explicit", "export", + "extern", "false", "float", "for", "friend", "goto", + "if", "inline", "int", "long", "mutable", "namespace", + "new", "noexcept", "not_eq", "not", "nullptr", + "operator", "or_eq", "or", "private", "protected", + "public", "register", "reinterpret_cast", "return", + "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch", "template", "this", - "throw", "true", "try", "typedef", "typeid", - "typename", "union", "unsigned", "using", "virtual", - "void", "volatile", "wchar_t", "while", "xor_eq", "xor" + "thread_local", "throw", "true", "try", "typedef", + "typeid", "typename", "union", "unsigned", "using", + "virtual", "void", "volatile", "wchar_t", "while", + "xor_eq", "xor" ; python @@ -270,12 +273,21 @@ namespace quickbook do_macro(self.actions, &syntax_highlight_actions::do_macro); error_action error(self.actions.state); - program - = - *( (+cl::space_p) [plain_char] + program = + *( (*cl::space_p) [plain_char] + >> (line_start | rest_of_line) + >> *rest_of_line + ) + ; + + line_start = + preprocessor [span("preprocessor")] + ; + + rest_of_line = + (+cl::blank_p) [plain_char] | macro | escape - | preprocessor [span("preprocessor")] | cl::eps_p(ph::var(self.actions.support_callouts)) >> ( line_callout [callout] | inline_callout [callout] @@ -287,8 +299,8 @@ namespace quickbook | string_ [span("string")] | char_ [span("char")] | number [span("number")] - | u8_codepoint_p [unexpected_char] - ) + | ~cl::eps_p(cl::eol_p) + >> u8_codepoint_p [unexpected_char] ; macro = @@ -359,7 +371,7 @@ namespace quickbook ; // make sure we recognize whole words only special - = +cl::chset_p("~!%^&*()+={[}]:;,<.>?/|\\-") + = +cl::chset_p("~!%^&*()+={[}]:;,<.>?/|\\#-") ; string_char = ('\\' >> u8_codepoint_p) | (cl::anychar_p - '\\'); @@ -387,7 +399,7 @@ namespace quickbook } cl::rule - program, macro, preprocessor, + program, line_start, rest_of_line, macro, preprocessor, inline_callout, line_callout, comment, special, string_, char_, number, identifier, keyword, escape, diff --git a/test/code_cpp-1_5.gold b/test/code_cpp-1_5.gold index be33bfd..d0bc79a 100644 --- a/test/code_cpp-1_5.gold +++ b/test/code_cpp-1_5.gold @@ -3,7 +3,11 @@
C++ Code Blocks -// No escape +#include <some_header> + #include "another_header.hpp" +# define A_MACRO value +#define stringize(hello) #hello +// No escape /* No escape */ /* No escape * with newlines @@ -13,6 +17,7 @@ /* Multiple escapes: italic * underlinebold */ +/* Token pasting: */ a##b A badly formed comment: @@ -24,4 +29,12 @@ /* Oh dear bold + + Just some code: + +int main() { + constexpr char32_t x = 'a'; + const auto y = x - ' '; +} +
diff --git a/test/code_cpp-1_5.quickbook b/test/code_cpp-1_5.quickbook index be8043a..fdaa926 100644 --- a/test/code_cpp-1_5.quickbook +++ b/test/code_cpp-1_5.quickbook @@ -2,6 +2,10 @@ [quickbook 1.5] ] + #include + #include "another_header.hpp" + # define A_MACRO value + #define stringize(hello) #hello // No escape /* No escape */ /* No escape @@ -12,6 +16,7 @@ /* Multiple escapes: ``/italic/`` * ``_underline_````*bold*`` */ + /* Token pasting: */ a##b A badly formed comment: @@ -20,3 +25,10 @@ A badly formed comment: A badly formed comment with an escape: /* Oh dear ``*bold*`` + +Just some code: + + int main() { + constexpr char32_t x = 'a'; + const auto y = x - ' '; + } diff --git a/test/doc-info/Jamfile.v2 b/test/doc-info/Jamfile.v2 index 9d4913b..bfb06cf 100644 --- a/test/doc-info/Jamfile.v2 +++ b/test/doc-info/Jamfile.v2 @@ -20,6 +20,8 @@ test-suite quickbook.test : [ quickbook-test escaped_attributes2-1_7 ] [ quickbook-test duplicates-1.1 ] [ quickbook-test duplicates-1.5 ] + [ quickbook-test macros1-1_5 ] + [ quickbook-test macros1-1_6 ] [ quickbook-test source-mode-1.4 ] [ quickbook-test source-mode-1.5 ] [ quickbook-test source-mode-1.6 ] diff --git a/test/doc-info/macros1-1_5.gold b/test/doc-info/macros1-1_5.gold new file mode 100644 index 0000000..0b76b9d --- /dev/null +++ b/test/doc-info/macros1-1_5.gold @@ -0,0 +1,11 @@ + + +
+ Macro shouldn't expand: __DATE__ + + + Unfortunately this does expand: 2000-Dec-20, but I'm not fixing it, as I don't + think it'll cause any real problems. + + +
diff --git a/test/doc-info/macros1-1_5.quickbook b/test/doc-info/macros1-1_5.quickbook new file mode 100644 index 0000000..c66a1de --- /dev/null +++ b/test/doc-info/macros1-1_5.quickbook @@ -0,0 +1,6 @@ +[article Macro shouldn't expand: __DATE__ + [quickbook 1.5] + [last-revision __DATE__] + [purpose Unfortunately this does expand: __DATE__, but I'm not fixing it, + as I don't think it'll cause any real problems.] +] diff --git a/test/doc-info/macros1-1_6.gold b/test/doc-info/macros1-1_6.gold new file mode 100644 index 0000000..92ac1a1 --- /dev/null +++ b/test/doc-info/macros1-1_6.gold @@ -0,0 +1,8 @@ + + +
+ Testing date: 2000-Dec-20 + + Testing macro date: 5 May 2013 + +
diff --git a/test/doc-info/macros1-1_6.quickbook b/test/doc-info/macros1-1_6.quickbook new file mode 100644 index 0000000..058c349 --- /dev/null +++ b/test/doc-info/macros1-1_6.quickbook @@ -0,0 +1,7 @@ +[article Testing date: __DATE__ + [quickbook 1.6] + [last-revision __DATE__] +] + +[def NESTED_MACRO 5 May 2013] +[include macros1-inc_1_6.quickbook] diff --git a/test/doc-info/macros1-inc_1_6.quickbook b/test/doc-info/macros1-inc_1_6.quickbook new file mode 100644 index 0000000..47fc84a --- /dev/null +++ b/test/doc-info/macros1-inc_1_6.quickbook @@ -0,0 +1,4 @@ +[chapter Testing macro date: NESTED_MACRO + [quickbook 1.6] + [last-revision NESTED_MACRO] +] diff --git a/test/empty.qbk b/test/empty-inc.quickbook similarity index 100% rename from test/empty.qbk rename to test/empty-inc.quickbook diff --git a/test/include-1_5.quickbook b/test/include-1_5.quickbook index 849d19c..9720121 100644 --- a/test/include-1_5.quickbook +++ b/test/include-1_5.quickbook @@ -3,15 +3,15 @@ [id include-test] ] -[include include_sub-1_5.qbk] -[include .\include_sub.qbk] -[include:foo include_sub.qbk] -[include empty.qbk] +[include include-inc-1_5.quickbook] +[include .\include-inc.quickbook] +[include:foo include-inc.quickbook] +[include empty-inc.quickbook] [def __defined__] -[? __undefined__ [include:foo1 include_sub.qbk] ] -[? __undefined__ [include:foo1 not_a_file.qbk] ] +[? __undefined__ [include:foo1 include-inc.quickbook] ] +[? __undefined__ [include:foo1 not_a_file.quickbook] ] [? __defined__ - Just trying including in a conditional macro. [include:foo2 include_sub.qbk] + Just trying including in a conditional macro. [include:foo2 include-inc.quickbook] With some text around it.] diff --git a/test/include-1_6.quickbook b/test/include-1_6.quickbook index 00d6033..29a7611 100644 --- a/test/include-1_6.quickbook +++ b/test/include-1_6.quickbook @@ -3,13 +3,13 @@ [id include-test] ] -[include include_sub.qbk] -[include:foo include_sub.qbk] +[include include-inc.quickbook] +[include:foo include-inc.quickbook] [def __defined__] -[? __undefined__ [include:foo1 include_sub.qbk] ] -[? __undefined__ [include:foo1 not-a-file.qbk] ] +[? __undefined__ [include:foo1 include-inc.quickbook] ] +[? __undefined__ [include:foo1 not-a-file.quickbook] ] [? __defined__ - Just trying including in a conditional macro. [include:foo2 include_sub.qbk] + Just trying including in a conditional macro. [include:foo2 include-inc.quickbook] With some text around it.] diff --git a/test/include_sub-1_5.qbk b/test/include-inc-1_5.quickbook similarity index 100% rename from test/include_sub-1_5.qbk rename to test/include-inc-1_5.quickbook diff --git a/test/include_sub.qbk b/test/include-inc.quickbook similarity index 100% rename from test/include_sub.qbk rename to test/include-inc.quickbook diff --git a/test/include/compatibility-1_1.quickbook b/test/include/compatibility-1_1.quickbook index ec5d62f..afdd39d 100644 --- a/test/include/compatibility-1_1.quickbook +++ b/test/include/compatibility-1_1.quickbook @@ -5,14 +5,14 @@ ] [section:collision Outer] -[include compatibility-inc.qbk] +[include compatibility-inc.quickbook] [endsect] [section:collision Include compatibility 1.1] -[include compatibility-inc_1_1.qbk] +[include compatibility-inc_1_1.quickbook] [endsect] [section:collision Include compatibility 1.5] -[include compatibility-inc_1_5.qbk] +[include compatibility-inc_1_5.quickbook] [endsect] [section:collision Include compatibility 1.6] -[include compatibility-inc_1_6.qbk] +[include compatibility-inc_1_6.quickbook] [endsect] diff --git a/test/include/compatibility-1_5.quickbook b/test/include/compatibility-1_5.quickbook index c16ddac..9593df7 100644 --- a/test/include/compatibility-1_5.quickbook +++ b/test/include/compatibility-1_5.quickbook @@ -5,14 +5,14 @@ ] [section:collision Outer] -[include compatibility-inc.qbk] +[include compatibility-inc.quickbook] [endsect] [section:collision Include compatibility 1.1] -[include compatibility-inc_1_1.qbk] +[include compatibility-inc_1_1.quickbook] [endsect] [section:collision Include compatibility 1.5] -[include compatibility-inc_1_5.qbk] +[include compatibility-inc_1_5.quickbook] [endsect] [section:collision Include compatibility 1.6] -[include compatibility-inc_1_6.qbk] +[include compatibility-inc_1_6.quickbook] [endsect] diff --git a/test/include/compatibility-1_6.quickbook b/test/include/compatibility-1_6.quickbook index 276674a..46880a8 100644 --- a/test/include/compatibility-1_6.quickbook +++ b/test/include/compatibility-1_6.quickbook @@ -4,14 +4,14 @@ ] [section:collision Outer] -[include compatibility-inc.qbk] +[include compatibility-inc.quickbook] [endsect] [section:collision Include compatibility 1.1] -[include compatibility-inc_1_1.qbk] +[include compatibility-inc_1_1.quickbook] [endsect] [section:collision Include compatibility 1.5] -[include compatibility-inc_1_5.qbk] +[include compatibility-inc_1_5.quickbook] [endsect] [section:collision Include compatibility 1.6] -[include compatibility-inc_1_6.qbk] +[include compatibility-inc_1_6.quickbook] [endsect] diff --git a/test/include/compatibility-inc.qbk b/test/include/compatibility-inc.quickbook similarity index 100% rename from test/include/compatibility-inc.qbk rename to test/include/compatibility-inc.quickbook diff --git a/test/include/compatibility-inc_1_1.qbk b/test/include/compatibility-inc_1_1.quickbook similarity index 100% rename from test/include/compatibility-inc_1_1.qbk rename to test/include/compatibility-inc_1_1.quickbook diff --git a/test/include/compatibility-inc_1_5.qbk b/test/include/compatibility-inc_1_5.quickbook similarity index 100% rename from test/include/compatibility-inc_1_5.qbk rename to test/include/compatibility-inc_1_5.quickbook diff --git a/test/include/compatibility-inc_1_6.qbk b/test/include/compatibility-inc_1_6.quickbook similarity index 100% rename from test/include/compatibility-inc_1_6.qbk rename to test/include/compatibility-inc_1_6.quickbook diff --git a/test/include/in_section-1_5.quickbook b/test/include/in_section-1_5.quickbook index 9cd15f6..2818309 100644 --- a/test/include/in_section-1_5.quickbook +++ b/test/include/in_section-1_5.quickbook @@ -3,14 +3,14 @@ ] [section:container Container] -[include in_section-include1.qbk] -[include in_section-include2.qbk] +[include in_section-inc1.quickbook] +[include in_section-inc2.quickbook] [endsect] -[include in_section-include1.qbk] -[include in_section-include2.qbk] +[include in_section-inc1.quickbook] +[include in_section-inc2.quickbook] [section:container2 Container2] -[include in_section-include1.qbk] -[include in_section-include2.qbk] +[include in_section-inc1.quickbook] +[include in_section-inc2.quickbook] [endsect] diff --git a/test/include/in_section-1_6.quickbook b/test/include/in_section-1_6.quickbook index 45be441..686f97e 100644 --- a/test/include/in_section-1_6.quickbook +++ b/test/include/in_section-1_6.quickbook @@ -3,14 +3,14 @@ ] [section:container Container] -[include in_section-include1.qbk] -[include in_section-include2.qbk] +[include in_section-inc1.quickbook] +[include in_section-inc2.quickbook] [endsect] -[include in_section-include1.qbk] -[include in_section-include2.qbk] +[include in_section-inc1.quickbook] +[include in_section-inc2.quickbook] [section:container2 Container2] -[include in_section-include1.qbk] -[include in_section-include2.qbk] +[include in_section-inc1.quickbook] +[include in_section-inc2.quickbook] [endsect] diff --git a/test/include/in_section-include1.qbk b/test/include/in_section-inc1.quickbook similarity index 100% rename from test/include/in_section-include1.qbk rename to test/include/in_section-inc1.quickbook diff --git a/test/include/in_section-include2.qbk b/test/include/in_section-inc2.quickbook similarity index 100% rename from test/include/in_section-include2.qbk rename to test/include/in_section-inc2.quickbook diff --git a/test/include/include_id_unbalanced-1_6.quickbook b/test/include/include_id_unbalanced-1_6.quickbook index 0b299a6..b1568d4 100644 --- a/test/include/include_id_unbalanced-1_6.quickbook +++ b/test/include/include_id_unbalanced-1_6.quickbook @@ -5,7 +5,7 @@ [/ Sections start in included files ] -[include:include1 include_id_unbalanced-inc1.qbk] +[include:include1 include_id_unbalanced-inc1.quickbook] [heading:x1 X1] [endsect] [heading:x2 X2] @@ -16,4 +16,4 @@ [heading:x1 X1] [section:sect2 Section 2] [heading:x2 X2] -[include:include2 include_id_unbalanced-inc2.qbk] +[include:include2 include_id_unbalanced-inc2.quickbook] diff --git a/test/include/include_id_unbalanced-inc1.qbk b/test/include/include_id_unbalanced-inc1.quickbook similarity index 57% rename from test/include/include_id_unbalanced-inc1.qbk rename to test/include/include_id_unbalanced-inc1.quickbook index 3170f26..d321481 100644 --- a/test/include/include_id_unbalanced-inc1.qbk +++ b/test/include/include_id_unbalanced-inc1.quickbook @@ -1,4 +1,4 @@ [section:inc1 Include 1] [heading:inc1_1 Heading 1] -[include:include1a include_id_unbalanced-inc1a.qbk] +[include:include1a include_id_unbalanced-inc1a.quickbook] [heading:inc1_2 Heading 2] diff --git a/test/include/include_id_unbalanced-inc1a.qbk b/test/include/include_id_unbalanced-inc1a.quickbook similarity index 100% rename from test/include/include_id_unbalanced-inc1a.qbk rename to test/include/include_id_unbalanced-inc1a.quickbook diff --git a/test/include/include_id_unbalanced-inc2.qbk b/test/include/include_id_unbalanced-inc2.quickbook similarity index 61% rename from test/include/include_id_unbalanced-inc2.qbk rename to test/include/include_id_unbalanced-inc2.quickbook index b719324..37c313c 100644 --- a/test/include/include_id_unbalanced-inc2.qbk +++ b/test/include/include_id_unbalanced-inc2.quickbook @@ -1,5 +1,5 @@ [heading:inc2_1 Heading 1] [endsect] [heading:inc2_2 Heading 2] -[include:include2a include_id_unbalanced-inc2a.qbk] +[include:include2a include_id_unbalanced-inc2a.quickbook] [heading:inc2_3 Heading 3] diff --git a/test/include/include_id_unbalanced-inc2a.qbk b/test/include/include_id_unbalanced-inc2a.quickbook similarity index 100% rename from test/include/include_id_unbalanced-inc2a.qbk rename to test/include/include_id_unbalanced-inc2a.quickbook diff --git a/test/include/nested_compatibility-1_5.quickbook b/test/include/nested_compatibility-1_5.quickbook index 8276715..f9d78b1 100644 --- a/test/include/nested_compatibility-1_5.quickbook +++ b/test/include/nested_compatibility-1_5.quickbook @@ -2,11 +2,11 @@ [article Nested Compatibility Test] [section Duplicate Name] -[include nested_compatibility_inc-1_5.qbk] -[include nested_compatibility_inc-1_6.qbk] +[include nested_compatibility-inc-1_5.quickbook] +[include nested_compatibility-inc-1_6.quickbook] [endsect] [section Duplicate Name] -[include nested_compatibility_inc-1_5.qbk] -[include nested_compatibility_inc-1_6.qbk] +[include nested_compatibility-inc-1_5.quickbook] +[include nested_compatibility-inc-1_6.quickbook] [endsect] diff --git a/test/include/nested_compatibility-1_6.quickbook b/test/include/nested_compatibility-1_6.quickbook index 72c4b65..8beeb8a 100644 --- a/test/include/nested_compatibility-1_6.quickbook +++ b/test/include/nested_compatibility-1_6.quickbook @@ -2,11 +2,11 @@ [article Nested Compatibility Test] [section Duplicate Name] -[include nested_compatibility_inc-1_5.qbk] -[include nested_compatibility_inc-1_6.qbk] +[include nested_compatibility-inc-1_5.quickbook] +[include nested_compatibility-inc-1_6.quickbook] [endsect] [section Duplicate Name] -[include nested_compatibility_inc-1_5.qbk] -[include nested_compatibility_inc-1_6.qbk] +[include nested_compatibility-inc-1_5.quickbook] +[include nested_compatibility-inc-1_6.quickbook] [endsect] diff --git a/test/include/nested_compatibility_inc-1_5.qbk b/test/include/nested_compatibility-inc-1_5.quickbook similarity index 100% rename from test/include/nested_compatibility_inc-1_5.qbk rename to test/include/nested_compatibility-inc-1_5.quickbook diff --git a/test/include/nested_compatibility_inc-1_6.qbk b/test/include/nested_compatibility-inc-1_6.quickbook similarity index 100% rename from test/include/nested_compatibility_inc-1_6.qbk rename to test/include/nested_compatibility-inc-1_6.quickbook diff --git a/test/include/source_mode-1_5.quickbook b/test/include/source_mode-1_5.quickbook index 24e52a0..9700cd1 100644 --- a/test/include/source_mode-1_5.quickbook +++ b/test/include/source_mode-1_5.quickbook @@ -1,3 +1,3 @@ [article Souce Mode Include [source-mode teletype][quickbook 1.5]] -[include source_mode-inc1.qbk] \ No newline at end of file +[include source_mode-inc1.quickbook] \ No newline at end of file diff --git a/test/include/source_mode-1_6.quickbook b/test/include/source_mode-1_6.quickbook index 9eb81d9..77ccae4 100644 --- a/test/include/source_mode-1_6.quickbook +++ b/test/include/source_mode-1_6.quickbook @@ -1,4 +1,4 @@ [source-mode teletype][quickbook 1.6] [article Souce Mode Include] -[include source_mode-inc1.qbk] \ No newline at end of file +[include source_mode-inc1.quickbook] \ No newline at end of file diff --git a/test/include/source_mode-inc1.qbk b/test/include/source_mode-inc1.quickbook similarity index 100% rename from test/include/source_mode-inc1.qbk rename to test/include/source_mode-inc1.quickbook diff --git a/test/include2-1_6.quickbook b/test/include2-1_6.quickbook index be78fcc..66b4897 100644 --- a/test/include2-1_6.quickbook +++ b/test/include2-1_6.quickbook @@ -3,6 +3,6 @@ [id include-test] ] -[include include_sub-1_5.qbk] -[include include_sub.qbk] -[include:foo include_sub.qbk] +[include include-inc-1_5.quickbook] +[include include-inc.quickbook] +[include:foo include-inc.quickbook] diff --git a/test/include_win_path-1_6-fail.quickbook b/test/include_win_path-1_6-fail.quickbook index 2e25423..aff5fd2 100644 --- a/test/include_win_path-1_6-fail.quickbook +++ b/test/include_win_path-1_6-fail.quickbook @@ -2,4 +2,4 @@ [quickbook 1.6] ] -[include .\empty.qbk] +[include .\empty-inc.quickbook] diff --git a/test/python/include_path.qbk b/test/python/include_path.qbk index c9a4dcd..3af3b37 100644 --- a/test/python/include_path.qbk +++ b/test/python/include_path.qbk @@ -1,3 +1,11 @@ +[/ + Copyright 2012-2013 Daniel James + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +] + [quickbook 1.5] [article Include Path] [include a.qbk] diff --git a/test/python/missing_relative.qbk b/test/python/missing_relative.qbk index 8fdc0ee..ff96b10 100644 --- a/test/python/missing_relative.qbk +++ b/test/python/missing_relative.qbk @@ -1,3 +1,11 @@ +[/ + Copyright 2012-2013 Daniel James + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +] + [quickbook 1.5] [article Missing Relative] diff --git a/test/python/sub1/a.qbk b/test/python/sub1/a.qbk index 7898192..f3abe6e 100644 --- a/test/python/sub1/a.qbk +++ b/test/python/sub1/a.qbk @@ -1 +1,9 @@ +[/ + Copyright 2012-2013 Daniel James + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +] + a diff --git a/test/python/sub2/b.qbk b/test/python/sub2/b.qbk index 6178079..9b4336b 100644 --- a/test/python/sub2/b.qbk +++ b/test/python/sub2/b.qbk @@ -1 +1,9 @@ +[/ + Copyright 2012-2013 Daniel James + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +] + b diff --git a/test/python/svg_missing.qbk b/test/python/svg_missing.qbk index 2b25c2f..1b54ece 100644 --- a/test/python/svg_missing.qbk +++ b/test/python/svg_missing.qbk @@ -1,3 +1,11 @@ +[/ + Copyright 2012-2013 Daniel James + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +] + [article Dependencies for missing svg] [$missing.svg] diff --git a/test/snippets/unbalanced_snippet1.cpp b/test/snippets/unbalanced_snippet1.cpp index ec49a78..c9a0c88 100644 --- a/test/snippets/unbalanced_snippet1.cpp +++ b/test/snippets/unbalanced_snippet1.cpp @@ -1,3 +1,3 @@ //[unclosed -int main() {} \ No newline at end of file +int main() {} diff --git a/test/snippets/unbalanced_snippet2.cpp b/test/snippets/unbalanced_snippet2.cpp index b057517..a7d8b04 100644 --- a/test/snippets/unbalanced_snippet2.cpp +++ b/test/snippets/unbalanced_snippet2.cpp @@ -1 +1 @@ -//] \ No newline at end of file +//] diff --git a/test/unit/source_map_test.cpp b/test/unit/source_map_test.cpp index ead5b5f..3eb3057 100644 --- a/test/unit/source_map_test.cpp +++ b/test/unit/source_map_test.cpp @@ -303,14 +303,93 @@ void indented_map_leading_blanks_test() BOOST_TEST_EQ(f1->source(), boost::string_ref("Code line1\n\nCode line2")); } +} + +void indented_map_trailing_blanks_test() +{ + quickbook::mapped_file_builder builder; + + { + boost::string_ref source("\n\n Code line1\n "); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n")); + } + + { + boost::string_ref source(" \n \n Code line1\n "); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n ")); + } + + { + boost::string_ref source(" Code line1\n \n Code line2\n "); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line1\n\nCode line2\n")); + } } +void indented_map_mixed_test() +{ + quickbook::mapped_file_builder builder; + + { + boost::string_ref source("\tCode line 1\n Code line 2\n\t Code line 3\n \tCode line 4"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line 1\nCode line 2\n Code line 3\n Code line 4")); + } + + { + boost::string_ref source(" Code line 1\n\tCode line 2"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line 1\n Code line 2")); + } + + { + boost::string_ref source(" Code line 1\n \tCode line 2"); + quickbook::file_ptr fake_file = new quickbook::file( + "(fake file)", source, 105u); + builder.start(fake_file); + builder.unindent_and_add(fake_file->source()); + quickbook::file_ptr f1 = builder.release(); + BOOST_TEST_EQ(f1->source(), + boost::string_ref("Code line 1\n\tCode line 2")); + } +} + + int main() { simple_map_tests(); indented_map_tests(); indented_map_tests2(); indented_map_leading_blanks_test(); + indented_map_trailing_blanks_test(); + indented_map_mixed_test(); return boost::report_errors(); } diff --git a/test/versions/invalid_macro-1_6.quickbook b/test/versions/invalid_macro-1_6.quickbook index f579f72..860d58b 100644 --- a/test/versions/invalid_macro-1_6.quickbook +++ b/test/versions/invalid_macro-1_6.quickbook @@ -4,11 +4,11 @@ Import: -[import invalid_macro-inc-1_1.qbk] +[import invalid_macro-inc-1_1.quickbook] * __valid__ * __invalid\macro__ Include: -[include invalid_macro-inc-1_1.qbk] +[include invalid_macro-inc-1_1.quickbook] diff --git a/test/versions/invalid_macro-inc-1_1.qbk b/test/versions/invalid_macro-inc-1_1.quickbook similarity index 100% rename from test/versions/invalid_macro-inc-1_1.qbk rename to test/versions/invalid_macro-inc-1_1.quickbook diff --git a/test/versions/templates-1_1.qbk b/test/versions/templates-inc-1_1.quickbook similarity index 100% rename from test/versions/templates-1_1.qbk rename to test/versions/templates-inc-1_1.quickbook diff --git a/test/versions/templates-1_4.qbk b/test/versions/templates-inc-1_4.quickbook similarity index 100% rename from test/versions/templates-1_4.qbk rename to test/versions/templates-inc-1_4.quickbook diff --git a/test/versions/templates-1_5.qbk b/test/versions/templates-inc-1_5.quickbook similarity index 100% rename from test/versions/templates-1_5.qbk rename to test/versions/templates-inc-1_5.quickbook diff --git a/test/versions/versions-1_6.quickbook b/test/versions/versions-1_6.quickbook index baac8e0..fed5a93 100644 --- a/test/versions/versions-1_6.quickbook +++ b/test/versions/versions-1_6.quickbook @@ -1,9 +1,9 @@ [quickbook 1.6] [article Mixed version tests] -[import templates-1_1.qbk] -[import templates-1_4.qbk] -[import templates-1_5.qbk] +[import templates-inc-1_1.quickbook] +[import templates-inc-1_4.quickbook] +[import templates-inc-1_5.quickbook] [/ This test calls a 1.4 template -> 1.5 template -> 1.4 template. The name lookup in the 1.4 template should skip the 1.5 template @@ -21,6 +21,6 @@ [/ For comparison] -[include templates-1_1.qbk] -[include templates-1_4.qbk] -[include templates-1_5.qbk] +[include templates-inc-1_1.quickbook] +[include templates-inc-1_4.quickbook] +[include templates-inc-1_5.quickbook] From 24ab5cc5bc7cf6b7e365651518afe4fae0709e2a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 25 May 2013 15:57:48 +0000 Subject: [PATCH 83/94] Merge quickbook to release. [SVN r84500] --- src/quickbook.cpp | 2 +- test/python/include_path_deps.txt | 3 +++ test/python/include_path_locs.txt | 3 +++ test/python/missing_relative_deps.txt | 3 +++ test/python/missing_relative_locs.txt | 3 +++ test/python/output-deps.py | 6 ++++++ test/python/svg_missing_deps.txt | 3 +++ test/python/svg_missing_locs.txt | 3 +++ test/snippets/unbalanced_snippet1.cpp | 8 ++++++++ test/snippets/unbalanced_snippet2.cpp | 9 +++++++++ test/xinclude/sub/boost-no-inspect | 2 ++ 11 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test/xinclude/sub/boost-no-inspect diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 2af638c..128bb0b 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -40,7 +40,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.5.9 (dev)" +#define QUICKBOOK_VERSION "Quickbook Version 1.5.9" namespace quickbook { diff --git a/test/python/include_path_deps.txt b/test/python/include_path_deps.txt index 994d776..86875d7 100644 --- a/test/python/include_path_deps.txt +++ b/test/python/include_path_deps.txt @@ -1,3 +1,6 @@ +# Copyright 2012-2013 Daniel James +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) include_path.qbk sub1/a.qbk sub2/b.qbk diff --git a/test/python/include_path_locs.txt b/test/python/include_path_locs.txt index aaffb8d..7926db6 100644 --- a/test/python/include_path_locs.txt +++ b/test/python/include_path_locs.txt @@ -1,3 +1,6 @@ +# Copyright 2012-2013 Daniel James +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + include_path.qbk - a.qbk + sub1/a.qbk diff --git a/test/python/missing_relative_deps.txt b/test/python/missing_relative_deps.txt index a9de670..fb8f27f 100644 --- a/test/python/missing_relative_deps.txt +++ b/test/python/missing_relative_deps.txt @@ -1 +1,4 @@ +# Copyright 2012-2013 Daniel James +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) missing_relative.qbk diff --git a/test/python/missing_relative_locs.txt b/test/python/missing_relative_locs.txt index 69b51f2..ac85cec 100644 --- a/test/python/missing_relative_locs.txt +++ b/test/python/missing_relative_locs.txt @@ -1,3 +1,6 @@ +# Copyright 2012-2013 Daniel James +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + missing_relative.qbk - ../missing.qbk - missing-dir/x.qbk diff --git a/test/python/output-deps.py b/test/python/output-deps.py index 7b77c27..159b6c9 100644 --- a/test/python/output-deps.py +++ b/test/python/output-deps.py @@ -1,5 +1,9 @@ #!/usr/bin/env python +# Copyright 2012-2013 Daniel James +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + import sys, os, subprocess, tempfile, re def main(args, directory): @@ -110,6 +114,7 @@ def load_dependencies(filename, adjust_paths = False): dependencies = set() f = open(filename, 'r') for path in f: + if path[0] == '#': continue if adjust_paths: path = os.path.realpath(path) if path in dependencies: @@ -122,6 +127,7 @@ def load_locations(filename, adjust_paths = False): dependencies = {} f = open(filename, 'r') for line in f: + if line[0] == '#': continue m = line_matcher.match(line) if not m: raise Exception("Invalid dependency file: %1s" % filename) diff --git a/test/python/svg_missing_deps.txt b/test/python/svg_missing_deps.txt index 25d1c0e..91487e8 100644 --- a/test/python/svg_missing_deps.txt +++ b/test/python/svg_missing_deps.txt @@ -1 +1,4 @@ +# Copyright 2012-2013 Daniel James +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) svg_missing.qbk diff --git a/test/python/svg_missing_locs.txt b/test/python/svg_missing_locs.txt index 379d414..0f4c9b8 100644 --- a/test/python/svg_missing_locs.txt +++ b/test/python/svg_missing_locs.txt @@ -1,2 +1,5 @@ +# Copyright 2012-2013 Daniel James +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - html/missing.svg + svg_missing.qbk diff --git a/test/snippets/unbalanced_snippet1.cpp b/test/snippets/unbalanced_snippet1.cpp index c9a0c88..ee59839 100644 --- a/test/snippets/unbalanced_snippet1.cpp +++ b/test/snippets/unbalanced_snippet1.cpp @@ -1,3 +1,11 @@ +/*============================================================================= + Copyright (c) 2011 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + //[unclosed int main() {} diff --git a/test/snippets/unbalanced_snippet2.cpp b/test/snippets/unbalanced_snippet2.cpp index a7d8b04..238b976 100644 --- a/test/snippets/unbalanced_snippet2.cpp +++ b/test/snippets/unbalanced_snippet2.cpp @@ -1 +1,10 @@ //] + +/*============================================================================= + Copyright (c) 2011 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + diff --git a/test/xinclude/sub/boost-no-inspect b/test/xinclude/sub/boost-no-inspect new file mode 100644 index 0000000..099a233 --- /dev/null +++ b/test/xinclude/sub/boost-no-inspect @@ -0,0 +1,2 @@ +This directory just contains simple test files, which might be disrupted by +adding copyright etc. From d4f93121dd6d661ab6284a8251234e34ddd8563d Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 23 Jun 2013 21:20:06 +0000 Subject: [PATCH 84/94] Cherry-pick quickbook documentation fix. [SVN r84890] --- doc/1_6.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/1_6.qbk b/doc/1_6.qbk index eac1ea2..05eb902 100644 --- a/doc/1_6.qbk +++ b/doc/1_6.qbk @@ -70,7 +70,7 @@ before. [endsect] [/docinfo] -[section:doc-info-macros Macros in docinfo block] +[section:doc_info_macros Macros in docinfo block] You can now expand macros in text fields in the docinfo block. In the top docinfo block only the predefined macros are available, but in nested documents From 202b0f90e721981daae6a88a7f4b6b9877115fc6 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 15 Jul 2013 21:45:25 +0000 Subject: [PATCH 85/94] Merge quickbook. Starting 1.6 alpha, plus some 1.7 development. [SVN r85050] --- doc/1_6.qbk | 70 ++--- doc/Jamfile.v2 | 2 +- doc/change_log.qbk | 7 + src/dependency_tracker.cpp | 18 +- src/dependency_tracker.hpp | 1 + src/doc_info_actions.cpp | 19 +- src/main_grammar.cpp | 46 +-- src/quickbook.cpp | 11 +- test/Jamfile.v2 | 4 +- test/command-line/Jamfile.v2 | 4 +- test/doc-info/Jamfile.v2 | 2 +- test/include/Jamfile.v2 | 2 +- test/list_test-1_6-fail.quickbook | 46 +++ test/list_test-1_6.gold | 112 ++----- test/list_test-1_6.quickbook | 47 +-- test/list_test-1_7.gold | 483 ++++++++++++++++++++++++++++++ test/list_test-1_7.quickbook | 134 +++++++++ test/snippets/Jamfile.v2 | 2 +- test/unit/Jamfile.v2 | 2 +- test/versions/Jamfile.v2 | 2 +- test/xinclude/Jamfile.v2 | 2 +- 21 files changed, 795 insertions(+), 221 deletions(-) create mode 100644 test/list_test-1_6-fail.quickbook create mode 100644 test/list_test-1_7.gold create mode 100644 test/list_test-1_7.quickbook diff --git a/doc/1_6.qbk b/doc/1_6.qbk index 05eb902..ee6b14d 100644 --- a/doc/1_6.qbk +++ b/doc/1_6.qbk @@ -8,7 +8,7 @@ ] [chapter Language Versions - [quickbook 1.6] + [quickbook 1.7] [compatibility-mode 1.5] [id quickbook.versions] [source-mode teletype] @@ -313,40 +313,6 @@ And then you can use css to style this however you wish. [endsect] -[section:listparagraphs Pargraphs in lists] - -I'm still refining this, but paragraphs and block elements can now be used -in lists: - -[pre -* Para 1 - - Para 2 - * Nested Para 1 - - Nested Para 2 - - Code block - Para 3 -] - -generates: - -* Para 1 - - Para 2 - * Nested Para 1 - - Nested Para 2 - - Code block - Para 3 - -The docbook markup that this generates is pretty bad, but seems to create okay -html. - -[endsect] - [endsect] [/ Quickbok 1.6] [section:1_7 Quickbook 1.7] @@ -414,6 +380,40 @@ well. [endsect] [/escaped_docinfo_attributes] +[section:listparagraphs Pargraphs in lists] + +I'm still refining this, but paragraphs and block elements can now be used +in lists: + +[pre +* Para 1 + + Para 2 + * Nested Para 1 + + Nested Para 2 + + Code block + Para 3 +] + +generates: + +* Para 1 + + Para 2 + * Nested Para 1 + + Nested Para 2 + + Code block + Para 3 + +The docbook markup that this generates is pretty bad, but seems to create okay +html. + +[endsect] + [section:templates_in_link_values Templates in link values] There's very premilinary support for calling templates in link values. A lot diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index f2f11f0..3fd8409 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -8,7 +8,7 @@ # http://www.boost.org/LICENSE_1_0.txt) #============================================================================== -project boost/quickbook/doc ; +project quickbook/doc ; using boostbook ; using quickbook ; diff --git a/doc/change_log.qbk b/doc/change_log.qbk index 77413eb..5e05368 100644 --- a/doc/change_log.qbk +++ b/doc/change_log.qbk @@ -296,3 +296,10 @@ Boost 1.46.1: * Convert to use `boost::string_ref`. * Clean up the source map implementation (used to get the correct location for error messages in things like templates and snippets). + +[heading Version 1.6.0 alpha] + +* Remove nested blocks in lists from 1.6, move to 1.7. + (Can still nest block elements in lists though). +* Don't break out of lists after a nested block element. +* Check for errors when writing dependency files. diff --git a/src/dependency_tracker.cpp b/src/dependency_tracker.cpp index ff28198..2af8c01 100644 --- a/src/dependency_tracker.cpp +++ b/src/dependency_tracker.cpp @@ -9,6 +9,7 @@ #include "dependency_tracker.hpp" #include "input_path.hpp" #include +#include #include namespace quickbook @@ -90,7 +91,7 @@ namespace quickbook static std::string get_path(fs::path const& path, dependency_tracker::flags f) { - std::string generic = detail::path_to_generic(path); + std::string generic = quickbook::detail::path_to_generic(path); if (f & dependency_tracker::escaped) { generic = escaped_path(generic); @@ -105,6 +106,21 @@ namespace quickbook return found; } + void dependency_tracker::write_dependencies(fs::path const& file_out, + flags f) + { + fs::ofstream out(file_out); + + if (out.fail()) { + throw std::runtime_error( + "Error opening dependency file " + + quickbook::detail::path_to_generic(file_out)); + } + + out.exceptions(std::ios::badbit); + write_dependencies(out, f); + } + void dependency_tracker::write_dependencies(std::ostream& out, flags f) { diff --git a/src/dependency_tracker.hpp b/src/dependency_tracker.hpp index 6b477b9..123b534 100644 --- a/src/dependency_tracker.hpp +++ b/src/dependency_tracker.hpp @@ -35,6 +35,7 @@ namespace quickbook // list of dependencies. Returns true if file exists. bool add_dependency(fs::path const&); + void write_dependencies(fs::path const&, flags = default_); void write_dependencies(std::ostream&, flags = default_); }; } diff --git a/src/doc_info_actions.cpp b/src/doc_info_actions.cpp index 8ceac6c..30e80a5 100644 --- a/src/doc_info_actions.cpp +++ b/src/doc_info_actions.cpp @@ -208,12 +208,21 @@ namespace quickbook unsigned new_version = get_version(state, use_doc_info, qbk_version); - if (new_version != qbk_version_n && new_version >= 106) + if (new_version != qbk_version_n) { - detail::outwarn(state.current_file->path) - << "Quickbook " << (new_version / 100) << "." << (new_version % 100) - << " is still under development and is " - "likely to change in the future." << std::endl; + if (new_version >= 107u) + { + detail::outwarn(state.current_file->path) + << "Quickbook " << (new_version / 100) << "." << (new_version % 100) + << " is still under development and is " + "likely to change in the future." << std::endl; + } + else if (new_version >= 106u) + { + detail::outwarn(state.current_file->path) + << "Quickbook " << (new_version / 100) << "." << (new_version % 100) + << " is in alpha." << std::endl; + } } if (new_version) { diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index a01c00a..0d76d01 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -90,37 +90,6 @@ namespace quickbook string_iterator last); void clear_stack(); - struct in_list_impl { - main_grammar_local& l; - - in_list_impl(main_grammar_local& l) : - l(l) {} - - bool operator()() const { - return !l.list_stack.top().root; - } - }; - - struct set_no_eols_scoped : scoped_action_base - { - set_no_eols_scoped(main_grammar_local& l) - : l(l) {} - - bool start() { - saved_no_eols = l.no_eols; - l.no_eols = false; - - return true; - } - - void cleanup() { - l.no_eols = saved_no_eols; - } - - main_grammar_local& l; - bool saved_no_eols; - }; - //////////////////////////////////////////////////////////////////////// // Local members @@ -438,8 +407,8 @@ namespace quickbook >> (cl::ch_p('*') | '#') >> (*cl::blank_p) [local.list.still_in_block = true] >> *( cl::eps_p(local.list.still_in_block) - >> ( qbk_ver(106u) >> local.list_item(element_info::only_block) - | qbk_ver(0, 106u) >> local.list_item(element_info::only_list_block) + >> ( qbk_ver(107u) >> local.list_item(element_info::only_block) + | qbk_ver(0, 107u) >> local.list_item(element_info::only_list_block) ) ) // TODO: This is sometimes called in the wrong place. Currently @@ -449,7 +418,7 @@ namespace quickbook local.list_item = local.element(local.list_item.context) - >> !eol [local.list.still_in_block = false] + >> !(qbk_ver(0, 106u) >> eol) [local.list.still_in_block = false] | local.paragraph_separator [local.list.still_in_block = false] | local.common(element_info::in_phrase) ; @@ -470,7 +439,6 @@ namespace quickbook inside_paragraph = state.values.save() [ *( local.paragraph_separator [paragraph] - >> *eol | ~cl::eps_p(']') >> local.common(element_info::in_nested_block) ) @@ -1054,6 +1022,14 @@ namespace quickbook block_type = block_types::paragraph; } + + if (qbk_version_n == 106u && !list_stack.top().root) { + detail::outerr(state_.current_file, first) + << "Nested blocks in lists won't be supported in " + << "quickbook 1.6" + << std::endl; + ++state_.error_count; + } } else { clear_stack(); diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 128bb0b..ca9fa2a 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -40,7 +40,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.5.9" +#define QUICKBOOK_VERSION "Quickbook Version 1.6.0 alpha (dev)" namespace quickbook { @@ -162,15 +162,14 @@ namespace quickbook if (!options_.deps_out.empty()) { - fs::ofstream out(options_.deps_out); - state.dependencies.write_dependencies(out, + state.dependencies.write_dependencies(options_.deps_out, options_.deps_out_flags); } if (!options_.locations_out.empty()) { fs::ofstream out(options_.locations_out); - state.dependencies.write_dependencies(out, + state.dependencies.write_dependencies(options_.locations_out, dependency_tracker::checked); } } @@ -178,6 +177,10 @@ namespace quickbook detail::outerr(filein_) << e.what() << std::endl; result = 1; } + catch (std::runtime_error& e) { + detail::outerr() << e.what() << std::endl; + result = 1; + } if (!fileout_.empty() && result == 0) { diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 900b475..7544f69 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # -project test +project quickbook/test : requirements msvc:off ; @@ -70,6 +70,8 @@ test-suite quickbook.test : [ quickbook-test link-1_7 ] [ quickbook-test list_test-1_5 ] [ quickbook-test list_test-1_6 ] + [ quickbook-error-test list_test-1_6-fail ] + [ quickbook-test list_test-1_7 ] [ quickbook-test macro-1_5 ] [ quickbook-test macro-1_6 ] [ quickbook-error-test mismatched_brackets-1_1-fail ] diff --git a/test/command-line/Jamfile.v2 b/test/command-line/Jamfile.v2 index 052ec82..9e838e0 100644 --- a/test/command-line/Jamfile.v2 +++ b/test/command-line/Jamfile.v2 @@ -7,7 +7,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # -project quickook/tests/command-line ; +project quickbook/tests/command-line ; import quickbook-testing : quickbook-test quickbook-fail-test quickbook-error-test ; @@ -25,4 +25,4 @@ test-suite command-line.test : output_nested_in_file : basic-1_6.quickbook : --output-file=basic-1_6.quickbook/basic.xml ] - ; \ No newline at end of file + ; diff --git a/test/doc-info/Jamfile.v2 b/test/doc-info/Jamfile.v2 index bfb06cf..a35229c 100644 --- a/test/doc-info/Jamfile.v2 +++ b/test/doc-info/Jamfile.v2 @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # -project quickook/tests/doc-info ; +project quickbook/tests/doc-info ; import quickbook-testing : quickbook-test quickbook-error-test ; diff --git a/test/include/Jamfile.v2 b/test/include/Jamfile.v2 index 3ab39b2..73c00e5 100644 --- a/test/include/Jamfile.v2 +++ b/test/include/Jamfile.v2 @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # -project test/includes +project quickbook/test/includes : requirements msvc:off ; diff --git a/test/list_test-1_6-fail.quickbook b/test/list_test-1_6-fail.quickbook new file mode 100644 index 0000000..7ca8a93 --- /dev/null +++ b/test/list_test-1_6-fail.quickbook @@ -0,0 +1,46 @@ +[article List Test +[quickbook 1.6] +] + +Markup in list: + +* [table [[Heading]][[Cell]]] +* [heading The heading for a list item] + + The content of the list item. + +[section Paragraphs in list items] + +* A1 + + A2 + +* B1 + * C1 + + C2 + + B2 + +* D1 + * E1 + + E2 + + E3 + + D2 + +[endsect] + +[section Indented code blocks in lists] + +* A + + B + C +* D + + E +* F +[endsect] diff --git a/test/list_test-1_6.gold b/test/list_test-1_6.gold index f005525..1721110 100644 --- a/test/list_test-1_6.gold +++ b/test/list_test-1_6.gold @@ -333,17 +333,28 @@ + Some text. + + + + + [section Doesn't expand] Blah, blah. [endsect] - - The - heading for a list item - - The content of the list item. + Paragraph cheat 1. + Paragraph cheat 2. + + + + + + Paragraph cheat 3. + + Paragraph cheat 4. @@ -426,99 +437,12 @@ - One - - - -
- <link linkend="list_test.list_immediately_following_mark0.nested_section">Nested - section</link> - - - - Two - - - -
- -
- <link linkend="list_test.paragraphs_in_list_items">Paragraphs in list - items</link> - - - - A1 - - A2 - + One [section Nested section] - B1 - - - - C1 - - C2 - - - - - - B2 - - - - - - D1 - - - - E1 - - E2 - - - E3 - - - - - - D2 - - - - -
-
- <link linkend="list_test.indented_code_blocks_in_lists">Indented code - blocks in lists</link> - - - - A -B - - - C - - - - - - D -E - - - - - - F + Two [endsect] diff --git a/test/list_test-1_6.quickbook b/test/list_test-1_6.quickbook index dbba742..fe1e187 100644 --- a/test/list_test-1_6.quickbook +++ b/test/list_test-1_6.quickbook @@ -74,9 +74,17 @@ Markup in list: * ["Quoted] * [footnote Footnote] * [table [[Heading]][[Cell]]] -* [heading The heading for a list item] + Some text. +* [section Doesn't expand] + Blah, blah. + [endsect] - The content of the list item. +* Paragraph cheat 1. + [block] + Paragraph cheat 2. +* Paragraph cheat 3. + [block] + Paragraph cheat 4. Don't end list with comment 1: @@ -108,40 +116,5 @@ Don't end list with comment 2: [section Nested section] * Two [endsect] -[endsect] - -[section Paragraphs in list items] - -* A1 - - A2 - -* B1 - * C1 - - C2 - - B2 - -* D1 - * E1 - - E2 - - E3 - - D2 [endsect] - -[section Indented code blocks in lists] - -* A - - B - C -* D - - E -* F -[endsect] diff --git a/test/list_test-1_7.gold b/test/list_test-1_7.gold new file mode 100644 index 0000000..49fe0cf --- /dev/null +++ b/test/list_test-1_7.gold @@ -0,0 +1,483 @@ + + +
+ List Test + + Simple list: + + + + + A + + + + + B + + + + + Simple list: + + + + + A + + + + + B + + + + + Two level list: + + + + + A + + + + A + + + + + B + + + + + + + + B + + + + A + + + + + B + + + + + + + + Two level list: + + + + + A + + + + A + + + + + B + + + + + + + + B + + + + A + + + + + B + + + + + + + + Three level list: + + + + + A + + + + A + + + + + B + + + + C + + + + + D + + + + + + + + E + + + + + F + + + + G + + + + + H + + + + + + + + + + + Three level list: + + + + + A + + + + A + + + + + B + + + + C + + + + + D + + + + + + + + + + + G + + + + + H + + + + + Inconsistent Indentation: + + + + + A1 + + + + B1 + + + + + B2 + + + + C1 + + + + + C2 + + + + + + + + B3 + + + + + B4 + + + + + B5 + + + + C3 + + + + + + + + B6 + + + + + + + + A2 + + + + + A3 + + + + + Markup in list: + + + + + Bold + + + + + Bold + + + + + Quoted + + + + + + + Footnote + + + + + + + + + + + + + Heading + + + + + + + + + Cell + + + + + + + + + + + + The + heading for a list item + + + The content of the list item. + + + + + + Don't end list with comment 1: + + + + + A1 + + + + + A2 + + + + + A3 + + + + + A4 + + + + + Don't end list with comment 2: + + + + + A1 + + + + B1 + + + + + B2 + + + + + B3 + + + + + + +
+ <link linkend="list_test.paragraphs_in_list_items">Paragraphs in list + items</link> + + + + A1 + + A2 + + + + + + B1 + + + + C1 + + C2 + + + + + + B2 + + + + + + D1 + + + + E1 + + E2 + + + E3 + + + + + + D2 + + + + +
+
+ <link linkend="list_test.indented_code_blocks_in_lists">Indented code + blocks in lists</link> + + + + A +B + + + C + + + + + + D +E + + + + + + F + + + +
+
diff --git a/test/list_test-1_7.quickbook b/test/list_test-1_7.quickbook new file mode 100644 index 0000000..8eac6a7 --- /dev/null +++ b/test/list_test-1_7.quickbook @@ -0,0 +1,134 @@ +[article List Test +[quickbook 1.7] +] + +Simple list: + +* A +* B + +Simple list: + +#A +#B + +Two level list: + +* A + * A + * B +* B + * A + * B + +Two level list: + +# A + * A + * B +# B + * A + * B + +Three level list: + +# A + * A + * B + * C + * D + * E + * F + * G + * H + +Three level list: + +# A + * A + * B + # C + # D +# G +# H + +Inconsistent Indentation: + +* A1 + * B1 + * B2 + * C1 + * C2 + * B3 + * B4 + * B5 + * C3 + * B6 + * A2 +* A3 + +Markup in list: + +* *Bold* +* [*Bold] +* ["Quoted] +* [footnote Footnote] +* [table [[Heading]][[Cell]]] +* [heading The heading for a list item] + + The content of the list item. + +Don't end list with comment 1: + +* A1 +* A2 + +[/ End list?] +* A3 +* A4 + +Don't end list with comment 2: + +* A1 + * B1 + +[/ End list?] + * B2 + * B3 + +[section Paragraphs in list items] + +* A1 + + A2 + +* B1 + * C1 + + C2 + + B2 + +* D1 + * E1 + + E2 + + E3 + + D2 + +[endsect] + +[section Indented code blocks in lists] + +* A + + B + C +* D + + E +* F + +[endsect] diff --git a/test/snippets/Jamfile.v2 b/test/snippets/Jamfile.v2 index 4dfd0d0..6765dff 100644 --- a/test/snippets/Jamfile.v2 +++ b/test/snippets/Jamfile.v2 @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # -project quickook/tests/snippets ; +project quickbook/test/snippets ; import quickbook-testing : quickbook-test quickbook-error-test ; diff --git a/test/unit/Jamfile.v2 b/test/unit/Jamfile.v2 index 2dca669..b3e229b 100644 --- a/test/unit/Jamfile.v2 +++ b/test/unit/Jamfile.v2 @@ -8,7 +8,7 @@ import testing ; -project quickbook-unit-tests +project quickbook/test/unit-tests : requirements ../../src all diff --git a/test/versions/Jamfile.v2 b/test/versions/Jamfile.v2 index ccb46dc..dd185d5 100644 --- a/test/versions/Jamfile.v2 +++ b/test/versions/Jamfile.v2 @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # -project test/versions +project quickbook/test/versions : requirements msvc:off ; diff --git a/test/xinclude/Jamfile.v2 b/test/xinclude/Jamfile.v2 index 2974e86..fbc8981 100644 --- a/test/xinclude/Jamfile.v2 +++ b/test/xinclude/Jamfile.v2 @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) # -project test/xinclude +project quickbook/test/xinclude : requirements msvc:off ; From 9e16e8943866f4e952c9fa5fb9a4e388e8a30d2a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 17 Aug 2013 09:46:47 +0000 Subject: [PATCH 86/94] Merge quickbook from trunk. From the change log: - Improved markup for lists. - Make escaping templates with a punctuation identifier illegal. Escaping templates with an alphanumeric identifier is still fine. - 1.7 changes: - Make it an error to use an element in the wrong context. - Error if the body of a phrase element doesn't parse. - List markup in nested blocks. - Allow block elements in phrase templates. - Make it an error to put a paragraph break (i.e. a blank line) in a phrase template. - Internal changes: - Clean up the id manager implementation. [SVN r85369] --- doc/1_6.qbk | 177 +---- doc/1_7.qbk | 176 +++++ doc/block.qbk | 4 +- doc/change_log.qbk | 12 + doc/language_versions.qbk | 46 ++ doc/quickbook.qbk | 3 +- src/Jamfile.v2 | 2 + src/actions.cpp | 245 +++--- src/actions.hpp | 39 +- src/block_element_grammar.cpp | 13 +- src/block_tags.hpp | 2 +- src/doc_info_grammar.cpp | 4 +- src/grammar.cpp | 4 +- src/grammar.hpp | 4 +- src/grammar_impl.hpp | 22 +- src/id_generation.cpp | 378 +++++++++ src/id_manager.cpp | 987 ++++-------------------- src/id_manager.hpp | 1 - src/id_manager_impl.hpp | 144 ++++ src/id_xml.cpp | 153 ++++ src/main_grammar.cpp | 450 +++++++---- src/markups.cpp | 1 + src/phrase_element_grammar.cpp | 2 +- src/quickbook.cpp | 2 +- src/state.cpp | 41 +- src/state.hpp | 9 + src/state_save.hpp | 19 +- src/syntax_highlight.cpp | 50 +- test/Jamfile.v2 | 10 + test/elements-1_6.gold | 24 +- test/elements-1_6.quickbook | 10 +- test/include/in_section-1_5.gold | 28 + test/include/in_section-1_6.gold | 24 + test/include/in_section-inc1.quickbook | 4 +- test/include/in_section-inc2.quickbook | 4 +- test/link-1_7-fail.quickbook | 5 + test/list_test-1_6.gold | 56 +- test/list_test-1_7-fail1.quickbook | 9 + test/list_test-1_7.gold | 102 ++- test/mismatched_brackets3-1_1.gold | 12 + test/mismatched_brackets3-1_1.quickbook | 6 + test/role-1_7-fail.quickbook | 5 + test/role-1_7.gold | 9 + test/role-1_7.quickbook | 5 + test/table-1_7.gold | 514 ++++++++++++ test/table-1_7.quickbook | 148 ++++ test/templates-1_3.gold | 23 +- test/templates-1_3.quickbook | 16 + test/templates-1_4.gold | 7 + test/templates-1_4.quickbook | 18 +- test/templates-1_5.gold | 269 ++++++- test/templates-1_5.quickbook | 255 +++++- test/templates-1_6-fail1.quickbook | 8 + test/templates-1_6.gold | 257 ++++++ test/templates-1_6.quickbook | 313 ++++++++ test/templates-1_7-fail1.quickbook | 12 + test/templates-1_7.gold | 302 ++++++++ test/templates-1_7.quickbook | 322 ++++++++ 58 files changed, 4239 insertions(+), 1528 deletions(-) create mode 100644 doc/1_7.qbk create mode 100644 doc/language_versions.qbk create mode 100644 src/id_generation.cpp create mode 100644 src/id_manager_impl.hpp create mode 100644 src/id_xml.cpp create mode 100644 test/link-1_7-fail.quickbook create mode 100644 test/list_test-1_7-fail1.quickbook create mode 100644 test/mismatched_brackets3-1_1.gold create mode 100644 test/mismatched_brackets3-1_1.quickbook create mode 100644 test/role-1_7-fail.quickbook create mode 100644 test/role-1_7.gold create mode 100644 test/role-1_7.quickbook create mode 100644 test/table-1_7.gold create mode 100644 test/table-1_7.quickbook create mode 100644 test/templates-1_6-fail1.quickbook create mode 100644 test/templates-1_6.gold create mode 100644 test/templates-1_6.quickbook create mode 100644 test/templates-1_7-fail1.quickbook create mode 100644 test/templates-1_7.gold create mode 100644 test/templates-1_7.quickbook diff --git a/doc/1_6.qbk b/doc/1_6.qbk index ee6b14d..fe9ca32 100644 --- a/doc/1_6.qbk +++ b/doc/1_6.qbk @@ -1,47 +1,12 @@ [/ Copyright 2002,2004,2006 Joel de Guzman, Eric Niebler - Copyright 2010-2011 Daniel James + Copyright 2010-2013 Daniel James Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] -[chapter Language Versions - [quickbook 1.7] - [compatibility-mode 1.5] - [id quickbook.versions] - [source-mode teletype] -] - -[section:stable Stable Versions] - -Since quickbook 1.3 the `quickbook` attribute in the document block selects -which version of the language to use. Not all changes to quickbook are -implemented using a version switch, it's mainly just the changes that change -the way a document is interpreted or would break existing documentation. - -[heading Quickbook 1.3 and later] - -* Introduced quickbook language versioning. -* In the documentation info, allow phrase markup in license and purpose - attributes. -* Fully qualified section and headers. Subsection names are concatenated to the - ID to avoid clashing. Example: `doc_name.sect_name.sub_sect_name.sub_sub_sect_name`. - -[heading Quickbook 1.5 and later] - -* Ignore template argument separators inside square brackets. -* Don't separate the final template argument if the `..` separator was - used. i.e. never mix `..` and whitespace separators. -* Statically scope templates and their arguments rather than dynamically - scope them. -* Give table ids, and let you set them. -* Allow spaces between the `:` character and ids in elements which can - have ids. - -[endsect] - [section:1_6 Quickbook 1.6] Everything described in here may change depending on the feedback received. @@ -246,6 +211,30 @@ if you're totally sure that you will need it. [endsect] [/xmlbase] +[section:template_parser Improved template parser] + +There's a new parser for template declarations and parameters which does +a better job of understanding escaped and bracketed text. Unfortunately +it does not understand element names so there are some cases where it +could go wrong. For example: + + [template doesnt_work[] + [ordered_list + [`code phrase`] + ] + ] + +In this case it will think the `[\`` is a template call and give a parse +error. To work around this put an escaped space before the code phrase: + + [template works[] + [ordered_list + [\ `code phrase`] + ] + ] + +[endsect] + [section:elements New Elements] [section:block `block`] @@ -314,119 +303,3 @@ And then you can use css to style this however you wish. [endsect] [endsect] [/ Quickbok 1.6] - -[section:1_7 Quickbook 1.7] - -[section:source_mode Source mode for single entities] - -1.7 introduces a new `!` element type for setting the source mode of a single -entity without changing the source mode otherwise. This can be used for -code blocks and other elements. For example: - -``` -[!c++] - void foo() {}; - -[!python]``\`\`\`\ ``def foo():``\`\`\`\ `` -``` - -It can also be used to set the source mode for elements: - -``` -[!teletype][table - [[code][meaning]] - [[`+`][addition]] -] -``` - -When used a section, it's only set for the section element, not the -whole section. - -Currently it does support other syntactic entities such as paragraphs -and lists. I'm not sure if it would be a good idea. - -[endsect] - -[section:callouts Callouts in code block] - -Currently callouts can only be used in code snippets. 1.7 add -support in normal code blocks. The same syntax is used as in -code snippets, the callout descriptions appear immediately -after the code block. - -[endsect] - -[section:escaped_docinfo_attributes Escaped docbook in docinfo blocks] - -Quickbook docinfo attributes will probably never be as rich as docbook -attributes so to allow more flexible markup, not supported by quickbook -escaped docbook can be included in the docinfo block: - -``` -[article Some article -[quickbook 1.7] -''' - John - Doe - john.doe@example.com -''' -] -``` - -The escaped docbook is always placed at the end of the docinfo block, -so it shouldn't be assumed that it will interleave the markup. A mixture -of quickbook and docbook attributes for the same information will not work -well. - -[endsect] [/escaped_docinfo_attributes] - -[section:listparagraphs Pargraphs in lists] - -I'm still refining this, but paragraphs and block elements can now be used -in lists: - -[pre -* Para 1 - - Para 2 - * Nested Para 1 - - Nested Para 2 - - Code block - Para 3 -] - -generates: - -* Para 1 - - Para 2 - * Nested Para 1 - - Nested Para 2 - - Code block - Para 3 - -The docbook markup that this generates is pretty bad, but seems to create okay -html. - -[endsect] - -[section:templates_in_link_values Templates in link values] - -There's very premilinary support for calling templates in link values. A lot -more work needs to be done, including: - -* Considering other places where templates could be called (e.g. images are - quite tricky, as templates could get confused with attributes, should - templates be callable from something like an element's id?). -* Trimming spaces from the body of the template (which can cause surprising - results). -* Checking that the contents of the template are appropriate for the context. - Possibly even using a different grammar. - -[endsect] [/templates_in_link_values] - -[endsect] [/ Quickbok 1.7] diff --git a/doc/1_7.qbk b/doc/1_7.qbk new file mode 100644 index 0000000..38e614e --- /dev/null +++ b/doc/1_7.qbk @@ -0,0 +1,176 @@ +[/ + Copyright 2002,2004,2006 Joel de Guzman, Eric Niebler + Copyright 2012-2013 Daniel James + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +] + +[section:1_7 Quickbook 1.7] + +[section:context_error Error for elements used in incorrect context] + +Previously if you used an element in the wrong context it would just be +unprocessed, which was surprising. People often didn't realise that their +element hadn't been processed. So now it's an error. + +[endsect] + +[section:phrase_parse_error Error for invalid phrase elements] + +If the body of a phrase element didn't parse, it would be just used +unprocessed. Now change it to be a hard error. + +[endsect] + +[section:source_mode Source mode for single entities] + +1.7 introduces a new `!` element type for setting the source mode of a single +entity without changing the source mode otherwise. This can be used for +code blocks and other elements. For example: + +``` +[!c++] + void foo() {}; + +[!python]``\`\`\`\ ``def foo():``\`\`\`\ `` +``` + +It can also be used to set the source mode for elements: + +``` +[!teletype][table + [[code][meaning]] + [[`+`][addition]] +] +``` + +When used before a section, it sets the source mode for the section element, +not the whole section. + +Currently it does not support other syntactic entities such as paragraphs +and lists. It will currently be used to the next code block or element. +This is a bit messy, but I'm not sure what would be a good idea. + +[endsect] + +[section:callouts Callouts in code blocks] + +Currently callouts can only be used in code snippets. 1.7 add +support in normal code blocks. The same syntax is used as in +code snippets, the callout descriptions appear immediately +after the code block. + +[endsect] + +[section:escaped_docinfo_attributes Escaped docbook in docinfo blocks] + +Quickbook docinfo attributes will probably never be as rich as docbook +attributes so to allow more flexible markup, not supported by quickbook +escaped docbook can be included in the docinfo block: + +``` +[article Some article +[quickbook 1.7] +''' + John + Doe + john.doe@example.com +''' +] +``` + +The escaped docbook is always placed at the end of the docinfo block, +so it shouldn't be assumed that it will interleave the markup. A mixture +of quickbook and docbook attributes for the same information will not work +well. + +[endsect] [/escaped_docinfo_attributes] + +[section:listparagraphs Pargraphs in lists] + +I'm still refining this, but paragraphs and block elements can now be used +in lists: + +[pre +* Para 1 + + Para 2 + * Nested Para 1 + + Nested Para 2 + + Code block + Para 3 +] + +generates: + +* Para 1 + + Para 2 + * Nested Para 1 + + Nested Para 2 + + Code block + Para 3 + +The docbook markup that this generates is pretty bad, but seems to create okay +html. + +[endsect] + +[section:templates_in_link_values Templates in link values] + +There's very premilinary support for calling templates in link values. A lot +more work needs to be done, including: + +* Considering other places where templates could be called (e.g. images are + quite tricky, as templates could get confused with attributes, should + templates be callable from something like an element's id?). +* Trimming spaces from the body of the template (which can cause surprising + results). +* Checking that the contents of the template are appropriate for the context. + Possibly even using a different grammar. + +[endsect] [/templates_in_link_values] + +[section:list_markup_in_tables List Markup in Nested Blocks] + +Can now place list markup in nested blocks, e.g in tables, variables lists etc. +Unfortunately indented code blocks are more tricky, because the contents of +these blocks are often indented already. It seemed easier to just not support +indented code blocks in this context than to try to work out sensible actions +for the edges cases. If you want to use code blocks in this context, you should +still be able to use explicit markup. + +[endsect] + +[section:phrase_block_templates Allow block elements in phrase templates] + +Block elements can now be used in phrase templates, but paragraphs breaks aren't +allowed, so this is an error: + + [template paras[] Something or other. + + Second paragraph.] + +If a phrase template only contains block elements, then it's practically +indistinguishable from a block template. So you'll get the same output from: + + [template foo[] [blurb Blah, blah, blah]] + +as: + + [template foo[] + [blurb Blah, blah, blah] + ] + +If a phrase template has phrase content mixed with block elements, it'll generate +output as if it was expanded inline. + +[endsect] + +[endsect] [/ Quickbok 1.7] diff --git a/doc/block.qbk b/doc/block.qbk index c676513..9b31403 100644 --- a/doc/block.qbk +++ b/doc/block.qbk @@ -973,9 +973,7 @@ into the current document, with the following exceptions: * Any macros defined in the included file are scoped to that file. The [^\[include\]] directive lets you specify a document id to use for the -included file. When this id is not explicitly specified, the id defaults to -the filename ("someother", in the example above). You can specify the id -like this: +included file. You can specify the id like this: ``` [include:someid someother.qbk] diff --git a/doc/change_log.qbk b/doc/change_log.qbk index 5e05368..2649df4 100644 --- a/doc/change_log.qbk +++ b/doc/change_log.qbk @@ -303,3 +303,15 @@ Boost 1.46.1: (Can still nest block elements in lists though). * Don't break out of lists after a nested block element. * Check for errors when writing dependency files. +* Improved markup for lists. +* Make escaping templates with a punctuation identifier illegal. + Escaping templates with an alphanumeric identifier is still fine. +* 1.7 changes: + * Make it an error to use an element in the wrong context. + * Error if the body of a phrase element doesn't parse. + * List markup in nested blocks. + * Allow block elements in phrase templates. + * Make it an error to put a paragraph break (i.e. a blank line) + in a phrase template. +* Internal changes: + * Clean up the id manager implementation. diff --git a/doc/language_versions.qbk b/doc/language_versions.qbk new file mode 100644 index 0000000..df9089d --- /dev/null +++ b/doc/language_versions.qbk @@ -0,0 +1,46 @@ +[/ + Copyright 2002,2004,2006 Joel de Guzman, Eric Niebler + Copyright 2010-2013 Daniel James + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +] + +[chapter Language Versions + [quickbook 1.7] + [compatibility-mode 1.5] + [id quickbook.versions] + [source-mode teletype] +] + +[section:stable Stable Versions] + +Since quickbook 1.3 the `quickbook` attribute in the document block selects +which version of the language to use. Not all changes to quickbook are +implemented using a version switch, it's mainly just the changes that change +the way a document is interpreted or would break existing documentation. + +[heading Quickbook 1.3 and later] + +* Introduced quickbook language versioning. +* In the documentation info, allow phrase markup in license and purpose + attributes. +* Fully qualified section and headers. Subsection names are concatenated to the + ID to avoid clashing. Example: `doc_name.sect_name.sub_sect_name.sub_sub_sect_name`. + +[heading Quickbook 1.5 and later] + +* Ignore template argument separators inside square brackets. +* Don't separate the final template argument if the `..` separator was + used. i.e. never mix `..` and whitespace separators. +* Statically scope templates and their arguments rather than dynamically + scope them. +* Give table ids, and let you set them. +* Allow spaces between the `:` character and ids in elements which can + have ids. + +[endsect] + +[include 1_6.qbk] +[include 1_7.qbk] diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index ea988f9..6de2921 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -87,8 +87,9 @@ [include structure.qbk] [include phrase.qbk] [include block.qbk] +[include language_versions.qbk] [include 1_6.qbk] [include install.qbk] [include editors.qbk] [include faq.qbk] -[include ref.qbk] \ No newline at end of file +[include ref.qbk] diff --git a/src/Jamfile.v2 b/src/Jamfile.v2 index e699cd9..7add3ff 100644 --- a/src/Jamfile.v2 +++ b/src/Jamfile.v2 @@ -33,6 +33,8 @@ exe quickbook input_path.cpp values.cpp id_manager.cpp + id_generation.cpp + id_xml.cpp post_process.cpp collector.cpp template_stack.cpp diff --git a/src/actions.cpp b/src/actions.cpp index fdfa5eb..6f21d9c 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -198,7 +198,7 @@ namespace quickbook void break_action::operator()(parse_iterator first, parse_iterator) const { - write_anchors(state, phrase); + write_anchors(state, state.phrase); if(*first == '\\') { @@ -216,7 +216,7 @@ namespace quickbook state.warned_about_breaks = true; } - phrase << detail::get_markup(phrase_tags::break_mark).pre; + state.phrase << detail::get_markup(phrase_tags::break_mark).pre; } void error_message_action::operator()(parse_iterator first, parse_iterator last) const @@ -322,27 +322,18 @@ namespace quickbook while(pos != end && cl::space_p.test(*pos)) ++pos; if(pos != end) { - detail::markup markup = detail::get_markup(block_tags::paragraph); + detail::markup markup = state.in_list ? + detail::get_markup(block_tags::paragraph_in_list) : + detail::get_markup(block_tags::paragraph); state.out << markup.pre << str; write_anchors(state, state.out); state.out << markup.post; } } - void list_item_action::operator()() const + void explicit_list_action::operator()() const { - // Be careful as this is sometimes called in the wrong place - // for markup such as: - // - // * A - // [endsect] - // - // This action is called before [endsect] (to end the list item) - // and then also after it due to the way the parser works. - std::string str; - state.phrase.swap(str); - state.out << str; - write_anchors(state, state.out); + state.explicit_list = true; } void phrase_end_action::operator()() const @@ -405,6 +396,8 @@ namespace quickbook if (!element_id.empty()) { + // Use an explicit id. + std::string anchor = state.ids.add_id( element_id.get_quickbook(), id_category::explicit_id); @@ -412,40 +405,54 @@ namespace quickbook write_bridgehead(state, level, content.get_encoded(), anchor, self_linked_headers); } - else if (!generic && state.ids.compatibility_version() < 103) // version 1.2 and below + else if (state.ids.compatibility_version() >= 106u) { - // This generates the old id style if both the interpreting - // version and the generation version are less then 103u. + // Generate ids for 1.6+ - std::string anchor = state.ids.old_style_id( - detail::make_identifier( - state.ids.replace_placeholders_with_unresolved_ids( - content.get_encoded())), - id_category::generated_heading); - - write_bridgehead(state, level, - content.get_encoded(), anchor, false); - - } - else - { std::string anchor = state.ids.add_id( - detail::make_identifier( - state.ids.compatibility_version() >= 106 ? - content.get_quickbook() : - state.ids.replace_placeholders_with_unresolved_ids( - content.get_encoded()) - ), + detail::make_identifier(content.get_quickbook()), id_category::generated_heading); write_bridgehead(state, level, content.get_encoded(), anchor, self_linked_headers); } + else + { + // Generate ids that are compatible with older versions of quickbook. + + // Older versions of quickbook used the generated boostbook, but + // we only have an intermediate version which can contain id + // placeholders. So to generate the ids they must be replaced + // by the ids that the older versions would have used - i.e. the + // unresolved ids. + // + // Note that this doesn't affect the actual boostbook generated for + // the content, it's just used to generate this id. + + std::string id = detail::make_identifier( + state.ids.replace_placeholders_with_unresolved_ids( + content.get_encoded())); + + if (generic || state.ids.compatibility_version() >= 103) { + std::string anchor = + state.ids.add_id(id, id_category::generated_heading); + + write_bridgehead(state, level, + content.get_encoded(), anchor, self_linked_headers); + } + else { + std::string anchor = + state.ids.old_style_id(id, id_category::generated_heading); + + write_bridgehead(state, level, + content.get_encoded(), anchor, false); + } + } } void simple_phrase_action::operator()(char mark) const { - write_anchors(state, out); + write_anchors(state, state.phrase); int tag = mark == '*' ? phrase_tags::bold : @@ -461,9 +468,9 @@ namespace quickbook value content = values.consume(); values.finish(); - out << markup.pre; - out << content.get_encoded(); - out << markup.post; + state.phrase << markup.pre; + state.phrase << content.get_encoded(); + state.phrase << markup.post; } bool cond_phrase_push::start() @@ -480,8 +487,7 @@ namespace quickbook state.conditional = find(state.macro, macro.c_str()); if (!state.conditional) { - state.phrase.push(); - state.out.push(); + state.push_output(); state.anchors.swap(anchors); } } @@ -493,8 +499,7 @@ namespace quickbook { if (saved_conditional && !state.conditional) { - state.phrase.pop(); - state.out.pop(); + state.pop_output(); state.anchors.swap(anchors); } @@ -522,9 +527,11 @@ namespace quickbook void state::start_list(char mark) { - write_anchors(*this, out); + write_anchors(*this, (in_list ? phrase : out)); assert(mark == '*' || mark == '#'); + push_output(); out << ((mark == '#') ? "\n" : "\n"); + in_list = true; } void state::end_list(char mark) @@ -532,18 +539,27 @@ namespace quickbook write_anchors(*this, out); assert(mark == '*' || mark == '#'); out << ((mark == '#') ? "\n" : "\n"); + + std::string list_output; + out.swap(list_output); + + pop_output(); + + (in_list ? phrase : out) << list_output; } void state::start_list_item() { - out << ""; - write_anchors(*this, out); + out << ""; + write_anchors(*this, phrase); } void state::end_list_item() { - write_anchors(*this, out); - out << ""; + write_anchors(*this, phrase); + paragraph_action para(*this); + para(); + out << ""; } namespace @@ -593,7 +609,7 @@ namespace quickbook std::string callout_value; { - template_state state(*this); + state_save save(*this, state_save::scope_all); ++template_depth; bool r = parse_template(callout_body, *this); @@ -654,35 +670,35 @@ namespace quickbook void do_macro_action::operator()(std::string const& str) const { - write_anchors(state, phrase); + write_anchors(state, state.phrase); if (str == quickbook_get_date) { char strdate[64]; strftime(strdate, sizeof(strdate), "%Y-%b-%d", current_time); - phrase << strdate; + state.phrase << strdate; } else if (str == quickbook_get_time) { char strdate[64]; strftime(strdate, sizeof(strdate), "%I:%M:%S %p", current_time); - phrase << strdate; + state.phrase << strdate; } else { - phrase << str; + state.phrase << str; } } void raw_char_action::operator()(char ch) const { - out << ch; + state.phrase << ch; } void raw_char_action::operator()(parse_iterator first, parse_iterator last) const { while (first != last) - out << *first++; + state.phrase << *first++; } void source_mode_action(quickbook::state& state, value source_mode) @@ -742,52 +758,50 @@ namespace quickbook boost::swap(state.current_file, saved_file); // print the code with syntax coloring - std::string str = syntax_highlight(first_, last_, state, - source_mode, block); + // + // We must not place a \n after the tag + // otherwise PDF output starts code blocks with a blank line: + state.phrase << ""; + syntax_highlight(first_, last_, state, source_mode, block); + state.phrase << "\n"; boost::swap(state.current_file, saved_file); - collector& output = inline_code ? state.phrase : state.out; + if (qbk_version_n >= 107u) state.phrase << state.end_callouts(); - // We must not place a \n after the tag - // otherwise PDF output starts code blocks with a blank line: - // - output << ""; - output << str; - output << "\n"; - - if (qbk_version_n >= 107u) output << state.end_callouts(); + if (!inline_code) { + state.out << state.phrase.str(); + state.phrase.clear(); + } } else { parse_iterator first_(code_value.begin()); parse_iterator last_(code_value.end()); - std::string str = syntax_highlight(first_, last_, state, - source_mode, block); state.phrase << ""; - state.phrase << str; + syntax_highlight(first_, last_, state, source_mode, block); state.phrase << ""; } } void plain_char_action::operator()(char ch) const { - write_anchors(state, phrase); + write_anchors(state, state.phrase); - detail::print_char(ch, phrase.get()); + detail::print_char(ch, state.phrase.get()); } void plain_char_action::operator()(parse_iterator first, parse_iterator last) const { - write_anchors(state, phrase); + write_anchors(state, state.phrase); while (first != last) - detail::print_char(*first++, phrase.get()); + detail::print_char(*first++, state.phrase.get()); } void escape_unicode_action::operator()(parse_iterator first, parse_iterator last) const { - write_anchors(state, phrase); + write_anchors(state, state.phrase); while(first != last && *first == '0') ++first; @@ -799,10 +813,11 @@ namespace quickbook if(hex_digits.size() == 2 && *first > '0' && *first <= '7') { using namespace std; - detail::print_char(strtol(hex_digits.c_str(), 0, 16), phrase.get()); + detail::print_char(strtol(hex_digits.c_str(), 0, 16), + state.phrase.get()); } else { - phrase << "&#x" << hex_digits << ";"; + state.phrase << "&#x" << hex_digits << ";"; } } @@ -1217,7 +1232,7 @@ namespace quickbook bool r = cl::parse(first, last, content.get_tag() == template_tags::phrase ? state.grammar().inline_phrase : - state.grammar().block + state.grammar().block_start ).full; boost::swap(state.current_file, saved_current_file); @@ -1232,23 +1247,17 @@ namespace quickbook string_iterator first) { bool is_block = symbol->content.get_tag() != template_tags::phrase; + quickbook::paragraph_action paragraph_action(state); + + // Finish off any existing paragraphs. + if (is_block) paragraph_action(); // If this template contains already encoded text, then just // write it out, without going through any of the rigamarole. if (symbol->content.is_encoded()) { - if (is_block) - { - paragraph_action para(state); - para(); - state.out << symbol->content.get_encoded(); - } - else - { - state.phrase << symbol->content.get_encoded(); - } - + (is_block ? state.out : state.phrase) << symbol->content.get_encoded(); return; } @@ -1259,11 +1268,11 @@ namespace quickbook // arguments are expanded. template_scope const& call_scope = state.templates.top_scope(); - std::string block; - std::string phrase; - { - template_state save(state); + state_save save(state, state_save::scope_callables); + std::string save_block; + std::string save_phrase; + state.templates.start_template(symbol); qbk_version_n = symbol->content.get_file()->version(); @@ -1296,6 +1305,11 @@ namespace quickbook /////////////////////////////////// // parse the template body: + if (symbol->content.get_file()->version() < 107u) { + state.out.swap(save_block); + state.phrase.swap(save_phrase); + } + if (!parse_template(symbol->content, state)) { detail::outerr(state.current_file, first) @@ -1321,19 +1335,24 @@ namespace quickbook return; } - state.out.swap(block); - state.phrase.swap(phrase); - } + if (symbol->content.get_file()->version() < 107u) { + state.out.swap(save_block); + state.phrase.swap(save_phrase); - if(is_block || !block.empty()) { - paragraph_action para(state); - para(); // For paragraphs before the template call. - state.out << block; - state.phrase << phrase; - para(); - } - else { - state.phrase << phrase; + if(is_block || !save_block.empty()) { + paragraph_action(); + state.out << save_block; + state.phrase << save_phrase; + paragraph_action(); + } + else { + state.phrase << save_phrase; + } + } + else + { + if (is_block) paragraph_action(); + } } } @@ -1933,10 +1952,10 @@ namespace quickbook // // For old versions of quickbook, templates aren't scoped by the // file. - file_state save(state, - load_type == block_tags::import ? file_state::scope_output : - qbk_version_n >= 106u ? file_state::scope_callables : - file_state::scope_macros); + state_save save(state, + load_type == block_tags::import ? state_save::scope_output : + qbk_version_n >= 106u ? state_save::scope_callables : + state_save::scope_macros); state.current_file = load(paths.filename); // Throws load_error state.filename_relative = paths.filename_relative; @@ -2069,8 +2088,7 @@ namespace quickbook bool to_value_scoped_action::start(value::tag_type t) { - state.out.push(); - state.phrase.push(); + state.push_output(); state.anchors.swap(saved_anchors); tag = t; @@ -2101,8 +2119,7 @@ namespace quickbook void to_value_scoped_action::cleanup() { - state.phrase.pop(); - state.out.pop(); + state.pop_output(); state.anchors.swap(saved_anchors); } } diff --git a/src/actions.hpp b/src/actions.hpp index 5a93cf9..21c37ce 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -46,7 +46,7 @@ namespace quickbook int load_snippets(fs::path const& file, std::vector& storage, std::string const& extension, value::tag_type load_type); - std::string syntax_highlight( + void syntax_highlight( parse_iterator first, parse_iterator last, quickbook::state& state, std::string const& source_mode, @@ -119,12 +119,12 @@ namespace quickbook quickbook::state& state; }; - struct list_item_action + struct explicit_list_action { // implicit paragraphs // doesn't output the paragraph if it's only whitespace. - list_item_action( + explicit_list_action( quickbook::state& state) : state(state) {} @@ -149,15 +149,11 @@ namespace quickbook { // Handles simple text formats - simple_phrase_action( - collector& out - , quickbook::state& state) - : out(out) - , state(state) {} + simple_phrase_action(quickbook::state& state) + : state(state) {} void operator()(char) const; - collector& out; quickbook::state& state; }; @@ -178,12 +174,9 @@ namespace quickbook { // Handles macro substitutions - do_macro_action(collector& phrase, quickbook::state& state) - : phrase(phrase) - , state(state) {} + do_macro_action(quickbook::state& state) : state(state) {} void operator()(std::string const& str) const; - collector& phrase; quickbook::state& state; }; @@ -191,13 +184,12 @@ namespace quickbook { // Prints a space - raw_char_action(collector& out) - : out(out) {} + raw_char_action(quickbook::state& state) : state(state) {} void operator()(char ch) const; void operator()(parse_iterator first, parse_iterator last) const; - collector& out; + quickbook::state& state; }; struct plain_char_action @@ -205,36 +197,29 @@ namespace quickbook // Prints a single plain char. // Converts '<' to "<"... etc See utils.hpp - plain_char_action(collector& phrase, quickbook::state& state) - : phrase(phrase) - , state(state) {} + plain_char_action(quickbook::state& state) : state(state) {} void operator()(char ch) const; void operator()(parse_iterator first, parse_iterator last) const; - collector& phrase; quickbook::state& state; }; struct escape_unicode_action { - escape_unicode_action(collector& phrase, quickbook::state& state) - : phrase(phrase) - , state(state) {} + escape_unicode_action(quickbook::state& state) : state(state) {} + void operator()(parse_iterator first, parse_iterator last) const; - collector& phrase; quickbook::state& state; }; struct break_action { - break_action(collector& phrase, quickbook::state& state) - : phrase(phrase), state(state) {} + break_action(quickbook::state& state) : state(state) {} void operator()(parse_iterator f, parse_iterator) const; - collector& phrase; quickbook::state& state; }; diff --git a/src/block_element_grammar.cpp b/src/block_element_grammar.cpp index 1d998b9..c37a31d 100644 --- a/src/block_element_grammar.cpp +++ b/src/block_element_grammar.cpp @@ -47,7 +47,8 @@ namespace quickbook // Actions error_action error(state); element_id_warning_action element_id_warning(state); - raw_char_action raw_char(state.phrase); + raw_char_action raw_char(state); + explicit_list_action explicit_list(state); scoped_parser to_value(state); local.element_id = @@ -66,8 +67,8 @@ namespace quickbook !(qbk_ver(106u) >> local.element_id); elements.add - ("section", element_info(element_info::block, &local.begin_section, block_tags::begin_section)) - ("endsect", element_info(element_info::block, &local.end_section, block_tags::end_section)) + ("section", element_info(element_info::section_block, &local.begin_section, block_tags::begin_section)) + ("endsect", element_info(element_info::section_block, &local.end_section, block_tags::end_section)) ; local.begin_section = @@ -261,7 +262,11 @@ namespace quickbook ("itemized_list", element_info(element_info::nested_block, &local.list, block_tags::itemized_list, 106)) ; - local.list = *local.cell; + local.list = + *( cl::eps_p [explicit_list] + >> local.cell + ) + ; local.cell = space diff --git a/src/block_tags.hpp b/src/block_tags.hpp index b01271f..3049b57 100644 --- a/src/block_tags.hpp +++ b/src/block_tags.hpp @@ -22,7 +22,7 @@ namespace quickbook (macro_definition)(template_definition) (variable_list)(table) (xinclude)(import)(include) - (paragraph) + (paragraph)(paragraph_in_list) (ordered_list)(itemized_list) (hr) ) diff --git a/src/doc_info_grammar.cpp b/src/doc_info_grammar.cpp index 563efc3..868ac63 100644 --- a/src/doc_info_grammar.cpp +++ b/src/doc_info_grammar.cpp @@ -118,8 +118,8 @@ namespace quickbook // Actions error_action error(state); - plain_char_action plain_char(state.phrase, state); - do_macro_action do_macro(state.phrase, state); + plain_char_action plain_char(state); + do_macro_action do_macro(state); scoped_parser to_value(state); doc_info_details = diff --git a/src/grammar.cpp b/src/grammar.cpp index 8f244f1..90f8c4b 100644 --- a/src/grammar.cpp +++ b/src/grammar.cpp @@ -17,8 +17,8 @@ namespace quickbook : impl_(new impl(s)) , command_line_macro(impl_->command_line, "command_line_macro") , inline_phrase(impl_->inline_phrase, "inline_phrase") - , phrase(impl_->phrase_start, "phrase") - , block(impl_->block_start, "block") + , phrase_start(impl_->phrase_start, "phrase") + , block_start(impl_->block_start, "block") , doc_info(impl_->doc_info_details, "doc_info") { } diff --git a/src/grammar.hpp b/src/grammar.hpp index 54aaf2b..b362950 100644 --- a/src/grammar.hpp +++ b/src/grammar.hpp @@ -58,8 +58,8 @@ namespace quickbook public: grammar command_line_macro; grammar inline_phrase; - grammar phrase; - grammar block; + grammar phrase_start; + grammar block_start; grammar doc_info; quickbook_grammar(quickbook::state&); diff --git a/src/grammar_impl.hpp b/src/grammar_impl.hpp index 800e9f8..b84903c 100644 --- a/src/grammar_impl.hpp +++ b/src/grammar_impl.hpp @@ -24,7 +24,7 @@ namespace quickbook { enum type_enum { nothing = 0, - block = 1, + section_block = 1, conditional_or_block = 2, nested_block = 4, phrase = 8, @@ -32,14 +32,20 @@ namespace quickbook }; enum context { - in_phrase = phrase | maybe_block, - in_nested_block = phrase | maybe_block | nested_block, + // At the top level we allow everything. + in_top_level = phrase | maybe_block | nested_block | conditional_or_block | section_block, + // In conditional phrases and list blocks we everything but section elements. in_conditional = phrase | maybe_block | nested_block | conditional_or_block, - in_block = phrase | maybe_block | nested_block | conditional_or_block | block, - only_nested_block = nested_block, - only_block = nested_block | conditional_or_block | block, - only_list_block = nested_block | conditional_or_block, - only_contextual_block = maybe_block | nested_block | conditional_or_block | block + in_list_block = phrase | maybe_block | nested_block | conditional_or_block, + // In nested blocks we allow a much more limited range of elements. + in_nested_block = phrase | maybe_block | nested_block, + // In a phrase we only allow phrase elements, ('maybe_block' + // elements are treated as phrase elements in this context) + in_phrase = phrase | maybe_block, + // At the start of a block these are all block elements. + is_contextual_block = maybe_block | nested_block | conditional_or_block | section_block, + // These are all block elements in all other contexts. + is_block = nested_block | conditional_or_block | section_block, }; element_info() diff --git a/src/id_generation.cpp b/src/id_generation.cpp new file mode 100644 index 0000000..3b1f57d --- /dev/null +++ b/src/id_generation.cpp @@ -0,0 +1,378 @@ +/*============================================================================= + Copyright (c) 2011, 2013 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include "id_manager_impl.hpp" +#include +#include +#include +#include +#include + +// TODO: This should possibly try to always generate valid XML ids: +// http://www.w3.org/TR/REC-xml/#NT-NameStartChar + +namespace quickbook { + // + // The maximum size of a generated part of an id. + // + // Not a strict maximum, sometimes broken because the user + // explicitly uses a longer id, or for backwards compatibility. + + static const std::size_t max_size = 32; + + typedef std::vector placeholder_index; + placeholder_index index_placeholders(id_state const&, boost::string_ref); + + void generate_id_block( + placeholder_index::iterator, placeholder_index::iterator, + std::vector& generated_ids); + + std::vector generate_ids(id_state const& state, boost::string_ref xml) + { + std::vector generated_ids(state.placeholders.size()); + + // Get a list of the placeholders in the order that we wish to + // process them. + placeholder_index placeholders = index_placeholders(state, xml); + + typedef std::vector::iterator iterator; + iterator it = placeholders.begin(), end = placeholders.end(); + + while (it != end) { + // We process all the ids that have the same number of dots + // together. Note that ids with different parents can clash, e.g. + // because of old fashioned id generation or anchors containing + // multiple dots. + // + // So find the group of placeholders with the same number of dots. + iterator group_begin = it, group_end = it; + while (group_end != end && (*group_end)->num_dots == (*it)->num_dots) + ++group_end; + + generate_id_block(group_begin, group_end, generated_ids); + it = group_end; + } + + return generated_ids; + } + + // + // index_placeholders + // + // Create a sorted index of the placeholders, in order + // to make numbering duplicates easy. A total order. + // + + struct placeholder_compare + { + std::vector& order; + + placeholder_compare(std::vector& order) : order(order) {} + + bool operator()(id_placeholder const* x, id_placeholder const* y) const + { + bool x_explicit = x->category.c >= id_category::explicit_id; + bool y_explicit = y->category.c >= id_category::explicit_id; + + return + x->num_dots < y->num_dots ? true : + x->num_dots > y->num_dots ? false : + x_explicit > y_explicit ? true : + x_explicit < y_explicit ? false : + order[x->index] < order[y->index]; + } + }; + + struct get_placeholder_order_callback : xml_processor::callback + { + id_state const& state; + std::vector& order; + unsigned count; + + get_placeholder_order_callback(id_state const& state, + std::vector& order) + : state(state), + order(order), + count(0) + {} + + void id_value(boost::string_ref value) + { + set_placeholder_order(state.get_placeholder(value)); + } + + void set_placeholder_order(id_placeholder const* p) + { + if (p && !order[p->index]) { + set_placeholder_order(p->parent); + order[p->index] = ++count; + } + } + }; + + placeholder_index index_placeholders( + id_state const& state, + boost::string_ref xml) + { + // The order that the placeholder appear in the xml source. + std::vector order(state.placeholders.size()); + + xml_processor processor; + get_placeholder_order_callback callback(state, order); + processor.parse(xml, callback); + + placeholder_index sorted_placeholders; + sorted_placeholders.reserve(state.placeholders.size()); + BOOST_FOREACH(id_placeholder const& p, state.placeholders) + if (order[p.index]) sorted_placeholders.push_back(&p); + boost::sort(sorted_placeholders, placeholder_compare(order)); + + return sorted_placeholders; + } + + // Resolve and generate ids. + + struct generate_id_block_type + { + // The ids which won't require duplicate handling. + typedef boost::unordered_map + chosen_id_map; + chosen_id_map chosen_ids; + std::vector& generated_ids; + + generate_id_block_type(std::vector& generated_ids) : + generated_ids(generated_ids) {} + + void generate(placeholder_index::iterator begin, + placeholder_index::iterator end); + + std::string resolve_id(id_placeholder const*); + std::string generate_id(id_placeholder const*, std::string const&); + }; + + void generate_id_block(placeholder_index::iterator begin, + placeholder_index::iterator end, + std::vector& generated_ids) + { + generate_id_block_type impl(generated_ids); + impl.generate(begin, end); + } + + void generate_id_block_type::generate(placeholder_index::iterator begin, + placeholder_index::iterator end) + { + std::vector resolved_ids; + + for (placeholder_index::iterator i = begin; i != end; ++i) + resolved_ids.push_back(resolve_id(*i)); + + unsigned index = 0; + for (placeholder_index::iterator i = begin; i != end; ++i, ++index) + { + generated_ids[(**i).index] = + generate_id(*i, resolved_ids[index]); + } + } + + std::string generate_id_block_type::resolve_id(id_placeholder const* p) + { + std::string id = p->parent ? + generated_ids[p->parent->index] + "." + p->id : + p->id; + + if (p->category.c > id_category::numbered) { + // Reserve the id if it isn't already reserved. + chosen_id_map::iterator pos = chosen_ids.emplace(id, p).first; + + // If it was reserved by a placeholder with a lower category, + // then overwrite it. + if (p->category.c > pos->second->category.c) + pos->second = p; + } + + return id; + } + + std::string generate_id_block_type::generate_id(id_placeholder const* p, + std::string const& resolved_id) + { + if (p->category.c > id_category::numbered && + chosen_ids.at(resolved_id) == p) + { + return resolved_id; + } + + // Split the id into its parent part and child part. + // + // Note: can't just use the placeholder's parent, as the + // placeholder id might contain dots. + unsigned child_start = resolved_id.rfind('.'); + std::string parent_id, base_id; + + if (child_start == std::string::npos) { + base_id = normalize_id(resolved_id, max_size - 1); + } + else { + parent_id = resolved_id.substr(0, child_start + 1); + base_id = normalize_id(resolved_id.substr(child_start + 1), + max_size - 1); + } + + // Since we're adding digits, don't want an id that ends in + // a digit. + + unsigned int length = base_id.size(); + + if (length > 0 && std::isdigit(base_id[length - 1])) { + if (length < max_size - 1) { + base_id += '_'; + ++length; + } + else { + while (length > 0 && std::isdigit(base_id[length -1])) + --length; + base_id.erase(length); + } + } + + unsigned count = 0; + + while (true) + { + std::string postfix = + boost::lexical_cast(count++); + + if ((base_id.size() + postfix.size()) > max_size) { + // The id is now too long, so reduce the length and + // start again. + + // Would need a lot of ids to get this far.... + if (length == 0) throw std::runtime_error("Too many ids"); + + // Trim a character. + --length; + + // Trim any trailing digits. + while (length > 0 && std::isdigit(base_id[length -1])) + --length; + + base_id.erase(length); + count = 0; + } + else { + // Try to reserve this id. + std::string generated_id = parent_id + base_id + postfix; + + if (chosen_ids.emplace(generated_id, p).second) { + return generated_id; + } + } + } + } + + // + // replace_ids + // + // Return a copy of the xml with all the placeholders replaced by + // generated_ids. + // + + struct replace_ids_callback : xml_processor::callback + { + id_state const& state; + std::vector const* ids; + boost::string_ref::const_iterator source_pos; + std::string result; + + replace_ids_callback(id_state const& state, + std::vector const* ids) + : state(state), + ids(ids), + source_pos(), + result() + {} + + void start(boost::string_ref xml) + { + source_pos = xml.begin(); + } + + void id_value(boost::string_ref value) + { + if (id_placeholder const* p = state.get_placeholder(value)) + { + boost::string_ref id = ids ? + (*ids)[p->index] : p->unresolved_id; + + result.append(source_pos, value.begin()); + result.append(id.begin(), id.end()); + source_pos = value.end(); + } + } + + void finish(boost::string_ref xml) + { + result.append(source_pos, xml.end()); + source_pos = xml.end(); + } + }; + + std::string replace_ids(id_state const& state, boost::string_ref xml, + std::vector const* ids) + { + xml_processor processor; + replace_ids_callback callback(state, ids); + processor.parse(xml, callback); + return callback.result; + } + + // + // normalize_id + // + // Normalizes generated ids. + // + + std::string normalize_id(boost::string_ref src_id) + { + return normalize_id(src_id, max_size); + } + + std::string normalize_id(boost::string_ref src_id, std::size_t size) + { + std::string id(src_id.begin(), src_id.end()); + + std::size_t src = 0; + std::size_t dst = 0; + + while (src < id.length() && id[src] == '_') { + ++src; + } + + if (src == id.length()) { + id = "_"; + } + else { + while (src < id.length() && dst < size) { + if (id[src] == '_') { + do { + ++src; + } while(src < id.length() && id[src] == '_'); + + if (src < id.length()) id[dst++] = '_'; + } + else { + id[dst++] = id[src++]; + } + } + + id.erase(dst); + } + + return id; + } +} diff --git a/src/id_manager.cpp b/src/id_manager.cpp index 1f84ad1..c194331 100644 --- a/src/id_manager.cpp +++ b/src/id_manager.cpp @@ -1,229 +1,90 @@ /*============================================================================= - Copyright (c) 2011 Daniel James + Copyright (c) 2011, 2013 Daniel James Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ -#include "id_manager.hpp" +#include "id_manager_impl.hpp" #include "utils.hpp" -#include #include -#include #include #include -#include -#include -#include #include namespace quickbook { - // TODO: This should possibly try to make ids are generated: - // http://www.w3.org/TR/REC-xml/#NT-NameStartChar - - // - // Forward declarations - // - - struct id_placeholder; - struct id_data; - std::string replace_ids(id_state& state, boost::string_ref xml, - bool use_resolved_ids = true); - std::string process_ids(id_state&, boost::string_ref); - - static const std::size_t max_size = 32; - - // - // id_placeholder - // - - struct id_placeholder - { - enum state_enum { child, unresolved, resolved, generated }; - - unsigned index; // The poisition in the placeholder deque. - state_enum generation_state; - // Placeholder's position in generation - // process. - std::string unresolved_id; - // The id that would be generated without any - // duplicate handling. - std::string id; // The id so far. - id_placeholder* parent; // Placeholder of the parent id. - // Only when generation_state == child - id_category category; - unsigned num_dots; // Number of dots in the id. - // Normally equal to the section level. - unsigned order; // Order of the placeholders in the generated - // xml. Stored because it can be slightly - // different to the order they're generated - // in. e.g. for nested tables the cells - // are processed before the title id. - // Only set when processing ids. - id_data* data; // Assigned data shared by duplicate ids - // used to detect them. Only when - // generation_state == resolved - - id_placeholder( - unsigned index, - boost::string_ref id, - id_category category, - id_placeholder* parent_ = 0) - : index(index), - generation_state(parent_ ? child : unresolved), - unresolved_id(parent_ ? - parent_->unresolved_id + '.' + detail::to_s(id) : - detail::to_s(id)), - id(id.begin(), id.end()), - parent(parent_), - category(category), - num_dots(boost::range::count(id, '.') + - (parent_ ? parent_->num_dots + 1 : 0)), - order(0), - data(0) - { - } - - std::string to_string() - { - return '$' + boost::lexical_cast(index); - } - - bool check_state() const - { - return ( - (generation_state == child) == (bool) parent && - (generation_state == resolved) == (bool) data); - } - - bool check_state(state_enum s) const - { - return s == generation_state && check_state(); - } - }; - - // - // id_state - // - - struct file_info; - struct doc_info; - struct section_info; - - struct id_state - { - boost::shared_ptr current_file; - std::deque placeholders; - - // Placeholder methods - - id_placeholder* add_placeholder( - boost::string_ref, id_category, id_placeholder* parent = 0); - - id_placeholder* get_placeholder(boost::string_ref); - - // Events - - id_placeholder* start_file( - unsigned compatibility_version, - bool document_root, - boost::string_ref include_doc_id, - boost::string_ref id, - value const& title); - - void end_file(); - - id_placeholder* add_id( - boost::string_ref id, - id_category category); - id_placeholder* old_style_id( - boost::string_ref id, - id_category category); - id_placeholder* begin_section( - boost::string_ref id, - id_category category); - void end_section(); - -private: - id_placeholder* add_id_to_section( - boost::string_ref id, - id_category category, - boost::shared_ptr const& section); - id_placeholder* create_new_section( - boost::string_ref id, - id_category category); - - void switch_section(id_placeholder*); - void reswitch_sections(boost::shared_ptr const&, - boost::shared_ptr const&); - void restore_section(); - }; - struct file_info { - boost::shared_ptr parent; - boost::shared_ptr document; + boost::shared_ptr const parent; + boost::shared_ptr const document; - bool document_root; // !parent || document != parent->document - unsigned compatibility_version; - boost::shared_ptr switched_section; - id_placeholder* original_placeholder; + bool const document_root; // !parent || document != parent->document + unsigned const compatibility_version; + unsigned const depth; + unsigned const override_depth; + id_placeholder const* const override_id; // The 1.1-1.5 document id would actually change per file due to // explicit ids in includes and a bug which would sometimes use the // document title instead of the id. - std::string doc_id_1_1; + std::string const doc_id_1_1; + // Constructor for files that aren't the root of a document. file_info(boost::shared_ptr const& parent, - unsigned compatibility_version) : + unsigned compatibility_version, + boost::string_ref doc_id_1_1, + id_placeholder const* override_id) : parent(parent), document(parent->document), document_root(false), compatibility_version(compatibility_version), - switched_section(), original_placeholder() + depth(parent->depth + 1), + override_depth(override_id ? depth : parent->override_depth), + override_id(override_id ? override_id : parent->override_id), + doc_id_1_1(detail::to_s(doc_id_1_1)) {} + // Constructor for files that are the root of a document. file_info(boost::shared_ptr const& parent, boost::shared_ptr const& document, - unsigned compatibility_version) : + unsigned compatibility_version, + boost::string_ref doc_id_1_1) : parent(parent), document(document), document_root(true), compatibility_version(compatibility_version), - switched_section(), original_placeholder() + depth(0), override_depth(0), override_id(0), + doc_id_1_1(detail::to_s(doc_id_1_1)) {} }; struct doc_info { boost::shared_ptr current_section; + + // Note: these are mutable to remain bug compatible with old versions + // of quickbook. They would set these values at the start of new files + // and sections and then not restore them at the end. std::string last_title_1_1; std::string section_id_1_1; - - doc_info() : - current_section(), last_title_1_1(), section_id_1_1() - {} }; struct section_info { - boost::shared_ptr parent; - unsigned compatibility_version; - unsigned level; - std::string id_1_1; - id_placeholder* placeholder_1_6; + boost::shared_ptr const parent; + unsigned const compatibility_version; + unsigned const file_depth; + unsigned const level; + std::string const id_1_1; + id_placeholder const* const placeholder_1_6; section_info(boost::shared_ptr const& parent, - unsigned compatibility_version, boost::string_ref id) : - parent(parent), compatibility_version(compatibility_version), + file_info const* current_file, boost::string_ref id, + boost::string_ref id_1_1, id_placeholder const* placeholder_1_6) : + parent(parent), + compatibility_version(current_file->compatibility_version), + file_depth(current_file->depth), level(parent ? parent->level + 1 : 1), - id_1_1(), placeholder_1_6(0) - { - if (parent && compatibility_version < 106u) { - id_1_1 = parent->id_1_1; - if (!id_1_1.empty() && !id.empty()) - id_1_1 += "."; - id_1_1.append(id.begin(), id.end()); - } - } + id_1_1(detail::to_s(id_1_1)), + placeholder_1_6(placeholder_1_6) {} }; // @@ -295,13 +156,14 @@ private: std::string id_manager::replace_placeholders_with_unresolved_ids( boost::string_ref xml) const { - return replace_ids(*state, xml, false); + return replace_ids(*state, xml); } std::string id_manager::replace_placeholders(boost::string_ref xml) const { assert(!state->current_file); - return process_ids(*state, xml); + std::vector ids = generate_ids(*state, xml); + return replace_ids(*state, xml, &ids); } unsigned id_manager::compatibility_version() const @@ -310,70 +172,45 @@ private: } // - // normalize_id - // - // Normalizes generated ids. + // id_placeholder // - namespace + id_placeholder::id_placeholder( + unsigned index, + boost::string_ref id, + id_category category, + id_placeholder const* parent_) + : index(index), + unresolved_id(parent_ ? + parent_->unresolved_id + '.' + detail::to_s(id) : + detail::to_s(id)), + id(id.begin(), id.end()), + parent(parent_), + category(category), + num_dots(boost::range::count(id, '.') + + (parent_ ? parent_->num_dots + 1 : 0)) { - std::string normalize_id( - boost::string_ref src_id, - std::size_t prefix = 0, - std::size_t size = max_size) - { - std::string id(src_id.begin(), src_id.end()); + } - std::size_t src = prefix; - std::size_t dst = prefix; - size += prefix; - - if (src >= id.length()) { - return id; - } - - while (src < id.length() && id[src] == '_') { - ++src; - } - - if (src >= id.length()) { - id += '_'; - return id; - } - - while (src < id.length() && dst < size) { - if (id[src] == '_') { - do { - ++src; - } while(src < id.length() && id[src] == '_'); - - if (src < id.length()) id[dst++] = '_'; - } - else { - id[dst++] = id[src++]; - } - } - - id.erase(dst); - - return id; - } + std::string id_placeholder::to_string() const + { + return '$' + boost::lexical_cast(index); } // // id_state // - id_placeholder* id_state::add_placeholder( + id_placeholder const* id_state::add_placeholder( boost::string_ref id, id_category category, - id_placeholder* parent) + id_placeholder const* parent) { placeholders.push_back(id_placeholder( placeholders.size(), id, category, parent)); return &placeholders.back(); } - id_placeholder* id_state::get_placeholder(boost::string_ref value) + id_placeholder const* id_state::get_placeholder(boost::string_ref value) const { // If this isn't a placeholder id. if (value.size() <= 1 || *value.begin() != '$') @@ -385,68 +222,26 @@ private: return &placeholders.at(index); } - void id_state::switch_section(id_placeholder* p) + id_placeholder const* id_state::get_id_placeholder( + boost::shared_ptr const& section) const { - assert(!current_file->original_placeholder); - current_file->switched_section = current_file->document->current_section; - current_file->original_placeholder = current_file->switched_section->placeholder_1_6; - current_file->switched_section->placeholder_1_6 = p; + return !section ? 0 : + section->file_depth < current_file->override_depth ? + current_file->override_id : section->placeholder_1_6; } - void id_state::reswitch_sections( - boost::shared_ptr const& popped_section, - boost::shared_ptr const& parent_section) - { - boost::shared_ptr file = current_file; - boost::shared_ptr first_switched_file; - - for (;;) { - if (file->switched_section == popped_section) - { - first_switched_file = file; - file->switched_section = parent_section; - } - - if (file->document_root) break; - file = file->parent; - } - - if (first_switched_file) { - first_switched_file->original_placeholder = - parent_section->placeholder_1_6; - parent_section->placeholder_1_6 = - popped_section->placeholder_1_6; - } - } - - void id_state::restore_section() - { - if (current_file->original_placeholder) { - current_file->switched_section->placeholder_1_6 = - current_file->original_placeholder; - } - } - - id_placeholder* id_state::start_file( + id_placeholder const* id_state::start_file( unsigned compatibility_version, bool document_root, boost::string_ref include_doc_id, boost::string_ref id, value const& title) { - // Create new file - boost::shared_ptr parent = current_file; + assert(parent || document_root); - if (document_root) { - current_file = boost::make_shared(parent, - boost::make_shared(), - compatibility_version); - } - else { - current_file = - boost::make_shared(parent, compatibility_version); - } + boost::shared_ptr document = + document_root ? boost::make_shared() : parent->document; // Choose specified id to use. Prefer 'include_doc_id' (the id // specified in an 'include' element) unless backwards compatibility @@ -456,32 +251,39 @@ private: if (document_root || compatibility_version >= 106u || - (parent && parent->compatibility_version >= 106u)) { + parent->compatibility_version >= 106u) + { initial_doc_id = !include_doc_id.empty() ? include_doc_id : id; } else { initial_doc_id = !id.empty() ? id : include_doc_id; } - // Set variables used for backwards compatible id generation. - // They're a bit odd because of old bugs. + // Work out this file's doc_id for older versions of quickbook. + // A bug meant that this need to be done per file, not per + // document. + + std::string doc_id_1_1; if (document_root || compatibility_version < 106u) { - // Note: this is done for older versions even if docinfo is - // otherwise ignored. - if (title.check()) - current_file->document->last_title_1_1 = - detail::to_s(title.get_quickbook()); + document->last_title_1_1 = detail::to_s(title.get_quickbook()); - current_file->doc_id_1_1 = !initial_doc_id.empty() ? detail::to_s(initial_doc_id) : - detail::make_identifier(current_file->document->last_title_1_1); + doc_id_1_1 = !initial_doc_id.empty() ? detail::to_s(initial_doc_id) : + detail::make_identifier(document->last_title_1_1); } else if (parent) { - current_file->doc_id_1_1 = parent->doc_id_1_1; + doc_id_1_1 = parent->doc_id_1_1; } if (document_root) { + // Create new file + + current_file = boost::make_shared(parent, + document, compatibility_version, doc_id_1_1); + + // Create a section for the new document. + if (!initial_doc_id.empty()) { return create_new_section(id, id_category::explicit_section_id); } @@ -498,28 +300,41 @@ private: } } else { - // If an id was set for the file, then switch the current section - // with a new section with this id. This will be maintained in - // 'end_section' if the current section ends, and then the original - // section restored in 'end_file' + // If an id was set for the file, then the file overrides the + // current section's id with this id. + // + // Don't do this for document_root as it will create a section + // for the document. + // + // Don't do this for older versions, as they use a different + // backwards compatible mechanism to handle file ids. - if (compatibility_version >= 106u && !initial_doc_id.empty()) { - switch_section(add_id_to_section(initial_doc_id, - id_category::explicit_section_id, - boost::shared_ptr())); + id_placeholder const* override_id = 0; + + if (!initial_doc_id.empty() && compatibility_version >= 106u) + { + boost::shared_ptr null_section; + + override_id = add_id_to_section(initial_doc_id, + id_category::explicit_section_id, null_section); } + // Create new file + + current_file = + boost::make_shared(parent, compatibility_version, + doc_id_1_1, override_id); + return 0; } } void id_state::end_file() { - restore_section(); current_file = current_file->parent; } - id_placeholder* id_state::add_id( + id_placeholder const* id_state::add_id( boost::string_ref id, id_category category) { @@ -527,7 +342,7 @@ private: current_file->document->current_section); } - id_placeholder* id_state::add_id_to_section( + id_placeholder const* id_state::add_id_to_section( boost::string_ref id, id_category category, boost::shared_ptr const& section) @@ -542,27 +357,27 @@ private: id_part = normalize_id(id); } + id_placeholder const* placeholder_1_6 = get_id_placeholder(section); + if(!section || section->compatibility_version >= 106u) { - return add_placeholder(id_part, category, - section ? section->placeholder_1_6 : 0); + return add_placeholder(id_part, category, placeholder_1_6); } else { std::string const& qualified_id = section->id_1_1; std::string new_id; - if (!section->placeholder_1_6) + if (!placeholder_1_6) new_id = current_file->doc_id_1_1; if (!new_id.empty() && !qualified_id.empty()) new_id += '.'; new_id += qualified_id; if (!new_id.empty() && !id_part.empty()) new_id += '.'; new_id += id_part; - return add_placeholder(new_id, category, - section->placeholder_1_6); + return add_placeholder(new_id, category, placeholder_1_6); } } - id_placeholder* id_state::old_style_id( + id_placeholder const* id_state::old_style_id( boost::string_ref id, id_category category) { @@ -572,7 +387,7 @@ private: add_id(id, category); } - id_placeholder* id_state::begin_section( + id_placeholder const* id_state::begin_section( boost::string_ref id, id_category category) { @@ -580,564 +395,62 @@ private: return create_new_section(id, category); } - id_placeholder* id_state::create_new_section( + id_placeholder const* id_state::create_new_section( boost::string_ref id, id_category category) { boost::shared_ptr parent = current_file->document->current_section; - boost::shared_ptr new_section = - boost::make_shared(parent, - current_file->compatibility_version, id); + id_placeholder const* p = 0; + id_placeholder const* placeholder_1_6 = 0; - id_placeholder* p; + std::string id_1_1; - if (new_section->compatibility_version >= 106u) { - p = add_id_to_section(id, category, parent); - new_section->placeholder_1_6 = p; + if (parent && current_file->compatibility_version < 106u) { + id_1_1 = parent->id_1_1; + if (!id_1_1.empty() && !id.empty()) + id_1_1 += "."; + id_1_1.append(id.begin(), id.end()); } - else if (new_section->compatibility_version >= 103u) { - if (parent) - new_section->placeholder_1_6 = parent->placeholder_1_6; + + if (current_file->compatibility_version >= 106u) { + p = placeholder_1_6 = add_id_to_section(id, category, parent); + } + else if (current_file->compatibility_version >= 103u) { + placeholder_1_6 = get_id_placeholder(parent); std::string new_id; - if (!new_section->placeholder_1_6) { + if (!placeholder_1_6) { new_id = current_file->doc_id_1_1; - if (!new_section->id_1_1.empty()) new_id += '.'; + if (!id_1_1.empty()) new_id += '.'; } - new_id += new_section->id_1_1; + new_id += id_1_1; - p = add_placeholder(new_id, category, - new_section->placeholder_1_6); + p = add_placeholder(new_id, category, placeholder_1_6); } else { - if (parent) - new_section->placeholder_1_6 = parent->placeholder_1_6; + placeholder_1_6 = get_id_placeholder(parent); std::string new_id; - if (parent && !new_section->placeholder_1_6) + if (parent && !placeholder_1_6) new_id = current_file->doc_id_1_1 + '.'; new_id += detail::to_s(id); - p = add_placeholder(new_id, category, - new_section->placeholder_1_6); + p = add_placeholder(new_id, category, placeholder_1_6); } - current_file->document->current_section = new_section; + current_file->document->current_section = + boost::make_shared(parent, + current_file.get(), id, id_1_1, placeholder_1_6); return p; } void id_state::end_section() { - boost::shared_ptr popped_section = - current_file->document->current_section; - current_file->document->current_section = popped_section->parent; - - reswitch_sections(popped_section, popped_section->parent); - } - - // - // Xml subset parser used for finding id values. - // - // I originally tried to integrate this into the post processor - // but that proved tricky. Alternatively it could use a proper - // xml parser, but I want this to be able to survive badly - // marked up escapes. - // - - struct xml_processor - { - xml_processor(); - - std::vector id_attributes; - - struct callback { - virtual void start(boost::string_ref) {} - virtual void id_value(boost::string_ref) {} - virtual void finish(boost::string_ref) {} - virtual ~callback() {} - }; - - void parse(boost::string_ref, callback&); - }; - - namespace - { - char const* id_attributes_[] = - { - "id", - "linkend", - "linkends", - "arearefs" - }; - } - - xml_processor::xml_processor() - { - static int const n_id_attributes = sizeof(id_attributes_)/sizeof(char const*); - for (int i = 0; i != n_id_attributes; ++i) - { - id_attributes.push_back(id_attributes_[i]); - } - - boost::sort(id_attributes); - } - - template - bool read(Iterator& it, Iterator end, char const* text) - { - for(Iterator it2 = it;; ++it2, ++text) { - if (!*text) { - it = it2; - return true; - } - - if (it2 == end || *it2 != *text) - return false; - } - } - - template - void read_past(Iterator& it, Iterator end, char const* text) - { - while (it != end && !read(it, end, text)) ++it; - } - - bool find_char(char const* text, char c) - { - for(;*text; ++text) - if (c == *text) return true; - return false; - } - - template - void read_some_of(Iterator& it, Iterator end, char const* text) - { - while(it != end && find_char(text, *it)) ++it; - } - - template - void read_to_one_of(Iterator& it, Iterator end, char const* text) - { - while(it != end && !find_char(text, *it)) ++it; - } - - void xml_processor::parse(boost::string_ref source, callback& c) - { - typedef boost::string_ref::const_iterator iterator; - - c.start(source); - - iterator it = source.begin(), end = source.end(); - - for(;;) - { - read_past(it, end, "<"); - if (it == end) break; - - if (read(it, end, "!--quickbook-escape-prefix-->")) - { - read_past(it, end, ""); - continue; - } - - switch(*it) - { - case '?': - ++it; - read_past(it, end, "?>"); - break; - - case '!': - if (read(it, end, "!--")) - read_past(it, end, "-->"); - else - read_past(it, end, ">"); - break; - - default: - if ((*it >= 'a' && *it <= 'z') || - (*it >= 'A' && *it <= 'Z') || - *it == '_' || *it == ':') - { - read_to_one_of(it, end, " \t\n\r>"); - - for (;;) { - read_some_of(it, end, " \t\n\r"); - iterator name_start = it; - read_to_one_of(it, end, "= \t\n\r>"); - if (it == end || *it == '>') break; - boost::string_ref name(name_start, it - name_start); - ++it; - - read_some_of(it, end, "= \t\n\r"); - if (it == end || (*it != '"' && *it != '\'')) break; - - char delim = *it; - ++it; - - iterator value_start = it; - - it = std::find(it, end, delim); - if (it == end) break; - boost::string_ref value(value_start, it - value_start); - ++it; - - if (boost::find(id_attributes, detail::to_s(name)) - != id_attributes.end()) - { - c.id_value(value); - } - } - } - else - { - read_past(it, end, ">"); - } - } - } - - c.finish(source); - } - - // - // process_ids - // - - // - // Data used for generating placeholders that have duplicates. - // - - struct id_generation_data - { - id_generation_data(boost::string_ref src_id) - : child_start(src_id.rfind('.') + 1), - id(normalize_id(src_id, child_start, max_size - 1)), - // 'max_size - 1' leaves a character to append - // a number. - count(0) - { - if (std::isdigit(id[id.length() - 1])) - { - if (child_length() < max_size - 1) - id += '_'; - else - reduce_id(); - } - } - - void reduce_id() - { - assert(id.length() > child_start); - std::size_t length = id.length() - 1; - while(length > child_start && std::isdigit(id[length - 1])) --length; - id.erase(length); - count = 0; - } - - std::size_t child_length() const - { - return id.length() - child_start; - } - - std::size_t child_start; - std::string id; - int count; - }; - - // Created for all desired ids, either when resolving an id or due to - // generating a new id to avoid duplicates. - struct id_data - { - id_data() - : category(id_category::numbered), - used(false), - generation_data() - {} - - void update_category(id_category c) - { - if (c.c > category.c) category = c; - } - - id_category category; // The highest priority category of the - // placeholders that want to use this id. - bool used; // Whether this id has been used. - boost::shared_ptr generation_data; - // If a duplicates are found, this is - // created to generate new ids. - // - // Many to one relationship, because truncation - // can lead to different ids contending for the - // same id prefix. - }; - - typedef boost::unordered_map allocated_ids; - typedef std::vector placeholder_index; - - placeholder_index index_placeholders(id_state&, boost::string_ref xml); - void resolve_id(id_placeholder&, allocated_ids&); - void generate_id(id_placeholder&, allocated_ids&); - - std::string process_ids(id_state& state, boost::string_ref xml) - { - placeholder_index placeholders = index_placeholders(state, xml); - - typedef std::vector::iterator iterator; - - iterator it = placeholders.begin(), - end = placeholders.end(); - - // Placeholder ids are processed in blocks of ids with - // an equal number of dots. - while (it != end) { - unsigned num_dots = (*it)->num_dots; - - // ids can't clash with ids at a different num_dots, so - // this only needs to track the id generation data - // for a single num_dots at a time. - allocated_ids ids; - - iterator it2 = it; - do { - resolve_id(**it2++, ids); - } while(it2 != end && (*it2)->num_dots == num_dots); - - do { - generate_id(**it++, ids); - } while(it != it2); - } - - return replace_ids(state, xml); - } - - // - // index_placeholders - // - // Create a sorted index of the placeholders, in order - // to make numbering duplicates easy. A total order. - // - - struct placeholder_compare - { - bool operator()(id_placeholder* x, id_placeholder* y) const - { - bool x_explicit = x->category.c >= id_category::explicit_id; - bool y_explicit = y->category.c >= id_category::explicit_id; - - return - x->num_dots < y->num_dots ? true : - x->num_dots > y->num_dots ? false : - x_explicit > y_explicit ? true : - x_explicit < y_explicit ? false : - x->order < y->order; - } - }; - - struct number_placeholders_callback : xml_processor::callback - { - id_state& state; - unsigned count; - - number_placeholders_callback(id_state& state) - : state(state), - count(0) - {} - - void id_value(boost::string_ref value) - { - id_placeholder* p = state.get_placeholder(value); - number(p); - } - - void number(id_placeholder* p) - { - if (p && !p->order) { - number(p->parent); - p->order = ++count; - } - } - }; - - placeholder_index index_placeholders( - id_state& state, - boost::string_ref xml) - { - xml_processor processor; - number_placeholders_callback callback(state); - processor.parse(xml, callback); - - placeholder_index sorted_placeholders; - sorted_placeholders.reserve(state.placeholders.size()); - BOOST_FOREACH(id_placeholder& p, state.placeholders) - if (p.order) sorted_placeholders.push_back(&p); - boost::sort(sorted_placeholders, placeholder_compare()); - - return sorted_placeholders; - } - - // - // resolve_id - // - // Convert child ids to full ids, and add to the - // allocated ids (although not yet set in stone because - // there might be duplicates). - // - // Note that the parent ids has to be generated before resolving - // the child id. - // - - void resolve_id(id_placeholder& p, allocated_ids& ids) - { - if (p.generation_state == id_placeholder::child) - { - assert(p.check_state()); - - assert(p.parent->check_state(id_placeholder::generated)); - - p.id = p.parent->id + "." + p.id; - p.generation_state = id_placeholder::unresolved; - p.parent = 0; - } - - assert(p.check_state(id_placeholder::unresolved)); - - id_data& data = ids.emplace(p.id, id_data()).first->second; - data.update_category(p.category); - - p.data = &data; - p.generation_state = id_placeholder::resolved; - } - - // - // generate_id - // - // Finally generate the final id. - // - - void register_generation_data(id_placeholder&, allocated_ids&); - - void generate_id(id_placeholder& p, allocated_ids& ids) - { - assert(p.check_state(id_placeholder::resolved)); - - // If the placeholder id is available, then update data - // and return. - if (p.category == p.data->category && !p.data->used && - p.category.c != id_category::numbered) - { - p.data->used = true; - p.generation_state = id_placeholder::generated; - p.data = 0; - return; - } - - if (!p.data->generation_data) - { - p.data->generation_data = - boost::make_shared(p.id); - register_generation_data(p, ids); - } - - // Loop until an available id is found. - for(;;) - { - id_generation_data& generation_data = *p.data->generation_data; - - std::string postfix = - boost::lexical_cast(generation_data.count++); - - if (generation_data.child_length() + postfix.length() > max_size) { - // The resulting id is too long, so move to a shorter id. - generation_data.reduce_id(); - register_generation_data(p, ids); - } - else { - std::string id = generation_data.id + postfix; - - if (ids.find(id) == ids.end()) { - p.id.swap(id); - p.generation_state = id_placeholder::generated; - p.data = 0; - return; - } - } - } - } - - // Every time the generation id is changed, this is called to - // check if that id is already in use. - void register_generation_data(id_placeholder& p, allocated_ids& ids) - { - std::string const& id = p.data->generation_data->id; - - id_data& new_data = ids.emplace(id, id_data()).first->second; - - // If there is already generation_data for the new id then use that. - // Otherwise use the placeholder's existing generation_data. - if (new_data.generation_data) - p.data->generation_data = new_data.generation_data; - else - new_data.generation_data = p.data->generation_data; - } - - // - // replace_ids - // - // Return a copy of the xml with all the placeholders replaced by - // generated_ids. - // - - struct replace_ids_callback : xml_processor::callback - { - id_state& state; - bool use_resolved_ids; - boost::string_ref::const_iterator source_pos; - std::string result; - - replace_ids_callback(id_state& state, bool resolved) - : state(state), - use_resolved_ids(resolved), - source_pos(), - result() - {} - - void start(boost::string_ref xml) - { - source_pos = xml.begin(); - } - - void id_value(boost::string_ref value) - { - if (id_placeholder* p = state.get_placeholder(value)) - { - assert(!use_resolved_ids || - p->check_state(id_placeholder::generated)); - boost::string_ref id = use_resolved_ids ? - p->id : p->unresolved_id; - - result.append(source_pos, value.begin()); - result.append(id.begin(), id.end()); - source_pos = value.end(); - } - } - - void finish(boost::string_ref xml) - { - result.append(source_pos, xml.end()); - source_pos = xml.end(); - } - }; - - std::string replace_ids(id_state& state, boost::string_ref xml, - bool use_unresolved_ids) - { - xml_processor processor; - replace_ids_callback callback(state, use_unresolved_ids); - processor.parse(xml, callback); - return callback.result; + current_file->document->current_section = + current_file->document->current_section->parent; } } diff --git a/src/id_manager.hpp b/src/id_manager.hpp index 9410d23..7548846 100644 --- a/src/id_manager.hpp +++ b/src/id_manager.hpp @@ -45,7 +45,6 @@ namespace quickbook }; struct id_state; - struct section_manager; struct id_manager { diff --git a/src/id_manager_impl.hpp b/src/id_manager_impl.hpp new file mode 100644 index 0000000..d26de52 --- /dev/null +++ b/src/id_manager_impl.hpp @@ -0,0 +1,144 @@ +/*============================================================================= + Copyright (c) 2011-2013 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#if !defined(BOOST_QUICKBOOK_ID_MANAGER_IMPL_HPP) +#define BOOST_QUICKBOOK_ID_MANAGER_IMPL_HPP + +#include "id_manager.hpp" +#include "utils.hpp" +#include +#include +#include +#include +#include + +namespace quickbook +{ + // + // id_placeholder + // + // When generating the xml, quickbook can't allocate the identifiers until + // the end, so it stores in the intermedia xml a placeholder string, + // e.g. id="$1". This represents one of these placeholders. + // + + struct id_placeholder + { + unsigned index; // The index in id_state::placeholders. + // Use for the dollar identifiers in + // intermediate xml. + std::string unresolved_id; + // The id that would be generated + // without any duplicate handling. + // Used for generating old style header anchors. + std::string id; // The node id. + id_placeholder const* parent; + // Placeholder of the parent id. + id_category category; + unsigned num_dots; // Number of dots in the id. + // Normally equal to the section level + // but not when an explicit id contains + // dots. + + id_placeholder(unsigned index, boost::string_ref id, + id_category category, id_placeholder const* parent_); + + std::string to_string() const; + }; + + // + // id_state + // + // Contains all the data tracked by the id_manager. + // + + struct file_info; + struct doc_info; + struct section_info; + + struct id_state + { + boost::shared_ptr current_file; + std::deque placeholders; + + // Placeholder methods + + id_placeholder const* add_placeholder(boost::string_ref, id_category, + id_placeholder const* parent = 0); + + id_placeholder const* get_placeholder(boost::string_ref) const; + + id_placeholder const* get_id_placeholder( + boost::shared_ptr const& section) const; + + // Events + + id_placeholder const* start_file( + unsigned compatibility_version, + bool document_root, + boost::string_ref include_doc_id, + boost::string_ref id, + value const& title); + + void end_file(); + + id_placeholder const* add_id( + boost::string_ref id, + id_category category); + id_placeholder const* old_style_id( + boost::string_ref id, + id_category category); + id_placeholder const* begin_section( + boost::string_ref id, + id_category category); + void end_section(); + + private: + id_placeholder const* add_id_to_section( + boost::string_ref id, + id_category category, + boost::shared_ptr const& section); + id_placeholder const* create_new_section( + boost::string_ref id, + id_category category); + }; + + std::string replace_ids(id_state const& state, boost::string_ref xml, + std::vector const* = 0); + std::vector generate_ids(id_state const&, boost::string_ref); + + std::string normalize_id(boost::string_ref src_id); + std::string normalize_id(boost::string_ref src_id, std::size_t); + + // + // Xml subset parser used for finding id values. + // + // I originally tried to integrate this into the post processor + // but that proved tricky. Alternatively it could use a proper + // xml parser, but I want this to be able to survive badly + // marked up escapes. + // + + struct xml_processor + { + xml_processor(); + + std::vector id_attributes; + + struct callback { + virtual void start(boost::string_ref) {} + virtual void id_value(boost::string_ref) {} + virtual void finish(boost::string_ref) {} + virtual ~callback() {} + }; + + void parse(boost::string_ref, callback&); + }; +} + +#endif diff --git a/src/id_xml.cpp b/src/id_xml.cpp new file mode 100644 index 0000000..1832436 --- /dev/null +++ b/src/id_xml.cpp @@ -0,0 +1,153 @@ +/*============================================================================= + Copyright (c) 2011-2013 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include "id_manager_impl.hpp" +#include "utils.hpp" +#include + +namespace quickbook +{ + namespace + { + char const* id_attributes_[] = + { + "id", + "linkend", + "linkends", + "arearefs" + }; + } + + xml_processor::xml_processor() + { + static int const n_id_attributes = sizeof(id_attributes_)/sizeof(char const*); + for (int i = 0; i != n_id_attributes; ++i) + { + id_attributes.push_back(id_attributes_[i]); + } + + boost::sort(id_attributes); + } + + template + bool read(Iterator& it, Iterator end, char const* text) + { + for(Iterator it2 = it;; ++it2, ++text) { + if (!*text) { + it = it2; + return true; + } + + if (it2 == end || *it2 != *text) + return false; + } + } + + template + void read_past(Iterator& it, Iterator end, char const* text) + { + while (it != end && !read(it, end, text)) ++it; + } + + bool find_char(char const* text, char c) + { + for(;*text; ++text) + if (c == *text) return true; + return false; + } + + template + void read_some_of(Iterator& it, Iterator end, char const* text) + { + while(it != end && find_char(text, *it)) ++it; + } + + template + void read_to_one_of(Iterator& it, Iterator end, char const* text) + { + while(it != end && !find_char(text, *it)) ++it; + } + + void xml_processor::parse(boost::string_ref source, callback& c) + { + typedef boost::string_ref::const_iterator iterator; + + c.start(source); + + iterator it = source.begin(), end = source.end(); + + for(;;) + { + read_past(it, end, "<"); + if (it == end) break; + + if (read(it, end, "!--quickbook-escape-prefix-->")) + { + read_past(it, end, ""); + continue; + } + + switch(*it) + { + case '?': + ++it; + read_past(it, end, "?>"); + break; + + case '!': + if (read(it, end, "!--")) + read_past(it, end, "-->"); + else + read_past(it, end, ">"); + break; + + default: + if ((*it >= 'a' && *it <= 'z') || + (*it >= 'A' && *it <= 'Z') || + *it == '_' || *it == ':') + { + read_to_one_of(it, end, " \t\n\r>"); + + for (;;) { + read_some_of(it, end, " \t\n\r"); + iterator name_start = it; + read_to_one_of(it, end, "= \t\n\r>"); + if (it == end || *it == '>') break; + boost::string_ref name(name_start, it - name_start); + ++it; + + read_some_of(it, end, "= \t\n\r"); + if (it == end || (*it != '"' && *it != '\'')) break; + + char delim = *it; + ++it; + + iterator value_start = it; + + it = std::find(it, end, delim); + if (it == end) break; + boost::string_ref value(value_start, it - value_start); + ++it; + + if (boost::find(id_attributes, detail::to_s(name)) + != id_attributes.end()) + { + c.id_value(value); + } + } + } + else + { + read_past(it, end, ">"); + } + } + } + + c.finish(source); + } +} diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index 0d76d01..da0fd63 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -33,8 +33,15 @@ namespace quickbook namespace cl = boost::spirit::classic; struct list_stack_item { - bool root; // Is this the root of the context - // (e.g. top, template, table cell etc.) + // Is this the root of the context + // (e.g. top, template, table cell etc.) + enum list_item_type { + syntactic_list, // In a list marked up '*' or '#' + top_level, // At the top level of a parse + // (might be a template body) + nested_block // Nested in a block element. + } type; + unsigned int indent; // Indent of list marker // (or paragraph if not in a list) unsigned int indent2; // Indent of paragraph @@ -46,11 +53,11 @@ namespace quickbook // * List item // |indent2 - list_stack_item() : - root(true), indent(0), indent2(0), mark('\0') {} + list_stack_item(list_item_type r) : + type(r), indent(0), indent2(0), mark('\0') {} list_stack_item(char mark, unsigned int indent, unsigned int indent2) : - root(false), indent(indent), indent2(indent2), mark(mark) + type(syntactic_list), indent(indent), indent2(indent2), mark(mark) {} }; @@ -82,6 +89,7 @@ namespace quickbook // Local actions void start_blocks_impl(parse_iterator first, parse_iterator last); + void start_nested_blocks_impl(parse_iterator first, parse_iterator last); void end_blocks_impl(parse_iterator first, parse_iterator last); void check_indentation_impl(parse_iterator first, parse_iterator last); void check_code_block_impl(parse_iterator first, parse_iterator last); @@ -94,8 +102,8 @@ namespace quickbook // Local members cl::rule - top_level, indent_check, - paragraph_separator, + template_phrase, top_level, indent_check, + paragraph_separator, inside_paragraph, code, code_line, blank_line, hr, inline_code, skip_inline_code, template_, @@ -112,36 +120,27 @@ namespace quickbook skip_escape ; - struct simple_markup_closure - : cl::closure + struct block_context_closure : cl::closure { - member1 mark; + member1 is_block; }; - struct block_item_closure : cl::closure - { - member1 still_in_block; - }; + cl::rule simple_markup, simple_markup_end; - struct context_closure : cl::closure - { - member1 context; - }; - - cl::rule simple_markup; - cl::rule simple_markup_end; - - cl::rule paragraph; - cl::rule paragraph_item; - cl::rule list; - cl::rule list_item; - cl::rule common; - cl::rule element; + cl::rule paragraph; + cl::rule list; + cl::rule syntactic_block_item; + cl::rule common; + cl::rule element; // state std::stack list_stack; unsigned int list_indent; bool no_eols; + element_info::context context; + char mark; // Simple markup's deliminator + bool still_in_block; // Inside a syntatic block // transitory state block_types::values block_type; @@ -158,31 +157,36 @@ namespace quickbook : list_stack() , list_indent(0) , no_eols(true) + , context(element_info::in_top_level) + , mark('\0') , state_(state) {} }; struct process_element_impl : scoped_action_base { process_element_impl(main_grammar_local& l) - : l(l) {} + : l(l), element_context_error_(false) {} bool start() { - if (!(l.info.type & l.element.context()) || - qbk_version_n < l.info.qbk_version) + // This element doesn't exist in the current language version. + if (qbk_version_n < l.info.qbk_version) return false; + // The element is not allowed in this context. + if (!(l.info.type & l.context)) + { + if (qbk_version_n < 107u) { + return false; + } + else { + element_context_error_ = true; + } + } + info_ = l.info; - if (!l.list_stack.empty() && !l.list_stack.top().root && - info_.type == element_info::block) - { - // If in a list and the element is a block, end the list. - list_item_action list_item(l.state_); - list_item(); - l.clear_stack(); - } - else if (info_.type != element_info::phrase && + if (info_.type != element_info::phrase && info_.type != element_info::maybe_block) { paragraph_action para(l.state_); @@ -205,12 +209,27 @@ namespace quickbook template bool result(ResultT result, ScannerT const& scan) { - if (result || info_.type & element_info::in_phrase) - return result; - - error_action error(l.state_); - error(scan.first, scan.first); - return true; + if (element_context_error_) { + error_message_action error(l.state_, + "Element not allowed in this context."); + error(scan.first, scan.first); + return true; + } + else if (result) { + return true; + } + else if (qbk_version_n < 107u && + info_.type & element_info::in_phrase) { + // Old versions of quickbook had a soft fail + // for unparsed phrase elements. + return false; + } + else { + // Parse error in body. + error_action error(l.state_); + error(scan.first, scan.first); + return true; + } } void success(parse_iterator, parse_iterator) { l.element_type = info_.type; } @@ -224,26 +243,7 @@ namespace quickbook main_grammar_local& l; element_info info_; std::string saved_source_mode_; - }; - - struct set_no_eols_scoped : scoped_action_base - { - set_no_eols_scoped(main_grammar_local& l) - : l(l) {} - - bool start() { - saved_no_eols = l.no_eols; - l.no_eols = false; - - return true; - } - - void cleanup() { - l.no_eols = saved_no_eols; - } - - main_grammar_local& l; - bool saved_no_eols; + bool element_context_error_; }; struct in_list_impl { @@ -253,10 +253,44 @@ namespace quickbook l(l) {} bool operator()() const { - return !l.list_stack.top().root; + return !l.list_stack.empty() && + l.list_stack.top().type == list_stack_item::syntactic_list; } }; + template + struct set_scoped_value_impl : scoped_action_base + { + typedef M T::*member_ptr; + + set_scoped_value_impl(T& l, member_ptr ptr) + : l(l), ptr(ptr), saved_value() {} + + bool start(M const& value) { + saved_value = l.*ptr; + l.*ptr = value; + + return true; + } + + void cleanup() { + l.*ptr = saved_value; + } + + T& l; + member_ptr ptr; + M saved_value; + }; + + template + struct set_scoped_value : scoped_parser > + { + typedef set_scoped_value_impl impl; + + set_scoped_value(T& l, typename impl::member_ptr ptr) : + scoped_parser(impl(l, ptr)) {} + }; + //////////////////////////////////////////////////////////////////////////// // Local grammar @@ -266,19 +300,18 @@ namespace quickbook new main_grammar_local(state)); // Global Actions - element_action element(state); - paragraph_action paragraph(state); - list_item_action list_item(state); + quickbook::element_action element_action(state); + quickbook::paragraph_action paragraph_action(state); phrase_end_action end_phrase(state); - raw_char_action raw_char(state.phrase); - plain_char_action plain_char(state.phrase, state); - escape_unicode_action escape_unicode(state.phrase, state); + raw_char_action raw_char(state); + plain_char_action plain_char(state); + escape_unicode_action escape_unicode(state); - simple_phrase_action simple_markup(state.phrase, state); + simple_phrase_action simple_markup(state); - break_action break_(state.phrase, state); - do_macro_action do_macro(state.phrase, state); + break_action break_(state); + do_macro_action do_macro(state); error_action error(state); element_id_warning_action element_id_warning(state); @@ -287,14 +320,23 @@ namespace quickbook // Local Actions scoped_parser process_element(local); - scoped_parser scoped_no_eols(local); in_list_impl in_list(local); + + set_scoped_value scoped_no_eols( + local, &main_grammar_local::no_eols); + set_scoped_value scoped_context( + local, &main_grammar_local::context); + set_scoped_value scoped_still_in_block( + local, &main_grammar_local::still_in_block); + member_action check_indentation(local, &main_grammar_local::check_indentation_impl); member_action check_code_block(local, &main_grammar_local::check_code_block_impl); member_action start_blocks(local, &main_grammar_local::start_blocks_impl); + member_action start_nested_blocks(local, + &main_grammar_local::start_nested_blocks_impl); member_action end_blocks(local, &main_grammar_local::end_blocks_impl); @@ -309,9 +351,9 @@ namespace quickbook // brackets. nested_phrase = state.values.save() - [ *( ~cl::eps_p(']') - >> local.common(element_info::in_phrase) - ) + [ + scoped_context(element_info::in_phrase) + [*(~cl::eps_p(']') >> local.common)] ] ; @@ -319,9 +361,9 @@ namespace quickbook // by a paragraph end. paragraph_phrase = state.values.save() - [ *( ~cl::eps_p(phrase_end) - >> local.common(element_info::in_phrase) - ) + [ + scoped_context(element_info::in_phrase) + [*(~cl::eps_p(phrase_end) >> local.common)] ] ; @@ -329,9 +371,9 @@ namespace quickbook // elements. extended_phrase = state.values.save() - [ *( ~cl::eps_p(phrase_end) - >> local.common(element_info::in_conditional) - ) + [ + scoped_context(element_info::in_conditional) + [*(~cl::eps_p(phrase_end) >> local.common)] ] ; @@ -341,28 +383,65 @@ namespace quickbook // is part of the paragraph that contains it. inline_phrase = state.values.save() - [ *local.common(element_info::in_phrase) + [ qbk_ver(107u) + >> local.template_phrase + | qbk_ver(0, 107u) + >> scoped_context(element_info::in_phrase) + [*local.common] ] ; table_title_phrase = state.values.save() - [ *( ~cl::eps_p(space >> (']' | '[' >> space >> '[')) - >> local.common(element_info::in_phrase) - ) + [ + scoped_context(element_info::in_phrase) + [ *( ~cl::eps_p(space >> (']' | '[' >> space >> '[')) + >> local.common + ) + ] ] ; inside_preformatted = - scoped_no_eols() + scoped_no_eols(false) [ paragraph_phrase ] ; + // Phrase templates can contain block tags, but can't contain + // syntatic blocks. + local.template_phrase = + scoped_context(element_info::in_top_level) + [ *( (local.paragraph_separator >> space >> cl::anychar_p) + [error("Paragraph in phrase template.")] + | local.common + ) + ] + ; + // Top level blocks block_start = - (*eol) [start_blocks] - >> (*local.top_level) [end_blocks] + (*eol) [start_blocks] + >> ( *( local.top_level + >> !( qbk_ver(106u) + >> cl::ch_p(']') + >> cl::eps_p [error("Mismatched close bracket")] + ) + ) + ) [end_blocks] + ; + + // Blocks contains within an element, e.g. a table cell or a footnote. + inside_paragraph = + state.values.save() + [ cl::eps_p [start_nested_blocks] + >> ( qbk_ver(107u) + >> (*eol) + >> (*local.top_level) + | qbk_ver(0, 107u) + >> local.inside_paragraph + ) [end_blocks] + ] ; local.top_level = @@ -387,40 +466,49 @@ namespace quickbook ; local.paragraph = - cl::eps_p [local.paragraph.still_in_block = true] - >> local.paragraph_item(element_info::only_contextual_block) - >> *( cl::eps_p(local.paragraph.still_in_block) - >> local.paragraph_item(element_info::only_block) - ) - >> cl::eps_p [paragraph] - ; - - local.paragraph_item = - local.element(local.paragraph_item.context) - >> !eol [local.paragraph.still_in_block = false] - | local.paragraph_separator [local.paragraph.still_in_block = false] - | local.common(element_info::in_phrase) + // Usually superfluous call + // for paragraphs in lists. + cl::eps_p [paragraph_action] + >> scoped_context(element_info::in_top_level) + [ scoped_still_in_block(true) + [ local.syntactic_block_item(element_info::is_contextual_block) + >> *( cl::eps_p(ph::var(local.still_in_block)) + >> local.syntactic_block_item(element_info::is_block) + ) + ] + ] [paragraph_action] ; local.list = *cl::blank_p >> (cl::ch_p('*') | '#') - >> (*cl::blank_p) [local.list.still_in_block = true] - >> *( cl::eps_p(local.list.still_in_block) - >> ( qbk_ver(107u) >> local.list_item(element_info::only_block) - | qbk_ver(0, 107u) >> local.list_item(element_info::only_list_block) - ) - ) - // TODO: This is sometimes called in the wrong place. Currently - // harmless. - >> cl::eps_p [list_item] + >> (*cl::blank_p) + >> scoped_context(element_info::in_list_block) + [ scoped_still_in_block(true) + [ *( cl::eps_p(ph::var(local.still_in_block)) + >> local.syntactic_block_item(element_info::is_block) + ) + ] + ] ; - local.list_item = - local.element(local.list_item.context) - >> !(qbk_ver(0, 106u) >> eol) [local.list.still_in_block = false] - | local.paragraph_separator [local.list.still_in_block = false] - | local.common(element_info::in_phrase) + local.syntactic_block_item = + local.paragraph_separator [ph::var(local.still_in_block) = false] + | (cl::eps_p(~cl::ch_p(']')) | qbk_ver(0, 107u)) + [ph::var(local.element_type) = element_info::nothing] + >> local.common + // If the element is a block, then a newline will end the + // current syntactic block. + // Note that we don't do this for lists in 1.6 to avoid messing + // up on nested block elements. + >> !( cl::eps_p(in_list) >> qbk_ver(106u) + | cl::eps_p + ( + ph::static_cast_(local.syntactic_block_item.is_block) & + ph::static_cast_(ph::var(local.element_type)) + ) + >> eol [ph::var(local.still_in_block) = false] + ) ; local.paragraph_separator = @@ -436,13 +524,13 @@ namespace quickbook ; // Blocks contains within an element, e.g. a table cell or a footnote. - inside_paragraph = - state.values.save() - [ *( local.paragraph_separator [paragraph] + local.inside_paragraph = + scoped_context(element_info::in_nested_block) + [ *( local.paragraph_separator [paragraph_action] | ~cl::eps_p(']') - >> local.common(element_info::in_nested_block) + >> local.common ) - ] [paragraph] + ] [paragraph_action] ; local.hr = @@ -454,7 +542,7 @@ namespace quickbook >> *(line_comment | (cl::anychar_p - (cl::eol_p | "[/"))) ) >> *eol - ] [element] + ] [element_action] ; local.element @@ -469,7 +557,7 @@ namespace quickbook [ cl::lazy_p(*ph::var(local.info.rule)) >> space >> ']' - ] [element] + ] [element_action] ] ; @@ -478,7 +566,7 @@ namespace quickbook [( local.code_line >> *(*local.blank_line >> local.code_line) ) [state.values.entry(ph::arg1, ph::arg2)] - ] [element] + ] [element_action] >> *eol ; @@ -497,7 +585,7 @@ namespace quickbook local.common = local.macro - | local.element(local.common.context) + | local.element | local.template_ | local.break_ | local.code_block @@ -512,6 +600,8 @@ namespace quickbook skip_entity = '[' + // For escaped templates: + >> !(space >> cl::ch_p('`') >> (cl::alpha_p | '_')) >> *(~cl::eps_p(']') >> skip_entity) >> !cl::ch_p(']') | local.skip_code_block @@ -547,17 +637,31 @@ namespace quickbook ( '[' >> space >> state.values.list(template_tags::template_) - [ !cl::str_p("`") [state.values.entry(ph::arg1, ph::arg2, template_tags::escape)] - >> ( cl::eps_p(cl::punct_p) - >> state.templates.scope [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)] - | state.templates.scope [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)] + [ ( cl::str_p('`') + >> cl::eps_p(cl::punct_p) + >> state.templates.scope + [state.values.entry(ph::arg1, ph::arg2, template_tags::escape)] + [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)] + >> !qbk_ver(106u) + [error("Templates with punctuation names can't be escaped in quickbook 1.6+")] + | cl::str_p('`') + >> state.templates.scope + [state.values.entry(ph::arg1, ph::arg2, template_tags::escape)] + [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)] + + | cl::eps_p(cl::punct_p) + >> state.templates.scope + [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)] + + | state.templates.scope + [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)] >> cl::eps_p(hard_space) ) >> space >> !local.template_args >> ']' ] - ) [element] + ) [element_action] ; local.template_args = @@ -637,7 +741,7 @@ namespace quickbook ) >> cl::eps_p('`') ) [state.values.entry(ph::arg1, ph::arg2)] >> '`' - ] [element] + ] [element_action] ; local.skip_inline_code = @@ -695,7 +799,7 @@ namespace quickbook >> !(*cl::blank_p >> cl::eol_p) ) [state.values.entry(ph::arg1, ph::arg2)] >> (*cl::space_p >> "```") - ] [element] + ] [element_action] | cl::eps_p [error("Unfinished code block")] >> *cl::anychar_p ) @@ -711,18 +815,18 @@ namespace quickbook >> !(*cl::blank_p >> cl::eol_p) ) [state.values.entry(ph::arg1, ph::arg2)] >> (*cl::space_p >> "``") - ] [element] + ] [element_action] | cl::eps_p [error("Unfinished code block")] >> *cl::anychar_p ) ; local.simple_markup = - cl::chset<>("*/_=") [local.simple_markup.mark = ph::arg1] + cl::chset<>("*/_=") [ph::var(local.mark) = ph::arg1] >> cl::eps_p(cl::graph_p) // graph_p must follow first mark >> lookback [ cl::anychar_p // skip back over the markup - >> ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark)) + >> ~cl::eps_p(cl::ch_p(boost::ref(local.mark))) // first mark not be preceeded by // the same character. >> (cl::space_p | cl::punct_p | cl::end_p) @@ -736,15 +840,15 @@ namespace quickbook [ cl::eps_p((state.macro & macro_identifier) >> local.simple_markup_end) >> state.macro [do_macro] - | ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark)) + | ~cl::eps_p(cl::ch_p(boost::ref(local.mark))) >> +( ~cl::eps_p - ( lookback [~cl::f_ch_p(local.simple_markup.mark)] + ( lookback [~cl::ch_p(boost::ref(local.mark))] >> local.simple_markup_end ) >> cl::anychar_p [plain_char] ) ] - >> cl::f_ch_p(local.simple_markup.mark) + >> cl::ch_p(boost::ref(local.mark)) [simple_markup] ] ; @@ -752,8 +856,8 @@ namespace quickbook local.simple_markup_end = ( lookback[cl::graph_p] // final mark must be preceeded by // graph_p - >> cl::f_ch_p(local.simple_markup.mark) - >> ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark)) + >> cl::ch_p(boost::ref(local.mark)) + >> ~cl::eps_p(cl::ch_p(boost::ref(local.mark))) // final mark not be followed by // the same character. >> (cl::space_p | cl::punct_p | cl::end_p) @@ -779,7 +883,7 @@ namespace quickbook [ (*(cl::anychar_p - "'''")) [state.values.entry(ph::arg1, ph::arg2, phrase_tags::escape)] >> ( cl::str_p("'''") | cl::eps_p [error("Unclosed boostbook escape.")] - ) [element] + ) [element_action] ] ; @@ -810,7 +914,7 @@ namespace quickbook >> (*(cl::anychar_p - "'''")) >> ( cl::str_p("'''") | cl::eps_p [error("Unclosed boostbook escape.")] - ) [element] + ) [element_action] ; attribute_value_1_7 = @@ -850,7 +954,7 @@ namespace quickbook >> *cl::space_p ) >> cl::end_p - ] [element] + ] [element_action] ; local.command_line_macro_identifier = @@ -933,7 +1037,21 @@ namespace quickbook void main_grammar_local::start_blocks_impl(parse_iterator, parse_iterator) { - list_stack.push(list_stack_item()); + list_stack.push(list_stack_item(list_stack_item::top_level)); + } + + void main_grammar_local::start_nested_blocks_impl(parse_iterator, parse_iterator) + { + // If this nested block is part of a list, then tell the + // output state. + // + // TODO: This is a bit dodgy, it would be better if this + // was handled when the output state is pushed (currently + // in to_value_scoped_action). + state_.in_list = state_.explicit_list; + state_.explicit_list = false; + + list_stack.push(list_stack_item(list_stack_item::nested_block)); } void main_grammar_local::end_blocks_impl(parse_iterator, parse_iterator) @@ -972,10 +1090,16 @@ namespace quickbook unsigned int new_indent = indent_length(first, last); if (new_indent > list_stack.top().indent2) { - block_type = block_types::code; + if (list_stack.top().type != list_stack_item::nested_block) { + block_type = block_types::code; + } + else { + block_type = block_types::paragraph; + } } else { - while (!list_stack.top().root && new_indent < list_stack.top().indent) + while (list_stack.top().type == list_stack_item::syntactic_list + && new_indent < list_stack.top().indent) { state_.end_list_item(); state_.end_list(list_stack.top().mark); @@ -983,7 +1107,8 @@ namespace quickbook list_indent = list_stack.top().indent; } - if (!list_stack.top().root && new_indent == list_stack.top().indent) + if (list_stack.top().type == list_stack_item::syntactic_list + && new_indent == list_stack.top().indent) { // If the paragraph is aligned with the list item's marker, // then end the current list item if that's aligned (or to @@ -1006,7 +1131,7 @@ namespace quickbook list_stack_item save = list_stack.top(); list_stack.pop(); - assert(list_stack.top().root ? + assert(list_stack.top().type != list_stack_item::syntactic_list ? new_indent >= list_stack.top().indent : new_indent > list_stack.top().indent); @@ -1023,7 +1148,8 @@ namespace quickbook block_type = block_types::paragraph; } - if (qbk_version_n == 106u && !list_stack.top().root) { + if (qbk_version_n == 106u && + list_stack.top().type == list_stack_item::syntactic_list) { detail::outerr(state_.current_file, first) << "Nested blocks in lists won't be supported in " << "quickbook 1.6" @@ -1034,10 +1160,11 @@ namespace quickbook else { clear_stack(); - if (last == first) - block_type = block_types::paragraph; - else + if (list_stack.top().type != list_stack_item::nested_block && + last != first) block_type = block_types::code; + else + block_type = block_types::paragraph; } } @@ -1048,12 +1175,14 @@ namespace quickbook unsigned int new_indent2 = indent_length(first, last); char mark = *mark_pos; - if (list_stack.top().root && new_indent > 0) { + if (list_stack.top().type == list_stack_item::top_level && + new_indent > 0) { block_type = block_types::code; return; } - if (list_stack.top().root || new_indent > list_indent) { + if (list_stack.top().type != list_stack_item::syntactic_list || + new_indent > list_indent) { list_stack.push(list_stack_item(mark, new_indent, new_indent2)); state_.start_list(mark); } @@ -1063,7 +1192,8 @@ namespace quickbook else { // This should never reach root, since the first list // has indentation 0. - while(!list_stack.top().root && new_indent < list_stack.top().indent) + while(list_stack.top().type == list_stack_item::syntactic_list && + new_indent < list_stack.top().indent) { state_.end_list_item(); state_.end_list(list_stack.top().mark); @@ -1090,7 +1220,7 @@ namespace quickbook void main_grammar_local::clear_stack() { - while (!list_stack.top().root) { + while (list_stack.top().type == list_stack_item::syntactic_list) { state_.end_list_item(); state_.end_list(list_stack.top().mark); list_stack.pop(); diff --git a/src/markups.cpp b/src/markups.cpp index 5588484..f077943 100644 --- a/src/markups.cpp +++ b/src/markups.cpp @@ -26,6 +26,7 @@ namespace quickbook { markup init_markups[] = { { block_tags::paragraph, "\n", "\n" }, + { block_tags::paragraph_in_list, "\n", "\n" }, { block_tags::blurb, "\n", "\n" }, { block_tags::blockquote, "
", "
" }, { block_tags::preformatted, "", "" }, diff --git a/src/phrase_element_grammar.cpp b/src/phrase_element_grammar.cpp index b287d63..c218be0 100644 --- a/src/phrase_element_grammar.cpp +++ b/src/phrase_element_grammar.cpp @@ -38,7 +38,7 @@ namespace quickbook new phrase_element_grammar_local); error_action error(state); - raw_char_action raw_char(state.phrase); + raw_char_action raw_char(state); scoped_parser scoped_cond_phrase(state); scoped_parser to_value(state); diff --git a/src/quickbook.cpp b/src/quickbook.cpp index ca9fa2a..e3c7718 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -99,7 +99,7 @@ namespace quickbook parse_iterator pos = info.stop; std::string doc_type = pre(state, pos, include_doc_id, nested_file); - info = cl::parse(info.hit ? info.stop : first, last, state.grammar().block); + info = cl::parse(info.hit ? info.stop : first, last, state.grammar().block_start); post(state, doc_type); diff --git a/src/state.cpp b/src/state.cpp index 9f2168a..fa3d92a 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -39,6 +39,8 @@ namespace quickbook , ids(ids) , callouts() , callout_depth(0) + , dependencies() + , explicit_list(false) , imported(false) , macro() @@ -50,8 +52,11 @@ namespace quickbook , template_depth(0) , min_section_level(1) + , in_list(false) + , in_list_save() , out(out_) , phrase() + , values(¤t_file) { // add the predefined macros @@ -69,8 +74,21 @@ namespace quickbook quickbook_grammar& state::grammar() const { return *grammar_; } + + void state::push_output() { + out.push(); + phrase.push(); + in_list_save.push(in_list); + } - file_state::file_state(quickbook::state& state, scope_flags scope) + void state::pop_output() { + phrase.pop(); + out.pop(); + in_list = in_list_save.top(); + in_list_save.pop(); + } + + state_save::state_save(quickbook::state& state, scope_flags scope) : state(state) , scope(scope) , qbk_version(qbk_version_n) @@ -80,17 +98,18 @@ namespace quickbook , xinclude_base(state.xinclude_base) , source_mode(state.source_mode) , macro() + , template_depth(state.template_depth) + , min_section_level(state.min_section_level) { if (scope & scope_macros) macro = state.macro; if (scope & scope_templates) state.templates.push(); if (scope & scope_output) { - state.out.push(); - state.phrase.push(); + state.push_output(); } state.values.builder.save(); } - file_state::~file_state() + state_save::~state_save() { state.values.builder.restore(); boost::swap(qbk_version_n, qbk_version); @@ -100,22 +119,10 @@ namespace quickbook boost::swap(state.xinclude_base, xinclude_base); boost::swap(state.source_mode, source_mode); if (scope & scope_output) { - state.out.pop(); - state.phrase.pop(); + state.pop_output(); } if (scope & scope_templates) state.templates.pop(); if (scope & scope_macros) state.macro = macro; - } - - template_state::template_state(quickbook::state& state) - : file_state(state, file_state::scope_all) - , template_depth(state.template_depth) - , min_section_level(state.min_section_level) - { - } - - template_state::~template_state() - { boost::swap(state.template_depth, template_depth); boost::swap(state.min_section_level, min_section_level); } diff --git a/src/state.hpp b/src/state.hpp index 8d5f389..67d2431 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -52,6 +52,7 @@ namespace quickbook value_builder callouts; // callouts are global as int callout_depth; // they don't nest. dependency_tracker dependencies; + bool explicit_list; // set when using a list // state saved for files and templates. bool imported; @@ -68,8 +69,13 @@ namespace quickbook int min_section_level; // output state - scoped by templates and grammar + bool in_list; // generating a list + std::stack in_list_save; // save the in_list state + // TODO: Something better... collector out; // main output stream collector phrase; // phrase output stream + + // values state - scoped by everything. value_parser values; // parsed values quickbook_grammar& grammar() const; @@ -78,6 +84,9 @@ namespace quickbook // actions /////////////////////////////////////////////////////////////////////////// + void push_output(); + void pop_output(); + void start_list(char mark); void end_list(char mark); void start_list_item(); diff --git a/src/state_save.hpp b/src/state_save.hpp index f8b53e7..4d94cc6 100644 --- a/src/state_save.hpp +++ b/src/state_save.hpp @@ -18,7 +18,7 @@ namespace quickbook // // Defined in state.cpp - struct file_state + struct state_save { enum scope_flags { scope_none = 0, @@ -29,8 +29,8 @@ namespace quickbook scope_all = scope_callables + scope_output }; - explicit file_state(quickbook::state&, scope_flags); - ~file_state(); + explicit state_save(quickbook::state&, scope_flags); + ~state_save(); quickbook::state& state; scope_flags scope; @@ -42,18 +42,11 @@ namespace quickbook fs::path xinclude_base; std::string source_mode; string_symbols macro; - private: - file_state(file_state const&); - file_state& operator=(file_state const&); - }; - - struct template_state : file_state - { - explicit template_state(quickbook::state&); - ~template_state(); - int template_depth; int min_section_level; + private: + state_save(state_save const&); + state_save& operator=(state_save const&); }; } diff --git a/src/syntax_highlight.cpp b/src/syntax_highlight.cpp index fdeaef5..4f0208e 100644 --- a/src/syntax_highlight.cpp +++ b/src/syntax_highlight.cpp @@ -87,7 +87,6 @@ namespace quickbook struct syntax_highlight_actions { - quickbook::collector out; quickbook::state& state; do_macro_action do_macro_impl; @@ -96,8 +95,8 @@ namespace quickbook boost::string_ref marked_text; syntax_highlight_actions(quickbook::state& state, bool is_block) : - out(), state(state), - do_macro_impl(out, state), + state(state), + do_macro_impl(state), support_callouts(is_block && (qbk_version_n >= 107u || state.current_file->is_code_snippets)), marked_text() @@ -119,26 +118,26 @@ namespace quickbook void syntax_highlight_actions::span(parse_iterator first, parse_iterator last, char const* name) { - out << ""; + state.phrase << ""; while (first != last) - detail::print_char(*first++, out.get()); - out << ""; + detail::print_char(*first++, state.phrase.get()); + state.phrase << ""; } void syntax_highlight_actions::span_start(parse_iterator first, parse_iterator last, char const* name) { - out << ""; + state.phrase << ""; while (first != last) - detail::print_char(*first++, out.get()); + detail::print_char(*first++, state.phrase.get()); } void syntax_highlight_actions::span_end(parse_iterator first, parse_iterator last) { while (first != last) - detail::print_char(*first++, out.get()); - out << ""; + detail::print_char(*first++, state.phrase.get()); + state.phrase << ""; } void syntax_highlight_actions::unexpected_char(parse_iterator first, @@ -152,30 +151,32 @@ namespace quickbook << "\n"; // print out an unexpected character - out << ""; + state.phrase << ""; while (first != last) - detail::print_char(*first++, out.get()); - out << ""; + detail::print_char(*first++, state.phrase.get()); + state.phrase << ""; } void syntax_highlight_actions::plain_char(parse_iterator first, parse_iterator last) { while (first != last) - detail::print_char(*first++, out.get()); + detail::print_char(*first++, state.phrase.get()); } void syntax_highlight_actions::pre_escape_back(parse_iterator, parse_iterator) { - state.phrase.push(); // save the stream + state.push_output(); // save the stream } void syntax_highlight_actions::post_escape_back(parse_iterator, parse_iterator) { - out << state.phrase.str(); - state.phrase.pop(); // restore the stream + std::string tmp; + state.phrase.swap(tmp); + state.pop_output(); // restore the stream + state.phrase << tmp; } void syntax_highlight_actions::do_macro(std::string const& v) @@ -191,7 +192,7 @@ namespace quickbook void syntax_highlight_actions::callout(parse_iterator, parse_iterator) { - out << state.add_callout(qbk_value(state.current_file, + state.phrase << state.add_callout(qbk_value(state.current_file, marked_text.begin(), marked_text.end())); marked_text.clear(); } @@ -318,7 +319,7 @@ namespace quickbook ( ( (+(cl::anychar_p - "``") >> cl::eps_p("``")) - & g.phrase + & g.phrase_start ) >> cl::str_p("``") ) @@ -473,7 +474,7 @@ namespace quickbook ( ( (+(cl::anychar_p - "``") >> cl::eps_p("``")) - & g.phrase + & g.phrase_start ) >> cl::str_p("``") ) @@ -595,7 +596,7 @@ namespace quickbook ( ( (+(cl::anychar_p - "``") >> cl::eps_p("``")) - & g.phrase + & g.phrase_start ) >> cl::str_p("``") ) @@ -619,7 +620,7 @@ namespace quickbook syntax_highlight_actions& actions; }; - std::string syntax_highlight( + void syntax_highlight( parse_iterator first, parse_iterator last, quickbook::state& state, @@ -648,10 +649,5 @@ namespace quickbook { BOOST_ASSERT(0); } - - std::string str; - syn_actions.out.swap(str); - - return str; } } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7544f69..aef18f8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -68,21 +68,26 @@ test-suite quickbook.test : [ quickbook-test link-1_1 ] [ quickbook-test link-1_6 ] [ quickbook-test link-1_7 ] + [ quickbook-error-test link-1_7-fail ] [ quickbook-test list_test-1_5 ] [ quickbook-test list_test-1_6 ] [ quickbook-error-test list_test-1_6-fail ] [ quickbook-test list_test-1_7 ] + [ quickbook-error-test list_test-1_7-fail1 ] [ quickbook-test macro-1_5 ] [ quickbook-test macro-1_6 ] [ quickbook-error-test mismatched_brackets-1_1-fail ] [ quickbook-test mismatched_brackets1-1_1 ] [ quickbook-test mismatched_brackets2-1_1 ] + [ quickbook-test mismatched_brackets3-1_1 ] [ quickbook-test newline-1_1 ] [ quickbook-test para_test-1_5 ] [ quickbook-error-test post_process-fail ] [ quickbook-test preformatted-1_1 ] [ quickbook-test preformatted-1_6 ] [ quickbook-test role-1_6 ] + [ quickbook-test role-1_7 ] + [ quickbook-error-test role-1_7-fail ] [ quickbook-test section-1_4 ] [ quickbook-test section-1_5-unclosed ] [ quickbook-test section-1_5 ] @@ -92,6 +97,7 @@ test-suite quickbook.test : [ quickbook-test table-1_3 ] [ quickbook-test table-1_5 ] [ quickbook-test table-1_6 ] + [ quickbook-test table-1_7 ] [ quickbook-error-test template_arguments1-1_1-fail ] [ quickbook-error-test template_arguments2-1_1-fail ] [ quickbook-error-test template_arguments3-1_1-fail ] @@ -102,6 +108,10 @@ test-suite quickbook.test : [ quickbook-test templates-1_3 ] [ quickbook-test templates-1_4 ] [ quickbook-test templates-1_5 ] + [ quickbook-test templates-1_6 ] + [ quickbook-error-test templates-1_6-fail1 ] + [ quickbook-test templates-1_7 ] + [ quickbook-error-test templates-1_7-fail1 ] [ quickbook-test unicode_escape-1_5 ] [ quickbook-test unmatched_element-1_5 ] [ quickbook-test unmatched_element-1_6 ] diff --git a/test/elements-1_6.gold b/test/elements-1_6.gold index bc9ee06..59a90af 100644 --- a/test/elements-1_6.gold +++ b/test/elements-1_6.gold @@ -5,28 +5,36 @@ 1.6 Elements - + item1 - + - + item2 - + - + item1 - + - + item2 - + + + + + Check that bold text isn't confused with + a list. + + + A <emphasis role="bold">simplesect</emphasis>! diff --git a/test/elements-1_6.quickbook b/test/elements-1_6.quickbook index 68372d1..e313cd9 100644 --- a/test/elements-1_6.quickbook +++ b/test/elements-1_6.quickbook @@ -8,6 +8,14 @@ [itemized_list [item1][item2]] +[ordered_list + [ + Check that + *bold text* + isn't confused with a list. + ] +] + [block''''''A *simplesect*!''''''] -[block''''''] \ No newline at end of file +[block''''''] diff --git a/test/include/in_section-1_5.gold b/test/include/in_section-1_5.gold index 1dfeaff..3548e2c 100644 --- a/test/include/in_section-1_5.gold +++ b/test/include/in_section-1_5.gold @@ -13,6 +13,11 @@ Test2 + + Simple + include +
Test1 @@ -22,6 +27,11 @@ Test2 + + Simple + include + @@ -32,6 +42,10 @@ Test2 + + Simple + include + Test1 @@ -41,6 +55,10 @@ Test2 + + Simple + include +
<link linkend="include_in_section_1_5.container2">Container2</link> @@ -52,6 +70,11 @@ Test2 + + Simple + include +
Test1 @@ -61,6 +84,11 @@ Test2 + + Simple + include + diff --git a/test/include/in_section-1_6.gold b/test/include/in_section-1_6.gold index 7601df4..3ffa601 100644 --- a/test/include/in_section-1_6.gold +++ b/test/include/in_section-1_6.gold @@ -16,6 +16,10 @@ Test2 + + Simple + include +
Test2 + + Simple + include +
@@ -43,6 +51,10 @@ Test2 + + Simple + include +
Test2 + + Simple + include +
@@ -71,6 +87,10 @@ Test2 + + Simple include +
Test2 + + Simple + include +
diff --git a/test/include/in_section-inc1.quickbook b/test/include/in_section-inc1.quickbook index f8fab4d..f74bf5d 100644 --- a/test/include/in_section-inc1.quickbook +++ b/test/include/in_section-inc1.quickbook @@ -8,4 +8,6 @@ [h1 Test2] -[endsect] \ No newline at end of file +[include include-id-inc1.quickbook] + +[endsect] diff --git a/test/include/in_section-inc2.quickbook b/test/include/in_section-inc2.quickbook index 9d8ee51..0a30aaa 100644 --- a/test/include/in_section-inc2.quickbook +++ b/test/include/in_section-inc2.quickbook @@ -9,4 +9,6 @@ [h1 Test2] -[endsect] \ No newline at end of file +[include include-id-inc1.quickbook] + +[endsect] diff --git a/test/link-1_7-fail.quickbook b/test/link-1_7-fail.quickbook new file mode 100644 index 0000000..9f2db1f --- /dev/null +++ b/test/link-1_7-fail.quickbook @@ -0,0 +1,5 @@ +[article Link fail test +[quickbook 1.7] +] + +[link something [table]] diff --git a/test/list_test-1_6.gold b/test/list_test-1_6.gold index 1721110..b6d3775 100644 --- a/test/list_test-1_6.gold +++ b/test/list_test-1_6.gold @@ -310,29 +310,29 @@ + + + + + + + Heading + + + + + + + + + Cell + + + + + + - - - - - - - Heading - - - - - - - - - Cell - - - - - - Some text. @@ -343,17 +343,17 @@ - - Paragraph cheat 1. - + Paragraph cheat 1. + + Paragraph cheat 2. - - Paragraph cheat 3. - + Paragraph cheat 3. + + Paragraph cheat 4. diff --git a/test/list_test-1_7-fail1.quickbook b/test/list_test-1_7-fail1.quickbook new file mode 100644 index 0000000..c8beed1 --- /dev/null +++ b/test/list_test-1_7-fail1.quickbook @@ -0,0 +1,9 @@ +[article List Fail Test 1 +[quickbook 1.7] +] + +[section List immediately following markup] +* One +* Two +* Three +[endsect] diff --git a/test/list_test-1_7.gold b/test/list_test-1_7.gold index 49fe0cf..dec074c 100644 --- a/test/list_test-1_7.gold +++ b/test/list_test-1_7.gold @@ -310,40 +310,36 @@ - - - - - - - - Heading - - - - - - - - - Cell - - - - - - - + + + + + + + Heading + + + + + + + + + Cell + + + + + + + + The + heading for a list item + - - The - heading for a list item - - - The content of the list item. - + The content of the list item. @@ -406,9 +402,9 @@ A1 - - A2 - + + + A2 @@ -418,15 +414,15 @@ C1 - - C2 - + + + C2 - - B2 - + + + B2 @@ -436,18 +432,18 @@ E1 - - E2 - - - E3 - + + + E2 + + + E3 - - D2 - + + + D2 @@ -459,19 +455,19 @@ A + B - - C - + + C D + E - diff --git a/test/mismatched_brackets3-1_1.gold b/test/mismatched_brackets3-1_1.gold new file mode 100644 index 0000000..a7ab11e --- /dev/null +++ b/test/mismatched_brackets3-1_1.gold @@ -0,0 +1,12 @@ + + +
+ Mismatched brackets +
+ Something +
+ + ] + +
diff --git a/test/mismatched_brackets3-1_1.quickbook b/test/mismatched_brackets3-1_1.quickbook new file mode 100644 index 0000000..dadd426 --- /dev/null +++ b/test/mismatched_brackets3-1_1.quickbook @@ -0,0 +1,6 @@ +[article Mismatched brackets] + +[section Something] + +[endsect] +] diff --git a/test/role-1_7-fail.quickbook b/test/role-1_7-fail.quickbook new file mode 100644 index 0000000..b01d16e --- /dev/null +++ b/test/role-1_7-fail.quickbook @@ -0,0 +1,5 @@ +[article Quickbook Role Fail Test +[quickbook 1.7] +] + +[role] diff --git a/test/role-1_7.gold b/test/role-1_7.gold new file mode 100644 index 0000000..0d6b2b6 --- /dev/null +++ b/test/role-1_7.gold @@ -0,0 +1,9 @@ + + +
+ Quickbook Role Test + + Keyword + +
diff --git a/test/role-1_7.quickbook b/test/role-1_7.quickbook new file mode 100644 index 0000000..ec5fa6b --- /dev/null +++ b/test/role-1_7.quickbook @@ -0,0 +1,5 @@ +[article Quickbook Role Test +[quickbook 1.6] +] + +[role keyword Keyword] [role keyword] diff --git a/test/table-1_7.gold b/test/table-1_7.gold new file mode 100644 index 0000000..14e219e --- /dev/null +++ b/test/table-1_7.gold @@ -0,0 +1,514 @@ + + +
+ Table 1.7 + + Table 1 + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + Table 2 + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + + + + + + Heading + + + + + + + + + cell + + + + + + + + + + + + + Heading + + + + + + + + + cell + + + + + + + + -table5- + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + Title + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + Title + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + Title containing a comment + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + Title + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + + + + + + Heading + + + + + + + + + Cell 1 + + + + + + + Cell 2 + + + + + + + + Title on multiple lines with <emphasis role="bold">bold</emphasis> text? + + + + + + Heading + + + + + + + + + Cell 1 + + + + + + + Cell 2 + + + + + +
+
+ <link linkend="table_tests.section1">Section 1</link> + + Table 1 + + + + + + Heading + + + + + + + + + cell + + + + + +
+ + A & B + + + + + + A + + + + + B + + + + + + + + + a + + + + + b + + + + + +
+ + Empty Table + + + + +
+ + Table with an empty cell + + + + + + x + + + + + +
+ + Indentation + + + + + + Header 1. Paragraph 1 + + + Header 1. Paragraph 2 + + + + + Header 2 + + + + + + + + + Row 1. Cell 1. + + + + + Row 1. Cell 2. + + + Row 1. Cell 2. Paragraph 2. + + + + + + + Row 2. Cell 1. + + + + + Row 2. Cell 1. List item 1. + + + + + Row 2. Cell 1. List item 2. + + + + + + + Row 2. Cell 2. + + + + + Row 2. Cell 2. List item 1. + + + + + Row 2. Cell 2. List item 2. + + + + + + + +
+ + Nested Tables + + + + + + Header 1 + + + + + Header 2 + + + + + + + +
+ Inner Table + + + + + + 1.1 + + + + + 1.2 + + + + + + + + + 2.1 + + + + + 2.2 + + + + + +
+ + + + + + Something. + + + + + + + + + Table with anchors + + + + + + a + + + + + + + + + b + + + + + +
+
+
diff --git a/test/table-1_7.quickbook b/test/table-1_7.quickbook new file mode 100644 index 0000000..4d9d196 --- /dev/null +++ b/test/table-1_7.quickbook @@ -0,0 +1,148 @@ +[article Table 1.7 + [quickbook 1.7] + [id table_tests] +] + +[table:table1 Table 1 [[Heading]][[cell]]] + +[table Table 2 + [[Heading]] + [[cell]] +] + +[table + [[Heading]] + [[cell]] +] + +[table:table4 + [[Heading]] + [[cell]] +] + +[table:-table5- + [[Heading]] + [[cell]] +] + +[table [/ Comment?] Title + [[Heading]] + [[cell]] +] + +[table [/ Multi line +comment] Title + [[Heading]] + [[cell]] +] + +[table Title [/ ] containing a comment + [[Heading]] + [[cell]] +] + +[table [/ Multi line +comment] + Title + [[Heading]] + [[cell]] +] + +[table [/ Multi line +comment] + [[Heading]] + [[Cell 1]] + [[Cell 2]] +] + +[table Title on multiple + lines with *bold* text? + [[Heading]] + [[Cell 1]] + [[Cell 2]] +] + +[section:section1 Section 1] + +[table:table1 Table 1 + [[Heading]] + [[cell]] +] + +[table A & B + [[A][B]] + [[a][b]] +] + +[table Empty Table] + +[table Table with an empty cell +[[x]]] + +[table Indentation + [ + [ + Header 1. Paragraph 1 + + Header 1. Paragraph 2 + ] + [ + Header 2 + ] + ] + [ + [ + Row 1. Cell 1. + ] + [ + Row 1. Cell 2. + + Row 1. Cell 2. Paragraph 2. + ] + ] + [ + [ +Row 2. Cell 1. + +* Row 2. Cell 1. List item 1. +* Row 2. Cell 1. List item 2. + ] + [ + Row 2. Cell 2. + + * Row 2. Cell 2. List item 1. + * Row 2. Cell 2. List item 2. + ] + ] +] + +[table Nested Tables + [ + [ + Header 1 + ] + [ + Header 2 + ] + ] + [ + [ + [table Inner Table + [[1.1][1.2]] + [[2.1][2.2]] + ] + ] + ] + [ + [ + Something. + ] + ] +] + +[#id1] +[table Table with anchors +[[[#id2]a[#id3]]][[b]] +] + +[endsect] diff --git a/test/templates-1_3.gold b/test/templates-1_3.gold index c53fef1..ed3668f 100644 --- a/test/templates-1_3.gold +++ b/test/templates-1_3.gold @@ -167,25 +167,26 @@
- - - + - int main() {} - - - Paragraphs 1 - - - Paragraphs 2 - + Paragraphs 1 + + + Paragraphs 2 +
+ <link linkend="templates.escaped_templates">Escaped templates</link> + + Not real boostbook Also not real boostbook + More fake boostbook Final fake boostbook + +
diff --git a/test/templates-1_3.quickbook b/test/templates-1_3.quickbook index 457cd15..a6d4348 100644 --- a/test/templates-1_3.quickbook +++ b/test/templates-1_3.quickbook @@ -198,3 +198,19 @@ Paragraphs 2 * [paragraphs] [endsect] + +[/----------------------------------- Escaped templates ] + +[section Escaped templates] + +[template raw_markup Not real boostbook] +[template | Also not real boostbook] +[template escaped1 [|] [`|]] +[template escaped2 [x] [`x]] + +[`raw_markup] +[`|] +[escaped1 More fake boostbook] +[escaped2 Final fake boostbook] + +[endsect] diff --git a/test/templates-1_4.gold b/test/templates-1_4.gold index 72e33e0..40c2443 100644 --- a/test/templates-1_4.gold +++ b/test/templates-1_4.gold @@ -18,4 +18,11 @@ {1-2-3} {1-2-3} {1-2-3 4} {1 2-3-4} {[1-2-3} +
+ <link linkend="template_1_4.escaped_templates">Escaped templates</link> + + Not real boostbook Also not real boostbook + More fake boostbook Final fake boostbook + +
diff --git a/test/templates-1_4.quickbook b/test/templates-1_4.quickbook index fc80855..3fb8937 100644 --- a/test/templates-1_4.quickbook +++ b/test/templates-1_4.quickbook @@ -34,4 +34,20 @@ [ternary 1 2 3] [/ {1-2-3} ] [ternary 1..2 3 4] [/ {1-2-3 4} ] [ternary 1 2..3 4] [/ {1 2-3-4} ] -[ternary [1..2..3] [/ {(1-2-3} (but with a square bracket) ] \ No newline at end of file +[ternary [1..2..3] [/ {(1-2-3} (but with a square bracket) ] + +[/----------------------------------- Escaped templates ] + +[section Escaped templates] + +[template raw_markup Not real boostbook] +[template | Also not real boostbook] +[template escaped1 [|] [`|]] +[template escaped2 [x] [`x]] + +[`raw_markup] +[`|] +[escaped1 More fake boostbook] +[escaped2 Final fake boostbook] + +[endsect] diff --git a/test/templates-1_5.gold b/test/templates-1_5.gold index bb05aac..9577f1a 100644 --- a/test/templates-1_5.gold +++ b/test/templates-1_5.gold @@ -3,40 +3,237 @@
Template 1.5 - - static scoping - - - [a] - - - new - - - foo foo - - - {1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {1..2-3} {1..2-3} - - - { {1 2-3}-4} { {1 2-3}-4} { {1-2 3}-4} - - - {[1-2] 3} {[1-2] 3} {[1-2} - - - {1-2-3} {1-2-3} - - - Some text - - - A <emphasis>paragraph</emphasis>. - - - Some *text* A paragraph. - - - Things - +
+ <link linkend="template_1_5.templates">Templates</link> + + nullary_arg + + + foo baz + + + foo baz + + + This is a complete paragraph. kalamazoo kalamazoo kalamazoo kalamazoo kalamazoo + kalamazoo kalamazoo kalamazoo kalamazoo.... blah blah blah...... + + + baz + + + This is a complete paragraph. madagascar madagascar madagascar madagascar madagascar + madagascar madagascar madagascar madagascar.... blah blah blah...... + + + zoom peanut zoom + + + exactly xanadu + + + wx + + + wxyz wxyz trail + +int main() +{ + std::cout << "Hello, World" << std::endl; +} + + + x2 + + + α2 + + + x2 + + + got a banana? + + + .0 00 + + + [fool] + +
+
+ <link linkend="template_1_5.empty_templates">Empty Templates</link> +
+
+ <link linkend="template_1_5.nested_templates">Nested Templates</link> + + Pre + + + Start block template. + + + Start block template. + + + Hello! + + + End block template. + + + End block template. + + + Post + + + Pre + + + Start block template. + + + Start phrase template. Hello! End phrase template. + + + End block template. + + + Post + + + Pre + + + Start phrase template. + + + Start block template. + + + Hello! + + + End block template. + + + End phrase template. + + + Post + + + Pre Start phrase template. Start phrase template. Hello! End phrase template. + End phrase template. Post + +
+
+ <link linkend="template_1_5.block_markup">Block Markup</link> + + + + a + + + + + b + + + + +int main() {} + + Paragraphs 1 + + + Paragraphs 2 + + + + + + + + a + + + + + b + + + + + + + + + +int main() {} + + + + Paragraphs 1 + + + Paragraphs 2 + + + +
+
+ <link linkend="template_1_5.static_scoping">Static Scoping</link> + + static scoping + + + [a] + + + new + + + foo foo + +
+
+ <link linkend="template_1_5.template_arguments">Template Arguments</link> + + {1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {1..2-3} {1..2-3} + + + { {1 2-3}-4} { {1 2-3}-4} { {1-2 3}-4} + + + {[1-2] 3} {[1-2] 3} {[1-2} + + + {1-2-3} {1-2-3} + +
+
+ <link linkend="template_1_5.block_and_phrase_templates">Block and phrase + templates</link> + + Some text + + + A <emphasis>paragraph</emphasis>. + + + Some *text* A paragraph. + + + Things + +
+
+ <link linkend="template_1_5.escaped_templates">Escaped templates</link> + + Not real boostbook Also not real boostbook + More fake boostbook Final fake boostbook + +
diff --git a/test/templates-1_5.quickbook b/test/templates-1_5.quickbook index 038b8b3..55ec031 100644 --- a/test/templates-1_5.quickbook +++ b/test/templates-1_5.quickbook @@ -2,12 +2,211 @@ [quickbook 1.5] ] -[/ 1.5 uses static scoping ] +[section Templates] + +[/-------------------------------- nullary arg ] + +[template foo0 nullary_arg] + +[foo0] + +[/-------------------------------- unary arg, phrase syle ] + +[template foo1[bar] foo [bar]] + +[foo1 baz] + +[/-------------------------------- unary arg, block syle ] + +[template foo2[bar] +foo [bar] +] + +[foo2 baz] + +[template foo3[bar] +This is a complete paragraph. [bar] [bar] [bar] [bar] [bar] +[bar] [bar] [bar] [bar].... blah blah blah...... +] + +[foo3 kalamazoo] + +[/-------------------------------- unary arg, using punctuation ] + +[template ![bar] ''''''[bar]''''''] + +[!baz] + +[/-------------------------------- recursive templates ] + +[template foo4[bar] +[foo3 [bar]] +] + +[foo3 madagascar] + +[template foo5[x] zoom [x]] +[template foo6[x] [x] zoom] + +[foo6[foo5 peanut]] + +[template kinda_weird[x y] [x] [y]] + +[kinda_weird exactly..xanadu] + + +[/-------------------------------- space delimitted args ] + +[template simple1[a b] [a][b]] + +[simple1 w x] + +[template simple2[a b c d] [a][b][c][d]] + +[simple2 w x y z][simple2 w x y z trail] + +[/-------------------------------- John's templates ] + +[template code[x] + int main() + { + std::cout << ``[x]`` << std::endl; + } +] + +[code "Hello\, World"] + +[template alpha '''α'''] +[template pow[a b] [a]''''''[b]'''''' ] +[template super[text]''''''[text]'''''' ] + +[pow x 2] + +[pow [alpha] 2] + +x[super 2] + +[/-------------------------------- Some more ] + +[template banana got a banana?] +[template plantation[bananarama] [bananarama]] + +[plantation [banana]] + +[/-------------------------------- Not a bug (there was a syntax error here) ] + +[template join1[a b] [b][a]] +[template join2[a b] [a][b]] +[template test[x] [join1 [join2 0 [x]]...0]] +[test 0] + +[/-------------------------------- Mismatched template ] + +[template foo 1] +[fool] + +[template blah 10] + +[endsect] + +[section Empty Templates] + +[template empty1] +[template empty2 ] +[template empty3 [/comment]] +[template empty4 [/comment] + +] +[template empty5 +] +[template empty6 + +] +[template empty7 +[/comment] +] +[template empty8 + +[/comment] +] +[template empty_arg1[x]] +[template empty_arg2[x y]] + +[empty1] +[empty2] +[empty3] +[empty4] +[empty5] +[empty6] +[empty7] +[empty8] +[empty_arg1 1] +[empty_arg2 1 2] + +[endsect] + +[/----------------------------------- Nested templates ] + +[section Nested Templates] + +[template block[content] + +Start block template. + +[content] + +End block template. +] + +[template phrase[content] Start phrase template. [content] End phrase template.] + +Pre [block [block Hello!]] Post + +Pre [block [phrase Hello!]] Post + +Pre [phrase [block Hello!]] Post + +Pre [phrase [phrase Hello!]] Post + +[endsect] + +[/----------------------------------- Block Markup ] + +[section Block Markup] + +[template list +* a +* b] + +[template horizontal +----] + +[template codeblock + int main() {}] + +[template paragraphs +Paragraphs 1 + +Paragraphs 2 +] + +[list][horizontal][codeblock][paragraphs] + +* [list] +* [horizontal] +* [codeblock] +* [paragraphs] + +[endsect] + +[/----------------------------------- 1.5+ use static scoping ] + +[section Static Scoping] [template x static scoping] -[template foo1[] [x]] -[template foo2[x] [foo1]] -[foo2 dynamic scoping] +[template static_test1[] [x]] +[template static_test2[x] [static_test1]] +[static_test2 dynamic scoping] [/ This should be '[a]' because [a] isn't matched. ] [template test1[] [a]] @@ -17,8 +216,8 @@ [/ In 1.5 template arguments are scoped at the point they are defined] [template y new] -[template foo3[a y] [a]] -[foo3 [y] old] +[template static_test3[a y] [a]] +[static_test3 [y] old] [/ From https://svn.boost.org/trac/boost/ticket/2034 ] @@ -27,7 +226,11 @@ [template echo_twice[x] [echo [same [x]]..[same [x]]]] [echo_twice foo] -[/ 1.5 template arguments] +[endsect] + +[/----------------------------------- 1.5+ template arguments ] + +[section Template Arguments] [template binary[x y] {[x]-[y]}] [binary 1..2] [/ {1-2} ] @@ -50,18 +253,22 @@ [ternary 1..2..3] [/ {1-2-3} ] [ternary 1 2 3] [/ {1-2-3} ] -[/ Block vs. phrase templates ] +[endsect] -[template phrase[] Some *text*] -[template block[] +[/----------------------------------- Block and phrases ] + +[section Block and phrase templates] + +[template phrase_template[] Some *text*] +[template block_template[] A paragraph. ] -[phrase] -[block] -[`phrase] -[`block] +[phrase_template] +[block_template] +[`phrase_template] +[`block_template] [/ Trailing newline shouldn't be included] @@ -69,4 +276,22 @@ A paragraph. ''''''[title]'''''' ] -[named_index things Things] \ No newline at end of file +[named_index things Things] + +[endsect] + +[/----------------------------------- Escaped templates ] + +[section Escaped templates] + +[template raw_markup Not real boostbook] +[template | Also not real boostbook] +[template escaped1 [|] [`|]] +[template escaped2 [x] [`x]] + +[`raw_markup] +[`|] +[escaped1 More fake boostbook] +[escaped2 Final fake boostbook] + +[endsect] diff --git a/test/templates-1_6-fail1.quickbook b/test/templates-1_6-fail1.quickbook new file mode 100644 index 0000000..0fd039b --- /dev/null +++ b/test/templates-1_6-fail1.quickbook @@ -0,0 +1,8 @@ +[article Template 1.6 fail 1 + [quickbook 1.6] +] + +[/ I've removed support for escaping punctuation templates in 1.6. ] + +[template ~ body] +[`~] diff --git a/test/templates-1_6.gold b/test/templates-1_6.gold new file mode 100644 index 0000000..b37604e --- /dev/null +++ b/test/templates-1_6.gold @@ -0,0 +1,257 @@ + + +
+ Template 1.6 +
+ <link linkend="template_1_6.templates">Templates</link> + + nullary_arg + + + foo baz + + + foo baz + + + This is a complete paragraph. kalamazoo kalamazoo kalamazoo kalamazoo kalamazoo + kalamazoo kalamazoo kalamazoo kalamazoo.... blah blah blah...... + + + baz + + + This is a complete paragraph. madagascar madagascar madagascar madagascar madagascar + madagascar madagascar madagascar madagascar.... blah blah blah...... + + + zoom peanut zoom + + + exactly xanadu + + + wx + + + wxyz wxyz trail + +int main() +{ + std::cout << "Hello, World" << std::endl; +} + + + x2 + + + α2 + + + x2 + + + got a banana? + + + .0 00 + + + [fool] + +
+
+ <link linkend="template_1_6.empty_templates">Empty Templates</link> +
+
+ <link linkend="template_1_6.nested_templates">Nested Templates</link> + + Pre + + + Start block template. + + + Start block template. + + + Hello! + + + End block template. + + + End block template. + + + Post + + + Pre + + + Start block template. + + + Start phrase template. Hello! End phrase template. + + + End block template. + + + Post + + + Pre + + + Start phrase template. + + + Start block template. + + + Hello! + + + End block template. + + + End phrase template. + + + Post + + + Pre Start phrase template. Start phrase template. Hello! End phrase template. + End phrase template. Post + +
+
+ <link linkend="template_1_6.block_markup">Block Markup</link> + + + + a + + + + + b + + + + +int main() {} + + Paragraphs 1 + + + Paragraphs 2 + + + + + + + + a + + + + + b + + + + + + + + + +int main() {} + + + + Paragraphs 1 + + + Paragraphs 2 + + + +
+
+ <link linkend="template_1_6.static_scoping">Static Scoping</link> + + static scoping + + + [a] + + + new + + + foo foo + +
+
+ <link linkend="template_1_6.template_arguments">Template Arguments</link> + + {1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {1..2-3} {1..2-3} + + + { {1 2-3}-4} { {1 2-3}-4} { {1-2 3}-4} + + + {[1-2] 3} {[1-2] 3} {[1-2} + + + {1-2-3} {1-2-3} + +
+
+ <link linkend="template_1_6.block_and_phrase_templates">Block and phrase + templates</link> + + Some text + + + A <emphasis>paragraph</emphasis>. + + + Some *text* A paragraph. + + + Things + +
+
+ <link linkend="template_1_6.template_body">Skipping the template body + correctly</link> + + Argument + + + +code + + + + + + code + + + +
+
+ <link linkend="template_1_6.escaped_templates">Escaped templates</link> + + Not real boostbook More fake boostbook + +
+
diff --git a/test/templates-1_6.quickbook b/test/templates-1_6.quickbook new file mode 100644 index 0000000..627bd7f --- /dev/null +++ b/test/templates-1_6.quickbook @@ -0,0 +1,313 @@ +[article Template 1.6 + [quickbook 1.6] +] + +[section Templates] + +[/-------------------------------- nullary arg ] + +[template foo0 nullary_arg] + +[foo0] + +[/-------------------------------- unary arg, phrase syle ] + +[template foo1[bar] foo [bar]] + +[foo1 baz] + +[/-------------------------------- unary arg, block syle ] + +[template foo2[bar] +foo [bar] +] + +[foo2 baz] + +[template foo3[bar] +This is a complete paragraph. [bar] [bar] [bar] [bar] [bar] +[bar] [bar] [bar] [bar].... blah blah blah...... +] + +[foo3 kalamazoo] + +[/-------------------------------- unary arg, using punctuation ] + +[template ![bar] ''''''[bar]''''''] + +[!baz] + +[/-------------------------------- recursive templates ] + +[template foo4[bar] +[foo3 [bar]] +] + +[foo3 madagascar] + +[template foo5[x] zoom [x]] +[template foo6[x] [x] zoom] + +[foo6[foo5 peanut]] + +[template kinda_weird[x y] [x] [y]] + +[kinda_weird exactly..xanadu] + + +[/-------------------------------- space delimitted args ] + +[template simple1[a b] [a][b]] + +[simple1 w x] + +[template simple2[a b c d] [a][b][c][d]] + +[simple2 w x y z][simple2 w x y z trail] + +[/-------------------------------- John's templates ] + +[template code[x] + int main() + { + std::cout << ``[x]`` << std::endl; + } +] + +[code "Hello\, World"] + +[template alpha '''α'''] +[template pow[a b] [a]''''''[b]'''''' ] +[template super[text]''''''[text]'''''' ] + +[pow x 2] + +[pow [alpha] 2] + +x[super 2] + +[/-------------------------------- Some more ] + +[template banana got a banana?] +[template plantation[bananarama] [bananarama]] + +[plantation [banana]] + +[/-------------------------------- Not a bug (there was a syntax error here) ] + +[template join1[a b] [b][a]] +[template join2[a b] [a][b]] +[template test[x] [join1 [join2 0 [x]]...0]] +[test 0] + +[/-------------------------------- Mismatched template ] + +[template foo 1] +[fool] + +[template blah 10] + +[endsect] + +[section Empty Templates] + +[template empty1] +[template empty2 ] +[template empty3 [/comment]] +[template empty4 [/comment] + +] +[template empty5 +] +[template empty6 + +] +[template empty7 +[/comment] +] +[template empty8 + +[/comment] +] +[template empty_arg1[x]] +[template empty_arg2[x y]] + +[empty1] +[empty2] +[empty3] +[empty4] +[empty5] +[empty6] +[empty7] +[empty8] +[empty_arg1 1] +[empty_arg2 1 2] + +[endsect] + +[/----------------------------------- Nested templates ] + +[section Nested Templates] + +[template block_foo[content] + +Start block template. + +[content] + +End block template. +] + +[template phrase_foo[content] Start phrase template. [content] End phrase template.] + +Pre [block_foo [block_foo Hello!]] Post + +Pre [block_foo [phrase_foo Hello!]] Post + +Pre [phrase_foo [block_foo Hello!]] Post + +Pre [phrase_foo [phrase_foo Hello!]] Post + +[endsect] + +[/----------------------------------- Block Markup ] + +[section Block Markup] + +[template list +* a +* b] + +[template horizontal +----] + +[template codeblock + int main() {}] + +[template paragraphs +Paragraphs 1 + +Paragraphs 2 +] + +[list][horizontal][codeblock][paragraphs] + +* [list] +* [horizontal] +* [codeblock] +* [paragraphs] + +[endsect] + +[/----------------------------------- 1.5+ use static scoping ] + +[section Static Scoping] + +[template x static scoping] +[template static_test1[] [x]] +[template static_test2[x] [static_test1]] +[static_test2 dynamic scoping] + +[/ This should be '[a]' because [a] isn't matched. ] +[template test1[] [a]] +[template test2[a] [test1]] +[test2 1] + +[/ In 1.5 template arguments are scoped at the point they are defined] + +[template y new] +[template static_test3[a y] [a]] +[static_test3 [y] old] + +[/ From https://svn.boost.org/trac/boost/ticket/2034 ] + +[template same[x] [x]] +[template echo[a b] [a] [b]] +[template echo_twice[x] [echo [same [x]]..[same [x]]]] +[echo_twice foo] + +[endsect] + +[/----------------------------------- 1.5+ template arguments ] + +[section Template Arguments] + +[template binary[x y] {[x]-[y]}] +[binary 1..2] [/ {1-2} ] +[binary 1 2] [/ {1-2} ] +[binary 1..2 3 4] [/ {1-2 3 4} ] +[binary 1 2..3 4] [/ {1 2-3 4} ] +[binary 1 2 3..4] [/ {1 2 3-4} ] +[binary 1.\.2..3] [/ {1..2-3} ] +[binary 1.\.2 3] [/ {1..2-3} ] + +[binary [binary 1 2..3]..4] [/ { {1 2-3}-4} ] +[binary [binary 1 2..3] 4] [/ { {1 2-3}-4} ] +[binary [binary 1 2 3]..4] [/ { {1-2 3}-4} ] + +[binary \[1 2\] 3] [/ {[1-2] 3} ] +[binary \[1..2\] 3] [/ {[1-2] 3} ] +[binary \[1 2] [/ {(1-2} ] + +[template ternary[x y z] {[x]-[y]-[z]}] +[ternary 1..2..3] [/ {1-2-3} ] +[ternary 1 2 3] [/ {1-2-3} ] + +[endsect] + +[/----------------------------------- Block and phrases ] + +[section Block and phrase templates] + +[template phrase_template[] Some *text*] +[template block_template[] + +A paragraph. +] + +[phrase_template] +[block_template] +[`phrase_template] +[`block_template] + +[/ Trailing newline shouldn't be included] + +[template named_index[type title] +''''''[title]'''''' +] + +[named_index things Things] + +[endsect] + +[/-------------------------------- Skipping template body ] + +[section:template_body Skipping the template body correctly] + +[template args1[x] [`x]] +[template args2[] +[ordered_list [``code``]] +] +[/ Due to a bug in the template parser need to stop the parser + thinking that the code is an escaped template. ] +[template args3[] +[ordered_list [\ `code`]] +] + +[args1 Argument] +[args2] +[args3] + +[endsect] + +[/----------------------------------- Escaped templates ] + +[section Escaped templates] + +[template raw_markup Not real boostbook] +[template escaped1 [x] [`x]] + +[`raw_markup] +[escaped1 More fake boostbook] + +[endsect] diff --git a/test/templates-1_7-fail1.quickbook b/test/templates-1_7-fail1.quickbook new file mode 100644 index 0000000..0618beb --- /dev/null +++ b/test/templates-1_7-fail1.quickbook @@ -0,0 +1,12 @@ +[article Template 1.7 fail +[quickbook 1.7] +] + +[/ This should fail because it's a phrase template containing a paragraph + separator. ] + +[template fail[] Phrase content. + +Paragraph content.] + +[fail] diff --git a/test/templates-1_7.gold b/test/templates-1_7.gold new file mode 100644 index 0000000..c7d4c64 --- /dev/null +++ b/test/templates-1_7.gold @@ -0,0 +1,302 @@ + + +
+ Template 1.7 +
+ <link linkend="template_1_7.templates">Templates</link> + + nullary_arg + + + foo baz + + + foo baz + + + This is a complete paragraph. kalamazoo kalamazoo kalamazoo kalamazoo kalamazoo + kalamazoo kalamazoo kalamazoo kalamazoo.... blah blah blah...... + + + baz + + + This is a complete paragraph. madagascar madagascar madagascar madagascar madagascar + madagascar madagascar madagascar madagascar.... blah blah blah...... + + + zoom peanut zoom + + + exactly xanadu + + + wx + + + wxyz wxyz trail + +int main() +{ + std::cout << "Hello, World" << std::endl; +} + + + x2 + + + α2 + + + x2 + + + got a banana? + + + .0 00 + + + [fool] + +
+
+ <link linkend="template_1_7.empty_templates">Empty Templates</link> +
+
+ <link linkend="template_1_7.nested_templates">Nested Templates</link> + + Pre + + + Start block template. + + + Start block template. + + + Hello! + + + End block template. + + + End block template. + + + Post + + + Pre + + + Start block template. + + + Start phrase template. Hello! End phrase template. + + + End block template. + + + Post + + + Pre Start phrase template. + + + Start block template. + + + Hello! + + + End block template. + + + End phrase template. Post + + + Pre Start phrase template. Start phrase template. Hello! End phrase template. + End phrase template. Post + +
+
+ <link linkend="template_1_7.block_markup">Block Markup</link> + + + + a + + + + + b + + + + +int main() {} + + Paragraphs 1 + + + Paragraphs 2 + + + + + + + + a + + + + + b + + + + + + + + + +int main() {} + + + + Paragraphs 1 + + + Paragraphs 2 + + + +
+
+ <link linkend="template_1_7.static_scoping">Static Scoping</link> + + static scoping + + + [a] + + + new + + + foo foo + +
+
+ <link linkend="template_1_7.template_arguments">Template Arguments</link> + + {1-2} {1-2} {1-2 3 4} {1 2-3 4} {1 2 3-4} {1..2-3} {1..2-3} + + + { {1 2-3}-4} { {1 2-3}-4} { {1-2 3}-4} + + + {[1-2] 3} {[1-2] 3} {[1-2} + + + {1-2-3} {1-2-3} + +
+
+ <link linkend="template_1_7.block_and_phrase_templates">Block and phrase + templates</link> + + Some text + + + A <emphasis>paragraph</emphasis>. + + + Some *text* A paragraph. + + + Things + + + + + + + + + + + + + + + Text2 afterwards. Text3 before. + + + + + + + + + Text4 before. + + + + + + + + + Text4 afterwards. + + + + + + + + + * Not a list. + + + + + + + + + * Not a list. + +
+
+ <link linkend="template_1_7.template_body">Skipping the template body + correctly</link> + + Argument + + + +code + + + + + + code + + + +
+
+ <link linkend="template_1_7.escaped_templates">Escaped templates</link> + + Not real boostbook More fake boostbook + +
+
diff --git a/test/templates-1_7.quickbook b/test/templates-1_7.quickbook new file mode 100644 index 0000000..bf1feac --- /dev/null +++ b/test/templates-1_7.quickbook @@ -0,0 +1,322 @@ +[article Template 1.7 + [quickbook 1.7] +] + +[section Templates] + +[/-------------------------------- nullary arg ] + +[template foo0 nullary_arg] + +[foo0] + +[/-------------------------------- unary arg, phrase syle ] + +[template foo1[bar] foo [bar]] + +[foo1 baz] + +[/-------------------------------- unary arg, block syle ] + +[template foo2[bar] +foo [bar] +] + +[foo2 baz] + +[template foo3[bar] +This is a complete paragraph. [bar] [bar] [bar] [bar] [bar] +[bar] [bar] [bar] [bar].... blah blah blah...... +] + +[foo3 kalamazoo] + +[/-------------------------------- unary arg, using punctuation ] + +[template |[bar] ''''''[bar]''''''] + +[|baz] + +[/-------------------------------- recursive templates ] + +[template foo4[bar] +[foo3 [bar]] +] + +[foo3 madagascar] + +[template foo5[x] zoom [x]] +[template foo6[x] [x] zoom] + +[foo6[foo5 peanut]] + +[template kinda_weird[x y] [x] [y]] + +[kinda_weird exactly..xanadu] + + +[/-------------------------------- space delimitted args ] + +[template simple1[a b] [a][b]] + +[simple1 w x] + +[template simple2[a b c d] [a][b][c][d]] + +[simple2 w x y z][simple2 w x y z trail] + +[/-------------------------------- John's templates ] + +[template code[x] + int main() + { + std::cout << ``[x]`` << std::endl; + } +] + +[code "Hello\, World"] + +[template alpha '''α'''] +[template pow[a b] [a]''''''[b]'''''' ] +[template super[text]''''''[text]'''''' ] + +[pow x 2] + +[pow [alpha] 2] + +x[super 2] + +[/-------------------------------- Some more ] + +[template banana got a banana?] +[template plantation[bananarama] [bananarama]] + +[plantation [banana]] + +[/-------------------------------- Not a bug (there was a syntax error here) ] + +[template join1[a b] [b][a]] +[template join2[a b] [a][b]] +[template test[x] [join1 [join2 0 [x]]...0]] +[test 0] + +[/-------------------------------- Mismatched template ] + +[template foo 1] +[fool] + +[template blah 10] + +[endsect] + +[section Empty Templates] + +[template empty1] +[template empty2 ] +[template empty3 [/comment]] +[template empty4 [/comment] + +] +[template empty5 +] +[template empty6 + +] +[template empty7 +[/comment] +] +[template empty8 + +[/comment] +] +[template empty_arg1[x]] +[template empty_arg2[x y]] + +[empty1] +[empty2] +[empty3] +[empty4] +[empty5] +[empty6] +[empty7] +[empty8] +[empty_arg1 1] +[empty_arg2 1 2] + +[endsect] + +[/----------------------------------- Nested templates ] + +[section Nested Templates] + +[template block_foo[content] + +Start block template. + +[content] + +End block template. +] + +[template phrase_foo[content] Start phrase template. [content] End phrase template.] + +Pre [block_foo [block_foo Hello!]] Post + +Pre [block_foo [phrase_foo Hello!]] Post + +Pre [phrase_foo [block_foo Hello!]] Post + +Pre [phrase_foo [phrase_foo Hello!]] Post + +[endsect] + +[/----------------------------------- Block Markup ] + +[section Block Markup] + +[template list +* a +* b] + +[template horizontal +----] + +[template codeblock + int main() {}] + +[template paragraphs +Paragraphs 1 + +Paragraphs 2 +] + +[list][horizontal][codeblock][paragraphs] + +* [list] +* [horizontal] +* [codeblock] +* [paragraphs] + +[endsect] + +[/----------------------------------- 1.5+ use static scoping ] + +[section Static Scoping] + +[template x static scoping] +[template static_test1[] [x]] +[template static_test2[x] [static_test1]] +[static_test2 dynamic scoping] + +[/ This should be '[a]' because [a] isn't matched. ] +[template test1[] [a]] +[template test2[a] [test1]] +[test2 1] + +[/ In 1.5 template arguments are scoped at the point they are defined] + +[template y new] +[template static_test3[a y] [a]] +[static_test3 [y] old] + +[/ From https://svn.boost.org/trac/boost/ticket/2034 ] + +[template same[x] [x]] +[template echo[a b] [a] [b]] +[template echo_twice[x] [echo [same [x]]..[same [x]]]] +[echo_twice foo] + +[endsect] + +[/----------------------------------- 1.5+ template arguments ] + +[section Template Arguments] + +[template binary[x y] {[x]-[y]}] +[binary 1..2] [/ {1-2} ] +[binary 1 2] [/ {1-2} ] +[binary 1..2 3 4] [/ {1-2 3 4} ] +[binary 1 2..3 4] [/ {1 2-3 4} ] +[binary 1 2 3..4] [/ {1 2 3-4} ] +[binary 1.\.2..3] [/ {1..2-3} ] +[binary 1.\.2 3] [/ {1..2-3} ] + +[binary [binary 1 2..3]..4] [/ { {1 2-3}-4} ] +[binary [binary 1 2..3] 4] [/ { {1 2-3}-4} ] +[binary [binary 1 2 3]..4] [/ { {1-2 3}-4} ] + +[binary \[1 2\] 3] [/ {[1-2] 3} ] +[binary \[1..2\] 3] [/ {[1-2] 3} ] +[binary \[1 2] [/ {(1-2} ] + +[template ternary[x y z] {[x]-[y]-[z]}] +[ternary 1..2..3] [/ {1-2-3} ] +[ternary 1 2 3] [/ {1-2-3} ] + +[endsect] + +[/----------------------------------- Block and phrases ] + +[section Block and phrase templates] + +[template phrase_template[] Some *text*] +[template block_template[] + +A paragraph. +] + +[phrase_template] +[block_template] +[`phrase_template] +[`block_template] + +[/ Trailing newline shouldn't be included] + +[template named_index[type title] +''''''[title]'''''' +] + +[named_index things Things] + +[/ Blocks in phrase templates ] + +[template phrase_block1[] [table]] +[template phrase_block2[] [table] Text2 afterwards.] +[template phrase_block3[] Text3 before. [table]] +[template phrase_block4[] Text4 before. [table] Text4 afterwards.] +[template phrase_block5[] [table] * Not a list.] +[template phrase_block6[] [table] +* Not a list.] + +[phrase_block1][phrase_block2][phrase_block3][phrase_block4] +[phrase_block5][phrase_block6] + +[endsect] + +[/-------------------------------- Skipping template body ] + +[section:template_body Skipping the template body correctly] + +[template args1[x] [`x]] +[template args2[] [ordered_list [``code``]]] +[/ Due to a bug in the template parser need to stop the parser + thinking that the code is an escaped template. ] +[template args3[] [ordered_list [\ `code`]]] + +[args1 Argument] +[args2] +[args3] + +[endsect] + +[/----------------------------------- Escaped templates ] + +[section Escaped templates] + +[template raw_markup Not real boostbook] +[template escaped1 [x] [`x]] + +[`raw_markup] +[escaped1 More fake boostbook] + +[endsect] From 67256b35274bf4f339dda4cdf23a207bed2e280a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 18 Aug 2013 10:04:46 +0000 Subject: [PATCH 87/94] Merge quickbook to release. [SVN r85390] --- doc/block.qbk | 13 +++++++++++-- doc/quickbook.qbk | 2 +- doc/structure.qbk | 37 +++++++++++++++++++++++++++++++++++++ src/quickbook.cpp | 2 +- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/doc/block.qbk b/doc/block.qbk index 9b31403..e7060f7 100644 --- a/doc/block.qbk +++ b/doc/block.qbk @@ -965,12 +965,18 @@ You can include one QuickBook file from another. The syntax is simply: [include someother.qbk] ``` -The included file will be processed as if it had been cut and pasted +If the included file has a [link quickbook.ref.docinfo docinfo block] then it +will create a nested document. Otherwise the included file will be processed +as if it had been cut and pasted into the current document, with the following exceptions: * The '''__FILENAME__''' predefined macro will reflect the name of the file currently being processed. -* Any macros defined in the included file are scoped to that file. +* Any macros or templates defined in the included file are scoped to that file. + +[note In quickbook 1.5 and earlier templates weren't scoped in included files. +If you want to use templates or macros from a file in quickbook 1.6, +use [link quickbook.ref.import import] instead.] The [^\[include\]] directive lets you specify a document id to use for the included file. You can specify the id like this: @@ -984,6 +990,9 @@ for instance, if there is a top section in someother.qbk named "Intro", the named anchor for that section will be "someid.intro", and you can link to it with [^\[link someid.intro The Intro\]]. +If the included file has a docinfo block, an id specified in an [^\[include\]] +directive will overwrite it. + [endsect] [/include] [#quickbook.ref.import] diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index 6de2921..f5c1ca4 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -11,7 +11,7 @@ [quickbook 1.6] [compatibility-mode 1.5] [id quickbook] - [version 1.5] + [version 1.6] [authors [de Guzman, Joel], [Niebler, Eric]] [copyright 2002 2004 2006 Joel de Guzman, Eric Niebler] [copyright 2010-2011 Daniel James] diff --git a/doc/structure.qbk b/doc/structure.qbk index c9a4be9..0409738 100644 --- a/doc/structure.qbk +++ b/doc/structure.qbk @@ -144,6 +144,43 @@ that's just ignored by the style sheets. [endsect] [/attributes] +[section:nesting Nesting quickbook documents] + +Docinfo blocks can only appear at the beginning of a quickbook file, so to +create a more complicated document you need to use several quickbook files and +use the [link quickbook.ref.include include tag] to nest them. For example, say +you wish to create a book with an introduction and a chapter, you first create +a file for the book: + + [book Simple example + [quickbook 1.6] + ] + + [include introduction.qbk] + [include chapter.qbk] + +[note Structuring a document like this was introduced in quickbook 1.6, so the +`[quickbook 1.6]` docinfo field is required.] + +The appropriate document type for an introduction is `preface`, so +the contents of `introduction.qbk` should be something like: + + [preface Introduction + [quickbook 1.6] + ] + + Write the introduction to the book here.... + +And `chapter.qbk`: + + [chapter A chapter + [quickbook 1.6] + ] + + Chapter contents.... + +[endsect] [/nesting] + [endsect] [/docinfo] [#quickbook.ref.section] diff --git a/src/quickbook.cpp b/src/quickbook.cpp index e3c7718..a311081 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -40,7 +40,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.6.0 alpha (dev)" +#define QUICKBOOK_VERSION "Quickbook Version 1.6.0 alpha 1" namespace quickbook { From dd1abc0e5c466552e2a2e1dd94d625eca0b6fa01 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 20 Aug 2013 17:22:58 +0000 Subject: [PATCH 88/94] Merge quickbook to release. Just documentation changes for 1.6. [SVN r85409] --- doc/1_6.qbk | 67 ++--------------- doc/block.qbk | 182 ++++++++++++++++++++++++++++++++++++++++++++-- doc/phrase.qbk | 26 +++++++ doc/structure.qbk | 28 ++++++- 4 files changed, 231 insertions(+), 72 deletions(-) diff --git a/doc/1_6.qbk b/doc/1_6.qbk index fe9ca32..0143559 100644 --- a/doc/1_6.qbk +++ b/doc/1_6.qbk @@ -237,69 +237,12 @@ error. To work around this put an escaped space before the code phrase: [section:elements New Elements] -[section:block `block`] +New elements added in quickbook 1.6: -`block` is a block element that just marks its contents as a block, -so that they aren't wrapped in paragraph tags. The main use is -for escaped docbook block tags, such as: +* [link quickbook.ref.block `block`] +* [link quickbook.ref.list_tags `ordered_list` and `itemized_list`] +* [link quickbook.ref.role `role`] - [template chapter[title] - [block''''''[title]''''''] - ] - - [template chapterend - [block''''''] - ] - - [chapter An example chapter] - - Content - - [chapterend] - -Without the `block` element, the `chapter` and `chapterend` templates -would be wrapped in paragraph tags. - -[note In this example, the template body has to start with a newline so that -the template will be interpreted in block mode.] - -[endsect] - -[section:lists `ordered_list` and `itemized_list`] - -These are used as an alternative to the normal wiki-style markup for -lists. They make it easier to nest lists inside other elements, and -nest elements inside lists. The markup is similar to a single level -table: - - [ordered_list [item1][item2]] - -is equivalent to: - - # item1 - # item2 - -[endsect] - -[section:role `role`] - -`role` is a phrase element used to mark up the text in the eventual html -with an a class. For example: - - [role red Text content] - -Will generate the docbook: - - Text content - -Which will generate html along the lines of: - - Text content - -And then you can use css to style this however you wish. - -[endsect] - -[endsect] +[endsect] [/ elements] [endsect] [/ Quickbok 1.6] diff --git a/doc/block.qbk b/doc/block.qbk index e7060f7..1be2041 100644 --- a/doc/block.qbk +++ b/doc/block.qbk @@ -26,6 +26,38 @@ You can include another XML file with: This is useful when file.xml has been generated by Doxygen and contains your reference section. +=xinclude= paths are normally used unchanged in the generated documentation, +which will not work if you wish them to be relative to the current quickbook +file. Quickbook can add a =xml:base= attribute to the boostbook documentation +to specify where =xinclude= files should be found. For example, if you wish +them to be relative to the current quickbook file: + + [article Article with xincludes + [quickbook 1.6] + [xmlbase .] + ] + + [xinclude file.xml] + +Now the xinclude should work if =file.xml= is in the same directory as the +quickbook file. Although it might not work if you distribute the generated +files (as their relative directories can change). + +Say the article is generated in a sub-directory, by running something like: + + quickbook article.qbk --output-file=output/article.xml + +This will generate a boostbook root tag: + +
+ +Because =xml:base= is set to =..=, the xml processor will know to look in +the parent directory to find =file.xml=, which it comes across the +=xi:include= tag. + [endsect] [/xinclude] [#quickbook.ref.paragraphs] @@ -190,6 +222,31 @@ will generate: * 2.b.2.b [endsect] [/mixed_lists] + +[#quickbook.ref.list_tags] +[section:list_tags Explicit list tags] + +Sometimes the wiki-style list markup can be tricky to use, especially +if you wish to include more complicated markup with the list. So in +quickbook 1.6, an alternative way to mark up lists introduced: + + [ordered_list [item1][item2]] + +is equivalent to: + + # item1 + # item2 + +And: + + [itemized_list [item1][item2]] + +is equivalent to: + + * item1 + * item2 + +[endsect] [/list_tags] [endsect] [/lists] [#quickbook.ref.code] @@ -356,8 +413,23 @@ to produce the desired effect. [h5 Heading 5] [h6 Heading 6] -Headings 1-3 \[h1 h2 and h3\] will automatically have anchors with -normalized names with +You can specify an id for a heading: + +``` +[h1:heading_id A heading to link to] +``` + +To link to it, you'll need to include the enclosing section's id: + +``` +[link document_id.section_id.heading_id The link text] +``` + +Although you can preceed a heading by an [link quickbook.ref.anchors anchor] +if you wish to use a location independent link. + +If a heading doesn't have an id, one will be automatically generated +with a normalized name with [^name="document_id.section_id.normalized_header_text"] (i.e. valid characters are =a-z=, =A-Z=, =0-9= and =_=. All non-valid characters are converted to underscore and all upper-case are converted to lower-case. @@ -370,6 +442,9 @@ For example: Heading 1 in section Section 2 will be normalized to to link to them. See __anchor_links__ and __section__ for more info. +[note Specifying heading ids is a quickbook 1.6 feature, earlier + versions don't support them.] + [endsect] [/headings] [#quickbook.ref.generic_heading] @@ -393,7 +468,7 @@ however, headings in a particular section is just flat. Example: ``` [section A] [h2 X] -[h2 Y] +[h2:link_id Y] [h2 Z] [endsect] ``` @@ -965,14 +1040,18 @@ You can include one QuickBook file from another. The syntax is simply: [include someother.qbk] ``` -If the included file has a [link quickbook.ref.docinfo docinfo block] then it -will create a nested document. Otherwise the included file will be processed -as if it had been cut and pasted +In quickbook 1.6 and later, if the included file has a +[link quickbook.ref.docinfo docinfo block] then it will create a nested +document. This will be processed as a standalone document, although any macros +or templates from the enclosing file will still be defined. + +Otherwise the included file will be processed as if it had been cut and pasted into the current document, with the following exceptions: * The '''__FILENAME__''' predefined macro will reflect the name of the file currently being processed. -* Any macros or templates defined in the included file are scoped to that file. +* Any macros or templates defined in the included file are scoped to that file, + i.e. they are not added to the enclosing file. [note In quickbook 1.5 and earlier templates weren't scoped in included files. If you want to use templates or macros from a file in quickbook 1.6, @@ -993,11 +1072,67 @@ it with [^\[link someid.intro The Intro\]]. If the included file has a docinfo block, an id specified in an [^\[include\]] directive will overwrite it. +You can also include C, C++ and python source files. This will include any +quickbook blocks in the file that aren't inside of named code snippets. See +the [link quickbook.ref.import Import section] for syntax details. For example, +say you included this file: + + /** + * Hello world example + */ + + // In this comment, the backtick indicates that this is a + // quickbook source block that will be included. + + /*` + First include the appropriate header: [hello_includes] + Then write your main function: [hello_main] + */ + + // This defines a code snippet, the syntax is + // described in the import section. It's available + // in the whole of this source file, not just after + // its definition. + + //[hello_includes + #include + //] + + //[hello_main + int main() { + std::cout << "Hello, trivial example" << std::endl; + } + //] + +It will generate: + + First include the appropriate header: + + #include + + Then write your main function: + + int main() { + std::cout << "Hello, trivial example" << std::endl; + } + [endsect] [/include] [#quickbook.ref.import] [section:import Import] +In quickbook 1.6 and later if you wish to use a template, macro or code +snippet from a file, you need to import it. This will not include any +of the content from that file, but will pull templates, macros and code +snippets into the current file's scope. + +With quickbook files, this allows you to create template and macro +libraries. For python (indicated by the `.py` extension), C or +C++ files this allows you to include code snippets from source files, +so that your code examples can be kept up to date and fully tested. + +[/ Old justification text, might move this into a new section: + When documenting code, you'd surely need to present code from actual source files. While it is possible to copy some code and paste them in your QuickBook file, doing so is error prone and the extracted code in the documentation tends @@ -1006,6 +1141,7 @@ always, is that once documentation is written, the tendency is for the docs to languish in the archives without maintenance. QuickBook's import facility provides a nice solution. +] [heading Example] @@ -1139,6 +1275,36 @@ Example: [class_] -See the actual code here: [@boost:/tools/quickbook/test/stub.cpp] +See the actual code here: +[@boost:/tools/quickbook/test/stub.cpp tools/quickbook/test/stub.cpp] [endsect] [/import] + +[#quickbook.ref.block] +[section:block Plain blocks] + +`block` is a plain block element, that doesn't wrap its contents +in any docbook or boostbook tags. This can be useful when using +escaped docbook block tags, such as: + + [template chapter[title] + [block''''''[title]''''''] + ] + + [template chapterend + [block''''''] + ] + + [chapter An example chapter] + + Content + + [chapterend] + +Without the `block` element, the `chapter` and `chapterend` templates +would be wrapped in paragraph tags. + +[note In this example, the template body has to start with a newline so that +the template will be interpreted in block mode.] + +[endsect] [/block] diff --git a/doc/phrase.qbk b/doc/phrase.qbk index f6f8859..9c26d42 100644 --- a/doc/phrase.qbk +++ b/doc/phrase.qbk @@ -165,6 +165,32 @@ And one for the little boy who lives down the lane. [endsect] [/simple_formatting] +[#quickbook.ref.role] +[section:role Role] + +Sometime the basic formatting options aren't enough, and you wish +to use CSS to style the generated html. For these cases you can +use the `role` phase element. For example: + + [role red Text content] + +Will generate the docbook: + + Text content + +Which will generate html along the lines of: + + Text content + +And then you can use css to style this however you wish. + +[note When generating other formats such as pdfs, your css is not going to + apply, so this will appear as normal, unstyled text. The docbook + =role= attribute is meant to be used as a more general mechanism, so + you might be able to take advantage of it by some other means.] + +[endsect] [/role] + [#quickbook.ref.inline_code] [section:inline_code Inline code] diff --git a/doc/structure.qbk b/doc/structure.qbk index 0409738..4e9bfb4 100644 --- a/doc/structure.qbk +++ b/doc/structure.qbk @@ -82,13 +82,37 @@ They are all optional. [heading Quickbook specific meta data] ``` - [quickbook 1.5] + [quickbook 1.6] ``` The `quickbook` attribute declares the version of quickbook the document is written for. In its absence, version 1.1 is assumed. It's recommended that -you use `[quickbook 1.5]` which is the version described here. +you use `[quickbook 1.6]` which is the version described here. + +[note + +The quickbook version also makes some changes to the markup +that's generated. Most notably, the ids that are automatically +for headers and sections are different in later versions. To +minimise disruption, you can use the =compatibility-mode= +attribute to generate similar markup to the old version: + +``` +[article Article that was original + written in quickbook 1.3 +[quickbook 1.6] +[compatibility-mode 1.3] +] +``` + +This feature shouldn't be used for new documents, just for +porting old documents to the new version. +] + +Both the =quickbook= and =compatibility-mode= tags can be used +at the start of the file, before the document info block, and +also in files that don't have a document info block. ``` [source-mode teletype] From c163ec42787366a7253e48959aeb34de14aa814d Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Fri, 23 Aug 2013 18:35:46 +0000 Subject: [PATCH 89/94] merge [85438] from trunk to release, fix quickbook build on msvc [SVN r85439] --- src/id_generation.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/id_generation.cpp b/src/id_generation.cpp index 3b1f57d..6c3be07 100644 --- a/src/id_generation.cpp +++ b/src/id_generation.cpp @@ -6,6 +6,7 @@ http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ +#include #include "id_manager_impl.hpp" #include #include From 11e4e0d9673a52cde63cb0ec06d688f412947ddf Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 22 Sep 2013 11:10:03 +0000 Subject: [PATCH 90/94] Merge quickbook. [SVN r85827] --- doc/1_6.qbk | 41 ++++++++++++++++++++++++- doc/1_7.qbk | 13 +++----- doc/Jamfile.v2 | 6 +++- doc/change_log.qbk | 4 ++- doc/quickbook.qbk | 1 - src/actions.cpp | 6 ++-- src/doc_info_grammar.cpp | 13 +++++--- src/main_grammar.cpp | 2 +- src/quickbook.cpp | 2 +- src/state.cpp | 9 +++++- src/state.hpp | 2 ++ src/syntax_highlight.cpp | 1 - src/utils.cpp | 29 +++++++++++++++-- src/utils.hpp | 5 +-- test/Jamfile.v2 | 1 + test/include/source_mode-1_5.gold | 2 ++ test/include/source_mode-1_5.quickbook | 3 +- test/include/source_mode-1_6.gold | 2 ++ test/include/source_mode-1_6.quickbook | 3 +- test/include/source_mode-inc2.quickbook | 3 ++ test/link-1_7-fail2.quickbook | 6 ++++ 21 files changed, 123 insertions(+), 31 deletions(-) create mode 100644 test/include/source_mode-inc2.quickbook create mode 100644 test/link-1_7-fail2.quickbook diff --git a/doc/1_6.qbk b/doc/1_6.qbk index 0143559..7a10cb1 100644 --- a/doc/1_6.qbk +++ b/doc/1_6.qbk @@ -9,7 +9,46 @@ [section:1_6 Quickbook 1.6] -Everything described in here may change depending on the feedback received. +Upgrading a document from an earlier version of quickbook shouldn't be too +hard. The first thing to do is update the version in the docinfo block. +For example, if you were updating the Xpressive documentation, the existing +docinfo block looks like: + + [library Boost.Xpressive + [quickbook 1.3] + ... + ] + +Change this to: + + [library Boost.Xpressive + [quickbook 1.6] + [compatibility-mode 1.3] + ... + ] + +The =compatibility-mode= tag ensures that automatically generated links +won't change. It might turn out that it isn't required, but in Xpressive's +case if it isn't included it will break a lot of links. + +Then try building it. You might need to fix some stray square brackets. The +new version has a stricter parser which will have an error for brackets +which don't pair up. They might be there by mistake, in which case they +should probably be deleted, or if they're intentional escaped. For example, +to write out the half-open range \[a,b), use: `\[a,b)`. + +Next, you might need to reconsider how templates and macros are defined. +If you `include` a file to use its templates, you'll now need to `import` it +instead as templates are now scoped by included files. Also, if you define +templates and macros in your main quickbook file, you might want to put them +into a separate file and `import` that, which allows the main documentation +files to concentrate on the structure and contents of the document, making them +easier to read. + +Now that headings can have ids, it can be a good idea to add ids to existing +headings. This means that the headings will have more predictable ids which +don't change when the text of the heading changes. In order to preserve +links you can use the existing generated id as the heading. [section:docinfo Includes with docinfo] diff --git a/doc/1_7.qbk b/doc/1_7.qbk index 38e614e..ad8cc16 100644 --- a/doc/1_7.qbk +++ b/doc/1_7.qbk @@ -57,7 +57,7 @@ This is a bit messy, but I'm not sure what would be a good idea. [section:callouts Callouts in code blocks] -Currently callouts can only be used in code snippets. 1.7 add +Currently callouts can only be used in code snippets. 1.7 adds support in normal code blocks. The same syntax is used as in code snippets, the callout descriptions appear immediately after the code block. @@ -67,7 +67,7 @@ after the code block. [section:escaped_docinfo_attributes Escaped docbook in docinfo blocks] Quickbook docinfo attributes will probably never be as rich as docbook -attributes so to allow more flexible markup, not supported by quickbook +attributes. To allow more flexible markup that is not supported by quickbook, escaped docbook can be included in the docinfo block: ``` @@ -82,7 +82,8 @@ escaped docbook can be included in the docinfo block: ``` The escaped docbook is always placed at the end of the docinfo block, -so it shouldn't be assumed that it will interleave the markup. A mixture +so it shouldn't be assumed that it will interleave with markup generated from +quickbook. A mixture of quickbook and docbook attributes for the same information will not work well. @@ -90,8 +91,7 @@ well. [section:listparagraphs Pargraphs in lists] -I'm still refining this, but paragraphs and block elements can now be used -in lists: +Paragraphs and block elements can now be used in lists: [pre * Para 1 @@ -117,9 +117,6 @@ generates: Code block Para 3 -The docbook markup that this generates is pretty bad, but seems to create okay -html. - [endsect] [section:templates_in_link_values Templates in link values] diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 3fd8409..bfa7591 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -21,7 +21,11 @@ boostbook standalone : quickbook : - boost.root=../../../.. + html:boost.root=../../../.. + html:img.src.path=../../../../doc/html/ + xhtml:boost.root=../../../.. + xhtml:img.src.path=../../../../doc/html/ + #callout.graphics.path=../../images/callouts// pdf:img.src.path=$(images)/ pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html diff --git a/doc/change_log.qbk b/doc/change_log.qbk index 2649df4..b80a686 100644 --- a/doc/change_log.qbk +++ b/doc/change_log.qbk @@ -297,7 +297,7 @@ Boost 1.46.1: * Clean up the source map implementation (used to get the correct location for error messages in things like templates and snippets). -[heading Version 1.6.0 alpha] +[heading Version 1.6.0 beta 1 - Boost 1.55 beta] * Remove nested blocks in lists from 1.6, move to 1.7. (Can still nest block elements in lists though). @@ -306,6 +306,8 @@ Boost 1.46.1: * Improved markup for lists. * Make escaping templates with a punctuation identifier illegal. Escaping templates with an alphanumeric identifier is still fine. +* Fix detection of code blocks at the start of a file. +* XML encode the contents of the `__FILENAME__` macro. * 1.7 changes: * Make it an error to use an element in the wrong context. * Error if the body of a phrase element doesn't parse. diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index f5c1ca4..2c8de9f 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -88,7 +88,6 @@ [include phrase.qbk] [include block.qbk] [include language_versions.qbk] -[include 1_6.qbk] [include install.qbk] [include editors.qbk] [include faq.qbk] diff --git a/src/actions.cpp b/src/actions.cpp index 6f21d9c..db9d2f5 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1962,8 +1962,7 @@ namespace quickbook state.imported = (load_type == block_tags::import); // update the __FILENAME__ macro - *boost::spirit::classic::find(state.macro, "__FILENAME__") - = detail::path_to_generic(state.filename_relative); + state.update_filename_macro(); // parse the file quickbook::parse_file(state, include_doc_id, true); @@ -1973,8 +1972,7 @@ namespace quickbook } // restore the __FILENAME__ macro - *boost::spirit::classic::find(state.macro, "__FILENAME__") - = detail::path_to_generic(state.filename_relative); + state.update_filename_macro(); } void load_source_file(quickbook::state& state, diff --git a/src/doc_info_grammar.cpp b/src/doc_info_grammar.cpp index 868ac63..f3944be 100644 --- a/src/doc_info_grammar.cpp +++ b/src/doc_info_grammar.cpp @@ -123,11 +123,14 @@ namespace quickbook scoped_parser to_value(state); doc_info_details = - space [ph::var(local.source_mode_unset) = true] - >> *( local.doc_attribute - >> space + cl::eps_p [ph::var(local.source_mode_unset) = true] + >> *( space + >> local.doc_attribute ) - >> !local.doc_info_block + >> !( space + >> local.doc_info_block + ) + >> *eol ; local.doc_info_block = @@ -155,7 +158,7 @@ namespace quickbook ) ) [state.values.sort()] >> ( ']' - >> (+eol | cl::end_p) + >> (eol | cl::end_p) | cl::eps_p [error] ) ; diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp index da0fd63..9a95299 100644 --- a/src/main_grammar.cpp +++ b/src/main_grammar.cpp @@ -914,7 +914,7 @@ namespace quickbook >> (*(cl::anychar_p - "'''")) >> ( cl::str_p("'''") | cl::eps_p [error("Unclosed boostbook escape.")] - ) [element_action] + ) ; attribute_value_1_7 = diff --git a/src/quickbook.cpp b/src/quickbook.cpp index a311081..8902d88 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -40,7 +40,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.6.0 alpha 1" +#define QUICKBOOK_VERSION "Quickbook Version 1.6.0 beta 1" namespace quickbook { diff --git a/src/state.cpp b/src/state.cpp index fa3d92a..3d00649 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -13,6 +13,7 @@ #include "quickbook.hpp" #include "grammar.hpp" #include "input_path.hpp" +#include "utils.hpp" #if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310)) #pragma warning(disable:4355) @@ -63,8 +64,9 @@ namespace quickbook macro.add ("__DATE__", std::string(quickbook_get_date)) ("__TIME__", std::string(quickbook_get_time)) - ("__FILENAME__", detail::path_to_generic(filename_relative)) + ("__FILENAME__", std::string()) ; + update_filename_macro(); boost::scoped_ptr g( new quickbook_grammar(*this)); @@ -74,6 +76,11 @@ namespace quickbook quickbook_grammar& state::grammar() const { return *grammar_; } + + void state::update_filename_macro() { + *boost::spirit::classic::find(macro, "__FILENAME__") + = detail::encode_string(detail::path_to_generic(filename_relative)); + } void state::push_output() { out.push(); diff --git a/src/state.hpp b/src/state.hpp index 67d2431..479f5e9 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -84,6 +84,8 @@ namespace quickbook // actions /////////////////////////////////////////////////////////////////////////// + void update_filename_macro(); + void push_output(); void pop_output(); diff --git a/src/syntax_highlight.cpp b/src/syntax_highlight.cpp index 4f0208e..2165d54 100644 --- a/src/syntax_highlight.cpp +++ b/src/syntax_highlight.cpp @@ -13,7 +13,6 @@ #include #include #include "grammar.hpp" -#include "grammar_impl.hpp" // Just for context stuff. Should move? #include "state.hpp" #include "actions.hpp" #include "utils.hpp" diff --git a/src/utils.cpp b/src/utils.cpp index 9bd0bee..0d0d0c5 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -15,6 +15,27 @@ namespace quickbook { namespace detail { + std::string encode_string(boost::string_ref str) + { + std::string result; + result.reserve(str.size()); + + for (boost::string_ref::const_iterator it = str.begin(); + it != str.end(); ++it) + { + switch (*it) + { + case '<': result += "<"; break; + case '>': result += ">"; break; + case '&': result += "&"; break; + case '"': result += """; break; + default: result += *it; break; + } + } + + return result; + } + void print_char(char ch, std::ostream& out) { switch (ch) @@ -29,7 +50,7 @@ namespace quickbook { namespace detail } } - void print_string(boost::string_ref const& str, std::ostream& out) + void print_string(boost::string_ref str, std::ostream& out) { for (boost::string_ref::const_iterator cur = str.begin(); cur != str.end(); ++cur) @@ -45,8 +66,11 @@ namespace quickbook { namespace detail return static_cast(std::tolower(static_cast(ch))); } - std::string escape_uri(std::string uri) + std::string escape_uri(std::string uri_param) { + std::string uri; + uri.swap(uri_param); + for (std::string::size_type n = 0; n < uri.size(); ++n) { static char const mark[] = "-_.!~*'()?\\/"; @@ -60,6 +84,7 @@ namespace quickbook { namespace detail n += 2; } } + return uri; } }} diff --git a/src/utils.hpp b/src/utils.hpp index d867747..bdf1409 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -17,8 +17,9 @@ #include namespace quickbook { namespace detail { + std::string encode_string(boost::string_ref); void print_char(char ch, std::ostream& out); - void print_string(boost::string_ref const& str, std::ostream& out); + void print_string(boost::string_ref str, std::ostream& out); char filter_identifier_char(char ch); template @@ -34,7 +35,7 @@ namespace quickbook { namespace detail { } std::string escape_uri(std::string uri); - inline std::string escape_uri(boost::string_ref const& uri) { + inline std::string escape_uri(boost::string_ref uri) { return escape_uri(std::string(uri.begin(), uri.end())); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index aef18f8..7d464e4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -69,6 +69,7 @@ test-suite quickbook.test : [ quickbook-test link-1_6 ] [ quickbook-test link-1_7 ] [ quickbook-error-test link-1_7-fail ] + [ quickbook-error-test link-1_7-fail2 ] [ quickbook-test list_test-1_5 ] [ quickbook-test list_test-1_6 ] [ quickbook-error-test list_test-1_6-fail ] diff --git a/test/include/source_mode-1_5.gold b/test/include/source_mode-1_5.gold index 4fbee6f..2ed6b7f 100644 --- a/test/include/source_mode-1_5.gold +++ b/test/include/source_mode-1_5.gold @@ -4,4 +4,6 @@ xmlns:xi="http://www.w3.org/2001/XInclude"> Souce Mode Include void main() {} +void main() {} +
diff --git a/test/include/source_mode-1_5.quickbook b/test/include/source_mode-1_5.quickbook index 9700cd1..d5df05b 100644 --- a/test/include/source_mode-1_5.quickbook +++ b/test/include/source_mode-1_5.quickbook @@ -1,3 +1,4 @@ [article Souce Mode Include [source-mode teletype][quickbook 1.5]] -[include source_mode-inc1.quickbook] \ No newline at end of file +[include source_mode-inc1.quickbook] +[include source_mode-inc2.quickbook] diff --git a/test/include/source_mode-1_6.gold b/test/include/source_mode-1_6.gold index 6d20203..aa01d20 100644 --- a/test/include/source_mode-1_6.gold +++ b/test/include/source_mode-1_6.gold @@ -8,4 +8,6 @@ Source include with no source-mode void main() {} +void main() {} + diff --git a/test/include/source_mode-1_6.quickbook b/test/include/source_mode-1_6.quickbook index 77ccae4..fc4243f 100644 --- a/test/include/source_mode-1_6.quickbook +++ b/test/include/source_mode-1_6.quickbook @@ -1,4 +1,5 @@ [source-mode teletype][quickbook 1.6] [article Souce Mode Include] -[include source_mode-inc1.quickbook] \ No newline at end of file +[include source_mode-inc1.quickbook] +[include source_mode-inc2.quickbook] diff --git a/test/include/source_mode-inc2.quickbook b/test/include/source_mode-inc2.quickbook new file mode 100644 index 0000000..81dba8a --- /dev/null +++ b/test/include/source_mode-inc2.quickbook @@ -0,0 +1,3 @@ +[/ Source include with no source-mode, and no docinfo.] + + void main() {} diff --git a/test/link-1_7-fail2.quickbook b/test/link-1_7-fail2.quickbook new file mode 100644 index 0000000..30ac495 --- /dev/null +++ b/test/link-1_7-fail2.quickbook @@ -0,0 +1,6 @@ +[article Link fail test +[quickbook 1.7] +] + +[/ Escapes aren't allowed in links.] +[link '''escaped stuff'''] From 2cba84f33f5f5e73f5111d3c0f7c5666c8742c2e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 8 Oct 2013 20:24:11 +0000 Subject: [PATCH 91/94] Merge removal of quickbook 1.6 warning. I forgot to check this in to trunk, and then accidentally included it with some circular buffer changes which is why the history is a little odd. [SVN r86208] --- src/doc_info_actions.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/doc_info_actions.cpp b/src/doc_info_actions.cpp index 30e80a5..64f9317 100644 --- a/src/doc_info_actions.cpp +++ b/src/doc_info_actions.cpp @@ -217,12 +217,6 @@ namespace quickbook << " is still under development and is " "likely to change in the future." << std::endl; } - else if (new_version >= 106u) - { - detail::outwarn(state.current_file->path) - << "Quickbook " << (new_version / 100) << "." << (new_version % 100) - << " is in alpha." << std::endl; - } } if (new_version) { From 11cc9932ab714153667a19407d43e47e039d5090 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 17 Nov 2013 11:04:36 +0000 Subject: [PATCH 92/94] Merge documentation and version changes. Which really should have been merged before the release. [SVN r86738] --- doc/change_log.qbk | 2 +- doc/phrase.qbk | 40 +++++++++++++++++++++++++--------------- src/quickbook.cpp | 2 +- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/doc/change_log.qbk b/doc/change_log.qbk index b80a686..8eec6fd 100644 --- a/doc/change_log.qbk +++ b/doc/change_log.qbk @@ -297,7 +297,7 @@ Boost 1.46.1: * Clean up the source map implementation (used to get the correct location for error messages in things like templates and snippets). -[heading Version 1.6.0 beta 1 - Boost 1.55 beta] +[heading Version 1.6.0 - Boost 1.55] * Remove nested blocks in lists from 1.6, move to 1.7. (Can still nest block elements in lists though). diff --git a/doc/phrase.qbk b/doc/phrase.qbk index 9c26d42..2cdf57b 100644 --- a/doc/phrase.qbk +++ b/doc/phrase.qbk @@ -168,26 +168,36 @@ And one for the little boy who lives down the lane. [#quickbook.ref.role] [section:role Role] -Sometime the basic formatting options aren't enough, and you wish -to use CSS to style the generated html. For these cases you can -use the `role` phase element. For example: +This generates a docbook phrase with a `role` attribute, which can be used +to classify the phrase. This can be used to mark text for a use that isn't +covered elsewhere. The docbook `role` will generate a html class, which can +be used to style text. And the xsl stylesheets can be customized to treat +certain roles specially when generating pdfs. + +The boostbook css stylesheets, and xsl stylesheets +contain support for a limited number of colours that can be used with +`role`. For example if you write: [role red Text content] -Will generate the docbook: +You'll get red text if you're using the boostbook css (for html) or +the boostbook xsl for generating pdfs. - Text content +The full list of colours that will be available is: -Which will generate html along the lines of: - - Text content - -And then you can use css to style this however you wish. - -[note When generating other formats such as pdfs, your css is not going to - apply, so this will appear as normal, unstyled text. The docbook - =role= attribute is meant to be used as a more general mechanism, so - you might be able to take advantage of it by some other means.] +* [role red red] +* [role green green] +* [role lime lime] +* [role blue blue] +* [role navy navy] +* [role yellow yellow] +* [role magenta magenta] +* [role indigo indigo] +* [role cyan cyan] +* [role purple purple] +* [role gold gold] +* [role silver silver] +* [role gray gray] [endsect] [/role] diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 8902d88..1a52806 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -40,7 +40,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.6.0 beta 1" +#define QUICKBOOK_VERSION "Quickbook Version 1.6.0" namespace quickbook { From 6cacc8bfe4d5ee53d3503ed9be04d3b1ffb7352a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 5 Dec 2013 00:32:06 +0000 Subject: [PATCH 93/94] Update version. --- src/quickbook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quickbook.cpp b/src/quickbook.cpp index bfc1852..8db8ec9 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -40,7 +40,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.6.1 dev" +#define QUICKBOOK_VERSION "Quickbook Version 1.6.1 alpha 1" namespace quickbook { From 3fffd6da9e114883177da48f1613233cf4989853 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 13 Jul 2014 13:40:18 +0100 Subject: [PATCH 94/94] Update version for beta. --- src/quickbook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 390986e..19df096 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -40,7 +40,7 @@ #pragma warning(disable:4355) #endif -#define QUICKBOOK_VERSION "Quickbook Version 1.6.1 alpha 2" +#define QUICKBOOK_VERSION "Quickbook Version 1.6.1 beta 1" namespace quickbook {