Skip to content

Commit 0073fd9

Browse files
zhang-yuanruiCopilotviseshrpJennaPaikowsky
authored
Documentation Update (#381)
Finish documentation for template reordering in both server and serverless, along with JSON in serverless --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Visesh Rajendraprasad <viseshrp@users.noreply.github.com> Co-authored-by: JennaPaikowsky <98607744+JennaPaikowsky@users.noreply.github.com>
1 parent 759a865 commit 0073fd9

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

doc/source/lowlevelapi/TemplateObjects.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,19 @@ Returns the filter mode of the template. The possible outputs are:
198198
Sets the filter mode of the template. Takes as input a string. See
199199
get_filter_mode for the accepted values.
200200

201-
Example of usage. Let's assume you want to create a template like the
201+
**template.reorder_child(target_child_template, new_position)**
202+
203+
Reorders a child template within the list of children to a specified position.
204+
205+
206+
This method moves a child template (identified by its GUID or the template object itself)
207+
to a new position within the `children` list of the current template. It ensures that
208+
the specified position is valid and that the target child template exists in the `children` list.
209+
210+
Example of Usage
211+
^^^^^^^^^^^^^^^^
212+
213+
Let's assume you want to create a template like the
202214
one shown in the picture (from the documentation example in the
203215
Ansys Dynamic Reporting installer):
204216

doc/source/serverless/templates.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ Common methods include:
9999
- ``set_property(props_dict)``: Replace the “properties” dictionary.
100100
- ``add_property(props_dict)``: Add/update keys within the “properties” dictionary.
101101
- ``render(context=None, item_filter="", request=None)``: Render the template to HTML string.
102+
- ``to_dict()``: Returns a JSON-serializable dictionary of the full template tree.
103+
- ``to_json(filename)``: Store the template as a JSON file. Only allow this action if this template is a root template.
104+
- ``reorder_child(target_child_template, new_position_index)``: Reorder the target template in the `children` list to the specified position.
102105

103106
Template Parameters
104107
-------------------
@@ -285,6 +288,15 @@ Example: Creating a Nested Template Structure
285288
results_panel.set_filter("A|i_tags|cont|section=results;")
286289
results_panel.save()
287290
291+
Loading Templates from a JSON file
292+
----------------------------------
293+
294+
You can load a report with multiple templates from an existing JSON file.
295+
296+
.. code-block:: python
297+
298+
adr.load_templates_from_file("my_report.json")
299+
288300
Rendering Templates
289301
-------------------
290302

src/ansys/dynamicreporting/core/serverless/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def to_json(self, filename: str) -> None:
409409

410410
def reorder_child(self, target_child_template: "Template", new_position: int) -> None:
411411
"""
412-
Reorder the template.guid in parent.children to the specified position.
412+
Reorder the target template in the `children` list to the specified position.
413413
414414
Parameters
415415
----------

0 commit comments

Comments
 (0)