Guidedog マニュアル 0.6.3
言語
このページの内容
Guidedog / ドキュメント 0.6.3

小さな本を作る

Web はリンクをたどって読むものです。書籍には順序、章番号、柱、前付けが必要です。

toctree が両者をつなぎます。同じ目次が Web の階層案内と PDF の章順を定めます。

ルートの toctree は Web のサイドバーとパンくず、印刷の番号付き章に反映されます。
図 4 1 つの toctree から Web の案内と書籍の章順を作ります。

1. 章を追加する

notes に measurement.rst を作ります。

リスト 1 notes/measurement.rst
Measurement
===========

A scientific measurement consists of a numerical magnitude and an explicit unit.
Always report both. A bare number leaves the reader guessing.

.. _measurement-units:

Units of measurement
--------------------

Maintain a single, consistent unit system within every comparison.

When working with the International System of Units (SI):

* Length is expressed in meters (m).
* Mass is expressed in kilograms (kg).
* Time is expressed in seconds (s).

Prefixes scale units by powers of ten, simplifying very large or small values.

見出しの直前の .. _measurement-units: が参照先を定義します。Web と書籍のどちらでも使えます。

2. 読む順序を決める

notes/index.rst を開き、目次を書きます。

リスト 2 notes/index.rst
Field Notes
===========

These notes explain how to perform reliable physical measurements and document
them clearly.

.. toctree::
   :maxdepth: 2
   :numbered:

   measurement

Next steps:

* Begin with :doc:`measurement`.
* Review the standard unit conventions in :ref:`measurement-units`.

toctree のオプション:

  • :maxdepth: 2 は目次に載せる下位見出しの深さです。
  • :numbered: は「1. Measurement」「1.1 Units of measurement」のような階層番号を付けます。
  • measurement は拡張子 .rst を省いた文書名です。

相互参照の書き方:

  • :doc:`measurement` はパスで章へリンクします。
  • :ref:`measurement-units` はラベルへリンクします。PDF は節名を使い、テンプレートの page-ref でページ番号も加えられます。動作例は プロジェクトのテーマを作る を参照してください。

3. Graphviz の図を加える

Guidedog は Graphviz をネイティブに組み込み、Web 用 SVG と印刷用のベクター図を作ります。別のブラウザーレンダラーは要りません。

notes/measurement.rst に追加します。

Comparison workflow
-------------------

Before comparing two experimental values, convert both to a shared base unit:

.. graphviz::
   :class: graphviz-adaptive
   :caption: Converting values to a common base unit before comparison.
   :alt: Raw experimental values are converted to a shared unit before comparison.

   digraph comparison {
     graph [rankdir=LR, bgcolor="transparent", pad="0.2"];
     node [shape=box, style="rounded,filled", fillcolor="#edf5f2",
           color="#216553", fontname="Helvetica", fontcolor="#16382f", fontsize=12];
     edge [color="#216553"];

     "Raw values" -> "Unit conversion" -> "Common unit" -> "Comparison";
   }

:caption: は図の説明です。番号は notes/conf.toml の numfig = true で有効にします。:alt: はスクリーンリーダー用の代替テキストです。

4. 書籍をビルドして調べる

再ビルドします。

guidedog build html notes -W
guidedog build pdf notes -W

両方の結果を確認します。

  • HTML: notes/_build/html/index.html を開くと番号付きの章階層があります。「1. Measurement」を選び、パンくずと SVG を確認します。
  • PDF: notes/_build/pdf/field-notes-en.pdf を開きます。目次は章とページを示し、図はベクターのまま、文書参照は対象へリンクします。

5. 次に進む

両形式の仕組みが分かったら、次の話題へ進みましょう。