Guidedog マニュアル 1.0.0-beta.16
言語
このページの内容
Guidedog / ドキュメント 1.0.0-beta.16

ドメイン

ドメインは、ディレクティブとロールの集まりです。一つのプログラミング言語や一つの分野のオブジェクトを記述し、相互参照するために使います。

Guidedog は、Sphinx の標準ドメインを組み込みで実装しています。

  • 標準ドメイン(std): コマンドラインオプション、環境変数、用語、UI ラベルなどの汎用ドキュメントオブジェクト。
  • Python ドメイン(py): Python のモジュール、クラス、関数、メソッド、属性、プロパティ、例外。
  • C ドメイン(c): C の関数、型、構造体、共用体、列挙型、列挙子、変数、マクロ。
  • C++ ドメイン(cpp): C++ のクラス、コンセプト、テンプレート、名前空間、メソッド、式。
  • JavaScript ドメイン(js): JavaScript の関数、メソッド、クラス、プロパティ。
  • Odin ドメイン(odin): Odin のパッケージ、プロシージャー、構造体、共用体、列挙型(Odin の文書化 を参照)。
  • Rust ドメイン(rust): Rust のクレート、モジュール、関数、構造体、列挙型、トレイト、impl、マクロ(下記の Rust ドメイン を参照)。

主ドメインの設定

既定のドメインは conf.toml の primary_domain で設定します。初期値は "py" です。指定後は接頭辞を省略でき、.. py:function:: を .. function::、:py:func:`name` を :func:`name` と書けます。

一つの文書の中だけで、使用中のドメインを切り替えるには次のようにします。

.. default-domain:: c

標準ドメイン

標準ドメインはコマンドラインツール、環境変数、文書参照を扱います。

ディレクティブ

.. program:: mytool

.. option:: -c <config>, --config <config>

   Path to the configuration file.

.. envvar:: GUIDEDOG_THEME

   Specifies the default theme stylesheet.

ロール

  • :doc:`path`: 相対パスでプロジェクト内の文書へリンクします。
  • :ref:`label`: 明示的なラベル .. _label: にリンクします。
  • :term:`term`: glossary で定義した用語へリンクします。
  • :option:`--config`: option で記述したコマンドラインオプションにリンクします。
  • :envvar:`VARIABLE`: envvar で記述した環境変数にリンクします。
  • :command:`name`: システムコマンド名を示します。
  • :file:`path`: ファイルやディレクトリのパスを示します。{variable} も使えます。
  • :kbd:`Ctrl+C`: キー操作を示します。
  • :menuselection:`File --> Save As`: メニューの操作順を示します。
  • :guilabel:`Submit`: ボタンや UI 要素を示します。
  • :pep:`8`: Python Enhancement Proposal にリンクします。
  • :rfc:`7231`: IETF の RFC にリンクします。

Python ドメイン

Python ドメインは Python のインターフェースとシグネチャを記述します。

ディレクティブ

.. py:module:: pipeline.reader
   :synopsis: Document reading and normalization.

.. py:class:: DocumentReader(source_path: str, encoding: str = "utf-8")

   Base class for document readers.

   .. py:method:: parse(content: bytes) -> Document

      Parses raw bytes into a document tree.

      :param content: Raw source content bytes.
      :return: Parsed document tree instance.
      :raises ValueError: If the source format is unrecognized.

   .. py:attribute:: encoding
      :type: str

      The character encoding used for text decoding.

対応するディレクティブ: py:module、py:currentmodule、py:function、py:data、py:class、py:method、py:staticmethod、py:classmethod、py:attribute、py:property、py:exception、py:decorator、py:type。

ロール

  • :py:func:`name`: Python 関数にリンクします。
  • :py:class:`name`: Python クラスにリンクします。
  • :py:meth:`name`: Python のクラスメソッドまたはインスタンスメソッドにリンクします。
  • :py:attr:`name`: Python 属性にリンクします。
  • :py:data:`name`: Python のモジュールレベルのデータにリンクします。
  • :py:exc:`name`: Python の例外クラスにリンクします。
  • :py:mod:`name`: Python モジュールにリンクします。

C ドメイン

C ドメインは C のライブラリとヘッダーファイルを記述します。

ディレクティブ

.. c:namespace:: gd

.. c:struct:: Workspace

   Reusable conversion state; its buffers are kept between conversions.

   .. c:member:: size_t capacity

      Total byte size of the output buffer.

.. c:function:: int gd_convert(Workspace *ws, const char *input, char *output, size_t out_len)

   Converts source text into HTML.

   :param ws: Pointer to the initialized workspace.
   :param input: Null-terminated input string.
   :param output: Destination buffer.
   :param out_len: Size of destination buffer.
   :returns: 0 on success, or an error code.

ロール

  • :c:func:`name`: C 関数にリンクします。
  • :c:member:`name`: C の構造体または共用体のメンバーにリンクします。
  • :c:data:`name` / :c:var:`name`: C 変数にリンクします。
  • :c:type:`name`: C の typedef または型にリンクします。
  • :c:struct:`name`: C 構造体にリンクします。
  • :c:union:`name`: C 共用体にリンクします。
  • :c:enum:`name`: C 列挙型にリンクします。
  • :c:macro:`name`: C のプリプロセッサーマクロにリンクします。

C++ ドメイン

C++ ドメインは現代の C++ の構文、コンセプト、名前空間、スコープを扱います。

ディレクティブ

.. cpp:namespace:: guidedog

.. cpp:concept:: template<typename T> Reader

   Specifies requirements for document reader types.

.. cpp:class:: template<typename Allocator> Builder

   Constructs AST document nodes.

   .. cpp:function:: NodeId add_text(std::string_view text)

      Appends text to the active node.

ロール

  • :cpp:class:`name`: C++ のクラスまたは構造体にリンクします。
  • :cpp:func:`name`: C++ の関数またはメソッドにリンクします。
  • :cpp:member:`name` / :cpp:var:`name`: メンバーまたは変数にリンクします。
  • :cpp:type:`name`: C++ の型エイリアスまたは typedef にリンクします。
  • :cpp:concept:`name`: C++20 のコンセプトにリンクします。
  • :cpp:enum:`name`: C++ の列挙型にリンクします。

JavaScript ドメイン

JavaScript ドメインはブラウザースクリプト、ライブラリ、Node.js モジュールを記述します。

ディレクティブ

.. js:module:: theme

.. js:class:: ThemeController(options)

   Manages color themes and local storage persistence.

   .. js:method:: toggleTheme()

      Toggles between light and dark modes.

ロール

  • :js:func:`name`: JavaScript 関数にリンクします。
  • :js:meth:`name`: JavaScript メソッドにリンクします。
  • :js:class:`name`: JavaScript クラスにリンクします。
  • :js:data:`name`: JavaScript 変数にリンクします。
  • :js:attr:`name`: JavaScript オブジェクトの属性にリンクします。
  • :js:mod:`name`: JavaScript モジュールにリンクします。

Rust ドメイン

Rust ドメインは、rustdoc と同じ形でクレートを記述します。各ディレクティブは、Rust で書くとおりの宣言を可視性や修飾子も含めて一行で受け取ります。ターゲットは :: で区切ったフルパスで、先頭はクレート名です。

ディレクティブ

.. rust:module:: my_crate::geometry
   :synopsis: Points and shapes.

.. rust:struct:: pub struct Point<T = f32>

   A point in the plane.

   .. rust:field:: pub x: T

      The horizontal coordinate.

   .. rust:impl:: impl<T: Copy> Point<T>

      .. rust:method:: pub fn new(x: T, y: T) -> Self

         Makes a point.

.. rust:enum:: pub enum Shape

   .. rust:variant:: Circle(f32)

.. rust:trait:: pub trait Draw: Clone + Send

   .. rust:method:: fn draw(&self) -> u8
      :provided:

ディレクティブには rust:crate、rust:module、rust:function、rust:method、rust:struct、rust:enum、rust:variant、rust:union、rust:trait、rust:impl、rust:type、rust:const、rust:static、rust:macro、rust:field、rust:associatedtype、rust:associatedconst、rust:use があります。オプションには :visibility:、:cfg:、:unsafe:、:async:、:const:、:provided:、:attributes:、:deprecated:、:for:、:trait:、:target:、:noindex: があります。impl 自体がターゲットになることはなく、そのメンバーは対象の型に属します。

Guidedog は、クレートのソースからコンパイルせずにこれらのページを生成することもできます。コードベースの文書化 と、設定リファレンス の rust_autoapi_crates を参照してください。

ロール

  • :rust:mod:`path`: クレートまたはモジュールにリンクします。
  • :rust:fn:`path`: 関数またはメソッドにリンクします。
  • :rust:struct:`path`、:rust:enum:`path`、:rust:union:`path`、:rust:trait:`path`: それぞれの型にリンクします。
  • :rust:variant:`path`、:rust:field:`path`: バリアントまたはフィールドにリンクします。
  • :rust:type:`path`、:rust:const:`path`、:rust:static:`path`、:rust:macro:`path`: 型エイリアスと関連型、定数、static、マクロにリンクします。
  • :rust:any:`path`: 上記のいずれか、またはインベントリを通じて他のプロジェクト(std::vec::Vec)にリンクします。解決できないターゲットはコードとして表示します。

相互参照の規則

ドメインの相互参照では、次の修飾子が使えます。

  • 接頭辞を隠す: ターゲットの前にチルダ(~)を付けると、名前の末尾要素だけを表示します。たとえば :py:func:`~pipeline.reader.DocumentReader.parse` は parse() と表示されます。
  • 現在のスコープ解決: 相対参照は、まず現在のモジュールや名前空間を検索し、見つからなければ全体にフォールバックします。
  • 完全一致: 先頭にドット(.)を付けると、現在のモジュールまたは包含オブジェクトから検索します。

Rust ドメインも :: のパスで同じ規則に従います。:rust:struct:`~my_crate::geometry::Point` は Point と表示されます。