Contributors guide

Get started with contributing to the Dapr docs

In this guide, you’ll learn how to contribute to the Dapr docs repository. Since Dapr docs are published to docs.dapr.io, you must make sure your contributions compile and publish correctly.

Prerequisites

Before contributing to the Dapr docs:

Branch guidance

The Dapr docs handles branching differently than most code repositories. Instead of a main branch, every branch is labeled to match the major and minor version of a runtime release. For the full list visit the Docs repo

Generally, all of your docs updates should point to docs branch for the latest release of Dapr. The latest release is the default branch [https://github.com/dapr/docs\]. For example, if you are fixing a typo, adding notes, or clarifying a point, make your changes into the default Dapr branch.

For any docs changes applicable to a release candidate or a pre-release version of the docs, point your changes into that particular branch. For example, if you are documenting an upcoming change to a component or the runtime, make your changes to the pre-release branch.

Style and tone

Style and tone conventions should be followed throughout all Dapr documentation for consistency across all docs:

Style/ToneGuidance
CasingUse upper case only:
  • At the start of a sentence or header
  • For proper nouns, including names of technologies (Dapr, Redis, Kubernetes etc.)
Headers and titlesHeaders and titles must be brief, but descriptive and clear.
Use simple sentencesWrite easy-to-read, scannable sentences. Tip: Skip the formal tone and write as if you were talking directly to the reader.
Avoid the first personInstead of first person “I”, “we”, and “our”, use second person “you” and “your”.
Assume a “new developer” audienceSome seemingly obvious steps to an experienced developer might not be as obvious to a new developer. Give the reader more explicit, thorough instructions.
Use present tenseAvoid sentences like “this command will install Redis”. Instead, use “This command installs Redis”.

Diagrams and images

Diagrams and images are invaluable visual aids for documentation pages. Diagrams are kept in a Dapr Diagrams Deck, which includes guidance on style and icons.

As you create diagrams for your documentation:

  • Save them as high-res PNG files into the images folder.
  • Name your PNG files using the convention of a concept or building block so that they are grouped.
    • For example: service-invocation-overview.png.
    • For more information on calling out images using shortcode, see the Images guidance section below.
  • Add the diagram to the correct section in the Dapr-Diagrams.pptx deck so that they can be amended and updated during routine refresh.

Contributing a new docs page

If you’re creating a new article, make sure you:

  • Place the new document in the correct place in the hierarchy.
  • Avoid creating new sections. Most likely, the proper place is already in the docs hierarchy.
  • Include complete Hugo front-matter.

Select the topic type below to view a suggested template to help you get started.

Topic typeWhat is it?
ConceptAnswers the question, “What problems does this help me solve?” Avoid repeating the API or component spec; provide more details.
QuickstartProvides a “Five minutes to wow” experience. Walk the reader quickly through a feature or API and how it works in a controlled example.
How-toProvides a detailed, practical step-by-step through a Dapr feature or technology. Encourage the reader to try with their own scenario, rather than the controlled scenario provided in a quickstart.

Requirements for docs.dapr.io

Make sure your contribution doesn’t break the website build. The way Hugo builds the website requires following the guidance below:

Files and folder names

File and folder names should be globally unique. - \service-invocation - service-invocation-overview.md

Front-matter

Front-matter is what takes regular markdown files and upgrades them into Hugo compatible docs for rendering into the nav bars and ToCs.

Every page needs a section at the top of the document like this:

  1. ---
  2. type: docs
  3. title: "TITLE FOR THE PAGE"
  4. linkTitle: "SHORT TITLE FOR THE NAV BAR"
  5. weight: (number)
  6. description: "1+ SENTENCES DESCRIBING THE ARTICLE"
  7. ---

Example

  1. ---
  2. type: docs
  3. title: "Service invocation overview"
  4. linkTitle: "Overview"
  5. weight: 10
  6. description: "A quick overview of Dapr service invocation and how to use it to invoke services within your application"
  7. ---

Weight determines the order of the pages in the left sidebar, with 0 being the top-most.

Front-matter should be completed with all fields including type, title, linkTitle, weight, and description.

  • title should be 1 sentence, no period at the end
  • linkTitle should be 1-3 words, with the exception of How-to at the front.
  • description should be 1-2 sentences on what the reader will learn, accomplish, or do in this doc.

As per the styling conventions, titles should only capitalize the first word and proper nouns, with the exception of “How-To:”

  • “Getting started with Dapr service invocation”
  • “How-To: Setup a local Redis instance”

Referencing other pages

Hugo ref and relref shortcodes are used to reference other pages and sections. These shortcodes also allow the build to break if a page is incorrectly renamed or removed.

For example, this shortcode, written inline with the rest of the markdown page, will link to the _index.md of the section/folder name:

  1. {{< ref "folder" >}}

While this shortcode will link to a specific page:

  1. {{< ref "page.md" >}}

All pages and folders need to have globally unique names in order for the ref shortcode to work properly. If there are duplicate names, the build will break and an error will be thrown.

Referencing sections in other pages

To reference a specific section in another page, add #section-short-name to the end of your reference.

As a general rule, the section short name is the text of the section title, all lowercase, with spaces changed to “-”. You can check the section short name by:

  1. Visiting the website page.
  2. Clicking the link icon (🔗) next to the section.
  3. Seeing how the URL renders in the nav bar.
  4. Copying the content after the “#” for your section shortname.

As an example, for this specific section, the complete reference to the page and section would be:

  1. {{< ref "contributing-docs.md#referencing-sections-in-other-pages" >}}

Shortcodes

The following are useful shortcodes for writing Dapr documentation

Images

The markdown spec used by Docsy and Hugo does not give an option to resize images using markdown notation. Instead, raw HTML is used.

Begin by placing images under /daprdocs/static/images with the naming convention of [page-name]-[image-name].[png|jpg|svg].

Then link to the image using:

  1. <img src="/images/[image-filename]" width=1000 alt="Description of image">

Don’t forget to set the alt attribute to keep the docs readable and accessible.

Example

This HTML will display the dapr-overview.png image on the overview.md page:

  1. <img src="/images/overview-dapr-overview.png" width=1000 alt="Overview diagram of Dapr and its building blocks">

Tabbed content

Tabs are made possible through Hugo shortcodes.

The overall format is:

  1. {{< tabs [Tab1] [Tab2]>}}
  2. {{% codetab %}}
  3. [Content for Tab1]
  4. {{% /codetab %}}
  5. {{% codetab %}}
  6. [Content for Tab2]
  7. {{% /codetab %}}
  8. {{< /tabs >}}

All content you author will be rendered to markdown, so you can include images, code blocks, YouTube videos, and more.

Example

  1. {{< tabs Windows Linux MacOS>}}
  2. {{% codetab %}}
  3. ```powershell
  4. powershell -Command "iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex"
  5. ```
  6. {{% /codetab %}}
  7. {{% codetab %}}
  8. ```bash
  9. wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
  10. ```
  11. {{% /codetab %}}
  12. {{% codetab %}}
  13. ```bash
  14. brew install dapr/tap/dapr-cli
  15. ```
  16. {{% /codetab %}}
  17. {{< /tabs >}}

This example will render to this:

  1. powershell -Command "iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex"
  1. wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
  1. brew install dapr/tap/dapr-cli

Embedded code snippets

Use the code-snippet shortcode to reference code snippets from the static/code directory.

  1. {{< code-snippet file="myfile.py" lang="python" >}}

Warning

All Dapr sample code should be self-contained in separate files, not in markdown. Use these techniques to highlight the parts of the sample code users should focus on.

Use the lang (default txt) parameter to configure the language used for syntax highlighting.

Use the marker parameter to limit the embedded snipped to a portion of the sample file. This is useful when you want to show just a portion of a larger file. Typically, you’d do this by:

  1. Surrounding the interesting code with comments.
  2. Passing the comment text into marker.

The shortcode below and code sample:

  1. {{< code-snippet file="./contributing-1.py" lang="python" marker="#SAMPLE" >}}
  1. import json
  2. import time
  3. from dapr.clients import DaprClient
  4. #SAMPLE
  5. with DaprClient() as d:
  6. req_data = {
  7. 'id': 1,
  8. 'message': 'hello world'
  9. }
  10. while True:
  11. # Create a typed message with content type and body
  12. resp = d.invoke_method(
  13. 'invoke-receiver',
  14. 'my-method',
  15. data=json.dumps(req_data),
  16. )
  17. # Print the response
  18. print(resp.content_type, flush=True)
  19. print(resp.text(), flush=True)
  20. time.sleep(2)
  21. #SAMPLE

Will result in the following output:

  1. with DaprClient() as d:
  2. req_data = {
  3. 'id': 1,
  4. 'message': 'hello world'
  5. }
  6. while True:
  7. # Create a typed message with content type and body
  8. resp = d.invoke_method(
  9. 'invoke-receiver',
  10. 'my-method',
  11. data=json.dumps(req_data),
  12. )
  13. # Print the response
  14. print(resp.content_type, flush=True)
  15. print(resp.text(), flush=True)
  16. time.sleep(2)

Use the replace-key-[token] and replace-value-[token] parameters to limit the embedded snipped to a portion of the sample file. This is useful when you want abbreviate a portion of the code sample. Multiple replacements are supported with multiple values of token.

The shortcode below and code sample:

  1. {{< code-snippet file="./contributing-2.py" lang="python" replace-key-imports="#IMPORTS" replace-value-imports="# Import statements" >}}
  1. #IMPORTS
  2. import json
  3. import time
  4. #IMPORTS
  5. from dapr.clients import DaprClient
  6. with DaprClient() as d:
  7. req_data = {
  8. 'id': 1,
  9. 'message': 'hello world'
  10. }
  11. while True:
  12. # Create a typed message with content type and body
  13. resp = d.invoke_method(
  14. 'invoke-receiver',
  15. 'my-method',
  16. data=json.dumps(req_data),
  17. )
  18. # Print the response
  19. print(resp.content_type, flush=True)
  20. print(resp.text(), flush=True)
  21. time.sleep(2)

Will result in the following output:

replace-value-imports

  1. # Import statements
  2. from dapr.clients import DaprClient
  3. with DaprClient() as d:
  4. req_data = {
  5. 'id': 1,
  6. 'message': 'hello world'
  7. }
  8. while True:
  9. # Create a typed message with content type and body
  10. resp = d.invoke_method(
  11. 'invoke-receiver',
  12. 'my-method',
  13. data=json.dumps(req_data),
  14. )
  15. # Print the response
  16. print(resp.content_type, flush=True)
  17. print(resp.text(), flush=True)
  18. time.sleep(2)

YouTube videos

Hugo can automatically embed YouTube videos using a shortcode:

  1. {{< youtube [VIDEO ID] >}}

Example

Given the video https://youtu.be/dQw4w9WgXcQ

The shortcode would be:

  1. {{< youtube dQw4w9WgXcQ >}}

Buttons

To create a button in a webpage, use the button shortcode.

An optional “newtab” parameter will indicate if the page should open in a new tab. Options are “true” or “false”. Default is “false”, where the page will open in the same tab.

  1. {{< button text="My Button" link="https://example.com" >}}

My Button

You can also reference pages in your button as well:

  1. {{< button text="My Button" page="contributing" newtab="true" >}}

My Button

Button colors

You can customize the colors using the Bootstrap colors:

  1. {{< button text="My Button" link="https://example.com" color="primary" >}}
  2. {{< button text="My Button" link="https://example.com" color="secondary" >}}
  3. {{< button text="My Button" link="https://example.com" color="success" >}}
  4. {{< button text="My Button" link="https://example.com" color="danger" >}}
  5. {{< button text="My Button" link="https://example.com" color="warning" >}}
  6. {{< button text="My Button" link="https://example.com" color="info" >}}

My Button My Button My Button My Button My Button My Button

References

Docsy authoring guide

Translations

The Dapr Docs supports adding language translations into the docs using git submodules and Hugo’s built in language support.

You can find an example PR of adding Chinese language support in PR 1286.

Steps to add a language:

  • Open an issue in the Docs repo requesting to create a new language-specific docs repo

  • Once created, create a git submodule within the docs repo:

    1. git submodule add <remote_url> translations/<language_code>
  • Add a language entry within daprdocs/config.toml:

    1. [languages.<language_code>]
    2. title = "Dapr Docs"
    3. weight = 3
    4. contentDir = "content/<language_code>"
    5. languageName = "<language_name>"
  • Create a mount within daprdocs/config.toml:

    1. [[module.mounts]]
    2. source = "../translations/docs-<language_code>/content/<language_code>"
    3. target = "content"
    4. lang = "<language_code>"
  • Repeat above step as necessary for all other translation directories.

Next steps

Get started by copying and working from one of the Dapr doc templates.

Last modified June 19, 2023: Merge pull request #3565 from dapr/aacrawfi/skip-secrets-close (b1763bf)