README.asciidoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. The Elasticsearch docs are in AsciiDoc format and can be built using the
  2. Elasticsearch documentation build process.
  3. See: https://github.com/elastic/docs
  4. Snippets marked with `// CONSOLE` are automatically annotated with "VIEW IN
  5. SENSE" in the documentation and are automatically tested by the command
  6. `gradle :docs:check`. By default `// CONSOLE` snippet runs as its own isolated
  7. test. You can manipulate the test execution in the following ways:
  8. * `// TEST`: Explicitly marks a snippet as a test. Snippets marked this way
  9. are tests even if they don't have `// CONSOLE`.
  10. * `// TEST[s/foo/bar/]`: Replace `foo` with `bar` in the test. This should be
  11. used sparingly because it makes the test "lie". Sometimes, though, you can use
  12. it to make the tests more clear.
  13. * `// TEST[catch:foo]`: Used to expect errors in the requests. Replace `foo`
  14. with `request` to expect a 400 error, for example. If the snippet contains
  15. multiple requests then only the last request will expect the error.
  16. * `// TEST[continued]`: Continue the test started in the last snippet. Between
  17. tests the nodes are cleaned: indexes are removed, etc. This will prevent that.
  18. This is really useful when you have text and snippets that work together to
  19. tell the story of some use case because it merges the snippets (and thus the
  20. use case) into one big test.
  21. * `// TEST[skip:reason]`: Skip this test. Replace `reason` with the actual
  22. reason to skip the test. Snippets without `// TEST` or `// CONSOLE` aren't
  23. considered tests anyway but this is useful for explicitly documenting the
  24. reason why the test shouldn't be run.
  25. * `// TEST[setup:name]`: Run some setup code before running the snippet. This
  26. is useful for creating and populating indexes used in the snippet. The setup
  27. code is defined in `docs/build.gradle`.
  28. * `// TEST[warning:some warning]`: Expect the response to include a `Warning`
  29. header. If the response doesn't include a `Warning` header with the exact
  30. text then the test fails. If the response includes `Warning` headers that
  31. aren't expected then the test fails.
  32. * `// TESTRESPONSE`: Matches this snippet against the body of the response of
  33. the last test. If the response is JSON then order is ignored. With
  34. `// TEST[continued]` you can make tests that contain multiple command snippets
  35. and multiple response snippets.
  36. * `// TESTRESPONSE[s/foo/bar/]`: Substitutions. See `// TEST[s/foo/bar]`.
  37. * `// TESTSETUP`: Marks this snippet as the "setup" for all other snippets in
  38. this file. This is a somewhat natural way of structuring documentation. You
  39. say "this is the data we use to explain this feature" then you add the
  40. snippet that you mark `// TESTSETUP` and then every snippet will turn into
  41. a test that runs the setup snippet first. See the "painless" docs for a file
  42. that puts this to good use. This is fairly similar to `// TEST[setup:name]`
  43. but rather than the setup defined in `docs/build.gradle` the setup is defined
  44. right in the documentation file.
  45. Any place you can use json you can use elements like `$body.path.to.thing`
  46. which is replaced on the fly with the contents of the thing at `path.to.thing`
  47. in the last response.