You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/README.md
+35-10Lines changed: 35 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,8 @@ We use asciidoc for writing documentation, and we render it to both HTML and PDF
8
8
9
9
### Rendering the docs locally
10
10
11
-
First, run `npm install` to install all dependencies. You only need to do this once.
11
+
First, run `npm install` to install all dependencies.
12
+
You only need to do this once.
12
13
To build and view the docs locally, use `npm start`.
13
14
This will build the docs, start a web server hosting the docs at http://localhost:8000.
14
15
@@ -22,7 +23,9 @@ If you experiene any kind of trouble, try `npm cache clear --force`
22
23
23
24
Currently, our toolchain cannot render LaTeX snippets into PDF (works for HTML tho!). So we are unable to use it.
24
25
25
-
What you can do though is use _cursive_, `monospace` and `.svg` images for anything more complicated. https://www.codecogs.com/latex/eqneditor.php is helpful for inputting LaTeX and outputting `.svg` images, or any other image format for that matter. We seem to use `.svg` so maybe stick to that.
26
+
What you can do though is use _cursive_, `monospace` and `.svg` images for anything more complicated.
27
+
https://www.codecogs.com/latex/eqneditor.php is helpful for inputting LaTeX and outputting `.svg` images, or any other image format for that matter.
28
+
We seem to use `.svg` so maybe stick to that.
26
29
27
30
28
31
### Documentation authoring
@@ -38,13 +41,20 @@ We use a few conventions for documentation source management:
38
41
39
42
## Documentation testing
40
43
41
-
We do documentation testing where we scan documentation pages; extract setup queries, project queries and example queries; and execute them as tests. A page is a natural boundary for a set of tests, and generally there is some data setup at the start, followed by several examples down the page. This pattern aligns very well with telling a coherent story.
44
+
We do documentation testing where we scan documentation pages; extract setup queries, project queries and example queries; and execute them as tests.
45
+
A page is a natural boundary for a set of tests, and generally there is some data setup at the start, followed by several examples down the page.
46
+
This pattern aligns very well with telling a coherent story.
42
47
43
48
**NB:** You can have tests that span several pages.
44
49
50
+
45
51
### Setup
46
52
47
-
Setup queries are executed first. Think Cypher `CREATE` statements and their friends. You need a database innit. These happen once per page, the JUnit equivalent is `@BeforeAll`. And that is an important point, we use JUnit as the driver for the tests, so we extract code snippets and turn pages into JUnit tests effectively.
53
+
Setup queries are executed first.
54
+
Think Cypher `CREATE` statements and their friends.
55
+
You need a database innit.
56
+
These happen once per page, the JUnit equivalent is `@BeforeAll`.
57
+
And that is an important point, we use JUnit as the driver for the tests, so we extract code snippets and turn pages into JUnit tests effectively.
AsciiDoc parses the above _source block_ and applies some _cypher_ styling, those are both unrelated to testing. So is the `role=noplay` attribute which controls rendering a button in the final documentation page.
70
+
AsciiDoc parses the above _source block_ and applies some _cypher_ styling, those are both unrelated to testing.
71
+
So is the `role=noplay` attribute which controls rendering a button in the final documentation page.
61
72
62
73
What you need to know is that the `setup-query` puts the `CREATE` statement in among the `@BeforeAll` queries on a Neo4j instance that is lifecycled with the page.
63
74
75
+
64
76
### Project
65
77
66
-
Project queries happen next, taking data from Neo4j into GDS. Scope here is, we give you a clean projection for each example, for safety. This is implemented with JUnit `@BeforeEach` semantics.
78
+
Project queries happen next, taking data from Neo4j into GDS.
79
+
Scope here is, we give you a clean projection for each example, for safety.
80
+
This is implemented with JUnit `@BeforeEach` semantics.
67
81
68
82
```
69
83
[source, cypher, role=noplay graph-project-query]
@@ -81,9 +95,12 @@ CALL gds.graph.project(
81
95
82
96
The interesting bit there is the `graph-project-query` attribute.
83
97
98
+
84
99
### Demonstrate/ test
85
100
86
-
And lastly, we execute examples. `@Test`s. Here the convention is to have a Cypher statement with a procedure call first, and then a result table that gets turned into assertions about the output of the procedure call.
101
+
And lastly, we execute examples.
102
+
`@Test`s.
103
+
Here the convention is to have a Cypher statement with a procedure call first, and then a result table that gets turned into assertions about the output of the procedure call.
87
104
88
105
```
89
106
[role=query-example]
@@ -127,9 +144,11 @@ We then need to provide two blocks inside, a query and a result table. We demarc
127
144
128
145
Remember to match and close the blocks!
129
146
147
+
130
148
#### Ignoring results
131
149
132
-
Sometimes you want to run a test that has no assertions. For this use case you have the `no-results` attribute:
150
+
Sometimes you want to run a test that has no assertions.
151
+
For this use case you have the `no-results` attribute:
133
152
134
153
```
135
154
It is now safe to drop the in-memory graph or shutdown the db, as we can restore it at a later point.
Sometimes you want your test to span multiple queries, so that one can observe side effects from another. You use the `group` attribute. Imagine you do first call a mutate procedure:
168
+
Sometimes you want your test to span multiple queries, so that one can observe side effects from another.
169
+
You use the `group` attribute.
170
+
Imagine you do first call a mutate procedure:
149
171
150
172
```
151
173
[role=query-example, group=louvain-conductance]
@@ -191,6 +213,7 @@ YIELD community, conductance
191
213
192
214
These two procedure calls are wrapped in a single test, and this within the scope of a single `@BeforeEach` (projection).
193
215
216
+
194
217
#### Impersonating a user
195
218
196
219
For some procedures the operator matters, and we have the `operator` attribute:
Remember, you are executing queries against an in-memory Neo4j Community database, so functional things like RBAC are not available. And hence, you would not be able to illustrate any procedures requiring administrator-like privileges.
232
+
Remember, you are executing queries against an in-memory Neo4j Community database, so functional things like RBAC are not available.
233
+
And hence, you would not be able to illustrate any procedures requiring administrator-like privileges
0 commit comments