Skip to content
BoKSA

Writing documentation

Writing documentation

Your documentation is a set of Markdown files in the docs/ folder. Every .md file becomes one page of the website. This page shows how to add pages, organise them and use the extras that are already switched on in your repository.

Everything in docs/ is public

Do not write down names, quotes or photos of people who did not agree to it, and do not paste API keys into examples. See What not to publish.

Add a page

  1. Create a file in docs/ that ends in .md, for example docs/how-it-fits-together.md.
  2. Start it with one title, using a single #. This title is shown in the navigation.
  3. Write the rest in Markdown, using ## and ### for sections.
1
2
3
4
5
6
7
# How our projects fit together

We studied object detection. Each of us built one application.

## What the applications have in common

...

Save the file and it appears in the navigation of your local preview. Push it and it appears on the website.

Use lowercase file names without spaces (my-page.md, not My Page.md). The file name becomes part of the web address.

Organise your pages

A folder in docs/ becomes a section in the navigation. A file called index.md in that folder becomes the front page of that section.

Choose a structure that follows your work, not the calendar. For a repository in which several people each build something, such as a learning group repository, one folder per application plus the shared pages works well:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
docs/
├── index.md                    Home page: who you are, what you work on
├── how-it-fits-together.md     A shared page
├── sign-language-explainer/
│   ├── index.md                What the application is and how to use it
│   ├── iterations.md           How it came to be, iteration by iteration
│   └── images/
├── gesture-game/
│   ├── index.md
│   └── iterations.md
└── apps/                       The applications themselves

The apps/ folder is explained in Publishing your application.

Set the order and the titles

By default, pages are sorted alphabetically. To decide the order yourself, put a file called .pages in the folder:

docs/.pages
1
2
3
4
5
6
nav:
    - index.md
    - How it fits together: how-it-fits-together.md
    - sign-language-explainer
    - gesture-game
    - ...
  • Each line is a file or a folder in that same folder.
  • Some title: file.md gives the page a different title in the navigation.
  • ... means "everything I did not mention". Leave it out and the pages you did not list disappear from the navigation.

To rename a folder in the navigation, put a .pages file inside that folder:

docs/sign-language-explainer/.pages
1
2
3
4
title: Sign language explainer
nav:
    - index.md
    - Iterations: iterations.md

Indentation matters

.pages files are YAML. Indent with spaces, not tabs, and keep the lines under nav: lined up exactly. A misaligned line breaks the build.

Always link relative to the file you are writing in, and link to the .md file, not to a web address. MkDocs converts it for you.

You are in You want to link to Write
docs/index.md docs/gesture-game/index.md [Gesture game](gesture-game/index.md)
docs/gesture-game/index.md docs/gesture-game/iterations.md [Iterations](iterations.md)
docs/gesture-game/iterations.md docs/gesture-game/index.md [Gesture game](./index.md)
docs/gesture-game/iterations.md docs/index.md [Home](../index.md)

.. means "one folder up". Never start a link with /: it can work in the local preview and break on the published website. Because your site has several files called index.md, write ./index.md when you link to the one in the same folder.

Images work the same way. Put them in a folder next to the page and link to them relatively:

1
![Screenshot of the second iteration](images/iteration-2.png)

The text between the square brackets is read aloud by screen readers and shown when the image fails to load, so describe what is in the picture. Add { width="400" } directly after the closing bracket to set a size.

What you can use

These extras are already switched on in your repository.

Call-outs

1
2
3
4
5
!!! note "Why we changed the dataset"
    The first dataset contained almost no examples of left-handed signs.

!!! warning
    The model was only tested in good lighting.

The text must be indented with four spaces. Useful types are note, tip, warning, danger, example and quote. Replace !!! with ??? to make the call-out collapsible, which is handy for long logs or code.

Code

1
2
3
4
```python
model = load_model("gestures.keras")
prediction = model.predict(frame)
```

Name the language after the three backticks to get syntax highlighting.

Diagrams

A code block with the language mermaid is drawn as a diagram:

1
2
3
4
```mermaid
flowchart LR
    Camera --> Model --> Prediction --> Feedback[Feedback to the user]
```

See the Mermaid documentation for flowcharts, sequence diagrams and more. Diagrams are a good way to show how your system works.

Checklists

1
2
- [x] Collect training data
- [ ] Test with three users

Video

Short screen recordings are a good way to document an iteration that no longer exists. Put the file next to your page and write:

1
![type:video](videos/iteration-1.mp4)

Keep videos short and small. Large files make the repository slow for everyone in your team. For longer recordings, upload the video elsewhere and link to it.

HTML and JavaScript

You can write HTML directly in a Markdown file, including <script> tags. The example page linear-regression-explorer.md in your repository does this. For anything bigger than a small demo, give your application its own folder, as described in Publishing your application.

Document your iterations

Good documentation shows how the work came to be, not only the end result. In a learning group this is required: your documentation must show how the application came to be, including the iterations. A structure that works well is one section per iteration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Iteration 2: showing the confidence of the model

**What I built:** a bar next to the camera image that shows how sure the model is.

**What I tested:** two fellow students used it without explanation.

**What I learned:** they read the bar as a score for their own performance.

**What I change next:** label the bar and add an explanation on hover.

![The confidence bar in iteration 2](images/iteration-2.png)

Write it in the week it happens. Screenshots and recordings of earlier versions are impossible to recreate afterwards.

Checklist

  • Every page starts with one # title.
  • My links are relative and point to .md files.
  • My images have a description.
  • The local preview shows no warnings.
  • The example pages of the template are removed.
  • There is nothing on my pages that should not be public.