Commit 909d330f authored by Pascal Sotin's avatar Pascal Sotin
Browse files

cleaning + transportable

parent ea2c7e23
# teachutils
An extension of the command rst2html with extensions dedicated to produce teaching supports.
\ No newline at end of file
A rst2html-like command with extensions dedicated to produce teaching supports.
\ No newline at end of file
......@@ -10,11 +10,11 @@ from docutils.parsers.rst import Directive
class ActivityInfo(Inline, Element):
def __init__(self,rawsource='', **kwargs):
def __init__(self, rawsource='', **kwargs):
Element.__init__(self, rawsource, **kwargs)
def visit(self, trans):
img = '<img src="rst/icons/' + self['label'] + '.png" \>'
img = '<img src="rst/icons/' + self['label'] + '.png" \\>'
overlay = '<a href="#" class="info" onclick="return false;">' + img + '<span>' + self['text'] + '</span></a>'
trans.body.append(overlay)
......
......@@ -8,6 +8,7 @@ import base64
from docutils.nodes import Element
from docutils.parsers.rst import Directive
import static
class HintInfo(Element):
javascript = """
......@@ -37,6 +38,7 @@ class HintInfo(Element):
HintInfo.written = True
png = 'icons/hints/' + self['kind'].lower() + '.png'
png = static.filename(png)
base64png = base64.b64encode(open(png, 'rb').read()).decode()
if self.can_wrap():
show_hide = ' class="clickable" onclick="ouvrirFermerHint(this);"'
......@@ -52,7 +54,7 @@ class HintInfo(Element):
</td><td class="content">'''
if self['title']:
opening += '<h4' + show_hide + '>' + self['title'] + '</h4>'
opening += '<div style="display: ' + initial_display +';">'
opening += '<div style="display: ' + initial_display + ';">'
trans.body.append(opening)
def depart(self, trans):
......@@ -62,6 +64,7 @@ class HintInfo(Element):
class Hint(Directive):
@staticmethod
def valid_wrap(value):
accepted_values = ['no', 'maybe', 'yes']
if value is None or value in accepted_values:
......@@ -72,7 +75,7 @@ class Hint(Directive):
required_arguments = 0
optional_arguments = 1
final_argument_whitespace = True
option_spec = {'wrap' : valid_wrap}
option_spec = {'wrap': valid_wrap}
has_content = True
node_class = HintInfo
......@@ -80,7 +83,7 @@ class Hint(Directive):
def run(self):
self.assert_has_content()
node = HintInfo(kind=self.name, title=self.title(),
can_wrap = self.can_wrap(), wrapped = self.wrapped_by_default())
can_wrap=self.can_wrap(), wrapped=self.wrapped_by_default())
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
......
......@@ -38,9 +38,9 @@ Signification des annotations
.. help::
Un :code:`help` contient des informations coup de pouce.
À priori les étudiants devraient ne pas en avoir besoin,
mais s'ils en ont besoin, c'est qu'il y a un couac dans
leur réflexion.
À priori les étudiants devraient ne pas en avoir besoin.
Mais si l'étudiant.e est bloqué.e, ça permet de se relancer
même en l'absence du prof.
.. context::
......
#!/usr/bin/python3
"""
A minimal front end to the Docutils Publisher, producing HTML.
A rst2html-like command with extensions dedicated to produce teaching supports.
Inspired by rst2html.py (2006-05-21).
"""
from translator import Writer
import sys
import locale
try:
import locale
locale.setlocale(locale.LC_ALL, '')
except:
pass
from translator import Writer
from docutils.core import publish_cmdline, default_description
locale.setlocale(locale.LC_ALL, '')
description = ('Generates HTML documents from reStructuredText extended to produce teaching supports.'
+ default_description)
......@@ -32,6 +30,7 @@ def extract_boolean_option(name):
solution = extract_boolean_option('--solution')
teacher = extract_boolean_option('--teacher')
writer = Writer(teacher=teacher, solution=solution or teacher)
writer = Writer(teacher=teacher,
solution=solution or teacher)
publish_cmdline(writer=writer, description=description)
import os
import sys
from pathlib import Path
root_dir = sys.path[0]
if not root_dir:
root_dir = os.getcwd()
static_dir = Path(root_dir) / 'static'
def filename(local_name):
return static_dir / local_name
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment