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 %}
{{ tables.paramtable(table.rows, [(table.title or "") ~ " Key", "Type", "Description"]) }}
{{ tables.paramtable(table.rows, ["Key", "Type", "Description"], (table.title or "")) }}
{% endfor %}

@ -13,7 +13,7 @@
{% 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 %}
Example{% if examples | length > 1 %}s{% endif %}:

@ -18,7 +18,7 @@ Request format:
{{ tables.split_paramtable(endpoint.req_param_by_loc) }}
{% if (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 -%}
{% endif -%}
@ -38,7 +38,7 @@ Response format:
{% 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 %}

@ -5,13 +5,7 @@
{{event.desc | wrap(80)}}
{% for table in event.content_fields -%}
{% if table.title -%}
{% set tabletitle = table.title -%}
{% else -%}
{% set tabletitle = "" -%}
{% endif -%}
{{ 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 %}
Example:

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

Loading…
Cancel
Save