Prevented (and corrected) single backtick usage in docs.

This commit is contained in:
Adam Johnson 2020-03-31 09:37:38 +01:00 committed by Carlton Gibson
parent 4a6f2b63d7
commit 1cdfe8d912
42 changed files with 105 additions and 88 deletions

View file

@ -11,10 +11,11 @@ from docutils.statemachine import ViewList
from sphinx import addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.directives import CodeBlock
from sphinx.errors import SphinxError
from sphinx.domains.std import Cmdoption
from sphinx.errors import ExtensionError
from sphinx.util import logging
from sphinx.util.console import bold
from sphinx.util.console import bold, red
from sphinx.writers.html import HTMLTranslator
logger = logging.getLogger(__name__)
@ -67,6 +68,7 @@ def setup(app):
)
app.add_directive('console', ConsoleDirective)
app.connect('html-page-context', html_page_context_hook)
app.add_role('default-role-error', default_role_error)
return {'parallel_read_safe': True}
@ -371,3 +373,14 @@ def html_page_context_hook(app, pagename, templatename, context, doctree):
# This way it's include only from HTML files rendered from reST files where
# the ConsoleDirective is used.
context['include_console_assets'] = getattr(doctree, '_console_directive_used_flag', False)
def default_role_error(
name, rawtext, text, lineno, inliner, options=None, content=None
):
msg = (
"Default role used (`single backticks`) at line %s: %s. Did you mean "
"to use two backticks for ``code``, or miss an underscore for a "
"`link`_ ?" % (lineno, rawtext)
)
raise SphinxError(red(msg))