summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examplerun.sh7
-rw-r--r--jinja_helpers.py20
-rw-r--r--smarker.conf1
-rw-r--r--templates/tex.jinja275
4 files changed, 100 insertions, 3 deletions
diff --git a/examplerun.sh b/examplerun.sh
index 1b8e5b2..eac57b8 100644
--- a/examplerun.sh
+++ b/examplerun.sh
@@ -1,3 +1,8 @@
zip -r 100301654.zip ./ExampleSubmission/
python ./mark.py -s 100301654.zip -a ./ExampleAssessments/example.yml -f tex -o auto
-rm 100301654.zip \ No newline at end of file
+rm 100301654.zip
+pdflatex 100301654_report.tex
+rm -v *.log
+rm -v *.aux
+rm -v *.tex
+rm -v *_test_report.pdf \ No newline at end of file
diff --git a/jinja_helpers.py b/jinja_helpers.py
index 7f51881..a9e0e2e 100644
--- a/jinja_helpers.py
+++ b/jinja_helpers.py
@@ -91,6 +91,26 @@ def len_(obj):
def get_source_numlines(source):
return "%d lines (%d characters)" % (source.count("\n"), len(source))
+#https://stackoverflow.com/questions/16259923/how-can-i-escape-latex-special-characters-inside-django-templates
+def tex_escape(text):
+ conv = {
+ '&': r'\&',
+ '%': r'\%',
+ '$': r'\$',
+ '#': r'\#',
+ '_': r'\_',
+ '{': r'\{',
+ '}': r'\}',
+ '~': r'\textasciitilde{}',
+ '^': r'\^{}',
+ '\\': r'\textbackslash{}',
+ '<': r'\textless{}',
+ '>': r'\textgreater{}',
+ }
+ regex = re.compile('|'.join(re.escape(str(key)) for key in sorted(conv.keys(), key = lambda item: - len(item))))
+ # print(text, regex.sub(lambda match: conv[match.group()], text))
+ return regex.sub(lambda match: conv[match.group()], text)
+
def _get_helpers():
import reflect
import os
diff --git a/smarker.conf b/smarker.conf
index 354762c..b4a0540 100644
--- a/smarker.conf
+++ b/smarker.conf
@@ -5,6 +5,7 @@ user = root
passwd = *************
[tex]
+columns = 2
show_full_docs = True
show_source = True
show_all_regex_occurrences = True
diff --git a/templates/tex.jinja2 b/templates/tex.jinja2
index 6aa366c..998ba37 100644
--- a/templates/tex.jinja2
+++ b/templates/tex.jinja2
@@ -1,6 +1,18 @@
+((* macro expand_function(function_name, function_contents, x = "Function") *))
+ \texttt{((( tex_escape(function_name) )))}:
+
+ ((* if function_contents["present"] *))
+ Arguments: \texttt{((( tex_escape(function_contents["arguments"]) )))}
+ ((* else *))
+ \errortext(Function \texttt{((( tex_escape(function_name) )))} not present.)
+ ((* endif *))
+((* endmacro *))
+
\documentclass{article}
\usepackage[margin=1in]{geometry} % margins
+\usepackage{multicol} % columns
+\usepackage{float} % layout
\usepackage{forest} % for the class tree
\usepackage{pdfpages} % for importing the test results pdf
\usepackage{xcolor} % colours
@@ -18,10 +30,12 @@ breaklines=true
\begin{document}
+\begin{multicols}{((( tex_columns )))}
+
\maketitle
\section{Class Tree}
-\begin{figure}[h]
+\begin{figure}[H]
\centering
\begin{forest}
((( recurse_class_tree_forest(class_tree)|indent(8, False) )))
@@ -50,7 +64,7 @@ breaklines=true
((( files_contents["exception"]["traceback"] )))
\end{lstlisting}
((* else *))
- \subsubsection{Documentation:}
+ \textbf{Documentation:}
((( len_documentation(files_contents["documentation"]["comments"], files_contents["documentation"]["doc"]) ))) characters long
((* if tex_show_full_docs == "True" *))
@@ -77,6 +91,61 @@ breaklines=true
((* if "classes" in files_contents.keys() *))
\subsubsection{Classes}
+ ((* set flat_classes = flatten_struct(files_contents["classes"]) *))
+ ((* for class_name, class_contents in flat_classes.items() *))
+
+
+ \texttt{((( class_name )))}:
+
+ ((* if class_contents["present"] *))
+ \textbf{Documentation:}
+
+ ((( len_documentation(class_contents["documentation"]["comments"], class_contents["documentation"]["doc"]) ))) characters long
+ ((* if tex_show_full_docs == "True" *))
+
+
+ \textbf{Comments:}
+
+ ((* if class_contents["documentation"]["comments"] == "None" *))
+ \errortext{No comments present.}
+ ((* else *))
+ \begin{lstlisting}
+((( class_contents["documentation"]["comments"] )))
+ \end{lstlisting}
+ ((* endif *))
+
+
+ \textbf{Docstring:}
+
+ ((* if class_contents["documentation"]["doc"] == "None" *))
+ \errortext{No docstring present.}
+ ((* else *))
+ \begin{lstlisting}
+((( class_contents["documentation"]["doc"] )))
+ \end{lstlisting}
+ ((* endif *))
+
+ ((* if "methods" in class_contents.keys() *))
+ \textbf{Methods:}
+ ((* set flat_methods = flatten_struct(class_contents["methods"]) *))
+ ((* for method_name, method_contents in flat_methods.items() *))
+ ((( expand_function(method_name, method_contents, x = "Method") )))
+ ((* endfor *))
+
+
+ ((* endif *))
+
+ ((* endif *))
+
+ ((* else *))
+
+ \errortext{Class not present.}
+
+ ((* endif *))
+
+
+ ((* endfor *))
+
((* endif *))
@@ -93,4 +162,6 @@ breaklines=true
\includepdf[pages={1-},scale=1.0]{((( junit_xml_to_html(test_results["junitxml"], student_no) )))}
((* endif *))
+\end{multicols}
+
\end{document} \ No newline at end of file