Skip to content

Commit 8ddc6bc

Browse files
Start breaking out templates
1 parent d71948a commit 8ddc6bc

5 files changed

Lines changed: 228 additions & 209 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% macro group_action_subheading(title, description) %}
2+
3+
.. rst-class:: action-subheading
4+
5+
{{ title }}
6+
7+
.. rst-class:: action-subheading-description
8+
9+
{{ description }}
10+
11+
{% endmacro %}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. role:: action-table-field-name
2+
.. role:: action-table-field-optional
3+
.. role:: action-table-field-required
4+
.. role:: action-table-field-type
5+
6+
.. role:: json(code)
7+
:language: JSON

linodecli/documentation/templates/group.rst.j2

Lines changed: 2 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -1,218 +1,11 @@
1-
.. role:: action-table-field-name
2-
.. role:: action-table-field-optional
3-
.. role:: action-table-field-required
4-
.. role:: action-table-field-type
5-
6-
.. role:: json(code)
7-
:language: JSON
8-
9-
{% macro action_details(action) %}
10-
{% set action_title = action.action[0] %}
11-
{% set action_title_format = "`%s <%s>`_" % (action_title, action.api_documentation_url) if action.api_documentation_url else action_title %}
12-
.. _commands_{{ action.command }}_{{ action.action[0] }}:
13-
14-
{{ action_title_format }}
15-
{{ "-" * (action_title_format | length) }}
16-
{% if action.action | length > 1 %}
17-
18-
*Aliases: {{ action[1:] | join(", ") }}*
19-
{% endif %}
20-
21-
{% if action.deprecated %}
22-
.. warning::
23-
This command is deprecated and may not be supported in the future.
24-
{% endif %}
25-
26-
{{ action.description }}
27-
{% if action.usage %}
28-
29-
.. rst-class:: action-subheading
30-
31-
Usage
32-
33-
.. rst-class:: action-subheading-description
34-
35-
The format accepted by this command.
36-
37-
.. code-block:: bash
38-
39-
{{ action.usage | indent(first=True) }}
40-
41-
{% endif %}
42-
{% if action.samples | length > 0 %}
43-
44-
.. rst-class:: action-subheading
45-
46-
Sample{% if action.samples | length > 1 %}s{% endif %}
47-
48-
49-
.. rst-class:: action-subheading-description
50-
51-
Examples of how this command might be used.
52-
53-
{% for sample in action.samples %}
54-
55-
.. code-block:: bash
56-
57-
{{ sample | indent(first=True) }}
58-
59-
{% endfor %}
60-
{% endif %}
61-
{% if action.parameters | length > 0 %}
62-
63-
.. rst-class:: action-subheading
64-
65-
Parameters
66-
67-
.. rst-class:: action-subheading-description
68-
69-
Positional parameters used to define the resource this command should target.
70-
71-
72-
.. rst-class:: action-parameter-table
73-
74-
.. list-table::
75-
:header-rows: 1
76-
:width: 100%
77-
:widths: 1 1 98
78-
79-
* - Name
80-
- Type
81-
- Description
82-
83-
{% for parameter in action.parameters %}
84-
* - :action-table-field-name:`{{ parameter.name }}`
85-
- :action-table-field-type:`{{ parameter.type }}`
86-
- {% if parameter.description %}{{ parameter.description }}{% else %}N/A{% endif %}
87-
88-
{% endfor %}
89-
{% endif %}
90-
{% if action.argument_sections | length > 0 %}
91-
92-
.. rst-class:: action-subheading
93-
94-
Arguments
95-
96-
.. rst-class:: action-subheading-description
97-
98-
Additional fields used to execute this request.
99-
100-
{% for section in action.argument_sections %}
101-
{% if section.name | length > 0 %}
102-
.. _commands_{{ action.command }}_{{ action.action[0] }}_argument_sections_{{ section.name }}:
103-
104-
.. rst-class:: action-section-header
105-
106-
{{ section.name }}
107-
108-
{% endif %}
109-
.. rst-class:: action-argument-section-table
110-
111-
.. list-table::
112-
:header-rows: 1
113-
:width: 100%
114-
:widths: 1 1 1 97
115-
116-
* - Name
117-
- Required
118-
- Type
119-
- Description
120-
121-
{% for argument in section.entries %}
122-
* - :action-table-field-name:`\-\-{{ argument.path }}`
123-
{% if argument.is_parent and argument.path in action.argument_sections_names %}
124-
:ref:`(section) <commands_{{ action.command }}_{{ action.action[0] }}_argument_sections_{{ argument.path }}>`
125-
{% endif %}
126-
- {% if argument.required %}:action-table-field-required:`Yes`{% else %}:action-table-field-optional:`No`{% endif %}
127-
128-
- :action-table-field-type:`{{ argument.type }}`
129-
- {% if argument.description %}{{ argument.description }}{% else %}N/A{% endif %}
130-
131-
{% endfor %}
132-
{% endfor %}
133-
{% endif %}
134-
{% if action.filterable_attributes | length > 0 %}
135-
136-
.. rst-class:: action-subheading
137-
138-
Filterable Attributes
139-
140-
.. rst-class:: action-subheading-description
141-
142-
Arguments used to define a filter for response entries.
143-
144-
.. rst-class:: action-filterable-field-table
145-
146-
.. list-table::
147-
:header-rows: 1
148-
:width: 100%
149-
:widths: 1 1 98
150-
151-
* - Name
152-
- Type
153-
- Description
154-
155-
{% for attr in action.filterable_attributes %}
156-
* - :action-table-field-name:`\-\-{{ attr.name }}`
157-
- :action-table-field-type:`{{ attr.type }}`
158-
- {% if attr.description %}{{ attr.description }}{% else %}N/A{% endif %}
159-
160-
{% endfor %}
161-
{% endif %}
162-
{% if action.attribute_sections | length > 0%}
163-
164-
.. rst-class:: action-subheading
165-
166-
Result Attributes
167-
168-
.. rst-class:: action-subheading-description
169-
170-
The attributes returned by this command.
171-
172-
.. rst-class:: action-attribute-table
173-
174-
{% for section in action.attribute_sections %}
175-
{% if section.name | length > 0 %}
176-
.. _commands_{{ action.command }}_{{ action.action[0] }}_attribute_sections_{{ section.name }}:
177-
178-
.. rst-class:: action-section-header
179-
180-
{{ section.name }}
181-
182-
{% endif %}
183-
.. rst-class:: action-attribute-section-table
184-
185-
.. list-table::
186-
:header-rows: 1
187-
:width: 100%
188-
:widths: 1 1 1 97
189-
190-
* - Name
191-
- Type
192-
- Example
193-
- Description
194-
195-
{% for attribute in section.entries %}
196-
* - :action-table-field-name:`{{ attribute.name }}`
197-
{% if attribute.name in action.attribute_sections_names %}
198-
:ref:`(section) <commands_{{ action.command }}_{{ action.action[0] }}_attribute_sections_{{ attribute.path }}>`
199-
{% endif %}
200-
- :action-table-field-type:`{{ attribute.type }}`
201-
- {% if attribute.example %}:json:`{{ attribute.example | tojson }}`{% else %}?{% endif %}
202-
203-
- {% if attribute.description %}{{ attribute.description }}{% else %}N/A{% endif %}
204-
205-
{% endfor %}
206-
{% endfor %}
207-
{% endif %}
208-
{% endmacro %}
1+
{% import "group_action.rst.j2" as action_tmpl %}
2092
{{ pretty_name }}
2103
{{ "=" * (pretty_name | length) }}
2114

2125
This section details {{ pretty_name[:-1] if pretty_name[-1] == "s" else pretty_name }}-related Linode CLI commands.
2136

2147
{% for action in actions %}
215-
{{ action_details(action) }}
8+
{{ action_tmpl.render(action) }}
2169

21710
{% if loop.index < (actions | length) - 1 %}
21811
------------

0 commit comments

Comments
 (0)