How to use the betelgeuse.parser.NoDocInfoReader function in Betelgeuse

To help you get started, we’ve selected a few Betelgeuse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SatelliteQE / betelgeuse / betelgeuse / parser.py View on Github external
def parse_rst(string, translator_class=None):
    """Parse a RST formatted string into HTML."""
    if not string:
        return ''
    if not hasattr(_register_roles, '_roles_registered'):
        _register_roles()
        _register_roles._roles_registered = True

    warning_stream = StringIO()
    parts = publish_parts(
        string,
        reader=NoDocInfoReader(),
        settings_overrides={
            'embed_stylesheet': False,
            'input_encoding': 'utf-8',
            'syntax_highlight': 'short',
            'warning_stream': warning_stream,
        },
        writer=HTMLWriter(translator_class=translator_class),
    )

    rst_parse_messages = []
    for warning in warning_stream.getvalue().splitlines():
        if not warning or ':' not in warning:
            continue
        warning = warning.split(' ', 2)
        rst_parse_messages.append(RSTParseMessage(
            line=warning[0].split(':')[1],