| 1 |
Build environment API |
| 2 |
===================== |
| 3 |
|
| 4 |
.. module:: sphinx.environment |
| 5 |
|
| 6 |
.. class:: BuildEnvironment |
| 7 |
|
| 8 |
**Attributes** |
| 9 |
|
| 10 |
.. attribute:: app |
| 11 |
|
| 12 |
Reference to the :class:`.Sphinx` (application) object. |
| 13 |
|
| 14 |
.. attribute:: config |
| 15 |
|
| 16 |
Reference to the :class:`.Config` object. |
| 17 |
|
| 18 |
.. attribute:: project |
| 19 |
|
| 20 |
Target project. See :class:`.Project`. |
| 21 |
|
| 22 |
.. attribute:: srcdir |
| 23 |
|
| 24 |
Source directory. |
| 25 |
|
| 26 |
.. attribute:: doctreedir |
| 27 |
|
| 28 |
Directory for storing pickled doctrees. |
| 29 |
|
| 30 |
.. attribute:: events |
| 31 |
|
| 32 |
An :class:`.EventManager` object. |
| 33 |
|
| 34 |
.. attribute:: found_docs |
| 35 |
|
| 36 |
A set of all existing docnames. |
| 37 |
|
| 38 |
.. attribute:: metadata |
| 39 |
|
| 40 |
Dictionary mapping docnames to "metadata" (see :ref:`metadata`). |
| 41 |
|
| 42 |
.. attribute:: titles |
| 43 |
|
| 44 |
Dictionary mapping docnames to the docutils node for their main title. |
| 45 |
|
| 46 |
.. autoattribute:: docname |
| 47 |
|
| 48 |
.. autoattribute:: parser |
| 49 |
|
| 50 |
**Per-document attributes** |
| 51 |
|
| 52 |
.. attribute:: current_document |
| 53 |
|
| 54 |
Temporary data storage while reading a document. |
| 55 |
|
| 56 |
Extensions may use the mapping interface provided by |
| 57 |
``env.current_document`` to store data relating to the current document, |
| 58 |
but should use a unique prefix to avoid name clashes. |
| 59 |
|
| 60 |
.. important:: |
| 61 |
Only the following attributes constitute the public API. |
| 62 |
The type itself and any methods or other attributes remain private, |
| 63 |
experimental, and will be changed or removed without notice. |
| 64 |
|
| 65 |
.. attribute:: current_document.docname |
| 66 |
:type: str |
| 67 |
|
| 68 |
The document name ('docname') for the current document. |
| 69 |
|
| 70 |
.. attribute:: current_document.default_role |
| 71 |
:type: str |
| 72 |
|
| 73 |
The default role for the current document. |
| 74 |
Set by the :dudir:`default-role` directive. |
| 75 |
|
| 76 |
.. attribute:: current_document.default_domain |
| 77 |
:type: Domain | None |
| 78 |
|
| 79 |
The default domain for the current document. |
| 80 |
Set by the :rst:dir:`default-domain` directive. |
| 81 |
|
| 82 |
.. attribute:: current_document.highlight_language |
| 83 |
:type: str |
| 84 |
|
| 85 |
The default language for syntax highlighting. |
| 86 |
Set by the :rst:dir:`highlight` directive to override |
| 87 |
the :confval:`highlight_language` config value. |
| 88 |
|
| 89 |
.. attribute:: current_document._parser |
| 90 |
:type: Parser | None |
| 91 |
|
| 92 |
*This attribute is experimental and may be changed without notice.* |
| 93 |
|
| 94 |
The parser being used to parse the current document. |
| 95 |
|
| 96 |
**Utility methods** |
| 97 |
|
| 98 |
.. automethod:: doc2path |
| 99 |
|
| 100 |
.. automethod:: relfn2path |
| 101 |
|
| 102 |
.. automethod:: note_dependency |
| 103 |
|
| 104 |
.. automethod:: new_serialno |
| 105 |
|
| 106 |
.. automethod:: note_reread |