diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-02-16 01:10:51 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-02-16 01:55:46 +0900 |
commit | 065ece6f4c223bdacd91e85c6b7a47e51093be6d (patch) | |
tree | f80ad6f5a7b899bb069533906144d96faecc6db6 /sphinx/util/docutils.py | |
parent | c892a5abeb0c9a28650cc6e01bcc851f85d68a41 (diff) | |
download | sphinx-git-065ece6f4c223bdacd91e85c6b7a47e51093be6d.tar.gz |
docs: Add SphinxRole and ReferenceRole
Diffstat (limited to 'sphinx/util/docutils.py')
-rw-r--r-- | sphinx/util/docutils.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 31c959a0e..393f97abf 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -392,6 +392,15 @@ class SphinxRole: .. note:: The subclasses of this class might not work with docutils. This class is strongly coupled with Sphinx. """ + name = None #: The role name actually used in the document. + rawtext = None #: A string containing the entire interpreted text input. + text = None #: The interpreted text content. + lineno = None #: The line number where the interpreted text begins. + inliner = None #: The ``docutils.parsers.rst.states.Inliner`` object. + options = None #: A dictionary of directive options for customization + #: (from the "role" directive). + content = None #: A list of strings, the directive content for customization + #: (from the "role" directive). def __call__(self, name, rawtext, text, lineno, inliner, options={}, content=[]): # type: (str, str, str, int, Inliner, Dict, List[str]) -> Tuple[List[nodes.Node], List[nodes.system_message]] # NOQA @@ -443,9 +452,13 @@ class ReferenceRole(SphinxRole): """A base class for reference roles. The reference roles can accpet ``link title <target>`` style as a text for - the role. The parsed result: link title and target will be stored to + the role. The parsed result; link title and target will be stored to ``self.title`` and ``self.target``. """ + has_explicit_title = None #: A boolean indicates the role has explicit title or not. + title = None #: The link title for the interpreted text. + target = None #: The link target for the interpreted text. + # \x00 means the "<" was backslash-escaped explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL) |