-
Notifications
You must be signed in to change notification settings - Fork 4
/
documentation.conf
204 lines (191 loc) · 6.09 KB
/
documentation.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
extensionName = "table"
markdownTemplate = """
# NetLogo Table Extension
{{> BUILDING.md}}
{{> USING.md}}
## Primitives
{{#contents}}{{#prims}}
[`{{name}}`](#{{primitive.extensionName}}{{primitive.name}})
{{/prims}}{{/contents}}
{{#primitives}}
{{> primTemplate}}
{{/primitives}}
{{> LICENSE.md}}
"""
primTemplate = """
### `{{name}}`
```NetLogo
{{#examples}}
{{primitive.fullName}}{{#args}} {{name}}{{/args}}
{{/examples}}
```
{{{description}}}
"""
filesToIncludeInManual = [ "USING.md", "primitives" ]
additionalVariables = {
netlogoUrl: "http://ccl.northwestern.edu/netlogo/docs/"
}
primitives = [
{
name: clear,
type: command,
arguments: [ { type: table } ],
description: "Removes all key-value pairs from *table*."
},
{
name: counts,
type: reporter,
returns: table,
arguments: [ { type: list} ],
description: "Counts the occurrences of each element of the given list and reports the counts in a table."
},
{
name: group-agents,
type: reporter,
returns: table,
arguments: [{type: agentset}, {type: reporter}],
description: """
Groups the agents in the agentset based on the given reporter.
Agents that report the same thing for reporter will be grouped together.
The results of the reporter will be used as the keys in the resulting table and the groups will be agentsets.
For example:
{{! prevent mustache from interpreting extension object as template variable }}{{= | | =}}
```
observer> create-turtles 100 [ set color one-of [ red green blue ] ]
observer> show table:group-agents turtles [ color ]
observer: {{table: [[105 (agentset, 38 turtles)] [55 (agentset, 32 turtles)] [15 (agentset, 30 turtles)]]}}
```
"""
},
{
name: group-items,
type: reporter,
returns: table,
arguments: [ { type: list }, { type: anonymous-reporter }],
description: """
Groups the items of the list based on the given reporter.
The reporter should take a single argument, which will be the items of the list.
Items that report the same thing when passed to the reporter will be grouped together.
The results of the reporter will be used as the keys in the resulting table and the groups will be lists.
For example:
{{! prevent mustache from interpreting extension object as template variable }}{{= | | =}}
```
observer> show table:group-items range 10 [ num -> num mod 3 ]
observer: {{table: [[0 [0 3 6 9]] [1 [1 4 7]] [2 [2 5 8]]]}}
```
"""
},
{
name: from-list,
type: reporter,
returns: table,
arguments: [ { type: list } ],
description: """
Reports a new table with the contents of *list*.
*list* must be a list of two element lists, or pairs.
The first element in the pair is the key and the second element is the value.
"""
},
{
name: from-json,
type: reporter,
returns: table,
arguments: [{type: string}],
description: """
Reads in the JSON object from the given string argument, converts it to a table, and reports the table.
The JSON object in the argument must be an object, not an array (i.e. the outmost characters must be `{` and `}`, not `[` and `]`),
but there can be arrays inside the JSON object which will be converted to NetLogo lists.
"""
},
{
name: from-json-file,
type: reporter,
returns: table,
arguments: [{type: filename}],
description: """
Reads in the JSON object from *filename.json*, converts it to a table and reports the table.
The JSON object in *filename.json* must be an object, not an array (i.e. the outmost characters of the file must be `{` and `}`, not `[` and `]`),
but there can be arrays inside the JSON object which will be converted to NetLogo lists.
"""
},
{
name: get,
type: reporter,
returns: anything,
arguments: [ { type: table }, { name: key, type: anything } ],
description: "Reports the value that *key* is mapped to in the table. Causes an error if there is no entry for the key."
},
{
name: get-or-default,
type: reporter,
returns: anything,
arguments: [ { type: table }, { name: key, type: anything }, { name: default-value, type: anything } ],
description: "Reports the value that *key* is mapped to in the table. Reports the default-value if there is no entry for the key."
},
{
name: "has-key?",
type: reporter,
returns: boolean,
arguments: [ { type: table}, { name: key, type: anything } ],
description: "Reports true if *key* has an entry in *table*."
},
{
name: keys,
type: reporter,
returns: list,
arguments: [ { type : table } ],
description: "Reports a list of all the keys in *table*, in the same order the keys were inserted."
},
{
name: length,
type: reporter,
returns: number,
arguments: [ { type: table } ],
description: "Reports the number of entries in *table*."
},
{
name: make,
type: reporter,
returns: table,
description: "Reports a new, empty table."
},
{
name: put,
type: command,
arguments: [ { type: table }, { name: key, type: anything }, { name: value, type: anything } ],
description: "Maps *key* to *value* in *table*. If an entry already exists in the table for the given key, it is replaced."
},
{
name: remove,
type: command,
arguments: [ { type: table }, { name: key, type: anything } ],
description: "Removes the mapping in *table* for *key*."
},
{
name: to-list,
type: reporter,
returns: list,
arguments: [ { type: table } ],
description: """
Reports a list with the content of <i>table</i>. The list will be a
list of two element lists, or pairs. The first element in the pair is
the key and the second element is the value. The keys appear in the
same order they were inserted."""
},
{
name: to-json,
type: reporter,
returns: string,
arguments: [ { type: table } ],
description: "Reports a string with the contents of the given table as a JSON string."
},
{
name: values,
type: reporter,
returns: list,
arguments: [ { type: table } ],
description: """
Reports a list with the entries of <i>table</i>. The entries will appear
in the same order they were inserted, with duplicates included."""
}
]