|
| 1 | +{# |
| 2 | + Document a chunk of the API by iterating through plot schema JSON. |
| 3 | + Note: this template may call itself recursively for structured objects. |
| 4 | + - toplevel (bool): is this a top-level documentation entry? |
| 5 | + - attribute (JSON): data to expand as documentation |
| 6 | + - keys_to_ignore (set): keys that are *not* to be documented |
| 7 | + - parentlink: slug for parent of this entry |
| 8 | + - block: section or "nested" for nested invocations |
| 9 | + - parentpath: possibly redundant? |
| 10 | + - attribute: dictionary with details to document |
| 11 | + - page: information pulled from YAML header of page |
| 12 | + - name: name of top-level entry (e.g., "annotations") |
| 13 | + - full_name (unused): qualified name (e.g., "layout.annotations") |
| 14 | + - description (unused): one-sentence description of this item |
| 15 | + - permalink (unused): path to output page |
| 16 | +#} |
| 17 | +{% set id=[parentlink, "-", page.name] | join %} |
| 18 | +{% if toplevel %}<a class="attribute-name" id="{{id}}" href="#{{parentlink}}-{{page.name}}">{{page.name}}</a>{% endif %} |
| 19 | +<br> |
| 20 | +<em>Parent:</em> <code>{{parentpath | replace('-', '.')}}</code> |
| 21 | +<ul> |
| 22 | +{% for key, obj in attribute.items() %} |
| 23 | + {% if key not in keys_to_ignore %} |
| 24 | + <li><code>{{key}}</code> |
| 25 | + {% if obj is string %} |
| 26 | + {{obj}}<!-- FIXME: backtick --> |
| 27 | + {% elif obj.valType %} |
| 28 | + <br> |
| 29 | + {% if obj.valType == "enumerated" or obj.valType.values %} |
| 30 | + <em>Type:</em> |
| 31 | + {{ obj.valType }} |
| 32 | + {% if obj["arrayOk"] %} or array of {{ obj.valType }}s{% endif %} |
| 33 | + , one of ( |
| 34 | + {% for value in obj["values"] %} |
| 35 | + {% if value != false and value != true %}<code>"{{value}}"</code>{% else %}<code>{{value}}</code>{% endif %} |
| 36 | + {% if not loop.last %}|{% endif %} |
| 37 | + {% endfor %} |
| 38 | + ) |
| 39 | + |
| 40 | + {% elif obj.valType == "number" or obj.valType == "integer" %} |
| 41 | + {% if obj["min"] and obj["max"] %} |
| 42 | + <em>Type:</em> {{ obj.valType }}{% if obj["arrayOk"] %} or array of {{ obj.valType }}s{% endif %} between or equal to {{obj["min"]}} and {{obj["max"]}} |
| 43 | + {% elif obj["min"] %} |
| 44 | + <em>Type:</em> {{ obj.valType }}{% if obj["arrayOk"] %} or array of {{ obj.valType }}s{% endif %} greater than or equal to {{obj["min"]}} |
| 45 | + {% elif obj["max"] %} |
| 46 | + <em>Type:</em> {{ obj.valType }}{% if obj["arrayOk"] %} or array of {{ obj.valType }}s{% endif %} less than or equal to {{obj["min"]}} |
| 47 | + {% else %} |
| 48 | + <em>Type:</em> {{ obj.valType }}{% if obj["arrayOk"] %} or array of {{ obj.valType }}s{% endif %} |
| 49 | + {% endif %} |
| 50 | + |
| 51 | + {% elif obj.valType == "boolean" %} |
| 52 | + <em>Type:</em> {{ obj.valType }}{% if obj["arrayOk"] %} or array of {{ obj.valType }}s{% endif %} |
| 53 | + |
| 54 | + {% elif obj.valType == "flaglist" %} |
| 55 | + <em>Type:</em> {{ obj.valType }} string. |
| 56 | + |
| 57 | + Any combination of |
| 58 | + {% for value in obj["flags"] %} |
| 59 | + {% if value != false and value != true %} |
| 60 | + <code>"{{value}}"</code> |
| 61 | + {% else %} |
| 62 | + <code>{{value}}</code> |
| 63 | + {% endif %} |
| 64 | + {% if not loop.last %}, {% endif %} |
| 65 | + {% endfor %} |
| 66 | + joined with a <code>"+"</code> |
| 67 | + |
| 68 | + {% if obj["extras"] %} |
| 69 | + OR |
| 70 | + {% for value in obj["extras"] %} |
| 71 | + {% if value != false and value != true %} |
| 72 | + <code>"{{value}}"</code> |
| 73 | + {% else %} |
| 74 | + <code>{{value}}</code> |
| 75 | + {% endif %} |
| 76 | + {% if not loop.last %} or {% endif %} |
| 77 | + {% endfor %}. |
| 78 | + {% endif %} |
| 79 | + |
| 80 | + <br> |
| 81 | + <em>Examples:</em> |
| 82 | + <code>"{{obj["flags"][0]}}"</code>, |
| 83 | + <code>"{{obj["flags"][1]}}"</code>, |
| 84 | + <code>"{{obj["flags"][0]}}+{{obj["flags"][1]}}"</code> |
| 85 | + {% if obj["flags"][2] %}, <code>"{{obj["flags"][0]}}+{{obj["flags"][1]}}+{{obj["flags"][2]}}"</code>{% endif %} |
| 86 | + {% if obj["extras"] %}, <code>"{{obj["extras"][0]}}"</code>{% endif %} |
| 87 | + |
| 88 | + {% elif obj.valType == "data_array" %} |
| 89 | + <em>Type:</em> {{obj.valType}} |
| 90 | + |
| 91 | + {% elif obj.valType == "info_array" %} |
| 92 | + <em>Type:</em> {array} |
| 93 | + |
| 94 | + {% elif obj.valType == "color" %} |
| 95 | + <em>Type:</em> {{ obj.valType }}{% if obj["arrayOk"] %} or array of {{ obj.valType }}s{% endif %} |
| 96 | + |
| 97 | + {% elif obj.valType == "any" %} |
| 98 | + <em>Type:</em> number or categorical coordinate string |
| 99 | + |
| 100 | + {% elif obj.valType == "string" %} |
| 101 | + <em>Type:</em> string{% if obj["arrayOk"] %} or array of strings{% endif %} |
| 102 | + |
| 103 | + {% else %} |
| 104 | + <em>Type:</em> {{ obj.valType }} |
| 105 | + {% endif %} |
| 106 | + |
| 107 | + {% if obj["role"] == "object" %} |
| 108 | + {% if obj["items"] %} |
| 109 | + <em>Type:</em> array of objects |
| 110 | + {% else %} |
| 111 | + <em>Type:</em> object |
| 112 | + {% endif %} |
| 113 | + {% endif %} |
| 114 | + {% endif %} |
| 115 | + |
| 116 | + {% if obj["dflt"] %} |
| 117 | + {% if obj["valType"] == "flaglist" %} |
| 118 | + <br><em>Default:</em> <code>"{{ obj["dflt"] }}"</code> |
| 119 | + {% else %} |
| 120 | + <br><em>Default:</em> |
| 121 | + <code> |
| 122 | + {%- if obj["dflt"] == "" -%} |
| 123 | + "" |
| 124 | + {%- elif obj["valType"] == "colorscale" -%} |
| 125 | + [{% for d in obj["dflt"] %}[{{d | join(", ")}}], {% endfor %}] |
| 126 | + {%- elif obj["valType"] == "info_array" or obj["valType"] == "colorlist" -%} |
| 127 | + [{{obj["dflt"] | join(", ")}}] |
| 128 | + {%- elif obj["valType"] == "string" or obj["valType"] == "color" or obj["dflt"] == "auto" -%} |
| 129 | + "{{ obj["dflt"] }}" |
| 130 | + {%- elif obj["valType"] == "enumerated" and obj["dflt"] != true and obj["dflt"] != false -%} |
| 131 | + "{{ obj["dflt"] }}" |
| 132 | + {%- else -%} |
| 133 | + {{obj["dflt"]}} |
| 134 | + {%- endif %} |
| 135 | + </code> |
| 136 | + {% endif %} |
| 137 | + {% endif %} |
| 138 | + |
| 139 | + {% if obj["items"] and obj["valType"] != "info_array" %} |
| 140 | + |
| 141 | + <br><em>Type:</em> array of object where |
| 142 | + each object has one or more of the keys listed below. |
| 143 | + {% if page.name == "annotations" %} |
| 144 | + {% if not obj["description"] %} |
| 145 | + <br>An annotation is a text element that can be placed anywhere in the plot. It can be positioned with respect to relative coordinates in the plot or with respect to the actual data coordinates of the graph. Annotations can be shown with or without an arrow. |
| 146 | + {% endif %} |
| 147 | + {% endif %} |
| 148 | + {% elif obj["role"] == "object" %} |
| 149 | + <br><em>Type:</em> object containing one or more of the keys listed below. |
| 150 | + {% endif %} |
| 151 | + |
| 152 | + {% if obj["description"] and obj["description"]!= "" %} |
| 153 | + <br> |
| 154 | + {{ obj["description"] | replace("*", '"') | escape}}<!-- FIXME: backtick --> |
| 155 | + {% endif %} |
| 156 | + |
| 157 | + {% if obj["role"] == "object" %} |
| 158 | + {% set localparentlink=[parentlink, "-", page.name] | join %} |
| 159 | + {% set localparentpath=[parentpath, "-", page.name] | join %} |
| 160 | + {% with toplevel=False, parentlink=localparentlink, block="nested", parentpath=localparentpath, attribute=obj %} |
| 161 | + {% include "block.jinja" %} |
| 162 | + {% endwith %} |
| 163 | + {% endif %} |
| 164 | + |
| 165 | + </li> |
| 166 | + {% endif %} |
| 167 | +{% endfor %} |
| 168 | +</ul> |
0 commit comments