[ADD] extensions: add a custom example admonition
closes odoo/documentation#1506
X-original-commit: 434bb66492
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
committed by
Antoine Vandevenne (anv)
parent
3d74c4584b
commit
0222285869
+15
-1
@@ -1,10 +1,18 @@
|
||||
""" Add a new "exercise" admonition directive. """
|
||||
""" Add new custom admonition directives. """
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst.directives import admonitions
|
||||
from sphinx.locale import admonitionlabels
|
||||
|
||||
|
||||
class example(nodes.Admonition, nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
class Example(admonitions.BaseAdmonition):
|
||||
node_class = example
|
||||
|
||||
|
||||
class exercise(nodes.Admonition, nodes.Element):
|
||||
pass
|
||||
|
||||
@@ -14,6 +22,11 @@ class Exercise(admonitions.BaseAdmonition):
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('example', Example)
|
||||
app.add_node(example, html=(
|
||||
lambda self, node: self.visit_admonition(node, 'example'),
|
||||
lambda self, node: self.depart_admonition(node),
|
||||
))
|
||||
app.add_directive('exercise', Exercise)
|
||||
app.add_node(exercise, html=(
|
||||
lambda self, node: self.visit_admonition(node, 'exercise'),
|
||||
@@ -26,4 +39,5 @@ def setup(app):
|
||||
}
|
||||
|
||||
|
||||
admonitionlabels['example'] = 'Example'
|
||||
admonitionlabels['exercise'] = 'Exercise'
|
||||
@@ -217,6 +217,7 @@ $brand-danger : #D9534F;
|
||||
|
||||
$doc_paper_dark: $gray-lighter;
|
||||
$doc_paper: #ffffff;
|
||||
$doc_example: #519161;
|
||||
$doc_exercise: #938E94;
|
||||
$doc_code-bg: #F8F8F8;
|
||||
$doc_lime: #CDDC39;
|
||||
@@ -255,4 +256,4 @@ $padding-m: 2rem;
|
||||
$padding-l: 3rem;
|
||||
$margin-s: $padding-s;
|
||||
$margin-m: $padding-m;
|
||||
$margin-l: $padding-l;
|
||||
$margin-l: $padding-l;
|
||||
|
||||
@@ -938,13 +938,28 @@ header.o_main_header {
|
||||
border-color: $danger;
|
||||
|
||||
> .alert-title, > h3 {
|
||||
color: darken($brand-danger,20%);
|
||||
color: darken($brand-danger, 20%);
|
||||
|
||||
&:before {
|
||||
content: '#{$i-danger}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.alert-example {
|
||||
border-color: tint-color($doc_example, 30%);
|
||||
background-color: tint-color($doc_example, 90%);
|
||||
color: shade-color($doc_example, 35%);
|
||||
|
||||
> .alert-title, > h3 {
|
||||
color: shade-color($doc_example, 35%);
|
||||
}
|
||||
|
||||
> .alert-title:before, > h3:before {
|
||||
content: '#{$i-knowledge}';
|
||||
}
|
||||
}
|
||||
|
||||
&.alert-exercise {
|
||||
border-color: tint-color($doc_exercise, 30%);
|
||||
background-color: tint-color($doc_exercise, 90%);
|
||||
|
||||
@@ -34,6 +34,7 @@ ADMONITION_MAPPING = {
|
||||
'danger': 'alert-danger',
|
||||
'error': 'alert-danger',
|
||||
|
||||
'example': 'alert-example',
|
||||
'exercise': 'alert-exercise',
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user