Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit a82085b

Browse files
authored
AQL syntax highlighter (#1032)
* Set code langauge to aql (WIP) * temp * Set proper language on fenced code blocks * Customize Pygments colors * Use AQL highlighter for 3.8 and 3.9 release notes * Add AQL Lexer * Fix typo
1 parent 822ae85 commit a82085b

File tree

124 files changed

+966
-848
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+966
-848
lines changed

3.10/administration-cluster.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ requested _shard_ (_numberOfShards_) within the Cluster.
3939

4040
Example:
4141

42-
```
42+
```js
4343
127.0.0.1:8530@_system> db._create("test", {"replicationFactor": 3})
4444
```
4545

@@ -100,20 +100,20 @@ key attributes are present in the documents you send, or in case of AQL, that
100100
you use a document reference or an object for the UPDATE, REPLACE or REMOVE
101101
operation which includes the shard key attributes:
102102

103-
```js
103+
```aql
104104
FOR doc IN sharded_collection
105105
FILTER doc._key == "123"
106106
UPDATE doc WITH { … } IN sharded_collection
107107
```
108108

109-
```js
109+
```aql
110110
UPDATE { _key: "123", country: "…" } WITH { … } IN sharded_collection
111111
```
112112

113113
Using a string with just the document key as key expression instead will be
114114
processed without shard hints and thus perform slower:
115115

116-
```js
116+
```aql
117117
UPDATE "123" WITH { … } IN sharded_collection
118118
```
119119

@@ -277,13 +277,13 @@ do {
277277
This script has to be executed in the [`arangosh`](programs-arangosh.html)
278278
by issuing the following command:
279279

280-
```
280+
```bash
281281
arangosh --server.username <username> --server.password <password> --javascript.execute <path/to/serverCleanMonitor.js> -- DBServer<number>
282282
```
283283

284284
The output should be similar to the one below:
285285

286-
```
286+
```bash
287287
arangosh --server.username root --server.password pass --javascript.execute ~./serverCleanMonitor.js -- DBServer0002
288288
[7836] INFO Checking shard distribution every 10 seconds...
289289
[7836] INFO Shards to be moved away from node DBServer0002: 9

3.10/administration-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ authentication = true
116116
So you see, a command line option `‑‑section.param value` can be easily
117117
translated to an option in a configuration file:
118118

119-
```js
119+
```conf
120120
[section]
121121
param = value
122122
```

3.10/administration-license.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ At any point you may check the current state of your license in _arangosh_:
4343
127.0.0.1:8529@_system> db._getLicense();
4444
```
4545

46-
```js
46+
```json
4747
{
4848
"features": {
4949
"expires": 1632411828
5050
},
5151
"license": "JD4E ... dnDw==",
5252
"version": 1,
5353
"status": "good"
54-
"hash" : "...."
54+
"hash" : "..."
5555
}
5656
```
5757

3.10/administration-managing-users-in-arangosh.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This is again for backward compatibility.
2323

2424
Fire up *arangosh* and require the users module. Use it to create a new user:
2525

26-
```
26+
```js
2727
arangosh --server.endpoint tcp://127.0.0.1:8529 ...
2828
...
2929
> const users = require('@arangodb/users');
@@ -37,7 +37,7 @@ Note that running the command like this may store the password literally in
3737
ArangoShell's history. To avoid that, either disable the history
3838
(`--console.history false`) or use a dynamically created password, e.g.:
3939

40-
```
40+
```js
4141
> passwd = require('internal').genRandomAlphaNumbers(20);
4242
> users.save('JohnSmith', passwd);
4343
```
@@ -49,15 +49,15 @@ While there, you probably want to change the password of the default `root`
4949
user too. Otherwise one will be able to connect with the default `root` user
5050
and its empty password. The following commands change the `root` user's password:
5151

52-
```
52+
```js
5353
> passwd = require('internal').genRandomAlphaNumbers(20);
5454
> require('@arangodb/users').update('root', passwd);
5555
```
5656

5757
Back to our user account *JohnSmith*. Let us create a new database
5858
and grant him access to it with `grantDatabase()`:
5959

60-
```
60+
```js
6161
> db._createDatabase('testdb');
6262
> users.grantDatabase('JohnSmith', 'testdb', 'rw');
6363
```
@@ -79,7 +79,7 @@ Before we can grant *JohnSmith* access to a collection, we first have to
7979
connect to the new database and create a collection. Disconnect `arangosh`
8080
by pressing Ctrl+C twice. Then reconnect, but to the database we created:
8181

82-
```
82+
```js
8383
arangosh --server.endpoint tcp://127.0.0.1:8529 --server.database testdb ...
8484
...
8585
> db._create('testcoll');

3.10/analyzers.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ attributes:
860860
removing tokens that contain non-printable characters. To encode UTF-8
861861
strings to hex strings you can use e.g.
862862
- AQL:
863-
```js
863+
```aql
864864
FOR token IN ["and","the"] RETURN TO_HEX(token)
865865
```
866866
- arangosh / Node.js:
@@ -1005,16 +1005,17 @@ The *properties* allowed for this Analyzer are an object with the following attr
10051005
10061006
**Examples**
10071007
1008-
Create and use a `classification` Analyzer with a stored "cooking" classifier to classify items.
1008+
Create and use a `classification` Analyzer with a stored "cooking" classifier
1009+
to classify items.
10091010
10101011
```js
10111012
var analyzers = require("@arangodb/analyzers");
10121013
var classifier_single = analyzers.save("classifier_single", "classification", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin" }, ["frequency", "norm", "position"]);
10131014
var classifier_top_two = analyzers.save("classifier_double", "classification", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin", "top_k": 2 }, ["frequency", "norm", "position"]);
1014-
db._query(`LET str = 'Which baking dish is best to bake a banana bread ?'
1015+
db._query(`LET str = "Which baking dish is best to bake a banana bread ?"
10151016
RETURN {
1016-
"all": TOKENS(str, 'classifier_single'),
1017-
"double": TOKENS(str, 'classifier_double')
1017+
"all": TOKENS(str, "classifier_single"),
1018+
"double": TOKENS(str, "classifier_double")
10181019
}
10191020
`);
10201021
```
@@ -1061,16 +1062,17 @@ The *properties* allowed for this Analyzer are an object with the following attr
10611062

10621063
**Examples**
10631064

1064-
Create and use a `nearest_neighbors` Analyzer with a stored "cooking" classifier to find similar terms.
1065+
Create and use a `nearest_neighbors` Analyzer with a stored "cooking" classifier
1066+
to find similar terms.
10651067

10661068
```js
10671069
var analyzers = require("@arangodb/analyzers");
10681070
var nn_single = analyzers.save("nn_single", "nearest_neighbors", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin" }, ["frequency", "norm", "position"]);
10691071
var nn_top_two = analyzers.save("nn_double", "nearest_neighbors", { "model_location": "/path_to_local_fasttext_model_directory/model_cooking.bin", "top_k": 2 }, ["frequency", "norm", "position"]);
1070-
db._query(`LET str = 'salt, oil'
1072+
db._query(`LET str = "salt, oil"
10711073
RETURN {
1072-
"all": TOKENS(str, 'nn_single'),
1073-
"double": TOKENS(str, 'nn_double')
1074+
"all": TOKENS(str, "nn_single"),
1075+
"double": TOKENS(str, "nn_double")
10741076
}
10751077
`);
10761078
```

3.10/appendix-glossary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ the application path. The filesystem layout could look like this:
7777
apps/ # the instance's application directory
7878
system/ # system applications (can be ignored)
7979
_db/ # sub-directory containing database-specific applications
80-
<database-dir>/ # sub-directory for a single database
80+
<database-dir>/ # sub-directory for a single database
8181
<mountpoint>/APP # sub-directory for a single application
8282
<mountpoint>/APP # sub-directory for a single application
83-
<database-dir>/ # sub-directory for another database
83+
<database-dir>/ # sub-directory for another database
8484
<mountpoint>/APP # sub-directory for a single application
8585
```
8686

3.10/aql-tutorial-crud.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ run by clicking **Execute**:
3333

3434
![Insert query in query editor](images/Query_Insert.png)
3535

36-
```js
36+
```aql
3737
INSERT {
3838
"name": "Ned",
3939
"surname": "Stark",
@@ -62,7 +62,7 @@ of strings. The entire document is an object.
6262

6363
Let's add a bunch of other characters in a single query:
6464

65-
```js
65+
```aql
6666
LET data = [
6767
{ "name": "Robert", "surname": "Baratheon", "alive": false, "traits": ["A","H","C"] },
6868
{ "name": "Jaime", "surname": "Lannister", "alive": true, "age": 36, "traits": ["A","F","B"] },
@@ -121,7 +121,7 @@ literal array definition like `[ {...}, {...}, ... ]`.
121121
This variable is then used in the `INSERT` statement instead of a literal
122122
object definition. What it does is basically:
123123

124-
```js
124+
```aql
125125
INSERT {
126126
"name": "Robert",
127127
"surname": "Baratheon",
@@ -154,7 +154,7 @@ There are a couple of documents in the *Characters* collection by now. We can
154154
retrieve them all using a `FOR` loop again. This time however we use it to
155155
go through all documents in the collection instead of an array:
156156

157-
```js
157+
```aql
158158
FOR c IN Characters
159159
RETURN c
160160
```
@@ -191,7 +191,7 @@ attributes starting with an underscore `_` are read-only.
191191
We can use either the document key or the document ID to retrieve a specific
192192
document with the help of an AQL function `DOCUMENT()`:
193193

194-
```js
194+
```aql
195195
RETURN DOCUMENT("Characters", "2861650")
196196
// --- or ---
197197
RETURN DOCUMENT("Characters/2861650")
@@ -219,7 +219,7 @@ Here, `"2861650"` is the key for the *Ned Stark* document, and `"2861653"` for
219219

220220
The `DOCUMENT()` function also allows you to fetch multiple documents at once:
221221

222-
```js
222+
```aql
223223
RETURN DOCUMENT("Characters", ["2861650", "2861653"])
224224
// --- or ---
225225
RETURN DOCUMENT(["Characters/2861650", "Characters/2861653"])
@@ -261,7 +261,7 @@ Update documents
261261
According to our *Ned Stark* document, he is alive. When we get to know that he
262262
died, we need to change the `alive` attribute. Let us modify the existing document:
263263

264-
```js
264+
```aql
265265
UPDATE "2861650" WITH { alive: false } IN Characters
266266
```
267267

@@ -270,7 +270,7 @@ specified document with the attributes listed (or adds them if they don't exist)
270270
but leaves the rest untouched. To replace the entire document content, you may
271271
use `REPLACE` instead of `UPDATE`:
272272

273-
```js
273+
```aql
274274
REPLACE "2861650" WITH {
275275
name: "Ned",
276276
surname: "Stark",
@@ -282,7 +282,7 @@ REPLACE "2861650" WITH {
282282

283283
This also works in a loop. For example, the following adds a new attribute to all documents:
284284

285-
```js
285+
```aql
286286
FOR c IN Characters
287287
UPDATE c WITH { season: 1 } IN Characters
288288
```
@@ -292,7 +292,7 @@ The query adds the `season` attribute to the documents' top level. You can
292292
inspect the result by re-running the query that returns all documents in a
293293
collection:
294294

295-
```js
295+
```aql
296296
FOR c IN Characters
297297
RETURN c
298298
```
@@ -335,13 +335,13 @@ Delete documents
335335
To fully remove documents from a collection, there is the `REMOVE` operation.
336336
It works similar to the other modification operations, yet without a `WITH` clause:
337337

338-
```js
338+
```aql
339339
REMOVE "2861650" IN Characters
340340
```
341341

342342
It can also be used in a loop body to effectively truncate a collection:
343343

344-
```js
344+
```aql
345345
FOR c IN Characters
346346
REMOVE c IN Characters
347347
```

3.10/aql-tutorial-filter.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ conditions for documents to match.
1818
Equality condition
1919
------------------
2020

21-
```js
21+
```aql
2222
FOR c IN Characters
2323
FILTER c.name == "Ned"
2424
RETURN c
@@ -28,7 +28,7 @@ The filter condition reads like: "the attribute *name* of a character document
2828
must be equal to the string *Ned*". If the condition applies, character
2929
document gets returned. This works with any attribute likewise:
3030

31-
```js
31+
```aql
3232
FOR c IN Characters
3333
FILTER c.surname == "Stark"
3434
RETURN c
@@ -41,7 +41,7 @@ Strict equality is one possible condition we can state. There are plenty of
4141
other conditions we can formulate however. For example, we could ask for all
4242
adult characters:
4343

44-
```js
44+
```aql
4545
FOR c IN Characters
4646
FILTER c.age >= 13
4747
RETURN c.name
@@ -71,7 +71,7 @@ and age of all characters younger than 13 by changing the operator to
7171
*less-than* and using the object syntax to define a subset of attributes to
7272
return:
7373

74-
```js
74+
```aql
7575
FOR c IN Characters
7676
FILTER c.age < 13
7777
RETURN { name: c.name, age: c.age }
@@ -99,7 +99,7 @@ Multiple conditions
9999
To not let documents pass the filter without an age attribute, we can add a
100100
second criterion:
101101

102-
```js
102+
```aql
103103
FOR c IN Characters
104104
FILTER c.age < 13
105105
FILTER c.age != null
@@ -115,7 +115,7 @@ FOR c IN Characters
115115

116116
This could equally be written with a boolean `AND` operator as:
117117

118-
```js
118+
```aql
119119
FOR c IN Characters
120120
FILTER c.age < 13 AND c.age != null
121121
RETURN { name: c.name, age: c.age }
@@ -129,7 +129,7 @@ Alternative conditions
129129
If you want documents to fulfill one or another condition, possibly for
130130
different attributes as well, use `OR`:
131131

132-
```js
132+
```aql
133133
FOR c IN Characters
134134
FILTER c.name == "Jon" OR c.name == "Joffrey"
135135
RETURN { name: c.name, surname: c.surname }

3.10/aql-tutorial-geospatial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ which you need to create first, then run the AQL query below:
2121

2222
![Create Locations collection](images/Locations_Collection_Creation.png)
2323

24-
```js
24+
```aql
2525
LET places = [
2626
{ "name": "Dragonstone", "coordinate": [ 55.167801, -6.815096 ] },
2727
{ "name": "King's Landing", "coordinate": [ 42.639752, 18.110189 ] },
@@ -75,7 +75,7 @@ to restrict the number of results to at most *n* matches.
7575
In the example below, the limit is set to 3. The origin (the reference point) is
7676
a coordinate somewhere in downtown Dublin, Ireland:
7777

78-
```js
78+
```aql
7979
FOR loc IN Locations
8080
LET distance = DISTANCE(loc.coordinate[0], loc.coordinate[1], 53.35, -6.25)
8181
SORT distance
@@ -124,7 +124,7 @@ Find locations within radius
124124
locations within a given radius from a reference point. Remember that the unit
125125
is meters. The example uses a radius of 200,000 meters (200 kilometers):
126126

127-
```js
127+
```aql
128128
FOR loc IN Locations
129129
LET distance = DISTANCE(loc.coordinate[0], loc.coordinate[1], 53.35, -6.25)
130130
SORT distance

0 commit comments

Comments
 (0)