Skip to content

Commit a2b3794

Browse files
committed
Ensure built-in functions are sorted before being documented
1 parent 781355c commit a2b3794

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

lkql_jit/language/src/main/java/com/adacore/lkql_jit/built_ins/BuiltInFunctions.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
import java.io.StringWriter;
4242
import java.util.Arrays;
4343
import java.util.Comparator;
44+
import java.util.List;
4445
import java.util.Map;
46+
import java.util.stream.Collectors;
4547

4648
/**
4749
* Module where most of the LKQL built-in functions are declared. General purpose built-in functions
@@ -192,7 +194,11 @@ public static String exec() {
192194
writer.write("^^^^^^^^^^^^^^^^^\n");
193195
writer.write("\n");
194196

195-
for (var func : AllBuiltIns.allFunctions()) {
197+
List<BuiltInFunctionValue> sortedBuiltinFunctions = AllBuiltIns.allFunctions()
198+
.stream()
199+
.sorted((l, r) -> l.getExecutableName().compareTo(r.getExecutableName()))
200+
.collect(Collectors.toList());
201+
for (var func : sortedBuiltinFunctions) {
196202
writer.write(".. function:: ");
197203
writer.write(func.getExecutableName());
198204
writer.write("(" + String.join(", ", func.parameterNames) + ")");

user_manual/generated/std.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,78 @@ Standard library
44
Builtin functions
55
^^^^^^^^^^^^^^^^^
66

7-
.. function:: unique(indexable)
8-
9-
Given a collection, create a list with all duplicates removed
10-
11-
.. function:: pattern(regex, case_sensitive)
12-
13-
Given a regex pattern string, create a pattern object
14-
15-
.. function:: print(to_print, new_line)
7+
.. function:: base_name(file_name)
168

17-
Built-in print function. Prints the argument
9+
Given a string that represents a file name, returns the basename
1810

19-
.. function:: img(string)
11+
.. function:: concat(list)
2012

21-
Return a string representation of an object
13+
Given a list, return the result of the concatenation of all its elements
2214

2315
.. function:: doc(value)
2416

2517
Given any object, return the documentation associated with it
2618

27-
.. function:: reduce(iterable, function, init_value)
28-
29-
Given a collection, a reduction function, and an initial value reduce the result
30-
3119
.. function:: document_builtins()
3220

3321
Return a string in the RsT format containing documentation for all built-ins
3422

35-
.. function:: base_name(file_name)
23+
.. function:: document_namespace(namespace, name)
3624

37-
Given a string that represents a file name, returns the basename
25+
Return a string in the RsT format containing documentation for all built-ins
3826

39-
.. function:: concat(list)
27+
.. function:: help(value)
4028

41-
Given a list, return the result of the concatenation of all its elements
29+
Print formatted help for the given object
4230

43-
.. function:: repeat(times, function)
31+
.. function:: img(string)
4432

45-
Call the given function N times
33+
Return a string representation of an object
4634

4735
.. function:: map(iterable, function)
4836

4937
Given a collection, a mapping function
5038

51-
.. function:: profile(val)
39+
.. function:: node_checker(root)
5240

53-
Given any object, if it is a callable, return its profile as text
41+
Given a root, execute all node checkers while traversing the tree
5442

55-
.. function:: document_namespace(namespace, name)
43+
.. function:: pattern(regex, case_sensitive)
5644

57-
Return a string in the RsT format containing documentation for all built-ins
45+
Given a regex pattern string, create a pattern object
5846

59-
.. function:: help(value)
47+
.. function:: print(to_print, new_line)
6048

61-
Print formatted help for the given object
49+
Built-in print function. Prints the argument
6250

63-
.. function:: units()
51+
.. function:: profile(val)
6452

65-
Return a list of all units
53+
Given any object, if it is a callable, return its profile as text
54+
55+
.. function:: reduce(iterable, function, init_value)
56+
57+
Given a collection, a reduction function, and an initial value reduce the result
58+
59+
.. function:: repeat(times, function)
60+
61+
Call the given function N times
6662

6763
.. function:: specified_units()
6864

6965
Return a list of units specified by the user
7066

71-
.. function:: node_checker(root)
67+
.. function:: unique(indexable)
7268

73-
Given a root, execute all node checkers while traversing the tree
69+
Given a collection, create a list with all duplicates removed
7470

7571
.. function:: unit_checker(unit)
7672

7773
Given a unit, apply all the unit checkers on it
7874

75+
.. function:: units()
76+
77+
Return a list of all units
78+
7979
Builtin methods
8080
^^^^^^^^^^^^^^^
8181

0 commit comments

Comments
 (0)