Attributes and Roles
Use attributes and roles to insert content or CSS styles into your pages.
Setting and Referencing Document Attributes
Use an AsciiDoc attribute to hold names, URLs, and reusable content phrases.
An attribute consists of a key-value pair set in a page header or in the playbook file for the documentation site. Some attributes are built-in to Asciidoctor. Others are defined especially for the Couchbase documentation or by the writer.
Adding an attribute to a document header makes an attribute available to an entire page and all of its includes. Each attribute must be entered on a separate line, known as an attribute entry. The syntax of an attribute entry as follows:
:name: value
In this case, name
is the name of the attribute and value
is the optional value.
The following example shows a document header with multiple included attributes:
= Page Title
:page-topic-type: concept (1)
:source-language: javascript (2)
:url-downloads: https://www.couchbase.com/downloads (3)
:tabs: (4)
Download Sync Gateway from the {url-downloads}[Couchbase downloads page]. (5)
[source] (6)
----
Snippet of javascript source code
----
1 | Attribute names that start with page- are specially handled by Antora. |
2 | A value can be assigned to a built-in attribute in the document header. |
3 | Writers can set and define their own attributes. |
4 | Some attributes are assigned an implicit value.
In this case, the tabs feature is turned on by setting tabs . |
5 | Reference an attribute in the body of the document by entering the attribute name inside a set of curly brackets ({attribute-name} ). |
6 | Code blocks are assigned the source language javascript . |
Available Document Attributes
The following document attributes must be included for every AsciiDoc file stored in a pages directory:
Attribute | Description | Allowed Values |
---|---|---|
|
The page topic type sets the content type for a page and automatically adds a corresponding badge. These badges help users quickly identify the kind of content they’re going to find on a page. |
|
|
The page description is used for SEO and provides a brief description of the page, which is displayed using the |
Enter a quick description of the content on the page. Emphasize what the user would want to know at a glance. Try to keep it to 1-2 sentences. |
You can also use the following optional attributes:
Attribute | Description | Allowed Values | ||
---|---|---|---|---|
|
Use the Set the For example, the following would become a valid image include: image::name-of-image.png[] |
Try to keep your images inside the |
||
|
Use the |
Any applicable keyword, separated by commas ( |
||
|
Use the
|
A valid cross reference to a page. For a page in the same module: For a page in a different module: For a page in another repository: When linking to a repository that has a version, you must specify which version in that repository redirects to your current page. |
||
|
If you’re writing content that only applies to a specific edition of Couchbase Server, usually the Enterprise Edition, use the |
|
||
|
Sets the UI layout to assign to a page.
By default, pages use the |
For the list of all available templates, see the docs-ui repository. |
||
|
Include the Set the attribute to Set the attribute to For an example of |
|
||
|
Allows this page to be included inside another page as a partial file.
You only need to set this attribute on a page that you add to the |
|
||
|
Assign a role to a page to change the default CSS or add new CSS styles to the entire page. The exact behavior depends on the assigned role. The |
|
||
|
If you’re writing content that only applies to a beta or specific software version, use the |
Any valid software name and version. For example, |
||
Use the |
|
|||
|
Unset the If You can always override these automatic IDs by assigning your own. |
|
||
|
To add the tabs feature to your page and allow tabbed content blocks, you must set the You can find an example of tabbed content in the Server documentation. |
|
||
|
Controls the generated text for cross references in a document, when linking to block content that has a caption set. For more information, see the AsiiDoc documentation. |
|
Antora also assigns several page attributes on each page to provide information about the component, version, and module where a page is located. You can find a list of these attributes in the Antora documentation.
See the production and staging Antora playbooks to review which AsciiDoc attributes are currently set and unset for all of the Couchbase documentation pages.
Unsetting a Document Attribute
Some built-in attributes are set (turned on) by default and set for all of the Couchbase document in the playbook.
For example, the sectids
attribute is turned on by default and automatically generates section IDs for all Couchbase documentation pages.
To unset (turn off) an attribute on a page, prefix the name with a bang (!
):
= Page Title
:!sectids:
Using Roles
A role applies alternative or additional CSS styles to a document, block, or phrase. The styles for each role are defined by the code in the docs-ui repository.
Inline Roles
Add a role to a block or phrase by prefixing the role name with a dot and inserting it between a set of square brackets:
[.role-name]`I'm a phrase with an assigned role!`
As stated in the AsciiDoc documentation, inline elements must be surrounded by formatting syntax to be assigned a role.
You can add multiple roles to a single block or phrase by separating each role name with a period (.
):
[.role1 .role2]*I'm a phrase with an assigned role!*
[.role1 .role2]
\----
I'm a block with an assigned role!
\----
Page Roles
Assigning a role to a page applies that role to the entire page, rather than a specific block or phrase.
page-role
is an example of a page attribute.
It must be defined in the document header.
Unlike with blocks and phrases, page roles are not prefixed with a dot and must be separated by a single space (following the same rules as CSS classes).
The Couchbase documentation currently supports two page roles:
-
tiles
-
-toc
These roles are often combined, as you can see in this example:
= Document Title
:page-role: tiles -toc
Page contents.
You can see the tiles -toc
page role combination in action on the Starter Kits page.
The tiles role arranges the secondary section titles as tiles (in two columns).
The -toc role tells the UI template not to add a table of contents (TOC) to the page.
Using Page Attributes
Certain document attribute names are reserved specifically for use with Antora.
These are know as page attributes.
All page attributes begin with the page-
prefix.
The prefix is removed and the remainder is passed on to the UI as metadata.
For the most part, it’s up to the UI to decide how to use this information.
Antora has several built-in page attributes, and some other attributes have been added to the Couchbase UI.
Do not create your own attributes that conflict with the names of any built-in page attributes or page attributes that are already in use. |
Custom Page Attributes
Use custom page attributes to pass information from the document to the UI. Use the docs-ui repository to control what these attributes actually do with the contents of a page.