Writing Documentation
You can improve MyPaint by making instructions for people using and people making it. Good documentation is vital for everyone. Any sort of improvement, including fixing typos and improving readability, is greatly appreciated.
Want to help improve our documentation but don’t know where to start? Our issue tracker contains problems with the website and documentation. Use our git workflow when contributing improvements/fixes.
Tone & Writing Style
- Readers visit a page for a reason, understand that reason when writing a page.
- Use informative, but concise language.
- Avoid large paragraphs when possible.
- Write using language understandable by a 12 to 14 year old.
- Do not assume readers’ level of technical or artistic skill.
- e.g. Avoid using “just” or “simply” when giving instructions.
- Use your preferred dialect of English, as long as it’s clearly understood by most English readers.
- Page titles and headings should be in title case.
Translating Pages
If a page is complete, please consider translating it into other languages. MyPaint’s contributor documentation aims to be a single source of truth, so decidedlly not translating it reduces overhead.
Translate a page by prepending the .md
extension with a language code.
e.g. to localise this page to Japanese, create a page
named documentation.ja.md
.
Please also consider translating MyPaint (the program).
Developer Documentation
Poor or missing documentation is an obstacle to new contributors, you can help prevent this by writing documentation.
If you are new to technical writing, here are some resources to get you started:
Backend
Backend docs exist for two reasons, to:
- Help new developers understand MyPaint’s general design as quickly as possible.
- Scope files/directories by describing them.
They are presented to the reader as:
- Here’s a file/concept.
- This is the gist of what you need to know.
- You’re now prepared to read through the code and understand the specifics.
The most detailed documentation for the project will always be contained within source code.
UX/UI
GUI changes are drafted in the docs, and then applied per those specifications in the program.
Using Hugo
This section details how to create and modify pages for this website. The MyPaint website is created using Hugo, a static site generator. Pages are written in Markdown (here’s a guide).
Quick Start
- At the left side of this page, there is an aside menu with the “Page Information” heading.
- Under the “Page Information” heading, there is a link to the source markdown file for this page. Click it.
- Start getting your bearings by comparing what you see on the source file to what you see on this page.
Conventions
When creating or modifying *.md
files:
- Break lines before the word that starts after the 80th column
- Pages have summaries generated from page content or front matter.
They may be created:
- Automatically at the 70th word
- At the position of the <!--more--> tag in the content.
- In front matter, using the
summary
key.
- Try to avoid the first case here and instead use case 2 or 3.
Build the Site Locally
- Install hugo-extended, dart sass, and git-lfs
- Clone the website repository
- Run
git submodule update --init
- Run
hugo
orhugo server
Update Submodules
When the website-theme or other submodules are updated, use
git submodule update --recursive --remote
to reflect the changes in
your development environment.
Adding Content
Page content is stored in the pages directory. To add a new page to the website,
type hugo new content pages/path/to/filename.md
.
Main page image:
Page bundles may include a file named index.jpg
or index.png
,
preferrably accompanied with imgAlt front matter.
Such image files will:
- Render the image behind the page title.
- Add meta image tags (for e.g. OpenGraph)
Front Matter
Front matter is used to store a page’s metadata. This site’s front matter is written in TOML.
Name | Value | Optional? | Description |
---|---|---|---|
title | String | No | Describe a title for the page |
author | String | Yes | Describe an author for the page |
date | RFC 3339 | Yes | Describe a creation/first published timestamp for the page |
summary | String | Yes | Define a summary instead of using page content |
draft | Boolean | Yes | Describe the page as a draft. These aren’t published in the production environment |
imgAlt | String | Yes | Describe the alt attribute for the page’s main image |
reversePageTurner | Boolean | Yes | Reverses the sort order of pages in the page turner (at the bottom of a page) |
sectionNavURL | Path | Yes | Enable the site navigation widget in aside at the path described |
showInfo | Boolean | Yes | Display page git info |
List Pages
Front matter specific to list pages
Name | Value | Optional? | Description |
---|---|---|---|
hideSummary | Boolean | Yes | Don’t render the summary in the page body |
hideList | Boolean | Yes | Don’t render the list of pages |
listByTitle | Boolean | Yes | Render list items alphabetically instead of by date |
reverseList | Boolean | Yes | Reverse the order of list items |
Shortcodes
Shortcodes extend markdown with custom HTML templates.
Useful Hugo Builtin Shortcodes
Shortcode | Type | Parameters | Description |
---|---|---|---|
ref | Inline | 0 : Path | Create an anchor to the specified page |
relref | Inline | 0 : Path | Create an anchor to the specified page relative to the current directory |
Custom Shortcodes
Shortcode | Type | Parameters | Description |
---|---|---|---|
bigbutton | Inline | title : string, subtitle : string, href : path, src | Add a styled anchor with title and subtitle and image (optional) |
button | Inline | content : string, href : path, src | Add a styled anchor labelled content with an image (optional) |
colour | Content | 0 : oneof (red, yellow) | Change the colour of the contained text |
embedpage | Inline | 0 : page | Embed the contents of another page |
flex | Content | direction : oneof (column, row), grow : boolean | Enclose the contained content in a flexbox |
grid | Inline | rows , columns , align | Enclose the contained content in a grid |
id | Content | 0 : string, 1 : oneof (nomd, yesmd) | Enclose the contained content in a span tag with id="0" with optional disabling of markdown rendering |
img | Inline | alt : string, src : path, caption : string, float , width | Insert an image |
info | Content | type : oneof (information, warning) | Draw an infobox |
md | Content | None | Renders markdown in contained content (for shortcodes without markdown) |
paramref | Inline | 0 : Site parameter | Like ref , but with a site parameter |
Documenting Python
Docstrings
We seem to be settling on Sphinx’s autodoc syntax for writing docstrings. Where it doesn’t contradict, please follow PEP 257 too.
Python code should always have docstrings describing what a public function or class does. We would like to use Sphinx’s autodoc
to generate API documentation one day, but conventions have not yet been settled for it. For now, please document parameters using Sphinx-style info field lists, and try not to use too much additional ReStructuredText markup.
class Example (_ExampleBase):
"""Demonstrative example class."""
def add_two(self, n1, n2):
"""Adds two numbers, or other objects.
:param object n1: The first object to addify.
:param object n2: The second object to addulate.
:returns: The summified results of the two arguments.
Any kind of object can be added provided it's supported
by the builtin "+" operator. You might as well use that.
"""
return n1 + n2
When it’s not obvious what a bit of code is doing, add comments to explain why you are doing something.