sanitise caption handling

pull/977/head
Ben Parsons 6 years ago
parent 380a53ecba
commit 9e1d6d7490

@ -7,6 +7,6 @@
{% for table in common_event.tables %} {% for table in common_event.tables %}
{{ tables.paramtable(table.rows, [(table.title or "") ~ " Key", "Type", "Description"]) }} {{ tables.paramtable(table.rows, ["Key", "Type", "Description"], (table.title or "")) }}
{% endfor %} {% endfor %}

@ -13,7 +13,7 @@
{% for table in event.content_fields %} {% for table in event.content_fields %}
{{ tables.paramtable(table.rows, [(table.title or "Content") ~ " Key", "Type", "Description"]) }} {{ tables.paramtable(table.rows, [(table.title or "Content") ~ " Key", "Type", "Description"], (table.title or "")) }}
{% endfor %} {% endfor %}
Example{% if examples | length > 1 %}s{% endif %}: Example{% if examples | length > 1 %}s{% endif %}:

@ -18,7 +18,7 @@ Request format:
{{ tables.split_paramtable(endpoint.req_param_by_loc) }} {{ tables.split_paramtable(endpoint.req_param_by_loc) }}
{% if (endpoint.req_body_tables) %} {% if (endpoint.req_body_tables) %}
{% for table in endpoint.req_body_tables -%} {% for table in endpoint.req_body_tables -%}
{{ tables.paramtable(table.rows, [(table.title or "") ~ " Parameter", "Type", "Description"] ) }} {{ tables.paramtable(table.rows, caption=(table.title or "")) }}
{% endfor -%} {% endfor -%}
{% endif -%} {% endif -%}
@ -38,7 +38,7 @@ Response format:
{% for table in endpoint.res_tables -%} {% for table in endpoint.res_tables -%}
{{ tables.paramtable(table.rows, [(table.title or "") ~ " Parameter", "Type", "Description"] ) }} {{ tables.paramtable(table.rows, caption=(table.title or "")) }}
{% endfor %} {% endfor %}

@ -5,13 +5,7 @@
{{event.desc | wrap(80)}} {{event.desc | wrap(80)}}
{% for table in event.content_fields -%} {% for table in event.content_fields -%}
{% if table.title -%} {{ tables.paramtable(table.rows, [(table.title or "Content") ~ " Key", "Type", "Description"], (table.title or "")) }}
{% set tabletitle = table.title -%}
{% else -%}
{% set tabletitle = "" -%}
{% endif -%}
{{ tables.paramtable(table.rows, [(table.title or "Content") ~ " Key", "Type", "Description"] ) }}
{% endfor %} {% endfor %}
Example: Example:

@ -8,8 +8,8 @@
# #
# 'rows' is the list of parameters. Each row should be a TypeTableRow. # 'rows' is the list of parameters. Each row should be a TypeTableRow.
#} #}
{% macro paramtable(rows, titles=["Parameter", "Type", "Description"]) -%} {% macro paramtable(rows, titles=["Parameter", "Type", "Description"], caption="") -%}
{{ split_paramtable({None: rows}, titles) }} {{ split_paramtable({None: rows}, titles, caption) }}
{% endmacro %} {% endmacro %}
@ -21,7 +21,7 @@
# written for that location. This is used by the standard 'paramtable' macro. # written for that location. This is used by the standard 'paramtable' macro.
#} #}
{% macro split_paramtable(rows_by_loc, {% macro split_paramtable(rows_by_loc,
titles=["Parameter", "Type", "Description"]) -%} titles=["Parameter", "Type", "Description"], caption="") -%}
{% set rowkeys = ['key', 'title', 'desc'] %} {% set rowkeys = ['key', 'title', 'desc'] %}
{% set titlerow = {'key': titles[0], 'title': titles[1], 'desc': titles[2]} %} {% set titlerow = {'key': titles[0], 'title': titles[1], 'desc': titles[2]} %}
@ -36,11 +36,6 @@
{% set fieldwidths = (([titlerow] + flatrows) | {% set fieldwidths = (([titlerow] + flatrows) |
fieldwidths(rowkeys[0:-1], [10, 10])) + [50] -%} fieldwidths(rowkeys[0:-1], [10, 10])) + [50] -%}
{% set caption = titlerow['key'] | replace (' Key', '') | replace ('Parameter', '') -%}
{% if caption == 'Content' -%}
{% set caption = '' -%}
{% endif -%}
{{".. table:: "}}{{ caption }} {{".. table:: "}}{{ caption }}
{{" :widths: auto"}} {{" :widths: auto"}}
{{""}} {{""}}

Loading…
Cancel
Save