Skip to content

Commit 5a6ad46

Browse files
author
doyougnu
committed
rst: add custom admonitions, css
1 parent 6ef7b00 commit 5a6ad46

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

_static/css/admonitions.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.admonition.key-idea {
2+
background: #FFF0B3;
3+
}
4+
.admonition.concept {
5+
background :#E6E6FA;
6+
}

conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
project = 'Haskell Optimization Handbook'
2424
html_title = 'Haskell Optimization Handbook'
25-
# FIXME: https://github.com/input-output-hk/hs-opt-handbook.github.io/issues/58
25+
# FIXME: https://github.com/haskellFoundation/hs-opt-handbook.github.io/issues/58
2626
copyright = u'2022-%s, Jeffrey Young (doyougnu)' % time.strftime('%Y')
2727
author = 'Jeffrey Young (doyugnu)'
2828

@@ -47,6 +47,7 @@
4747
, 'sphinx_copybutton'
4848
# , 'sphinxcontrib.execHS.ext'
4949
, 'sphinx_exec_directive'
50+
, 'conceptual_admonitions'
5051
]
5152

5253
# flags
@@ -95,7 +96,7 @@
9596
html_theme = "press"
9697
html_theme_options = { "body_max_width": 1600 }
9798
html_static_path = ['_static', 'code']
98-
html_css_files = [ 'css/s4defs-roles.css', 'css/iframe.css' ]
99+
html_css_files = [ 'css/s4defs-roles.css', 'css/iframe.css', 'css/admonitions.css' ]
99100

100101
# Add any paths that contain custom static files (such as style sheets) here,
101102
# relative to this directory. They are copied after the builtin static files,
@@ -106,3 +107,7 @@
106107
# bibtex file
107108
bibtex_bibfiles = ['bib/book.bib']
108109
bibtex_default_style = 'unsrt'
110+
111+
def setup(app):
112+
for sheet in html_css_files:
113+
app.add_css_file(sheet)

extensions/conceptual_admonitions.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from docutils import nodes
2+
from docutils.parsers.rst import Directive
3+
4+
from sphinx.locale import _
5+
from sphinx.util.docutils import SphinxDirective
6+
7+
class keyIdeaDirective(SphinxDirective):
8+
9+
has_content = True
10+
11+
def run(self):
12+
key_idea_node = keyIdea(self.content)
13+
key_idea_node += nodes.Title(_('Key Idea'), _('Key Idea'))
14+
self.state.nested_parse(self.content, self.content_offset, key_idea_node)
15+
return [key_idea_node]
16+
17+
class keyIdea(nodes.Admonition, nodes.Element):
18+
pass
19+
20+
def visit_keyidea_node(self,node):
21+
self.visit_admonition(node)
22+
23+
def depart_keyidea_node(self, node):
24+
self.depart_admonition(node)
25+
26+
def setup(app):
27+
app.add_node(keyIdea,
28+
html=(visit_keyidea_node, depart_keyidea_node),
29+
latex=(visit_keyidea_node, depart_keyidea_node),
30+
text=(visit_keyidea_node, depart_keyidea_node))
31+
app.add_directive("keyIdea", keyIdeaDirective)
32+
33+
return {
34+
'version': '0.1',
35+
'parallel_read_safe': True,
36+
'parallel_write_safe': True,
37+
}

src/Case_Studies/sbv_642.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,13 @@
22

33
SBV and the Bizarre GHC Regression
44
==================================
5+
6+
.. admonition:: Concept
7+
:class: concept
8+
9+
I'm a concept
10+
11+
.. admonition:: Key Idea
12+
:class: key-idea
13+
14+
I'm a key idea

0 commit comments

Comments
 (0)