Skip to content

Commit 6810c5e

Browse files
committed
Update the 'create_from_template' method documentation to include an
example Also update the generated LKQL user manual.
1 parent ab24408 commit 6810c5e

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Diff for: lkql_jit/language/src/main/java/com/adacore/lkql_jit/built_ins/methods/RewritingContextMethods.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,20 @@ public Object executeGeneric(VirtualFrame frame, RewritingContext ctx, Object ob
187187

188188
@BuiltInMethod(
189189
name = "create_from_template",
190-
doc = "Create a new node from the provided template, filling '{}' with provided" +
191-
" argument, and parsing the template with the specified grammar rule"
190+
doc = """
191+
Create a new node from the provided template, filling '{}' with provided
192+
argument, and parsing the template with the specified grammar rule. Example:
193+
194+
.. code-block:: lkql
195+
196+
# Create a new BinOp node with OpAdd as operator, representing the addition of the value
197+
# expressed by `my_other_node`, and "42".
198+
ctx.create_from_template(
199+
"{} + 42",
200+
"expr_rule",
201+
[my_other_node]
202+
)
203+
"""
192204
)
193205
public abstract static class CreateFromTemplateExpr extends BaseRewritingContextExpr {
194206

Diff for: user_manual/generated/std.rst

+16
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,22 @@ Methods for `RewritingContext`
415415

416416
Insert `new_node` at the end of `list_node`
417417

418+
.. method:: RewritingContext.create_from_template(this, template, grammar_rule, arguments)
419+
420+
Create a new node from the provided template, filling '{}' with provided
421+
argument, and parsing the template with the specified grammar rule. Example:
422+
423+
.. code-block:: lkql
424+
425+
# Create a new BinOp node with OpAdd as operator, representing the addition of the value
426+
# expressed by `my_other_node`, and "42".
427+
ctx.create_from_template(
428+
"{} + 42",
429+
"expr_rule",
430+
[my_other_node]
431+
)
432+
433+
418434
.. method:: RewritingContext.doc(this)
419435

420436
Given any object, return the documentation associated with it

0 commit comments

Comments
 (0)