docs: translate admonitions into bootstrap alerts
Sphinx and Bootstraps disagree on what these are called. Let's try to bridge that gap, by rewriting things a bit. Reviewed-by: Eric Engestrom <eric@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8399>
This commit is contained in:

committed by
Marge Bot

parent
f72033bb70
commit
e64dae9441
@@ -36,6 +36,7 @@ from docutils import nodes
|
||||
|
||||
import sphinx
|
||||
from sphinx.ext.autosummary import autosummary_table
|
||||
from sphinx.locale import admonitionlabels
|
||||
|
||||
import types
|
||||
|
||||
@@ -50,6 +51,28 @@ class BootstrapHTML5TranslatorMixin:
|
||||
kwargs["ARIA-LEVEL"] = "2"
|
||||
return super().starttag(*args, **kwargs)
|
||||
|
||||
def visit_admonition(self, node, name: str = '') -> None:
|
||||
admonitionclasses = {
|
||||
'attention': 'alert-primary',
|
||||
'caution': 'alert-secondary',
|
||||
'danger': 'alert-danger',
|
||||
'error': 'alert-danger',
|
||||
'hint': 'alert-secondary',
|
||||
'important': 'alert-primary',
|
||||
'note': 'alert-info',
|
||||
'seealso': 'alert-info',
|
||||
'tip': 'alert-info',
|
||||
'warning': 'alert-warning',
|
||||
}
|
||||
|
||||
self.body.append(self.starttag(
|
||||
node, 'div', CLASS=('alert ' + admonitionclasses[name])))
|
||||
if name:
|
||||
self.body.append(
|
||||
self.starttag(node, 'div', '', CLASS='h5'))
|
||||
self.body.append(str(admonitionlabels[name]))
|
||||
self.body.append('</div>')
|
||||
|
||||
def visit_table(self, node):
|
||||
# init the attributes
|
||||
atts = {}
|
||||
|
Reference in New Issue
Block a user