Guidedog 설명서 1.0.0-beta.16
언어
이 페이지의 내용
Guidedog / 문서 1.0.0-beta.16

작은 책 만들기

웹사이트는 서로 연결된 페이지의 그물입니다. 독자는 어떤 순서로든 둘러봅니다. 책에는 의도한 읽기 순서가 필요하고, 장 번호와 머리글, 앞부분 구성도 갖춰야 합니다.

Guidedog에서는 목차 지시문(toctree)이 두 형식을 모두 담당합니다. toctree 하나로 문서를 웹에서는 사이드바 트리로, PDF 책에서는 장의 순서로 구성합니다.

루트 toctree가 웹에서는 사이드바와 탐색 경로, 인쇄에서는 번호 있는 장으로 나타납니다.
그림 4 하나의 toctree가 웹 탐색과 책의 장 순서를 함께 만듭니다.

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:에 주목하세요. 레이블은 상호 참조 대상을 만듭니다. 웹에서도 인쇄본에서도 똑같이 동작합니다.

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 엔진이 내장되어 있습니다. 웹 페이지용으로는 SVG, 인쇄용으로는 PDF 도면으로 벡터 다이어그램을 그립니다. 외부 렌더러는 필요 없습니다.

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. 다음 단계

이제 소스 하나로 두 가지 출력을 만드는 방법을 알았습니다. 주제 안내 절에서는 더 깊이 다룹니다.