全般の設定
book.tomlファイルで、本のパラメーターを設定できます。
book.tomlファイルの例を示します。
[book]
title = "Example book"
authors = ["John Doe"]
description = "The example book covers examples."
[rust]
edition = "2018"
[build]
build-dir = "my-example-book"
create-missing = false
[preprocessor.index]
[preprocessor.links]
[output.html]
additional-css = ["custom.css"]
[output.html.search]
limit-results = 15
対応する設定項目
設定で指定したすべての相対パスは、常に設定ファイルが置かれている本のルートを基準に解釈されることに注意してください。
一般的なメタデータ
本についての一般的な情報です。
- title: 本のタイトル
- authors: 本の著者
- description: 本の説明。各ページのHTMLの
<head>へ、メタ情報として追加されます。 - src: 既定では、ソースディレクトリはルートフォルダー直下の
srcというディレクトリです。設定ファイルのsrcキーで変更できます。 - language: 本の主要な言語。たとえば
<html lang="en">のように、言語属性として使われます。本の文字の向き(RTL、LTR)の決定にも使われます。 - text-direction:本の文字の向き。左から右(LTR)または右から左(RTL)です。指定できる値は
ltr、rtlです。省略すると、本のlanguage属性から決定します。
book.toml
[book]
title = "Example book"
authors = ["John Doe", "Jane Doe"]
description = "The example book covers examples."
src = "my-src" # the source files will be found in `root/my-src` instead of `root/src`
language = "en"
text-direction = "ltr"
Rustの設定
Rust言語の設定です。テストの実行やplaygroundとの連携に関係します。
[rust]
edition = "2015" # the default edition for code blocks
-
edition:コードで既定として使うRustのエディションです。既定は
"2015"です。個々のコードブロックには、次のようにedition2015、edition2018、edition2021、edition2024の注釈を付けて指定できます。```rust,edition2015 // This only works in 2015. let try = true; ```
ビルドの設定
本のビルド処理を制御します。
[build]
build-dir = "book" # the directory where the output is placed
create-missing = true # whether or not to create missing pages
use-default-preprocessors = true # use the default preprocessors
extra-watch-dirs = [] # directories to watch for triggering builds
-
build-dir: 生成した本を出力するディレクトリです。既定は、本のルートにある
book/です。CLIオプション--dest-dirで上書きできます。 -
create-missing: 既定では、
SUMMARY.mdで指定したファイルがない場合、本のビルド時に作成します(create-missing = true)。falseなら、ファイルが存在しない場合はビルド処理がエラーで終了します。 -
use-default-preprocessors:
falseにすると、既定のプリプロセッサー(linksとindex)を無効にします。同じプリプロセッサーや、ほかのプリプロセッサーを設定テーブルで宣言している場合は、そちらが実行されます。
- 明確にすると、プリプロセッサーの設定がない場合は、既定の
linksとindexを実行します。 use-default-preprocessors = falseにすると、これらの既定のプリプロセッサーを実行しません。- たとえば
[preprocessor.links]を追加すると、use-default-preprocessorsの値にかかわらず、linksを実行します。
- 明確にすると、プリプロセッサーの設定がない場合は、既定の
-
extra-watch-dirs:
watchとserveコマンドで監視するディレクトリのパスのリストです。これらのディレクトリ内でファイルを変更すると、再ビルドが起動します。本がsrcディレクトリ外のファイルに依存している場合に便利です。