diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2022-04-22 16:02:28 +0100 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2022-04-22 16:02:28 +0100 |
commit | 12ac9bd354c664978523547ffac9bbebf0fcb577 (patch) | |
tree | eb9c3726edfa291d0b6c53cec0f25572946fb887 /Smarker/templates | |
parent | 5faf5c34d833f8467bce580e1e249f54856042dc (diff) | |
download | Smarker-12ac9bd354c664978523547ffac9bbebf0fcb577.tar.gz Smarker-12ac9bd354c664978523547ffac9bbebf0fcb577.zip |
Moved and adapted to move folder, added rendering to pdfs
Diffstat (limited to 'Smarker/templates')
-rw-r--r-- | Smarker/templates/markdown.jinja2 | bin | 0 -> 26 bytes | |||
-rw-r--r-- | Smarker/templates/md.jinja2 | 166 | ||||
-rw-r--r-- | Smarker/templates/tex.jinja2 | 249 | ||||
-rw-r--r-- | Smarker/templates/text.jinja2 | bin | 0 -> 28 bytes | |||
-rw-r--r-- | Smarker/templates/txt.jinja2 | 168 |
5 files changed, 583 insertions, 0 deletions
diff --git a/Smarker/templates/markdown.jinja2 b/Smarker/templates/markdown.jinja2 Binary files differnew file mode 100644 index 0000000..99c26ce --- /dev/null +++ b/Smarker/templates/markdown.jinja2 diff --git a/Smarker/templates/md.jinja2 b/Smarker/templates/md.jinja2 new file mode 100644 index 0000000..e764a49 --- /dev/null +++ b/Smarker/templates/md.jinja2 @@ -0,0 +1,166 @@ +{%- macro expand_function(function_name, function_contents, x = "Function") -%}
+ - `{{ function_name }}`:
+{%- if function_contents["present"] %}
+ - **Arguments:**
+ - `{{ function_contents["arguments"] }}`
+ - {{ bool_to_checkbox(function_contents["minimum_arguments"] >= get_required_num_args(function_name)) }} Enough?
+ - **Documentation**:
+ - {{ len_documentation(function_contents["documentation"]["comments"], function_contents["documentation"]["doc"]) }} characters long
+{%- if md_show_full_docs == "True" %}
+ - Comments:
+ {%- if function_contents["documentation"]["comments"] == "None" %}
+ - [ ] No comments present
+{%- else %}
+{{ code_block(function_contents["documentation"]["comments"])|indent(12, True) }}
+{%- endif %}
+ - Docstring:
+{%- if function_contents["documentation"]["doc"] == "None" %}
+ - [ ] No docstring present
+{%- else %}
+{{ code_block(function_contents["documentation"]["doc"])|indent(12, True) }}
+{%- endif -%}
+{%- endif %}
+ - **Source**:
+ - {{ get_source_numlines(function_contents["source_code"]) }}
+{%- if md_show_source == "True" %}
+ - Code:
+{{ code_block(function_contents["source_code"])|indent(12, True) }}
+{%- endif %}
+{%- else %}
+ - [ ] {{ x }} not present
+{%- endif %}
+{%- endmacro -%}
+
+{%- macro code_block(code) -%}
+```
+{{ code }}
+```
+{%- endmacro -%}
+
+# {{ name }} - Student ID: {{ student_no }} Automatic marking report
+Report generated at {{ get_datetime() }}
+## Class Tree:
+
+```
+{{ recurse_class_tree_text(class_tree) }}
+```
+
+## File Analysis
+
+{%- set flat_files = flatten_struct(files) %}
+{% for filename, files_contents in flat_files.items() %}
+### File `{{ filename }}`:
+{%- if files_contents["present"] -%}
+{%- if files_contents["has_exception"] %}
+*** File cannot be run - has compile time exception ***
+Please note that this file cannot be analysed or have tests preformed upon it-
+ this can lead to the whole test suite failing if another module imports this.
+ - Exception Type: `{{ files_contents["exception"]["type"] }}`
+ - Exception String: `{{ files_contents["exception"]["str"] }}`
+ - Full Traceback:
+```
+{{ files_contents["exception"]["traceback"] }}
+```
+{%- else %}
+ - #### Documentation:
+ {%- set len_docs = len_documentation(files_contents["documentation"]["comments"], files_contents["documentation"]["doc"]) %}
+ - {{ len_docs }} characters long
+{%- if md_show_full_docs == "True" %}
+ - ##### Comments:
+{%- if files_contents["documentation"]["comments"] == "None" %}
+ - [ ] No comments present
+{%- else %}
+{{ code_block(files_contents["documentation"]["comments"])|indent(8, True) }}
+{%- endif %}
+ - ##### Docstring:
+{%- if files_contents["documentation"]["doc"] == "None" %}
+ - [ ] No docstring present
+{%- else %}
+{{ code_block(files_contents["documentation"]["doc"])|indent(8, True) }}
+{%- endif -%}
+{%- endif %}
+{%- if "classes" in files_contents.keys() %}
+ - #### Classes:
+{%- set flat_classes = flatten_struct(files_contents["classes"]) -%}
+{% for class_name, class_contents in flat_classes.items() %}
+ - ##### `{{ class_name}}`:
+{%- if class_contents["present"] %}
+ - ###### Documentation:
+ {%- set len_docs = len_documentation(class_contents["documentation"]["comments"], class_contents["documentation"]["doc"]) %}
+ - {{ len_docs }} characters long
+{%- if md_show_full_docs == "True" %}
+ - *Comments*:
+{%- if class_contents["documentation"]["comments"] == "None" %}
+ - [ ] No comments present
+{%- else %}
+{{ code_block(class_contents["documentation"]["comments"])|indent(20, True) }}
+{%- endif %}
+ - *Docstring*:
+{%- if class_contents["documentation"]["doc"] == "None" %}
+ - [ ] No docstring present
+{%- else %}
+{{ code_block(class_contents["documentation"]["doc"])|indent(20, True) }}
+{%- endif -%}
+{%- endif %}
+{%- if "methods" in class_contents.keys() %}
+ - ###### Methods:
+{%- set flat_methods = flatten_struct(class_contents["methods"]) -%}
+{%- for method_name, method_contents in flat_methods.items() %}
+{{ expand_function(method_name, method_contents, "Method")|indent(16, True) }}
+{%- endfor -%}
+{%- endif -%}
+{%- else %}
+ - [ ] Class not present
+{%- endif -%}
+{%- endfor -%}
+{%- endif -%}
+{% if "functions" in files_contents.keys() %}
+ - #### Functions:
+{%- set flat_functions = flatten_struct(files_contents["functions"]) %}
+{%- for function_name, function_contents in flat_functions.items() %}
+{{ expand_function(function_name, function_contents)|indent(8, True) }}
+{%- endfor -%}
+{%- endif -%}
+{% if "run" in files_contents.keys() %}
+ - #### Runtime Analysis:
+{%- set flat_runtime = flatten_struct(files_contents["run"]) %}
+{%- for cmd, runtime_contents in flat_runtime.items() %}
+ - ##### Command `{{ cmd }}`:
+ - **Monitor:**
+{%- if "monitor" in runtime_contents.keys() %}
+ - {{ runtime_contents["monitor"] }}
+{%- else %}
+ - stdout
+{%- endif %}
+ - **Regexes:**
+{%- for regex_, results in runtime_contents["regexes"].items() %}
+ - `{{regex_}}`:
+ - Found occurrences: {{ len_(results) }}
+{%- if code_block(runtime_contents["full_output"]) == "*** File not produced ***" %}
+ - *** File was not produced- no occurrences ***
+{%- endif -%}
+{%- if md_show_all_regex_occurrences == "True" and len_(results) > 0 %}
+ - Occurrences list:
+{%- for result in results %}
+ - `{{ result.replace("\n", "\\n") }}`
+{%- endfor -%}
+{%- if md_show_all_run_output == "True" %}
+ - Full runtime output:
+{{ code_block(runtime_contents["full_output"])|indent(24, True) }}
+{%- endif -%}
+{%- endif -%}
+{%- endfor -%}
+{%- endfor -%}
+{%- endif -%}
+{%- endif -%}
+{% else %}
+ - [ ] File not present
+{% endif %}
+{% endfor %}
+
+{% if out != "stdout" and format != "html" -%}
+## Tests:
+```
+{{ test_results["pytest_report"].replace("\r", "") }}
+```
+{%- endif -%}
\ No newline at end of file diff --git a/Smarker/templates/tex.jinja2 b/Smarker/templates/tex.jinja2 new file mode 100644 index 0000000..eaa7db7 --- /dev/null +++ b/Smarker/templates/tex.jinja2 @@ -0,0 +1,249 @@ +((* macro expand_function(function_name, function_contents, x = "Function") *))
+ \texttt{((( tex_escape(function_name) )))}:
+
+ ((* if function_contents["present"] *))
+ \begin{itemize}
+ \item Arguments: \pyth{((( function_contents["arguments"] )))}
+ \item Documentation: ((( len_documentation(function_contents["documentation"]["comments"], function_contents["documentation"]["doc"]) ))) characters long
+ ((* if tex_show_full_docs == "True" *))
+
+ \textbf{Comments:}
+ ((*- if function_contents["documentation"]["comments"] == "None" *))
+ \errortext{No comments present.}
+ ((* else *))
+ \begin{lstlisting}
+((( function_contents["documentation"]["comments"] )))
+ \end{lstlisting}
+ ((* endif *))
+
+ \textbf{Docstring}:
+ ((*- if function_contents["documentation"]["doc"] == "None" *))
+ \errortext{No docstring present.}
+ ((* else *))
+ \begin{lstlisting}
+((( function_contents["documentation"]["doc"] )))
+ \end{lstlisting}
+ ((* endif *))
+ ((* endif *))
+ \item Code: ((( get_source_numlines(function_contents["source_code"]) )))
+ ((* if tex_show_source == "True" *))
+ \begin{python}
+((( function_contents["source_code"] )))
+ \end{python}
+ ((* endif *))
+ \end{itemize}
+ ((* else *))
+ \errortext{((( x ))) \texttt{((( tex_escape(function_name) )))} not present.}
+ ((* endif *))
+((* endmacro *))
+
+\documentclass{article}
+
+\usepackage{pythonhighlight}
+
+\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
+\usepackage{listings}
+\lstset{
+basicstyle=\small\ttfamily,
+columns=flexible,
+breaklines=true
+}
+
+\newcommand{\errortext}[1]{\textcolor{red}{\textbf{#1}}}
+
+\author{((( student_no )))}
+\title{((( name ))) - Automatic marking report}
+
+\begin{document}
+
+((* if tex_columns != "1" *))
+\begin{multicols}{((( tex_columns )))}
+((* endif *))
+
+\maketitle
+\section{Class Tree}
+
+\begin{figure}[H]
+ \centering
+ \begin{forest}
+ ((( recurse_class_tree_forest(class_tree)|indent(8, False) )))
+ \end{forest}
+ \caption{Class inheritance tree}
+\end{figure}
+
+\section{File Analysis}
+((* set flat_files = flatten_struct(files) *))
+((* for filename, files_contents in flat_files.items() *))
+ \subsection{\texttt{((( filename )))}}
+ ((* if files_contents["present"] *))
+ ((* if files_contents["has_exception"] *))
+ \errortext{File cannot be run - has compile time exception.}
+
+ Please note that this file cannot be analysed or have tests preformed upon it-
+ this can lead to the whole test suite failing if another module imports this.
+
+ \textbf{Exception Type:} \texttt{((( files_contents["exception"]["type"] )))}
+
+ \textbf{Exception String:} \texttt{((( files_contents["exception"]["str"] )))}
+
+ \textbf{Full Traceback:}
+
+ \begin{lstlisting}
+((( files_contents["exception"]["traceback"] )))
+ \end{lstlisting}
+ ((* else *))
+ \begin{itemize}
+ \item \textbf{Documentation:}
+
+ ((( len_documentation(files_contents["documentation"]["comments"], files_contents["documentation"]["doc"]) ))) characters long
+ ((* if tex_show_full_docs == "True" *))
+
+ \item \textbf{Comments:}
+ ((*- if files_contents["documentation"]["comments"] == "None" *))
+ \errortext{No comments present.}
+ ((* else *))
+ \begin{lstlisting}
+((( files_contents["documentation"]["comments"] )))
+ \end{lstlisting}
+ ((* endif *))
+
+ \item \textbf{Docstring:}
+ ((*- if files_contents["documentation"]["doc"] == "None" *))
+ \errortext{No docstring present.}
+ ((* else *))
+ \begin{lstlisting}
+((( files_contents["documentation"]["doc"] )))
+ \end{lstlisting}
+ ((* endif *))
+
+ ((* endif *))
+ \end{itemize}
+
+ ((* 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() *))
+ \begin{itemize}
+
+
+ \item \texttt{((( class_name )))}:
+
+ ((* if class_contents["present"] *))
+ \begin{itemize}
+ \item \textbf{Documentation:}
+ ((( len_documentation(class_contents["documentation"]["comments"], class_contents["documentation"]["doc"]) ))) characters long
+
+ ((* if tex_show_full_docs == "True" *))
+
+
+ \item \textbf{Comments:}
+
+ ((* if class_contents["documentation"]["comments"] == "None" -*))
+ \errortext{No comments present.}
+ ((* else *))
+ \begin{lstlisting}
+((( class_contents["documentation"]["comments"] )))
+ \end{lstlisting}
+ ((* endif *))
+
+
+ \item \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() *))
+ \item \textbf{Methods:}
+ ((* set flat_methods = flatten_struct(class_contents["methods"]) *))
+ \begin{itemize}
+ ((* for method_name, method_contents in flat_methods.items() *))
+ \item ((( expand_function(method_name, method_contents, x = "Method") )))
+ ((* endfor *))
+ \end{itemize}
+
+ ((* endif *))
+ \end{itemize}
+ ((* endif *))
+
+ ((* else *))
+
+ \errortext{Class not present.}
+
+ ((* endif *))
+
+ \end{itemize}
+ ((* endfor *))
+
+
+ ((* endif *))
+
+ ((* if "functions" in files_contents.keys() *))
+ \subsubsection{Functions}
+ ((* set flat_functions = flatten_struct(files_contents["functions"]) *))
+ \begin{itemize}
+ ((* for function_name, function_contents in flat_functions.items() *))
+ \item ((( expand_function(function_name, function_contents) )))
+ ((* endfor *))
+ \end{itemize}
+ ((* endif *))
+
+ \subsubsection{Runtime Analysis}
+ ((* set flat_runtime = flatten_struct(files_contents["run"]) *))
+ \begin{itemize}
+ ((* for cmd, runtime_contents in flat_runtime.items() *))
+ \item Command: \texttt{((( tex_escape(cmd) )))}
+ \item Monitor:
+ ((*- if "monitor" in runtime_contents.keys() *))
+ \texttt{((( tex_escape(runtime_contents["monitor"]) )))}
+ ((*- else *))
+ stdout
+ ((*- endif *))
+ \item Regexes:
+ ((* for regex_, results in runtime_contents["regexes"].items() *))
+ \begin{itemize}
+ \item \texttt{((( tex_escape(regex_) )))}:
+ \begin{itemize}
+ \item Found occurrences: ((( len_(results) )))
+ ((* if txt_show_all_regex_occurrences == "True" and len_(results) > 0 *))
+ \item Occurences list:
+ \begin{enumerate}
+ ((* for result in results *))
+ \item \texttt{((( tex_escape(result.replace("\n", "\\n")) )))}
+ ((* endfor *))
+ \end{enumerate}
+ ((* endif *))
+ \end{itemize}
+ \end{itemize}
+ ((*- endfor -*))
+ ((* endfor *))
+ \end{itemize}
+
+ ((* endif *))
+ ((* else *))
+ \errortext{File is not present.}
+ ((* endif *))
+((* endfor *))
+
+\section{Tests}
+((* if test_results["pytest_report"] == "*** No Tests ***" *))
+ No tests were executed.
+((* else *))
+ \includepdf[pages={1-},scale=1.0]{((( junit_xml_to_html(test_results["junitxml"], student_no) )))}
+((* endif *))
+
+((* if tex_columns != "1" *))
+\end{multicols}
+((* endif *))
+
+\end{document}
\ No newline at end of file diff --git a/Smarker/templates/text.jinja2 b/Smarker/templates/text.jinja2 Binary files differnew file mode 100644 index 0000000..eca6ebd --- /dev/null +++ b/Smarker/templates/text.jinja2 diff --git a/Smarker/templates/txt.jinja2 b/Smarker/templates/txt.jinja2 new file mode 100644 index 0000000..9eb4beb --- /dev/null +++ b/Smarker/templates/txt.jinja2 @@ -0,0 +1,168 @@ +{%- macro expand_function(function_name, function_contents, x = "Function") -%} +{{ function_name + ":" }} +{%- if function_contents["present"] %} + Arguments: + {{ function_contents["arguments"] }} + Enough? {{ bool_to_yesno(function_contents["minimum_arguments"] >= get_required_num_args(function_name)) }} + Documentation: + {{ len_documentation(function_contents["documentation"]["comments"], function_contents["documentation"]["doc"]) }} characters long + {%- if txt_show_full_docs == "True" %} + Comments: + {%- if function_contents["documentation"]["comments"] == "None" %} + *** No comments present *** + {%- else %} +``` +{{ function_contents["documentation"]["comments"] }} +``` + {%- endif %} + Docstring: + {%- if function_contents["documentation"]["doc"] == "None" %} + *** No docstring present *** + {%- else %} +``` +{{ function_contents["documentation"]["doc"] }} +``` + {%- endif -%} + {%- endif %} + Source: + {{ get_source_numlines(function_contents["source_code"]) }} + {%- if txt_show_source == "True" %} + Code: +``` +{{ function_contents["source_code"] }} +``` + {%- endif %} +{%- else %} + *** {{ x }} not present *** +{%- endif %} +{%- endmacro -%} + +=== {{ name }} - Student ID: {{ student_no }} Automatic marking report === +Report generated at {{ get_datetime() }} + +== Class Tree: == + +{{ recurse_class_tree_text(class_tree) }} + +== File Analysis == +{%- set flat_files = flatten_struct(files) %} +{% for filename, files_contents in flat_files.items() %} + = {{ filename + " =" -}} + {%- if files_contents["present"] -%} + {%- if files_contents["has_exception"] %} + *** File cannot be run - has compile time exception *** + Please note that this file cannot be analysed or have tests preformed upon it- + this can lead to the whole test suite failing if another module imports this. + Exception Type: + {{ files_contents["exception"]["type"] }} + Exception String: + {{ files_contents["exception"]["str"] }} + Full Traceback: +``` +{{ files_contents["exception"]["traceback"] }} +``` + {%- else %} + Documentation: + {{ len_documentation(files_contents["documentation"]["comments"], files_contents["documentation"]["doc"]) }} characters long + {%- if txt_show_full_docs == "True" %} + Comments: + {%- if files_contents["documentation"]["comments"] == "None" %} + *** No comments present *** + {%- else %} + ``` + {{ files_contents["documentation"]["comments"]|indent(16, False) }} + ``` + {%- endif %} + Docstring: + {%- if files_contents["documentation"]["doc"] == "None" %} + *** No docstring present *** + {%- else %} + ``` + {{ files_contents["documentation"]["doc"]|indent(16, False) }} + ``` + {%- endif -%} + {%- endif %} + {%- if "classes" in files_contents.keys() %} + Classes: + {%- set flat_classes = flatten_struct(files_contents["classes"]) -%} + {% for class_name, class_contents in flat_classes.items() %} + {{ class_name + ":" }} + {%- if class_contents["present"] %} + Documentation: + {{ len_documentation(class_contents["documentation"]["comments"], class_contents["documentation"]["doc"]) }} characters long + {%- if txt_show_full_docs == "True" %} + Comments: + {%- if class_contents["documentation"]["comments"] == "None" %} + *** No comments present *** + {%- else %} + ``` + {{ class_contents["documentation"]["comments"]|indent(16, False) }} + ``` + {%- endif %} + Docstring: + {%- if class_contents["documentation"]["doc"] == "None" %} + *** No docstring present *** + {%- else %} + ``` + {{ class_contents["documentation"]["doc"]|indent(16, False) }} + ``` + {%- endif -%} + {%- endif %} + {%- if "methods" in class_contents.keys() %} + Methods: + {%- set flat_methods = flatten_struct(class_contents["methods"]) -%} + {%- for method_name, method_contents in flat_methods.items() %} + {{ expand_function(method_name, method_contents, "Method")|indent(20, False) }} + {%- endfor -%} + {%- endif -%} + {%- else %} + *** Class not present *** + {%- endif -%} + {%- endfor -%} + {%- endif -%} + {% if "functions" in files_contents.keys() %} + Functions: + {%- set flat_functions = flatten_struct(files_contents["functions"]) %} + {%- for function_name, function_contents in flat_functions.items() %} + {{ expand_function(function_name, function_contents)|indent(12, False) }} + {%- endfor -%} + {%- endif -%} + {% if "run" in files_contents.keys() %} + Runtime Analysis: + {%- set flat_runtime = flatten_struct(files_contents["run"]) %} + {%- for cmd, runtime_contents in flat_runtime.items() %} + Command `{{ cmd }}`: + Monitor: + {%- if "monitor" in runtime_contents.keys() %} + {{ runtime_contents["monitor"] }} + {%- else %} + stdout + {%- endif %} + Regexes: + {%- for regex_, results in runtime_contents["regexes"].items() %} + `{{regex_}}`: + Found occurrences: {{ len_(results) }} + {%- if txt_show_all_regex_occurrences == "True" and len_(results) > 0 %} + Occurrences list: + {%- for result in results %} + {{ result.replace("\n", "\\n") }} + {%- endfor -%} + {%- endif -%} + {%- endfor -%} + {%- if txt_show_all_run_output == "True" %} + Full runtime output: + ``` + {{ runtime_contents["full_output"]|indent(20, False) }} + ``` + {%- endif -%} + {%- endfor -%} + {%- endif -%} + {%- endif -%} + {% else %} + *** File not present *** + {% endif %} +{% endfor %} + +{% if out != "stdout" -%} +{{ test_results["pytest_report"].replace("\r", "") }} +{%- endif -%}
\ No newline at end of file |