Builder API

課題

もっと拡張すること。

class sphinx.builders.Builder[ソース]

このクラスはすべてのビルダーのベースクラスです。

These attributes should be set on builder classes:

name = ''

The builder's name, for the -b command line option.

format = ''

The builder's output format, or '' if no document output is produced.

epilog = ''

The message emitted upon successful build completion. This can be a printf-style template string with the following keys: outdir, project

allow_parallel = False

allow parallel write_doc() calls

supported_image_types: list[str] = []

The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.

supported_remote_images = False

The builder supports remote images or not.

supported_data_uri_images = False

The builder supports data URIs or not.

default_translator_class: type[nodes.NodeVisitor]

default translator class for the builder. This can be overridden by set_translator().

これらのメソッドは事前に定義されており、アプリケーションから呼び出されます。

get_relative_uri(from_: str, to: str, typ: str | None = None) str[ソース]

2つのソースファイル間の相対URIを返します。

URIを返す方法がない場合には、 environment.NoUri 例外を投げる場合があります。

build_all() None[ソース]

すべてのソースファイルをビルドします。

build_specific(filenames: list[str]) None[ソース]

filenames に含まれる、変更が必要なものだけ再ビルドします。

build_update() None[ソース]

最後のビルドの後に変更されたり、追加されたものだけ再ビルドします。

build(docnames: Iterable[str] | None, summary: str | None = None, method: str = 'update') None[ソース]

メインのビルド用メソッドです。

First updates the environment, and then calls write().

これらのメソッドは派生されたビルダークラス側でオーバーライドできます:

init() None[ソース]

必要なテンプレートをロードしたり、初期化を行うためのメソッドです。 デフォルトの実装では、何も行いません。

get_outdated_docs() str | Iterable[str][ソース]

ビルドが必要な、古いファイルを返すイテレータを返します。言い換えると、アップデートビルドを行うと、何がビルドされるか、というのを説明する文字列を返します。

もしもビルダーがソースファイルに関連する、個別のファイルを出力しない場合には、ここでは文字列を返してください。その場合には、書かれるべきファイルのイテレータを返します。

get_target_uri(docname: str, typ: str | None = None) str[ソース]

ドキュメント名に関連する、対象のURLを返します。

typ はそれぞれのビルダーごとのリンクの修飾子として使うことができます。

prepare_writing(docnames: set[str]) None[ソース]

write_doc() が実行される前に実行したい動作を記述する場所です。

write_doc(docname: str, doctree: document) None[ソース]

ファイルシステムに実際になにかを書き込む際に使う場所です。

finish() None[ソース]

ビルドプロセスの終了です。

デフォルトの実装では何も呼び出されません。

属性

events

EventManager オブジェクト。