Skip to content

Commit

Permalink
Register Sphinx's Python roles on RST parser
Browse files Browse the repository at this point in the history
This will avoid warning related to Sphinx's Python Roles users may be
using on their source code.
  • Loading branch information
elyezer committed Apr 5, 2017
1 parent ab1b4c7 commit 8c47fac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions testimony/parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding=utf-8
"""Docstring parser utilities for Testimony."""
from docutils.core import publish_string
from docutils.parsers.rst import nodes, roles
from docutils.readers import standalone
from docutils.transforms import frontmatter
from xml.etree import ElementTree
Expand Down Expand Up @@ -41,6 +42,13 @@ def __init__(self, tokens=None, minimum_tokens=None):
if not self.minimum_tokens.issubset(self.tokens):
raise ValueError('tokens should contain minimum_tokens')

for role in (
'data', 'exc', 'func', 'class', 'const', 'attr', 'meth', 'mod',
'obj'
):
roles.register_generic_role(role, nodes.raw)
roles.register_generic_role('py:' + role, nodes.raw)

def parse(self, docstring=None):
"""Parse the docstring and return the valid and invalid tokens.
Expand Down

0 comments on commit 8c47fac

Please sign in to comment.