Documentation widgets are a way to simplify and single source information for
use in the documentation.

The Fuchsia.dev documentation widgets are created with Jinja2 macros and are
also supported in markdown format. The transformation of the widgets from
markdown to an actual Jinja2 macro happens before the page is published on
fuchsia.dev. For more information on Jinja2 macros, see
[macros](https://jinja.palletsprojects.com/en/2.11.x/templates/#macros).

All of the documentation widgets are defined in
[//docs/_common/_doc_widgets.md](https://fuchsia.dev/docs/_common/_doc_widgets).

## Prerequisites: (only for HTML/Jinja2)

> [!NOTE]
> **Note:** This is not required if you use markdown syntax. You only need to use an import statement when using the HTML/Jinja2 version of the widgets.

Before you can use the documentation widgets in HTML/Jinja2, you must import
them into your markdown (.md) file. At the top of your file, specify the
following:


    {% import 'fuchsia-src/_common/_doc_widgets.md' as widgets %}

## General widgets

### inline_toc

Creates a bulleted list of a table of contents (TOC) based on a `_toc.yaml` file.

#### Examples

- Bulleted list of a TOC:

  ### Rendered


  - [Overview](https://fuchsia.dev/fuchsia-src/contribute/docs)
  - [Documentation standards](https://fuchsia.dev/fuchsia-src/contribute/docs/documentation-standards)
  - [Document types](https://fuchsia.dev/fuchsia-src/contribute/docs/documentation-types)
  - [Documentation style guide](https://fuchsia.dev/fuchsia-src/contribute/docs/documentation-style-guide)
  - [Markdown reference guide](https://fuchsia.dev/fuchsia-src/contribute/docs/markdown)
  - [Code sample style guide](https://fuchsia.dev/fuchsia-src/contribute/docs/code-sample-style-guide)
  - [Adding a glossary term](https://fuchsia.dev/fuchsia-src/contribute/docs/glossary-entries)
  - [Adding diagrams to documentation](https://fuchsia.dev/fuchsia-src/contribute/docs/adding-diagrams)
  - [Using documentation widgets](https://fuchsia.dev/fuchsia-src/contribute/docs/widgets)
  - [Update site navigation and TOC](https://fuchsia.dev/fuchsia-src/contribute/docs/documentation-navigation-toc)
  - [Modifying non-inclusive words in mdlint](https://fuchsia.dev/fuchsia-src/contribute/docs/modify-mdlint-inclusive-language)
  - [Deprecating documentation](https://fuchsia.dev/fuchsia-src/contribute/docs/deprecating-docs)
  - [Automated documentation checks - doc-checker](https://fuchsia.dev/fuchsia-src/contribute/docs/doc-checker)
  - [Markdown linter - mdlint](https://fuchsia.dev/fuchsia-src/contribute/docs/mdlint)
  - [Generate reference documentation locally](https://fuchsia.dev/fuchsia-src/contribute/docs/docsgen)
  - Shortlinks

  <br />

  ### HTML/Jinja2


  {% set tocmeta \| yamlloads %}
  {% include "fuchsia-src/contribute/docs/_toc.yaml" %} {% endset %}

  {{ widgets.inline_toc () }}

#### Usage

> [!NOTE]
> **Note:** This widget does not have a markdown equivalent and must also import the widgets on the page. For more information on how to import widgets, see [Prerequisites: (only for HTML/Jinja2)](https://fuchsia.dev/fuchsia-src/contribute/docs/widgets#widgets-prereq).

Due to limitations, you cannot specify the `_toc.yaml` file as a parameter of
the widget.


    {% set tocmeta | yamlloads %}
    {% include "_toc_file.yaml" %}
    {% endset %}
    {{ widgets.inline_toc () }}

#### Parameters

This widget does not use parameters, make sure to specify the
[prerequisites](https://fuchsia.dev/fuchsia-src/contribute/docs/widgets#widgets-prereq) before using this widget.

## Glossary

These widgets are specifically created to work with the glossary terms defined
in [//docs/glossary/glossary.yaml](https://fuchsia.dev/docs/glossary/_glossary.yaml).

In order to enable over-hover definitions, you must use one of the syntaxes listed below. The
markdown version is recommended. Using any other syntax will result in simple links without
over-hover definitions.

For more information on adding a term to the glossary, see
[Adding glossary entries](https://fuchsia.dev/docs/contribute/docs/glossary-entries).

### glossary_simple

Creates a hover-over definition of the `short_description` of a term with
a link to the glossary term. Optionally, this term can be unclickable.

#### Examples

- Clickable over-hover definition:

  ### Rendered

  Definition of


  [](https://fuchsia.dev/docs/glossary#abi)


  .
- Non-clickable over-hover definition:

  > [!NOTE]
  > **Note:** This option is only available when using the Jinja2 syntax.

  ### Rendered

  Definition of


  .

#### Usage

There are several ways of using this widget:

### Markdown

- Xref link (preferred):

```
[display_name][glossary.term]
```

Alternatively, you don't need to specify `display_name`, which lets the actual term
be used as the `display_name`:

```
[glossary.term]
```

For both formats, you must define the Xref at the bottom of the markdown file. For example:

```
[glossary.display_name]: /docs/glossary/README.md#term
```

- Inline link:

```
[display_name](/docs/glossary/README.md#term)
```

- Inline link (shortened):

```
[display_name](/docs/glossary#term)
```

### HTML/Jinja2

> [!NOTE]
> **Note:** To use the glossary widgets in any HTML markup, you muse use the JINJA2 syntax. This is useful when creating HTML tables. Also, make sure to follow the [Prerequisites: (only for HTML/Jinja2)](https://fuchsia.dev/fuchsia-src/contribute/docs/widgets#widgets-prereq).

    {{ widgets.glossary_simple ('term', 'display_name', 'notClickable')}}

#### Parameters

> [!NOTE]
> **Note:** When using the widgets in Jinja2 there are additional parameters available.

### Markdown

| Parameters ||
|---|---|
| `display_name` | **Required** Specify the text in your markdown file that will have hover over text. Not required when using the xref syntax of \[glossary.<var translate="no">term</var>\]. In that case, the glossary term is used as the <var translate="no">display_name</var>. |
| `term` | **Required** Specify a term that is defined in the [_glossary.yaml](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/glossary/_glossary.yaml) file. |

### HTML/Jinja2

| Parameters ||
|---|---|
| `term` | **Required** Specify a term that is defined in the [_glossary.yaml](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/glossary/_glossary.yaml) file. |
| `display_name` | **Optional** Specify the text in your markdown file that will have hover over text. |
| `notClickable` | **Optional** Required if using `display_name`Determines if the term gets a link to the full glossary. If this is not specified, the term will become clickable and have a link to its glossary entry. |

### glossary_box

Creates a definition box of the `full_description` of a term. If the term
does not have a `full_description`, the `short_description` is used.

The definition box also displays an edit button for contributors to edit the
glossary.

#### Examples

- Definition box:

  ### Rendered


  > [!IMPORTANT]
  > **[ABI](https://fuchsia.dev/docs/glossary#abi):** The [Application Binary Interface](https://fuchsia.dev/docs/concepts/kernel/system)(ABI) for a system is the binary-level interface to the system. Typically you don't write software that uses the system ABI directly. Instead, you write software against the system API. When the software is compiled, the binary artifact created by the compiler interfaces with the system through the ABI. Changes to the system ABI may require you to recompile your source code to account for the changes in the ABI. [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/glossary/_glossary.yaml "Edit the glossary")

  <br />

#### Usage

> [!NOTE]
> **Note:** The definition box should not be used inside of other markdown elements such as paragraphs. It should only be used between other elements such as pagraphs, headings, lists, etc... If you use the definition box inside a paragraph it will cause text around it to get wrapped.

There are several ways of using this widget:

### Markdown

- Xref link (preferred):

```
[display_name][glossary.box.term]
```

Then, you must define the Xref at the bottom of the markdown file. For example:

```
[glossary.box.display_name]: /docs/glossary/README.md#term
```

- Inline link:

```
[display_name](/docs/glossary/README.md?style=box#term)
```

- Inline link (shortened):

```
[display_name](/docs/glossary?style=box#term)
```

### HTML/Jinja2

> [!NOTE]
> **Note:** The <var translate="no">display_name</var> parameter does not do anything and is only defined to ensure consistency with the usage of the simple glossary widgets. Also, make sure to follow the [Prerequisites: (only for HTML/Jinja2)](https://fuchsia.dev/fuchsia-src/contribute/docs/widgets#widgets-prereq).

    {{ widgets.glossary_box ('term', 'display_name') }}

#### Parameters

> [!NOTE]
> **Note:** The parameters for markdown and Jinja2 are the same.

| Parameters ||
|---|---|
| `term` | **Required** Specify a term that is defined in the [_glossary.yaml](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/glossary/_glossary.yaml) file. |
| `display_name` | **Required** This parameter is required to prevent errors, but does not do anything. |

[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/contribute/docs/widgets.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/contribute/docs/widgets.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/contribute/docs/widgets.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/contribute/docs/widgets.md "Edit the source code of this page")