type | slideOptions | ||||||||
---|---|---|---|---|---|---|---|---|---|
slide |
|
- Introduction
- What is good documentation?
- Standard documentation building blocks (README, changelog, error messages, commit messages)
- API documentation
- Who has been annoyed by bad (or lack of) documentation before?
- Examples?
- Who has been happy/surprised by very good documentation before?
- Examples?
- Who documents their code well?
If people don’t know why your project exists, they won’t use it. If people can’t figure out how to install your code, they won’t use it. If people can’t figure out how to use your code, they won’t use it.
Taken from Write The Docs
Similar message and highly recommended: Bangerth and Heister, 2013: What makes computational open source software libraries successful?
- Be aware that documentation is crucial in RSE.
- Understand that there is a difference between documentation and good documentation.
- Know the purpose and basic structure of several standard documentation building blocks (README, commit message, changelog, ...).
- Not: Be able to really write good documentation. This takes practice and much more than 90 minutes.
- Not: Use any technical tools. This will come next week.
- ... is a job profile between technical know-how (computer science, engineering, ...) and language.
- ... can be a role in a software development team ("documentation").
- There is a whole community, e.g. Write the Docs.
Much content of this lecture is taken from Write the Docs.
- Like in a startup, no dedicated technical writer in team (even for large projects). Everybody does everything.
- --> You need writing skills.
- In research, one writes a lot (papers, proposals, lecture material, ...).
- --> Writing/communication skills are very important anyway.
- You will be using your code in 6 months.
- You want people to use your code.
- You want people to help out.
- You want your code to be better (act of putting words to paper requires a distillation of thought that may not be so easy).
- You want to be a better writer.
- ARID ("Accept (some) Repetition in Documentation")
- Not like good code (DRY: "don't repeat yourself"), but also not WET
- Repetition from code to docs
- Not everything can be auto-generated.
- Skimmable
- Headings: should be descriptive and concise
- Hyperlinks: descriptive, not click here
- Use listings etc. where appropriate, no "wall of text"
- Exemplary (some, but not too many)
- Consistent (language, formatting, wording)
- Current
User vs. developer documentation:
- Distinction important for larger projects, not so important for smaller projects
- Sometimes also third category "maintainer"
- User docs: How to use the software?
- Dev docs: Why does the software work a certain way? Not only how
- Dev docs typically closer to where the code is than user docs
- Example: preCICE: user docs, dev docs, dev docs close to code
From py-RSE:
The best function names in the world aren't going to answer the questions “Why does the software do this?” and “Why doesn’t it do this in a simpler way?”
py-RSE distinguishes novices, competent practitioners, and experts (following Wilson 2019, Teaching Tech Together)
- A novice doesn’t yet have a mental model of the domain. -> Needs tutorials that introduce key ideas one by one.
- Good example: deal.ii tutorials).
- A competent practitioner knows enough to accomplish routine tasks with routine effort. -> Needs reference guides, cookbooks, and Q&A sites.
- Good example: preCICE config reference).
- An expert need this material as well – nobody's memory is perfect.
Consistent tone and style ...
- makes content easier to read.
- reduces the reader's cognitive load.
- increases confidence in authority of content.
Read more: Write the Docs on style guides
- Different people write differently. Even the same person writes differently every day.
- Style guide contains a set of standards.
- Writer does not have to worry -> saves time.
- Traditional style guides have been around as long as publishing, e.g. The Chicago Manual of Style.
Example: brief excerpt of Google developer documentation style guide
-
Timeless documentation: Avoid words such as "currently", "in the future", "soon"
-
Use present tense, avoid "will"
- Bad: Send a query to the service. The server will send an acknowledgment.
- Good: Send a query to the service. The server sends an acknowledgment.
-
Exclamation points: Don't use them. Rather use notices such as Note or Caution.
-
Headings: Use "Sentence case for headings", not "Title Case for Headings"
-
Image URLs: Use site-root-relative URL from same domain
-
Referring to filenames: code font, word "file" after filename, exact spelling
- Good: In the following
build.sh
file, modify the default values for all parameters.
- Good: In the following
-
... even example person names
-
Another example: SSE lecture material style guide
... helps a lot to make tone of documentation consistent.
- If your software/product was a person, how would they be?
- Let it talk like this person.
Example preCICE:
- Three things to define character? Smart, approachable, responsible.
- Does preCICE have a sense of humor? Yes. When do they use it? Only rarely.
- ...
- Define how to talk to users
Example preCICE:
- Treat users as peers. preCICE is a Computer Science PhD student, user is a Mechanical Engineering PhD student.
- Example: Google style guide – voice and tone
Every code should contain a README file. There is even readme driven development.
Minimal variant should contain at least (following Write the Docs):
- What problem the project solves
- A small code example (for libraries) or how to run (for programs)
- A screenshot for code using a GUI or a visual part
- How to get support and a link to issue tracker
- Information for people who want to contribute back (also
CONTRIBUTING.md
) - Installation instructions
- The code's license (also
LICENSE
) - Frequently Asked Questions (FAQ)
Following Keep a Changelog:
- What is a changelog?
- A changelog is a file which contains a curated, chronologically ordered list of notable changes for each version of a project. Focus on the "what", not the "how" and "why".
- Why keep a changelog?
- To make it easier for users and contributors to see precisely what notable changes have been made between each release (or version) of the project.
- Who needs a changelog?
- People do. Whether consumers or developers, the end users of software are human beings who care about what's in the software. When the software changes, people want to know why and how.
The Keep a Changelog convention groups by categories:
- Added for new features.
- Changed for changes in existing functionality.
- Deprecated for soon-to-be removed features.
- Removed for now removed features.
- Fixed for any bug fixes.
- Security in case of vulnerabilities.
There are tools to auto-generate, but be careful.
Don’t let your friends dump git logs into changelogs
From How to write better error messages:
The first time a user encounters an application's documentation, it's not always with the user manual or online help. Often, that first encounter with documentation is an error message.
Examples from preCICE before Spring 2020:
- Safety Factor must be positive or 0
- Data with name "Forces" is not defined on mesh with ID 1.
- At least two participants need to be defined!
What is wrong with these?
Examples from preCICE after Spring 2020 (error messages sprint):
- Give context:
- Participant "Fluid" uses mesh "FluidMesh" with safety-factor="-0.5". Please use a positive or zero safety-factor instead.
- Give advice:
- Data with name "Forces" is not defined on mesh "FluidMesh". Please add
<use-data name="Forces"/>
under<mesh name="FluidMesh/>
.
- Data with name "Forces" is not defined on mesh "FluidMesh". Please add
- Improve tone:
- In the preCICE configuration, only one participant is defined. One participant makes no coupled simulation. Please add at least another one.
Tips from Write the Docs:
- Provide explicit indication that something has gone wrong.
- Write like a human, not a robot.
- Don’t blame the user – be humble.
- Make the message short and meaningful.
- Include precise descriptions of exact problems.
- Offer constructive advice on how to fix the problem.
Who did something wrong? The software or the user?
- Example preCICE:
- The user -> error
- The software -> assertion
- Make this transparent to the user
Same story again:
- Consistent
- Descriptive and concise (such that complete history becomes skimmable)
- Explain the "why" (the "how" is covered in the diff)
The seven rules of a great Git commit message:
- Separate subject from body with a blank line.
- Limit the subject line to 50 characters.
- Capitalize the subject line.
- Do not end the subject line with a period.
- Use the imperative mood in the subject line.
- Wrap the body at 72 characters.
- Use the body to explain what and why vs. how.
Tags can also be useful (e.g. [Bugfix]
), but consistency is key. Our lecture material is a bad example. 😁
- All basics apply (be consistent, descriptive, and concise; explain the why, ...)
- Consistency is also great for automatization: rendering, interlinking, suggestions by IDE, ... (next week)
- Different syntax (e.g. Google style for Python, numpydoc style, doxygen for C++ and more, Javadoc)
- The API reference of the Google developer documentation style guide is a very good source, language independent, and used on the following slides.
Description of a class or method is split into a short and a long description.
Short description:
- First sentence of description (many doc tools pick automatically)
- State intended purpose of class with information that can't be deduced from the class name and signature.
- Do not repeat the class name.
- Do not say "this class will/does ...".
Android's ActionBar class:
A primary toolbar within the activity that may display the activity title, application-level navigation affordances, and other interactive items.
Long description: how to use, key features, best practices, ...
Example: preCICE API
Short description:
- Briefly state what action the method performs.
- Use present tense:
- Adds a new bird to the ornithology list.
- Returns a bird.
- Operation + return data:
- Adds a new bird to the ornithology list and returns the ID of the new entry.
- "Getter" that returns a boolean:
- Checks whether ...
- "Getter" that return sth else:
- Gets the ...
- No return value:
- Sets the ..., Updates the ..., Deletes the ..., Registers ..., Creates a ...
Long description: why and how to use the method, prerequisites, related methods, ...
Parameters:
- Non-boolean parameters:
- The ID of the bird you want to get.
- A description of the bird.
- Boolean parameters:
- If true, turn traffic lines on. If false, turn them off.
- Return values:
- The bird specified by the given ID.
- True if the bird is in the sanctuary; false otherwise.
Example: preCICE API
- Documentation/technical writing is important.
- Be clear about your audience.
- Documentation should be skimmable, concise, and consistent.
- For consistency, define and/or follow a style guide.
- There are conventions/styles for README, changelog, commit messages, error messages, API documentation