sphinx.ext.graphviz
-- Graphvizのグラフを追加¶
Added in version 0.6.
この拡張モジュールを使用すると、 Graphviz のグラフをドキュメント内に埋め込むことができるようになります。
この拡張モジュールは以下のディレクティブを提供します:
- .. graphviz::¶
Graphvizのコードをドキュメント内に直接記述するためのディレクティブです。 ここでコンテンツとして入力された内容は、
dot
コマンドで処理されます。 例:.. graphviz:: digraph foo { "bar" -> "baz"; }
HTML出力されるときには、PNGのイメージファイルや、SVGイメージとしてレンダリングされます。 LaTeX出力時にはこのコードは埋め込み可能なPDFファイルとしてレンダリングされます。(
graphviz_output_format
を参照してください。)graphviz
ディレクティブの引数にファイル名を与えて、コンテンツを空にすることで、外部のdotファイルを埋め込むこともできます:.. graphviz:: external.dot
Sphinx内の他のファイル参照と同様に、絶対パスのファイル名はソースディレクトリからの相対パスとして扱われます。
バージョン 1.1 で変更: 外部ファイルのサポートを追加。
options
- :alt: alternate text (text)¶
The alternate text of the graph. By default, the graph code is used to the alternate text.
Added in version 1.0.
- :align: alignment of the graph (left, center or right)¶
The horizontal alignment of the graph.
Added in version 1.5.
- :caption: caption of the graph (text)¶
The caption of the graph.
Added in version 1.1.
- :layout: layout type of the graph (text)¶
The layout of the graph (e.g.
dot
,neato
and so on). A path to the graphviz commands are also allowed. By default,graphviz_dot
is used.Added in version 1.4.
バージョン 2.2 で変更: Renamed from
graphviz_dot
- :name: label (text)¶
The label of the graph.
Added in version 1.6.
- :class: class names (a list of class names separated by spaces)¶
The class name of the graph.
Added in version 2.4.
- .. graph::¶
無向グラフをひとつ埋め込むのに使用するディレクティブです。 グラフの名前はディレクティブ引数として渡します。ディレクティブのコンテンツがそのままグラフ作成に使用されます。 このディレクティブは
graph <名前> { <コンテンツ> }
というグラフを作成するための便利機能です。例えば:
.. graph:: foo "bar" -- "baz";
注釈
グラフの名前はそのままGraphvizに渡されます。名前に英数字でないもの(例えば、ダッシュ記号)が含まれているなら、それをダブルクオートで囲まなければならないでしょう。
options
Same as
graphviz
.- :alt: alternate text (text)¶
Added in version 1.0.
- :align: alignment of the graph (left, center or right)¶
Added in version 1.5.
- :caption: caption of the graph (text)¶
Added in version 1.1.
- :layout: layout type of the graph (text)¶
Added in version 1.4.
バージョン 2.2 で変更: Renamed from
graphviz_dot
- :name: label (text)¶
Added in version 1.6.
- :class: class names (a list of class names separated by spaces)¶
The class name of the graph.
Added in version 2.4.
- .. digraph::¶
有向グラフをひとつ埋め込むために使用するディレクティブです。 グラフの名前はディレクティブ引数として渡します。ディレクティブのコンテンツがそのままグラフ作成に使用されます。 このディレクティブは
digraph <名前> { <コンテンツ> }
というグラフを作成するための便利機能です。例えば:
.. digraph:: foo "bar" -> "baz" -> "quux";
options
Same as
graphviz
.- :alt: alternate text (text)¶
Added in version 1.0.
- :align: alignment of the graph (left, center or right)¶
Added in version 1.5.
- :caption: caption of the graph (text)¶
Added in version 1.1.
- :layout: layout type of the graph (text)¶
Added in version 1.4.
バージョン 2.2 で変更: Renamed from
graphviz_dot
- :name: label (text)¶
Added in version 1.6.
- :class: class names (a list of class names separated by spaces)¶
The class name of the graph.
Added in version 2.4.
There are also these config values:
- graphviz_dot¶
- Type:
str
- Default:
'dot'
The command name with which to invoke
dot
. You may need to set this to a full path ifdot
is not in the executable search path.この設定はシステム間で共通にはできないため、
conf.py
の中で設定することは通常行いません。むしろ、次のように sphinx-build コマンドの-D
オプションとして与えるほうが望ましいでしょう。sphinx-build -M html -D graphviz_dot=C:\graphviz\bin\dot.exe . _build
- graphviz_dot_args¶
- Type:
Sequence[str]
- Default:
()
Additional command-line arguments to give to dot, as a list. This is the right place to set global graph, node or edge attributes via dot's
-G
,-N
and-E
options.
- graphviz_output_format¶
- Type:
'png' | 'svg'
- Default:
'png'
The output format for Graphviz when building HTML files. This must be either
'png'
or'svg'
. If'svg'
is used, in order to make the URL links work properly, an appropriatetarget
attribute must be set, such as"_top"
and"_blank"
. For example, the link in the following graph should work in the svg output:.. graphviz:: digraph example { a [label="sphinx", href="https://www.sphinx-doc.org/", target="_top"]; b [label="other"]; a -> b; }
Added in version 1.0: 以前は出力はPNGしかありませんでした。