Skip to content

Commit ebc2cba

Browse files
committed
feat: Add a docutils extra context
1 parent c4ff52a commit ebc2cba

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/sphinxnotes/data/render/extractx.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from abc import ABC, abstractmethod
44

55
from sphinx.util.docutils import SphinxDirective
6+
from docutils.parsers.rst.directives import _directives
7+
from docutils.parsers.rst.roles import _roles
68

79
from .render import HostWrapper
810
from .datanodes import pending_node
@@ -50,6 +52,7 @@ def __init__(self) -> None:
5052
self.global_ = {}
5153

5254
self.add_global_context('sphinx', _SphinxExtraContext())
55+
self.add_global_context('docutils', _DocutilsExtraContext())
5356
self.add_parsing_phase_context('markup', _MarkupExtraContext())
5457
self.add_parsing_phase_context('section', _SectionExtraContext())
5558
self.add_parsing_phase_context('doc', _DocExtraContext())
@@ -120,6 +123,14 @@ class _SphinxExtraContext(GlobalExtraContxt):
120123
def generate(self) -> Any:
121124
return proxy(self.app)
122125

126+
class _DocutilsExtraContext(GlobalExtraContxt):
127+
@override
128+
def generate(self) -> Any:
129+
# FIXME: use unexported api
130+
return {
131+
'directives': _directives,
132+
'roles': _roles,
133+
}
123134

124135
# ========================
125136
# Extra Context Management

0 commit comments

Comments
 (0)