diff options
| -rw-r--r-- | pytest_template.jinja2 | 2 | ||||
| -rw-r--r-- | templates/txt.jinja2 | 109 | 
2 files changed, 71 insertions, 40 deletions
| diff --git a/pytest_template.jinja2 b/pytest_template.jinja2 index fad41db..473b7b4 100644 --- a/pytest_template.jinja2 +++ b/pytest_template.jinja2 @@ -4,5 +4,5 @@ import {{ module }}  {% for i, test_code in enumerate(filestests, 1) %}  def test_{{ i }}(): -{{ test_code|indent(4, True) }}     {# the code in the config file must be indented with 4 spaces only #} +    {{ test_code|indent(4, False) }}     {# the code in the config file must be indented with 4 spaces only #}  {% endfor %}
\ No newline at end of file diff --git a/templates/txt.jinja2 b/templates/txt.jinja2 index 97752fd..df2e100 100644 --- a/templates/txt.jinja2 +++ b/templates/txt.jinja2 @@ -1,3 +1,42 @@ +{%- 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 ===  == Class Tree: == @@ -21,54 +60,46 @@  ```  {{ files_contents["exception"]["traceback"] }}  ``` -    {%- else -%} -    {% if "classes" in files_contents.keys() %} +    {%- 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(8, False) }} +        ``` +                {%- endif %} +            Docstring: +                {%- if files_contents["documentation"]["doc"] == "None" %} +                *** No docstring present *** +                {%- else %} +        ``` +        {{ files_contents["documentation"]["doc"]|indent(8, 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 }} +            {{ class_name + ":" }} +            {%- 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 -%}          {%- 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() %} -            {{ 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 %} -                *** Function not present *** -            {%- endif %} +            {{ expand_function(function_name, function_contents)|indent(12, False) }}          {%- endfor -%}      {%- endif -%}      {%- endif -%} | 
