Skip to content

Commit a71afe3

Browse files
committed
Docs: rewrite the docs/README file
I originally wrote this file when we first added snippets testing and a lot has changed. We've grown quite fond of the `// TESTRESPONSE[s/foo/bar/]` construct, for example, but the docs discouraged its use. Relates to #18160
1 parent 3604e85 commit a71afe3

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

docs/README.asciidoc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@ Elasticsearch documentation build process.
44
See: https://github.com/elastic/docs
55

66
Snippets marked with `// CONSOLE` are automatically annotated with "VIEW IN
7-
CONSOLE" in the documentation and are automatically tested by the command
8-
`gradle :docs:check`. To test just the docs from a single page, use e.g.
9-
`gradle :docs:check -Dtest.method=*rollover*`.
7+
CONSOLE" and "COPY AS CURL" in the documentation and are automatically tested
8+
by the command `gradle :docs:check`. To test just the docs from a single page,
9+
use e.g. `gradle :docs:check -Dtests.method=*rollover*`.
1010

11-
By default `// CONSOLE` snippet runs as its own isolated
12-
test. You can manipulate the test execution in the following ways:
11+
By default each `// CONSOLE` snippet runs as its own isolated test. You can
12+
manipulate the test execution in the following ways:
1313

1414
* `// TEST`: Explicitly marks a snippet as a test. Snippets marked this way
15-
are tests even if they don't have `// CONSOLE`.
16-
* `// TEST[s/foo/bar/]`: Replace `foo` with `bar` in the test. This should be
17-
used sparingly because it makes the test "lie". Sometimes, though, you can use
18-
it to make the tests more clear.
15+
are tests even if they don't have `// CONSOLE` but usually `// TEST` is used
16+
for its modifiers:
17+
* `// TEST[s/foo/bar/]`: Replace `foo` with `bar` in the generated test. This
18+
should be used sparingly because it makes the snippet "lie". Sometimes,
19+
though, you can use it to make the snippet more clear more clear. Keep in
20+
mind the that if there are multiple substitutions then they are applied in
21+
the order that they are defined.
1922
* `// TEST[catch:foo]`: Used to expect errors in the requests. Replace `foo`
2023
with `request` to expect a 400 error, for example. If the snippet contains
2124
multiple requests then only the last request will expect the error.
2225
* `// TEST[continued]`: Continue the test started in the last snippet. Between
23-
tests the nodes are cleaned: indexes are removed, etc. This will prevent that.
24-
This is really useful when you have text and snippets that work together to
26+
tests the nodes are cleaned: indexes are removed, etc. This prevents that
27+
from happening between snippets because the two snippets are a single test.
28+
This is most useful when you have text and snippets that work together to
2529
tell the story of some use case because it merges the snippets (and thus the
2630
use case) into one big test.
2731
* `// TEST[skip:reason]`: Skip this test. Replace `reason` with the actual
@@ -38,8 +42,11 @@ are tests even if they don't have `// CONSOLE`.
3842
* `// TESTRESPONSE`: Matches this snippet against the body of the response of
3943
the last test. If the response is JSON then order is ignored. If you add
4044
`// TEST[continued]` to the snippet after `// TESTRESPONSE` it will continue
41-
in the same test, allowing you to interleve requests with responses to check.
42-
* `// TESTRESPONSE[s/foo/bar/]`: Substitutions. See `// TEST[s/foo/bar]`.
45+
in the same test, allowing you to interleave requests with responses to check.
46+
* `// TESTRESPONSE[s/foo/bar/]`: Substitutions. See `// TEST[s/foo/bar]` for
47+
how it works. These are much more common than `// TEST[s/foo/bar]` because
48+
they are useful for eliding portions of the response that are not pertinent
49+
to the documentation.
4350
* `// TESTRESPONSE[_cat]`: Add substitutions for testing `_cat` responses. Use
4451
this after all other substitutions so it doesn't make other substitutions
4552
difficult.

0 commit comments

Comments
 (0)