Files
kata-containers/Documentation-Requirements.md
James O. D. Hunt b9bc029977 docs: Advise use of non-interactive commands
If a doc contains commands, they should be non-interactive where
possible to allow for the possibility of automating the testing of the
document in the CI.

Fixes #477.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2019-05-16 17:56:31 +01:00

5.8 KiB

Introduction

This document outlines the requirements for all documentation in the Kata Containers project.

General requirements

All documents must:

  • Be written in GitHub Flavored Markdown format.

  • Have a .md file extension.

  • Include a TOC (table of contents) at the top of the document with links to all heading sections.

  • Be linked to from another document in the same repository.

    Although GitHub allows navigation of the entire repository, it should be possible to access all documentation purely by navigating links inside the documents, starting from the repositories top-level README.

    If you are adding a new document, ensure you add a link to it in the "closest" README above the directory where you created your document.

  • If the document needs to tell the user to manipulate files or commands, use a code block to specify the commands.

    If at all possible, ensure that every command in the code blocks can be run non-interactively. If this is possible, the document can be tested by the CI which can then execute the commands specified to ensure the instructions are correct. This avoids documents becoming out of date over time.

Linking advice

Linking between documents is strongly encouraged to help users and developers navigate the material more easily. Linking also avoids repetition - if a document needs to refer to a concept already well described in another section or document, do not repeat it, link to it (the DRY principle).

Another advantage of this approach is that changes only need to be applied in one place: where the concept is defined (not the potentially many places where the concept is referred to using a link).

Notes

Important information that is not part of the main document flow should be added as a Note in bold with all content contained within a block quote:

Note: This is areally important point!

This particular note also spans multiple lines. The entire note should be included inside the quoted block.

If there are multiple notes, bullets should be used:

Notes:

  • I am important point 1.

  • I am important point 2.

  • I am important point n.

Warnings and other admonitions

Use the same approach as for notes. For example:

Warning: Running this command assumes you understand the risks of doing so.

Other examples:

Warnings:

  • Do not unplug your computer!
  • Always read the label.
  • Do not pass go. Do not collect $200.

Tip: Read the manual page for further information on available options.

Hint: Look behind you!

Files and command names

All filenames and command names should be rendered in a fixed-format font using backticks:

Run the foo command to make it work.

Modify the bar option in file /etc/baz/baz.conf.

Render any options that need to be specified to the command in the same manner:

Run bar -axz --apply foo.yaml to make the changes.

For standard system commands, it is also acceptable to specify the name along with the manual page section that documents the command in brackets:

The command to list files in a directory is called ls(1).

Code blocks

This section lists requirements for displaying commands and command output.

The requirements must be adhered to since documentation containing code blocks is validated by the CI system, which executes the command blocks with the help of the doc-to-script utility.

  • If a document includes commands the user should run, they MUST be shown in a bash code block with every command line prefixed with $ to denote a shell prompt:

    
        ```bash
        $ echo "Hi - I am some bash code"
        $ sudo docker run -ti busybox true
        $ [ $? -eq 0 ] && echo "success"
        ```
    
    
  • If a command needs to be run as the root user, it must be run using sudo(8).

    
    $ sudo echo "I'm running as root"
    
  • All lines beginning # should be comment lines, NOT commands to run as the root user.

  • In the unusual case that you need to display command output, use an unadorned code block (```):

    
        The output of the `ls(1)` command is expected to be:
    
        ```
        ls: cannot access '/foo': No such file or directory
        ```
    
    
  • Long lines should not span across multiple lines by using the '\' continuation character.

    GitHub automatically renders such blocks with scrollbars. Consequently, backslash continuation characters are not necessary and are a visual distraction. These characters also mess up a user's shell history when commands are pasted into a terminal.

Images

All binary image files must be in a standard and well-supported format such as PNG. This format is preferred for vector graphics such as diagrams because the information is stored more efficiently, leading to smaller file sizes. JPEG images are acceptable, but this format is more appropriate to store photographic images.

When possible, generate images using freely available software.

Every binary image file MUST be accompanied by the "source" file used to generate it. This guarantees that the image can be modified by updating the source file and re-generating the binary format image file.

Ideally, the format of all image source files is an open standard, non-binary one such as SVG. Text formats are highly preferable because you can manipulate and compare them with standard tools (e.g. diff(1)).