arangodb / docs

⚠ DEPRECATED! Source code of the legacy ArangoDB online documentation. See arangodb/docs-hugo
https://github.com/arangodb/docs-hugo/
Apache License 2.0
20 stars 58 forks source link
arangodb database distributed-database document-database documentation graph-database graphdb jekyll key-value multi-model nosql

ArangoDB Documentation

Netlify Status

This is the ArangoDB documentation repository containing all documentation for all versions as published on arangodb.com/docs/.

The documentation uses the static site generator Jekyll.

View the latest successful preview build of the main branch.

Contributing

To suggest a concrete change to the documentation, you may edit files directly on GitHub. It will fork the repository automatically if necessary. Commit the changes to a new branch, give it a succinct name, and open a pull request (PR).

To add more changes to a PR, click on the branch name below the headline of the PR (the latter link of "<User> wants to merge <n> commits into main from branch-name"). Then locate and edit the next file. Commit the changes directly to your PR branch.

For general suggestions, feel free to create an issue.

Automatic Previews

In every pull request, there is a number of so-called checks (above the text field for entering a comment). The last entry should be netlify/zealous-morse-14392b/deploy-preview with a Details link. Whenever you push a change to the PR branch, Netlify will build a preview. While it is doing that or if it fails building the docs, then the Details link will get you to the build log. If it succeeded, then it gets you to the hosted preview of that PR. If no checks show up at all, then Netlify is probably busy with another build (or down). The checks should eventually appear, however.

Contributor License Agreement

To accept external contributions, we need you to fill out and sign our Contributor License Agreement (CLA). We use an Apache 2 CLA for ArangoDB, which can be found here: https://www.arangodb.com/documents/cla.pdf You can scan and email the CLA PDF file to cla@arangodb.com or send it via fax to +49-221-2722999-88.

Building the Documentation

The following section describes how you can build the documentation locally. This is not strictly necessary when contributing. You can also rely on automatic previews.

Symlink Support Required

Make sure that symlink support is enabled before you clone the repository with Git. It is turned off by default in Git for Windows. Start a terminal as administrator and run:

git config --system core.symlinks true

Options for Building

To work locally on the documentation you can:

Docker is generally easier, but may also be slower (at least under Windows).

Note that the Algolia plugin has a dependency which does not support Ruby 2.6+.

Jekyll

If you want to build the docs the first time, run bundle install to ensure that all dependencies (gems / plugins) are installed.

For local development, start Jekyll in watch mode:

bundle exec jekyll serve

This will build the documentation, rebuild it if you change files, and serve the documentation site locally using Jekyll's built-in web server.

You can then browse the docs in a browser at http://127.0.0.1:4000/docs/stable/. Note that it has to be /docs/stable/ (or another version than stable). Both paths / and /docs do not work (404 Page not found) because of the configured baseurl in _config.yml, and /docs/ redirects you to the online version of the documentation.

To let Jekyll build the static site without serving it or watching for file changes, use:

bundle exec jekyll build

The generated content will be stored in the _site/docs/ folder.

To serve the content from a previous build without watching for changes, use:

bundle exec jekyll serve --skip-initial-build --no-watch

Docker Container

In the docs directory, execute:

docker run --rm -v $(pwd):/docs -p 4000:4000 arangodb/arangodb-docs

This will watch for file changes and you will be able to see the resulting static site on http://127.0.0.1:4000/docs/stable/.

Note that Jekyll's --incremental build option is enabled. In addition, DocuBlocks are parsed once per invocation and then cached in memory. If you encounter stale content, then stop the container and run:

docker run --rm -v $(pwd):/docs -p 4000:4000 arangodb/arangodb-docs bundler exec jekyll serve -H 0.0.0.0 --trace

Alternatively, you may stop the container, execute either of the following commands, and run the normal Docker command again (without additional arguments).

To build the documentation without watch mode or serving the resulting site, you can execute:

docker run --rm -v $(pwd):/docs arangodb/arangodb-docs bundler exec jekyll build --trace

After that the HTML files in _site/ are ready to be served by a webserver:

cd _site
python3 -m http.server

To check for broken references (e.g. internal links), you can run htmltest:

docker run --rm -v $(pwd):/docs arangodb/arangodb-docs htmltest

Performance

A full build (all versions) will take quite a while. You can use Jekyll's watch mode to let it continuously rebuild the pages you change after an initial build. For simple documentation changes this process normally works perfect.

However there are cases where Jekyll won't detect changes. This is especially true when changing plugins and configuration (including the navigation YAML when adding a new page). To be sure you have an up-to-date version remove the _site directory and then abort and restart the watch mode.

To speed up the build process you may disable certain versions from being built by changing the _config.yml:

exclude:
# - 3.12/
# - 3.11/
# - 3.10/
  - 3.9/
  - 3.8/

Above example disables versions 3.8 and 3.9, so that only 3.10 through 3.12 are built. Do not commit these changes of the configuration!

Note that building may fail if you disable certain versions that contain the files that other versions refer to with symlinks, or required versions as defined in _config.yml:

versions:
  stable: "3.8"
  devel: "3.9"

Documentation Structure

Versions

In the root directory, the directories 3.8, 3.9 etc. represent the individual ArangoDB versions and their documentation. We only maintain one version of the documentation for every minor and major version (3.9, 4.0, etc.) but not for every patch release (e.g. 3.8.2).

The content for different documentation versions used to be in version branches (2.7, devel, etc.) in the arangodb/arangodb repository, but now all documentation versions live in the main branch of this repository. This has the advantage that all versions can be built at once, but the drawback of Git cherry-picking not being available and therefore requiring to manually apply changes to different versions as necessary (copy-pasting text or files).

Books (Parts)

The documentation is split into different parts, called "books" for historical reasons. The core book (Manual) of a version does not have an own folder for its content, but the files are found in the version directory, e.g. 3.8/*.md. Other books (AQL, HTTP) have subfolders in the version folder, e.g. 3.8/aql/.

There are also books (Drivers, ArangoGraph) that are not directly couple to ArangoDB versions, that have their files in an own folders in the root directory, e.g. arangograph/*.md. These folders are symlinked in multiple version folders. Some files, like release notes, are also symlinked to reduce maintenance costs.

The organization of documents is flat, namely there are no subdirectories per book (as opposed to the previous documentation system). For example, all files of the AQL part are in the aql/ folder. It does not have any subfolders like aql/examples/. Instead, the file name reflects which files belong together, e.g. aql/examples-counting.md.

Special Folders

Content folders aside, there are the following other directories:

Name Description
_data data files which are used by plugins and layouts, including the navigation definitions
_includes templates for custom tags and layout partials
_layouts layout definitions that can be used in YAML frontmatter like layout: default
_plugins Jekyll extensions for the navigation, version switcher, custom tags / blocks etc.
_site default output directory (not committed)
assets files not directly related to the documentation content that also need to be served (e.g. the ArangoDB logo)
js JavaScript files used by the documentation site
scripts Scripts which were used in the migration process from Gitbook to Jekyll (not really needed anymore)
styles CSS files for the site, including a lot of legacy from Gitbook

Working with the Documentation Content

Markup Overview

The documentation is written in the light-weight markup language Markdown. There are different flavors of Markdown and it is further extended by Liquid, Jekyll's templating language, as well as our own customization.

Below is a list of the most commonly used markup, and an approximation of how it gets rendered:

Element Markdown Preview HTML
Text line
A single line
of text
A single line of text A single line of text
Paragraph
A single
paragraph.

Another paragraph.

A single paragraph.

Another paragraph.

<p>A single paragraph.</p>
<p>Another paragraph.</p>
Heading 1 # Level 1

Level 1

<h1>Level 1</h1>
Heading 1 (Variant)
Level 1
=======

Level 1

<h1>Level 1</h1>
Headling 2 ## Level 2

Level 2

<h2>Level 2</h2>
Headling 2 (Variant)
Level 2
-------

Level 2

<h2>Level 2</h2>
Headling 3 ### Level 3

Level 3

<h3>Level 3</h3>
Headling 4 #### Level 4

Level 4

<h4>Level 4</h4>
Headling 5 ##### Level 5
Level 5
<h5>Level 5</h5>
Headling 6 ###### Level 6
Level 6
<h6>Level 6</h6>
Italic *italic* italic <em>italic</em>
Italic _italic_ italic <em>italic</em>
Bold **bold** bold <strong>bold</strong>
Bold __bold__ bold <strong>bold</strong>
Bold & Italic ***bold & italic*** bold & italic <strong><em>bold & italic</em></strong>
Bold & Italic ___bold & italic__ bold & italic <strong><em>bold & italic</em></strong>
Superscript 2<sup>32</sup> 232 2<sup>32</sup>
Subscript 2<sub>32</sub> H2O H<sub>2</sub>O
Blockquote > quote
quote
<blockquote>quote</blockquote>
Ordered List
1. First
2. Second
3. Third
  1. First
  2. Second
  3. Third
<ol>
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
</ol>
Unordered List
- First
- Second
- Third
  • First
  • Second
  • Third
<ul>
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
</ul>
Unordered List
* First
* Second
* Third
  • First
  • Second
  • Third
<ul>
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
</ul>
Inline Code `code value` code value <code>code value</code>
Fenced Code
```js
new Date(); // JavaScript
```
new Date(); // JavaScript
<pre><code>new Date(); // JavaScript</code></pre>
Code Block
    shell> pwd
    /home/alice
shell> pwd
/home/alice
<pre><code>shell&gt; pwd
/home/alice</code></pre>
Horizontal Rule ---
<hr />
Link (Internal) [label](book/file.html) label <a href="https://github.com/arangodb/docs/blob/main/book/file.html">label</a>
Link (Anchor) [label](#element-id) label <a href="#element-id">label</a>
Link (External) [label](https://www.arangodb.com/){:target="_blank"} label <a href="https://www.arangodb.com" target="_blank">label</a>
Link (External) <https://www.arangodb.com/>{:target="_blank"} https://www.arangodb.com/ <a href="https://www.arangodb.com" target="_blank">https://www.arangodb.com/</a>
Image ![ArangoDB Logo](assets/arangodb_logo_small_2016.png) ArangoDB Logo <img src="https://github.com/arangodb/docs/raw/main/assets/arangodb_logo_small_2016.png" alt="ArangoDB Logo">
Table
| A  | B  | C  |
|----|----|----|
| A1 | B1 | C1 |
| A2 | B2 | C2 |
ABC
A1B1C1
A2B2C2
<table>
  <thead>
    <tr>
      <th>A</th>
      <th>B</th>
      <th>C</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>A1</td>
      <td>B1</td>
      <td>C1</td>
    </tr>
    <tr>
      <td>A2</td>
      <td>B2</td>
      <td>C2</td>
    </tr>
  </tbody>
</table>
Frontmatter
---
layout: default
description: Page about X
title: Feature X
---
<title>Feature X | ArangoDB Documentation</title>
<meta itemprop="description" name="description" content="Page about X" />
Danger
{% hint 'danger' %}
Unrecoverable fault
{% endhint %}
❌ Unrecoverable fault
<div class="alert alert-danger" …>
Unrecoverable fault
</div>
Warning
{% hint 'warning' %}
Common pitfall
{% endhint %}
⚠ Common pitfall
<div class="alert alert-warning" …>
Common pitfall
</div>
Security
{% hint 'security' %}
Security warning
{% endhint %}
🛡 Security warning
<div class="alert alert-warning" …>
Security warning
</div>
Info
{% hint 'info' %}
Informative note
{% endhint %}
ℹ Informative note
<div class="alert alert-info" …>
Informative note
</div>
Tip
{% hint 'tip' %}
Useful hint
{% endhint %}
✔ Useful hint
<div class="alert alert-success" …>
Useful hint
</div>
Include {% include hint-ee-arangograph.md feature="SmartGraphs" plural=true %}
ℹ SmartGraphs are only available in the Enterprise Edition, including the ArangoGraph Insights Platform.
<div class="alert alert-info" …>
SmartGraphs are only available in the
<a href="https://www.arangodb.com/enterprise-server/" target="_blank">Enterprise Edition</a>,
including the <a href="https://cloud.arangodb.com/home" target="_blank">ArangoGraph Insights Platform</a>.
</div>
Version (full) {{ site.data.versions[page.version.name] }} v3.9.0-devel v3.9.0-devel
Version (major.minor) {{ page.version.version }} 3.9 3.9
Version Condition
{%- assign ver = "3.8" | version: ">=" %}
{%- if ver %}
Current version is greater than 3.8
{%- else %}
Current version is less than or equal to 3.8
{%- endif %}
Current version is greater than 3.8 Current version is greater than 3.8
Version Remark <small>Introduced in: v3.8.2</small> Introduced in: v3.8.2 <small>Introduced in: v3.8.2</small>

Content Guidelines

Syntax Guidelines

Adding links

The official way to cross-reference other pages within the documentation would be to use Jekyll's link tag ({% link path/to/file.md %}). This mechanism is not used, however. We use plain Markdown links, but this has the drawback of having to change the file extension from .md to .html so that it will work once the documentation is built.

This is an [internal link](aql/functions-numeric.html#max).

Note that internal links should be relative, i.e. not include a version number, unless it is supposed to point to a different version of the documentation on purpose. To point from one book to another, you may need to use .. to refer to the parent folder of a file.

From To Markdown
3.9/tutorials.md 3.9/graphs.md [Graphs](graphs.html)
3.9/tutorials.md 3.9/aql/operators.md [AQL Operators](aql/operators.html)
3.9/aql/operators.md 3.9/tutorials.md [Tutorials](../tutorials.html)
3.9/aql/operators.md 3.9/http/pregel.md [Pregel HTTP API](../http/pregel.html)
3.9/tutorials.md 3.8/architecture.md [Architecture v3.8](../3.8/architecture.html)
3.9/aql/operators.md 3.8/tutorials.md [Tutorials v3.8](../../3.8/tutorials.html)

You can also link to headlines within a page like [label](#anchor-id). The anchor ID is the headline text but with the characters converted to Latin base characters, all lower-case, spaces and other special characters replaced by hyphens -. Underscores remain, however. Some examples:

Headline Anchor
Some Text #some-text
Ümläuté #umlaute
Insert / Save #insert--save
TO_HEX() #to_hex
norm Analyzer #norm-analyzer
--startup.option-name #--startupoption-name

For external links, please add {:target="_blank"} so that they open in a new tab when clicked:

This is an [external link](https://www.arangodb.com/){:target="_blank"}

Version Remarks

The main page about a new feature should indicate the version the feature was added in, as shown below:

---
layout: default
description: >-
  Feature summary
---
# New feature

<small>Introduced in: v3.10.0</small>

{{ page.description }}
{:class="lead"}

...

Similarly, the remark should be added if only a section is added to an existing page, as shown below:

# Existing feature

...

## New feature section

<small>Introduced in: v3.10.0</small>

...

The value v3.10.0 implies that all later versions also have this feature (3.10.1, 3.10.2, etc., as well as 3.11.0 and later). If this is not the case, then also mention the other relevant versions. For example, if a feature is added to 3.9.6 and 3.10.2, then write the following in the 3.10 documentation:

<small>Introduced in: v3.9.6, v3.10.2</small>

All later documentation versions should use a copy of the content, as thus the 3.11 documentation would contain the same.

In the 3.9 documentation, only mention versions up to this documentation version (excluding 3.10 and later in this example), pretending no later version exists to be consistent with the rest of the 3.9 documentation and to avoid additional maintenance burdens:

<small>Introduced in: v3.9.6</small>

New options in the JavaScript and HTTP APIs are covered by the release notes, but if new options are added mid-release (not in the x.x.0 release but a later bugfix version), then this should be pointed out as follows:

- `existingOption` (number, _optional_): ...
- `newOption` (string, _optional_): ... (introduced in v3.9.6, v3.10.2).

You may also add a remark if an existing feature or option is significantly extended by a new (sub-)option in a x.x.0 release.

Edition Remarks

Pages and sections about Enterprise Edition features should indicate that the Enterprise Edition is required using a hint box. Use the following include in the general case:

{% include hint-ee-arangograph.md feature="New feature X" %}

This should be placed after version remarks if there are any.

Most Enterprise Edition features are also available in ArangoGraph, but some features are not or in a different form (e.g. DC2DC, Hot Backup). If a feature is not available in ArangoGraph, use the following include instead:

{% include hint-ee.md feature="New feature X" %}

If the feature name is a plural form of a word, set the plural option to true (this works with both includes):

{% include hint-ee-arangograph.md feature="EnterpriseGraphs" plural=true %}

In the release notes, add the following at the end of a section about a new Enterprise Edition feature:

This feature is only available in the Enterprise Edition.

API options that are only available in the Enterprise Edition should have a remark as follows:

- `enterpriseOption` (boolean, _optional_): ...
  (Enterprise Edition only).

If there are both a version remark and an Enterprise Edition remark, use:

- `enterpriseOption` (boolean, _optional_): ...
  (introduced in v3.9.6 and v3.10.2, Enterprise Edition only).

Adding a Lead Paragraph

A lead paragraph is the opening paragraph of a written work that summarizes its main ideas. Only few pages have one so far, but new content should be written with such a brief description. It is supposed to clarify the scope of the article so that the reader can quickly assess whether the following information is of relevance, but also acts as an introduction.

# Using Feature X

You can do this and that with X, and it is ideal to solve problem Y
{:class="lead"}

The lead paragraph needs to be placed between the top-level headline and the first content paragraph. It should end without a period, contain no links and usually avoid other markup as well (bold, italic). This also enables the use of the lead paragraph as metadata for the page:

---
layout: default
description: >-
  You can do this and that with X, and it is ideal to solve problem Y
title: Feature X
---
# Using Feature X

{{ page.description }}
{:class="lead"}

The generated metadata looks like this:

<meta property="og:title" content="Feature X | ArangoDB Documentation" />
<meta property="og:description" content="You can do this and that with X, and it is ideal to solve problem Y" />

Adding a page

Start off by finding a file name. It should be:

Note that the file name is independent of what will show in the navigation or what will be used as headline for that page. The file name will be used as part of the final URL, however. For example, 3.8/aql/examples.md will become http://www.arangodb.com/docs/3.8/aql/examples.html.

Create a new file with the file name and a .md file extension. Open the file in a text editor (Visual Studio Code is recommended). Add the following frontmatter:

---
layout: default
description: A meaningful description of the page
title: Short title
---

Add the actual content formatted in Markdown syntax below the frontmatter.

Then add the page to the navigation. Each book has a navigation tree represented as a nested data structure in YAML syntax. The NavigationTag plugin creates the navigation on the left-hand side from it. The YAML file for a book can be found here: _data/<version>-<book>.yml.

Open the respective navigation definition file, e.g. _data/3.8-aql.yml if the page should be added to the AQL book of version 3.8. Let us assume the file is aql/operations-create.md and the page is supposed to show above the FOR language construct in the navigation. Locate where that other page is added and insert a new pair of lines for the new page:

 - text: High level Operations
   href: operations.html
   children:
+    - text: CREATE
+      href: operations-create.html
     - text: FOR
       href: operations-for.html

text will be used as label in the navigation. href is the name of the file, relative to the current book. Note that the file extension needs to be .html, not .md!

Renaming a page

The URL of a page is derived from the file name. If you rename a file, e.g. from old-name.md to new-name.md, make sure to add a redirect for the old URL by adding the following to the frontmatter:

 ---
 layout: default
 description: ...
 title: ...
 ---
+redirect_from:
+  - old-name.html # 3.8 -> 3.9

The URL should be relative and the comment (#) indicate the versions it was renamed in (can also be the same version twice, e.g. # 3.8 -> 3.8).

Setting anchor IDs

Headlines are assigned automatically generated identifiers based on their text. In some cases you may want to set an ID explicitly:

### A headline {: #custom-id }

Disable or limit table of contents

The table of contents (ToC) on the right-hand side at the top of a page lists the headlines if there at least three on the page. It can be disabled for individual pages with the following frontmatter:

---
layout: default
page-toc:
  disable: true
---

It can also be restricted to a maximum headline level to omit the deeper nested headlines for less clutter:

---
layout: default
page-toc:
  max-headline-level: 3
---

A setting of 3 means that <h1>, <h2>, and <h3> headlines will be listed in the ToC, whereas <h4>, <h5>, and <h6> will be ignored.

Updating version numbers

Version number schema

The version number schema is vMajor.Minor.Patch, e.g. v3.9.5. Patch releases contain bugfixes only. Minor releases often add new features and come with some breaking changes. Major releases add new features and may contain substantial breaking changes.

Non-stable versions can have a suffix. The devel version usually ends with -devel, e.g. v3.9.0-devel. Preview releases can also have suffixes like -alpha.1, -beta.2, -rc.3.

Patch releases

When a new patch release is published, the respective version number in _data/versions.yml is incremented by the release automation:

-"3.8": "v3.8.1"
+"3.8": "v3.8.2"

The examples should be re-generated to ensure that they match the actual server behavior of the new version.

Major and minor releases

When a new major or minor version is released to the public, the new stable version needs to be made the default version for the documentation. It will be available under the stable alias at https://www.arangodb.com/docs/stable/. At the same time, the in-development version needs to be updated as well. It will be available under the devel alias at https://www.arangodb.com/docs/devel/.

The stable and devel versions can be adjusted in the _config.yml under the versions key:

 versions:
-  stable: "3.8"
-  devel: "3.9"
+  stable: "3.9"
+  devel: "3.10"

Also update the version number in the _redirects file to the latest stable version, so that Netlify previews default to this version:

-/              /docs/3.8/
+/              /docs/3.9/

Update the list of files to exclude to let Algolia index the new stable version:

 algolia:
   ...
   files_to_exclude:
     - 3.10/**/*
-    - 3.9/**/*
-#   - 3.8/**/*  # OUR STABLE VERSION
+#   - 3.9/**/*  # OUR STABLE VERSION
+    - 3.8/**/*
     - 3.7/**/*
     - ...

Do not forget to re-generate the examples before publishing.

Deprecating a version

When an ArangoDB version reaches End-of-Life, its documentation needs to be marked as such. The respective version needs to be added to the _data/deprecations.yml file for that:

 - "3.5"
 - "3.6"
+- "3.7"

It makes a warning show at the top of every page for that version.

Adding a new version

Adding a new arangosh example

A complete example with the preferred indentation:

    {% arangoshexample examplevar="examplevar" script="script" result="result" %}
    @startDocuBlockInline ensureUniquePersistentSingle
    @EXAMPLE_ARANGOSH_OUTPUT{ensureUniquePersistentSingle}
    ~ db._create("ids");
      db.ids.ensureIndex({ type: "persistent", fields: [ "myId" ], unique: true });
      db.ids.save({ "myId": 123 });
    | db.ids.save({ 
    |   "myId": 123
      }); // xpError(ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED)
    ~ db._drop("ids");
    @END_EXAMPLE_ARANGOSH_OUTPUT
    @endDocuBlock ensureUniquePersistentSingle
    {% endarangoshexample %}
    {% include arangoshexample.html id=examplevar script=script result=result %}

Jekyll requires the example code to be encapsulated by an arangoshexample block, followed by an include tag to embed the example:

{% arangoshexample examplevar="examplevar" script="script" result="result" %}
...
{% endarangoshexample %}
{% include arangoshexample.html id=examplevar script=script result=result %}

Inside the block, two more wrappers are needed. The outer one marks the beginning and end of a so-called DocuBlock and gives it a unique name that will be used as file name for the example transcript (e.g. 3.9/generated/Examples/name_of_docublock.generated). The inner one indicates that it is an arangosh example and not a curl example and repeats the DocuBlock name:

@startDocuBlockInline name_of_docublock
@EXAMPLE_ARANGOSH_OUTPUT{name_of_docublock}
...
@END_EXAMPLE_ARANGOSH_OUTPUT
@endDocuBlock name_of_docublock

Groups of examples should have the same name prefix. If an example needs to be run against an ArangoDB cluster instead of a single server (default), then give the name a suffix of _cluster.

Inside the wrappers, you can write the JavaScript code for arangosh:

db._create("collection");
db.collection.save({ _key: "foo", value: 123 });
db._query(`FOR doc IN collection RETURN doc.value`).toArray();
db._drop("collection");

Each statement needs to be either on a single line, or indicate that line continuation is required for statements spanning multiple lines. A leading pipe character | is required for all lines except the last line of a multi-line statement:

  db._create("collection");
| db.collection.save([
|   { multiple: true },
|   { lines: true }
  ]);
| for (var i = 0; i < 3; i++) {
|   db.collection.save({ _key: "k" + i });
  }
  db._drop("collection");

The statements as well as the results will be visible in the example transcript. To hide certain statements from the output, e.g. for setup/teardown that is not relevant for the example, you can use a leading tilde ~ to suppress individual lines:

~ db._create("collection");
  db.collection.save({ _key: "foo" });
~ db._drop("collection");

Examples need to remove the collections and Views they create. Not dropping them will raise an error unless they are specifically exempt:

~ db._create("collection");
~ db._createView("view", "arangosearch", {...});
  db.collection.save({...});
~ addIgnoreView("view");
~ addIgnoreCollection("collection");

This is helpful for creating collections and Views once, using them in multiple examples, and finally dropping them instead of having to create and drop them in each example. You need to choose the names for the DocuBlocks so that they are alphabetically sortable to have them execute in the correct order. The last example of the series should undo the ignore to catch unintended leftovers:

~ removeIgnoreCollection("collection");
~ removeIgnoreView("view");
~ db._dropView("view");
~ db._drop("collection");

If a statement is expected to fail (e.g. to demonstrate the error case), then this has to be indicated with a special JavaScript comment:

db._document("collection/does_not_exist"); // xpError(ERROR_ARANGO_DOCUMENT_NOT_FOUND)

This will make the example generation continue despite the error. See Error codes and meanings for a list of all error codes and their names. If a unexpected error is raised, then the example generation will abort with an error.

If you want to wrap the special comment to a new line but suppress and empty line in the output, you can use | on the first and ~ on the second line:

| db._document("collection/does_not_exist");
~ // xpError(ERROR_ARANGO_DOCUMENT_NOT_FOUND)

Every backslash in a query needs to be escaped with another backslash, i.e. JSON escape sequences require two backslashes, and literal backslashes four:

db._query(`RETURN REGEX_SPLIT("foo\\t bar\\r baz\\n foob", "\\\\s+|(?:b\\\\b)")`).toArray();

This does not apply to backslashes in bind variables:

db._query(`RETURN REGEX_SPLIT(@t, @r)`, {t: "foo\t bar\r baz\n foob", r: "\\s+|(?:b\\b)"}).toArray();

Adding a new AQL example

Complete example with the preferred indentation:

    {% aqlexample examplevar="examplevar" type="type" query="query" bind="bind" result="result" %}
    @startDocuBlockInline joinTuples
    @EXAMPLE_AQL{joinTuples}
    @DATASET{joinSampleDataset}
    @EXPLAIN{TRUE}
    FOR u IN users
      FILTER u.active == true
      LIMIT 0, 4
      FOR f IN relations
        FILTER f.type == @friend && f.friendOf == u.userId
        RETURN {
          "user" : u.name,
          "friendId" : f.thisUser
        }
    @BV {
      friend: "friend"
    }
    @END_EXAMPLE_AQL
    @endDocuBlock joinTuples
    {% endaqlexample %}
    {% include aqlexample.html id=examplevar type=type query=query bind=bind result=result %}

Similar to arangosh examples, several wrappers are required. The aqlexample block encapsulates the example for Jekyll, and the include tag embeds it:

{% aqlexample examplevar="examplevar" type="type" query="query" bind="bind" result="result" %}
...
{% endaqlexample %}
{% include aqlexample.html id=examplevar type=type query=query bind=bind result=result %}

Inside the block, there is a DocuBlock wrapper and a wrapper to indicate that this is an AQL example:

@startDocuBlockInline name_of_docublock
@EXAMPLE_AQL{name_of_docublock}
...
@END_EXAMPLE_AQL
@endDocuBlock name_of_docublock

The example can optionally specify a dataset that will be loaded before the query is run:

@DATASET{name_of_dataset}

See https://github.com/arangodb/arangodb/blob/devel/js/common/modules/@arangodb/examples/examples.js for the available datasets.

To get the query explain output including the execution plan instead of the actual query result, you can optionally specify:

@EXPLAIN{TRUE}

Then the actual AQL query follows, e.g.

FOR i IN 1..3
  RETURN i

The query can optionally use bind parameters that can be passed like this:

FOR elem IN @arr
  RETURN elem
@BV {
  arr: ["foo", "bar"]
}

Adding a new DocuBlock

DocuBlocks define reusable pieces of content but the DocuBlocks system is mainly used for describing the HTTP API by now. It is also used for arangosh and AQL examples, using inline DocuBlocks (see above).

To embed a DocuBlock in the documentation, use the docublock tag in a Markdown file:

{% docublock name %}

HTTP API DocuBlocks

The source files for DocuBlocks that describe and demonstrate the HTTP API are located in the main repository at Documentation/DocuBlocks/Rest/: https://github.com/arangodb/arangodb/tree/devel/Documentation/DocuBlocks/Rest They are written in a proprietary text format that can be converted to Swagger 2.0 definitions as well as rendered by the documentation tooling.

A complete example of such a DocuBlock:

@startDocuBlock post_api_foo
@brief creates a foo

@RESTHEADER{POST /_api/foo/{param}, Create foo, createFoo}

@HINTS
{% hint 'warning' %}
Text to be displayed in a callout box.
{% endhint %}

@RESTDESCRIPTION
Detailed description of the endpoint.

@RESTURLPARAMETERS

@RESTURLPARAM{param,string,required}
Dynamic piece of the URL path, signified by curly {braces} in the @RESTHEADER route.

@RESTQUERYPARAMETERS

@RESTQUERYPARAM{creationOption,boolean,optional}
One-off setting that is not persisted unlike e.g. collection properties.

@RESTHEADERPARAMETERS

@RESTHEADERPARAM{If-Match,string,optional}
An HTTP header field that you can set.

@RESTBODYPARAM{name,string,required,string}
Primitive body parameter that is of type string and mandatory.

@RESTBODYPARAM{fooOptions,object,optional,post_api_foo_opts}
Complex body parameter with key `fooOptions` and an object as value.
The object is described by @RESTSTRUCTs that reference `post_api_foo_opts`.

@RESTSTRUCT{type,post_api_foo_opts,integer,required,int64}
A nested parameter with parent `fooOptions`, key `type`, and expecting an integer as value.

@RESTRETURNCODES

@RESTRETURNCODE{200}
HTTP status code returned if the request was successful.

@RESTREPLYBODY{error,boolean,required,}
`false` in this case

@RESTRETURNCODE{400}
HTTP status code returned if the request failed.

@RESTREPLYBODY{error,boolean,required,}
`true` in this case

@EXAMPLES

@EXAMPLE_ARANGOSH_RUN{RestFooCreate}
    var url = "/_api/foo/example?creationOption=true";
    var body = {
      name: "testFoo",
      fooOptions: {
        type: 123
      }
    };

    var response = logCurlRequest('POST', url, body);
    assert(response.code === 200);
    logJsonResponse(response);
@END_EXAMPLE_ARANGOSH_RUN

@endDocuBlock

@startDocuBlock / @endDocuBlock

Every DocuBlock starts with @startDocuBlock followed by a name, and ends with @endDocuBlock.

@startDocuBlock post_api_foo
...
@endDocuBlock

There is typically just one DocuBlock in a file but a single file can contain multiple DocuBlocks.

The naming convention is to use snake_case and the pattern method_path, e.g. post_api_collection for the POST /_api/collection endpoint. The DocuBlock name is often used as file name, too, but it can deviate. The file extension is .md as the content is Markdown-formatted text (DocuBlock markup aside).


@brief

The first structural element in a DocuBlock should be @brief, followed by a summary of what the endpoint does:

@brief creates a foo

@RESTHEADER

The next element should be the @RESTHEADER:

@RESTHEADER{VERB /url/{param}, Description, operationId}

@HINTS

There can optionally be a @HINTS element with one or more hint blocks:

@HINTS
{% hint 'type' %}
Remarks to highlight.
{% endhint %}

@RESTURLPARAMETERS / @RESTURLPARAM

If @RESTHEADER contains at least one {placeholder} for URL parameters, then a @RESTURLPARAMETERS section with @RESTURLPARAM elements for every placeholder is required:

@RESTURLPARAMETERS

@RESTURLPARAM{param,type,necessity}
Description.

@RESTURLPARAM...

@RESTQUERYPARAMETERS / @RESTQUERYPARAM

If an endpoint supports query parameters (like ?param1=aaa&param2=bbb after the URL path), then a @RESTQUERYPARAMETERS section with @RESTQUERYPARAM elements for every query parameter is needed:

@RESTQUERYPARAMETERS

@RESTQUERYPARAM{name,type,necessity}
Description.

@RESTQUERYPARAM...

@RESTHEADERPARAMETERS / @RESTHEADERPARAM

If an endpoint supports options that can be set in the HTTP header, then a @RESTHEADERPARAMETERS section with @RESTHEADERPARAM elements for every header field is needed:

@RESTHEADERPARAMETERS

@RESTHEADERPARAM{Field,type,necessity}
Description.

@RESTHEADERPARAM...

@RESTBODYPARAM

To describe the request payload, use @RESTBODYPARAM elements. Note that there is no @RESTBODYPARAMETERS section:

@RESTBODYPARAM{name,type,necessity,subtype}
Description.

@RESTBODYPARAM...

Example of a body parameter that expects an array of strings:

@RESTBODYPARAM{fields,array,required,string}

Example of a body parameter that expects an array of objects without further description of these objects:

@RESTBODYPARAM{primarySort,array,optional,object}

Example of a body parameter that expects an array of objects. Each object needs to have a username key with a string value, and can optionally have an active key with a boolean value:

@RESTBODYPARAM{users,array,optional,user_object}

@RESTSTRUCT{username,user_object,string,required,}
Login name of an existing user or one to be created.

@RESTSTRUCT{active,user_object,boolean,optional,}
Whether the account should be activated or not. Defaults to `true`.

Note that you can reference @RESTSTRUCTs that are defined in other files. This is useful for sharing common data structures. The files called 1_structs.md are used for this kind of sharing. The 1_ prefix was chosen because operating systems typically iterate folder contents in alphabetical order, ensuring that it gets processed before other files in the same folder, so that the @RESTSTRUCT definition is available before it gets referenced.


@RESTALLBODYPARAM

If an endpoint has a schemaless JSON body or plaintext payload, then you can use a single @RESTALLBODYPARAM element instead of any @RESTBODYPARAMs:

@RESTALLBODYPARAM{name,type,necessity}
Description.

@RESTRETURNCODES / @RESTRETURNCODE / @RESTREPLYBODY

To describe the response payload, use a @RESTRETURNCODES section with one or more @RESTRETURNCODE subsections. You should add a subsection for every relevant HTTP status code. General status codes that are not specific to the endpoint (e.g. 503 Service Unavailable) should not be described. Each subsection may have @RESTREPLYBODY elements that describe the response data structure:

@RESTRETURNCODES

@RESTRETURNCODE{status}
Description.

@RESTREPLYBODY{name,type,necessity,subtype}
Description.

@RESTREPLYBODY...

@RESTRETURNCODE...

@RESTREPLYBODY...

@RESTSTRUCT

For nested data structures, as well for sharing structural descriptions between DocuBlocks, you can use @RESTSTRUCT. Such structs can be referenced in @RESTBODYPARAM, @RESTREPLYBODY, and other @RESTSTRUCT elements.

@RESTSTRUCT{name,struct,type,necessity,subtype}
Description.

Special case of a @RESTREPLYBODY element referencing a @RESTSTRUCT as top-level object description (note the empty name):

@RESTREPLYBODY{,object,required,collection_info}

Example of a response description with an array at the top-level (note the empty name):

@RESTREPLYBODY{,array,required,get_api_query_rules}

@EXAMPLES

You can add an arbitrary number of examples to a DocuBlock in an @EXAMPLES section. An HTTP API example needs to be wrapped by @EXAMPLE_ARANGOSH_RUN and @END_EXAMPLE_ARANGOSH_RUN:

@EXAMPLES

@EXAMPLE_ARANGOSH_RUN{name}
    /* code */
@END_EXAMPLE_ARANGOSH_RUN

@EXAMPLE_ARANGOSH_RUN...

Unlike arangosh examples (@EXAMPLE_ARANGOSH_OUTPUT), requests and responses need to be output explicitly by calling one of the following functions:

To test whether requests and replies are as expected, you can add assert(expression) calls. Expressions that evaluate to false will make the example generation fail. You may inspect the generated JavaScript code of the failed example in arangosh.examples.js.

Troubleshooting

CI/Netlify

For the CI process we currently use Netlify. This service has been built so that you can quickly test and deploy static sites. We only use it to have a live preview and a CI pipeline, not for hosting the actual documentation site.

There are a few files in the repo required for Netlify:

For details please check out the Netlify documentation.

License

The ArangoDB documentation is licensed under Apache-2.0. See LICENSE for details.

Parts not licensed under Apache-2.0 are outlined in LICENSES-OTHER-COMPONENTS.md