diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-02-14 22:44:32 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-02-16 00:34:24 +0900 |
commit | 9cb40436ed51068e3543e9332a7056a3212e119b (patch) | |
tree | 0c4156a33e71b028976344650191a77d1e5f96e7 /sphinx/util/docutils.py | |
parent | 1cf8ece5cc88f820780c7046929081e9ad88f444 (diff) | |
download | sphinx-git-9cb40436ed51068e3543e9332a7056a3212e119b.tar.gz |
Replace :pep: and :rfc: roles by class based implementation
Diffstat (limited to 'sphinx/util/docutils.py')
-rw-r--r-- | sphinx/util/docutils.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 71e8db268..56f8d124a 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -26,7 +26,7 @@ from docutils.statemachine import StateMachine from docutils.utils import Reporter, unescape from sphinx.deprecation import RemovedInSphinx30Warning -from sphinx.errors import ExtensionError +from sphinx.errors import ExtensionError, SphinxError from sphinx.locale import __ from sphinx.util import logging @@ -395,7 +395,6 @@ class SphinxRole: def __call__(self, typ, rawtext, text, lineno, inliner, options={}, content=[]): # type: (str, str, str, int, Inliner, Dict, List[str]) -> Tuple[List[nodes.Node], List[nodes.system_message]] # NOQA - self.type = typ self.rawtext = rawtext self.text = unescape(text) self.lineno = lineno @@ -403,6 +402,16 @@ class SphinxRole: self.options = options self.content = content + # guess role type + if typ: + self.type = typ.lower() + else: + self.type = self.env.temp_data.get('default_role') + if not self.type: + self.type = self.env.config.default_role + if not self.type: + raise SphinxError('cannot determine default role!') + return self.run() def run(self): |