@@ -154,46 +154,56 @@ Extra Context
154154-------------
155155
156156Templates can access additional context through **extra context **. Extra context
157- must be explicitly declared using the `` :extra: ` ` option and loaded in the
157+ must be explicitly declared using the :rst:dir: ` templat:extra ` option and loaded in the
158158template using the ``load_extra() `` function.
159159
160- Built-in extra context
161- ......................
162-
163- .. list-table ::
164- :header-rows: 1
165-
166- * - Name
167- - Available in Pahses
168- - Description
169- * - ``sphinx ``
170- - all
171- - A proxy to the Sphinx application object.
172- * - ``docutils ``
173- - all
174- - A mapping that exposes registered docutils directives and roles.
175- * - ``markup ``
176- - :term: `parsing ` and later
177- - Information about the current directive or role invocation, such as its
178- type, name, source text, and line number.
179- * - ``section ``
180- - :term: `parsing ` and later
181- - A proxy to the current section node, when one exists.
182- * - ``doc ``
183- - :term: `parsing ` and later
184- - A proxy to the current document node.
185-
186- These values are wrapped for safer template access. In practice this means
187- templates can read public, non-callable attributes, but should not rely on
188- arbitrary Python object behavior.
160+ Built-in Extra Contexts
161+ ~~~~~~~~~~~~~~~~~~~~~~~
162+
163+ ``sphinx ``
164+ ..........
165+
166+ :Phase: all
167+
168+ A proxy to the :py:class: `sphinx.application.Sphinx ` object.
169+
170+ ``env ``
171+ .......
172+
173+ :Phase: all
174+
175+ A proxy to the :py:class: `sphinx.environment.BuildEnvironment ` object.
176+
177+ ``markup ``
178+ ..........
179+
180+ :Phase: :term: `parsing ` and later
181+
182+ Information about the current directive or role invocation, such as its
183+ type, name, source text, and line number.
184+
185+ ``section ``
186+ ............
187+
188+ :Phase: :term: `parsing ` and later
189+
190+ A proxy to the current :py:class: `docutils.nodes.section ` node, when one exists.
191+
192+ ``doc ``
193+ .......
194+
195+ :Phase: :term: `parsing ` and later
196+
197+ A proxy to the current :py:class: `docutils.notes.document ` node.
189198
190199.. example ::
191200 :style: grid
192201
193202 .. data.render::
194203 :extra: doc
195204
196- Current document title is
205+
206+ Title of current document is
197207 "{{ load_extra('doc').title }}".
198208
199209 Extending extra context
@@ -237,16 +247,16 @@ Each :py:class:`~sphinxnotes.render.Template` has a render phase controlled by
237247
238248 .. data.render::
239249 :on: parsing
240- :extra: doc sphinx
250+ :extra: doc env
241251
242252 {% set doc = load_extra('doc') %}
243- {% set sphinx = load_extra('sphinx ') %}
253+ {% set env = load_extra('env ') %}
244254
245255 - The current document has
246256 {{ doc.sections | length }}
247257 section(s).
248258 - The current project has
249- {{ sphinx. env.all_docs | length }}
259+ {{ env.all_docs | length }}
250260 document(s).
251261
252262 ``parsed ``
@@ -261,41 +271,41 @@ Each :py:class:`~sphinxnotes.render.Template` has a render phase controlled by
261271
262272 .. data.render::
263273 :on: parsed
264- :extra: doc sphinx
274+ :extra: doc env
265275
266276 {% set doc = load_extra('doc') %}
267- {% set sphinx = load_extra('sphinx ') %}
277+ {% set env = load_extra('env ') %}
268278
269279 - The current document has
270280 {{ doc.sections | length }}
271281 section(s).
272282 - The current project has
273- {{ sphinx. env.all_docs | length }}
283+ {{ env.all_docs | length }}
274284 document(s).
275285
276286 ``resolving ``
277287 Corresponding to :py:data: `sphinxnotes.render.Phase.Resolving `.
278288 Render late in the build, after references and other transforms are being
279289 resolved.
280290
281- Choose this when the template depends on project-wide state or on document
291+ Choose this when the template depends on pr
282292 structure that is only stable near the end of the pipeline.
283293
284294 .. example ::
285295 :style: grid
286296
287297 .. data.render::
288298 :on: resolving
289- :extra: doc sphinx
299+ :extra: doc env
290300
291301 {% set doc = load_extra('doc') %}
292- {% set sphinx = load_extra('sphinx ') %}
302+ {% set env = load_extra('env ') %}
293303
294304 - The current document has
295305 {{ doc.sections | length }}
296306 section(s).
297307 - The current project has
298- {{ sphinx. env.all_docs | length }}
308+ {{ env.all_docs | length }}
299309 document(s).
300310
301311 Debugging
@@ -343,3 +353,9 @@ This pattern is often the most convenient way to build small, declarative
343353directives. For more control, subclass
344354:py:class: `~sphinxnotes.render.BaseDataDefineDirective ` directly and implement
345355``current_schema() `` and ``current_template() `` yourself.
356+ .. data.render::
357+ :extra: doc
358+
359+
360+ Title of current document is
361+ "{{ load_extra('doc').title }}".
0 commit comments