Boost C++ Libraries

PrevUpHomeNext

Include

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

[include someother.qbk]

In quickbook 1.6 and later, if the included file has a 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:

[Note] 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 import instead.

The [include] directive lets you specify a document id to use for the included file. 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].

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 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 <iostream>
//]

//[hello_main
int main() {
    std::cout << "Hello, trivial example" << std::endl;
}
//]

It will generate:

First include the appropriate header:

    #include <iostream>

Then write your main function:

    int main() {
        std::cout << "Hello, trivial example" << std::endl;
    }

PrevUpHomeNext