README.asciidoc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. * `// TESTRESPONSE`: Matches this snippet against the body of the response of
  29. the last test. If the response is JSON then order is ignored. With
  30. `// TEST[continued]` you can make tests that contain multiple command snippets
  31. and multiple response snippets.
  32. * `// TESTRESPONSE[s/foo/bar/]`: Substitutions. See `// TEST[s/foo/bar]`.
  33. * `// TESTSETUP`: Marks this snippet as the "setup" for all other snippets in
  34. this file. This is a somewhat natural way of structuring documentation. You
  35. say "this is the data we use to explain this feature" then you add the
  36. snippet that you mark `// TESTSETUP` and then every snippet will turn into
  37. a test that runs the setup snippet first. See the "painless" docs for a file
  38. that puts this to good use. This is fairly similar to `// TEST[setup:name]`
  39. but rather than the setup defined in `docs/build.gradle` the setup is defined
  40. right in the documentation file.
  41. Any place you can use json you can use elements like `$body.path.to.thing`
  42. which is replaced on the fly with the contents of the thing at `path.to.thing`
  43. in the last response.