Files
ODrive/docs/_layouts/api_documentation_template.j2
2020-06-15 14:20:32 +02:00

149 lines
5.2 KiB
Django/Jinja

---
title: '[% if interface %][[interface.fullname]][% else %][[enum.fullname]][% endif %]'
layout: default
edit_url: 'Firmware/odrive-interface.yaml'
download:
url: 'Firmware/odrive-interface.yaml'
text: 'download as YAML'
---
[%- macro interface_ref(type) -%]
**[['[']]<span [% if type.brief %]title="[[type.brief]]"[% endif %]>[[type.name]]</span>[[']']]([[type.fullname | lower]])**
[%- endmacro %]
[%- macro value_type_ref(type) -%]
[%- if type.builtin -%]
<span title="C type: [[type.c_name]], Python type: [[type.py_type]]">[[type.name]]</span>
[%- else -%]
[['[']]<span [% if type.brief %]title="[[type.brief]]"[% endif %]>[[type.name]]</span>[[']']]([[type.fullname | lower]])
[%- endif %]
[%- endmacro %]
[% macro attr_ref(token, attr) -%]
**[['[']]<span [% if attr.brief %]title="[[attr.brief]]"[% endif %]>[[token]]</span>[[']']]([[attr.parent.fullname | lower]]#[[attr.name]])**
[%- endmacro %]
[% if interface %]
[% set scope = interface %]
[% else %]
[% set scope = enum.parent %]
[% endif %]
[%- macro doc_tokenize(text) %][[ text | tokenize(scope, interface_ref, value_type_ref, attr_ref) ]][% endmacro %]
[%- macro status_badge(status) %]
[%- if status == 'experimental' %]
<span style="border: 1px solid; border-radius: 3px; padding: 1px 10px; color: #c35400; float: right;" title="This feature is still experimental. It may be buggy or change later. Use with caution.">Experimental</span>
[%- endif %]
[%- if status == 'deprecated' %]
<span style="border: 1px solid; border-radius: 3px; padding: 1px 10px; color: #c35400; float: right;" title="This feature is deprecated and may be removed in future versions.">Deprecated</span>
[%- endif %]
[%- endmacro %]
[%- macro breadcrumbs(title) %]
# [% for item in title.split('.') | diagonalize -%]
<a href="[[item | join('.') | lower]]">[[item[-1]]]</a>
[%- if not loop.last %]<span style="font-size: x-large;opacity: 50%;">&ensp;&#x3009;</span>[% endif %]
[%- endfor %]
[%- endmacro %]
[% if interface %]
[[breadcrumbs(interface.fullname)]]
[%- if interface.doc or interface.brief %]
[[doc_tokenize(interface.brief)]][% if interface.brief and interface.doc %]
[% endif %][[doc_tokenize(interface.doc)]]
[%- endif %]
## Attributes
[% if interface.attributes %]
[% for attr in interface.attributes.values() %]
[%- if attr.type.purename == 'fibre.Property' %]
<a name="[[attr.name]]"></a><span style="font-size: medium;">**<code markdown="span">[[attr.name]]</code>**&nbsp;&nbsp;&mdash;&nbsp;&nbsp;<code markdown="span">[[value_type_ref(attr.type.value_type)]]</code></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: small;">_[[attr.type.mode]]_</span>
[%- else %]
<a name="[[attr.name]]"></a><span style="font-size: medium;">**<code markdown="span">[[attr.name]]</code>**&nbsp;&nbsp;&mdash;&nbsp;&nbsp;<code markdown="span">[[interface_ref(attr.type)]]</code></span>
[%- endif %]
[[-status_badge(attr.status)]]
<ul markdown="block">
[% if attr.doc or attr.brief %]
[[doc_tokenize(attr.brief)]][% if attr.brief and attr.doc %]
[% endif %][%- if attr.unit %]
**Unit:** [[attr.unit]]
[% endif %][[doc_tokenize(attr.doc)]]
[%- else %]
_No description_
[%- endif %]
</ul>
[% endfor %]
[% else %]
This interface has no attributes.
[% endif %]
## Functions
[% if interface.functions %]
[% for function in interface.functions.values() %]
<a name="[[function.name]]"></a><span style="font-size: medium;"><code markdown="span">**[[function.name]]**([% for arg in function.in.values() | skip_first %][[arg.name]]: [[value_type_ref(arg.type)]][[', ' if not loop.last]][% endfor %])</code>[% if function.out %]&nbsp;&nbsp;&#x2794;&nbsp;&nbsp;<code markdown="span">[% for arg in function.out.values() %][[arg.name]]: [[value_type_ref(arg.type)]][[', ' if not loop.last]][% endfor %]</code>[% endif %]</span>
<ul markdown="block">
[% if function.doc or function.brief %]
[[doc_tokenize(function.brief)]][% if function.brief and function.doc %]
[% endif %][[doc_tokenize(function.doc)]]
[%- else %]
_No description_
[%- endif %]
[% if function.in.values() | skip_first %]
**Inputs:**
[%- for arg in function.in.values() | skip_first %]
- `[[arg.name]]`: [% if arg.doc %][[doc_tokenize(arg.doc)]][% else %]&nbsp;_No description_[% endif %]
[%- endfor %]
[%- endif %]
[% if function.out.values() %]
**Outputs:**
[%- for arg in function.out.values() %]
- `[[arg.name]]`: [% if arg.doc %][[doc_tokenize(arg.doc)]][% else %]&nbsp;_No description_[% endif %]
[%- endfor %]
[%- endif %]
</ul>
[% endfor %]
[% else %]
This interface has no functions.
[% endif %]
[% else %]
[[breadcrumbs(enum.fullname)]]
[%- if enum.doc or enum.brief %]
[[doc_tokenize(enum.brief)]][% if enum.brief and enum.doc %]
[% endif %][[doc_tokenize(enum.doc)]]
[%- endif %]
## [% if enum.is_flags %]Flags[% else %]Values[% endif %]
[% for k, value in enum['values'].items() %]
<a name="[[value.name]]"></a><span style="font-size: medium;">**<code markdown="span">[[(enum.name + value.name) | to_macro_case]]</code>**&nbsp;&nbsp;&mdash;&nbsp;&nbsp;[% if enum.is_flags %]0x[['%08x' | format(value.value)]][% else %][[value.value]][% endif %]</span>
[[-status_badge(value.status)]]
<ul markdown="block">
[% if value.doc or value.brief %]
[[doc_tokenize(value.brief)]][% if value.brief and value.doc %]
[% endif %][[doc_tokenize(value.doc)]]
[%- else %]
_No description_
[%- endif %]
</ul>
[% endfor %]
[% endif %]