Debian Codegraph @

guide/src/format/configuration/general.md

raw
1 # General configuration
2
3 You can configure the parameters for your book in the ***book.toml*** file.
4
5 Here is an example of what a ***book.toml*** file might look like:
6
7 ```toml
8 [book]
9 title = "Example book"
10 authors = ["John Doe"]
11 description = "The example book covers examples."
12
13 [rust]
14 edition = "2018"
15
16 [build]
17 build-dir = "my-example-book"
18 create-missing = false
19
20 [preprocessor.index]
21
22 [preprocessor.links]
23
24 [output.html]
25 additional-css = ["custom.css"]
26
27 [output.html.search]
28 limit-results = 15
29 ```
30
31 ## Supported configuration options
32
33 It is important to note that **any** relative path specified in the
34 configuration will always be taken relative from the root of the book where the
35 configuration file is located.
36
37 ### General metadata
38
39 This is general information about your book.
40
41 - **title:** The title of the book
42 - **authors:** The author(s) of the book
43 - **description:** A description for the book, which is added as meta
44 information in the html `<head>` of each page
45 - **src:** By default, the source directory is found in the directory named
46 `src` directly under the root folder. But this is configurable with the `src`
47 key in the configuration file.
48 - **language:** The main language of the book, which is used as a language attribute `<html lang="en">` for example.
49 This is also used to derive the direction of text (RTL, LTR) within the book.
50 - **text-direction**: The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL). Possible values: `ltr`, `rtl`.
51 When not specified, the text direction is derived from the book's `language` attribute.
52
53 **book.toml**
54 ```toml
55 [book]
56 title = "Example book"
57 authors = ["John Doe", "Jane Doe"]
58 description = "The example book covers examples."
59 src = "my-src" # the source files will be found in `root/my-src` instead of `root/src`
60 language = "en"
61 text-direction = "ltr"
62 ```
63
64 ### Rust options
65
66 Options for the Rust language, relevant to running tests and playground
67 integration.
68
69 ```toml
70 [rust]
71 edition = "2015" # the default edition for code blocks
72 ```
73
74 - **edition**: Rust edition to use by default for the code snippets. Default
75 is `"2015"`. Individual code blocks can be controlled with the `edition2015`,
76 `edition2018`, `edition2021` or `edition2024` annotations, such as:
77
78 ~~~text
79 ```rust,edition2015
80 // This only works in 2015.
81 let try = true;
82 ```
83 ~~~
84
85 ### Build options
86
87 This controls the build process of your book.
88
89 ```toml
90 [build]
91 build-dir = "book" # the directory where the output is placed
92 create-missing = true # whether or not to create missing pages
93 use-default-preprocessors = true # use the default preprocessors
94 extra-watch-dirs = [] # directories to watch for triggering builds
95 ```
96
97 - **build-dir:** The directory to put the rendered book in. By default this is
98 `book/` in the book's root directory.
99 This can overridden with the `--dest-dir` CLI option.
100 - **create-missing:** By default, any missing files specified in `SUMMARY.md`
101 will be created when the book is built (i.e. `create-missing = true`). If this
102 is `false` then the build process will instead exit with an error if any files
103 do not exist.
104 - **use-default-preprocessors:** Disable the default preprocessors (of `links` &
105 `index`) by setting this option to `false`.
106
107 If you have the same, and/or other preprocessors declared via their table
108 of configuration, they will run instead.
109
110 - For clarity, with no preprocessor configuration, the default `links` and
111 `index` will run.
112 - Setting `use-default-preprocessors = false` will disable these
113 default preprocessors from running.
114 - Adding `[preprocessor.links]`, for example, will ensure, regardless of
115 `use-default-preprocessors` that `links` it will run.
116 - **extra-watch-dirs**: A list of paths to directories that will be watched in
117 the `watch` and `serve` commands. Changes to files under these directories will
118 trigger rebuilds. Useful if your book depends on files outside its `src` directory.