{% macro render_steps(steps, display_job_attributes, summary_label="Steps") %}
   * <details><summary>{{summary_label}}</summary>
{%    for step_data in steps %}

     - **Step {{step_data.order_index + 1}}: {{step_data.workflow_step_label or (step_data.jobs[0].tool_id if step_data.jobs[0] else 'Unlabelled step')|replace("_", "\_")}}**:

        * step_state: {{step_data.state}}

{%      if step_data.jobs %}
        * <details><summary>Jobs</summary>

{{      render_step_jobs(step_data, display_job_attributes) }}

          </details>
{%      elif step_data.subworkflow%}

{{      render_steps(step_data.subworkflow.values(), display_job_attributes, "Subworkflow Steps")|indent(5, first=True) }}

{%      endif %}
{%    endfor %}
{% endmacro %}


{% macro render_step_jobs(step_data, display_job_attributes) %}
{%        for job in step_data.jobs %}
          - **Job {{loop.index}}:**

            * Job state is {{ job.state }}

{%          for key, description in display_job_attributes.items() %}
{%            if job[key] not in ("", None) %}
            **{{ description }}:**

             * ```console
               {{ job[key]|string|indent(width=15) }}
               ```
{%            endif %}
{%          endfor %}
         {{render_job_parameters(job)|indent(10)}}
{%        endfor %}
{% endmacro %}


{% macro render_job_parameters(job) %}
{%       if job.params %}
   **Job Parameters:**

   *   | Job parameter | Parameter value |
       | ------------- | --------------- |
{%         for key, value in job.params.items() %}
       | {{ key|replace('_', '\_') }} | ` {{ value }} ` |
{%         endfor %}
{%       endif %}
{% endmacro %}