Skip to content

Commit dc0c092

Browse files
committed
docguide: pull in updates from internal docs
1 parent 36c0e3a commit dc0c092

File tree

5 files changed

+167
-109
lines changed

5 files changed

+167
-109
lines changed

docguide/READMEs.md

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
# README.md files
1+
# READMEs
22

33
About README.md files.
44

55
1. [Overview](#overview)
6-
1. [Guidelines](#guidelines)
7-
1. [Filename](#filename)
8-
1. [Contents](#contents)
9-
1. [Example](#example)
6+
1. [Readable README files](#readable-readme-files)
7+
1. [Where to put your README](#where-to-put-your-readme)
8+
1. [What to put in your README](#what-to-put-in-your-readme)
109

1110
## Overview
1211

13-
`README.md` files are Markdown files that describe a directory.
14-
GitHub and Gitiles renders it when you browse the directory.
12+
A README is a short summary of the contents of a directory. The contents of the
13+
file are displayed in GitHub and Gitiles when you view the contents of the
14+
containing directory. README files provide critical information for people
15+
browsing your code, especially first-time users.
16+
17+
This document covers how to create README files that are readable with GitHub
18+
and Gitiles.
19+
20+
## Readable README files
21+
22+
**README files must be named `README.md`.** The file name *must* end with the
23+
`.md` extension and is case sensitive.
1524

1625
For example, the file /README.md is rendered when you view the contents of the
1726
containing directory:
@@ -23,47 +32,29 @@ index:
2332

2433
https://gerrit.googlesource.com/gitiles/
2534

26-
## Guidelines
35+
## Where to put your README
2736

28-
**`README.md` files are intended to provide orientation for engineers browsing
29-
your code, especially first-time users.** The `README.md` is likely the first
30-
file a reader encounters when they browse a directory that
31-
contains your code. In this way, it acts as a landing page for the directory.
37+
Unlike all other Markdown files, `README.md` files should not be located inside
38+
your product or library's documentation directory. `README.md` files should be
39+
located in the top-level directory for your product or library's actual
40+
codebase.
3241

33-
We recommend that top-level directories for your code have an up-to-date
42+
All top-level directories for a code package should have an up-to-date
3443
`README.md` file. This is especially important for package directories that
3544
provide interfaces for other teams.
3645

37-
### Filename
38-
39-
Use `README.md`.
40-
41-
Files named `README` are not displayed in the directory view in Gitiles.
46+
## What to put in your README
4247

43-
### Contents
48+
At a minimum, your `README.md` file should contain a link to your user- and/or
49+
team-facing documentation.
4450

45-
At minimum, every package-level `README.md` should include or point to the
46-
following information:
51+
Every package-level `README.md` should include or point to the following
52+
information:
4753

48-
1. **What** is in this package/library and what's it used for.
49-
2. **Who** to contact.
50-
3. **Status**: whether this package/library is deprecated, or not for general
54+
1. What is in this package or library and what's it used for.
55+
1. Points of contact.
56+
1. Status of whether this package or library is deprecated, or not for general
5157
release, etc.
52-
4. **More info**: where to go for more detailed documentation, such as:
53-
* An overview.md file for more detailed conceptual information.
54-
* Any API documentation for using this package/library.
55-
56-
## Example
57-
58-
```markdown
59-
# APIs
60-
61-
This is the top-level directory for all externally-visible APIs, plus some
62-
private APIs under `internal/` directories.
63-
See [API Style Guide](docs/apistyle.md) for more information.
64-
65-
*TL;DR*: API definitions and configurations should be defined in `.proto` files,
66-
checked into `apis/`.
67-
68-
...
69-
```
58+
1. How to use the package or library. Examples include sample code, copyable
59+
`bazel run` or `bazel test` commands, etc.
60+
1. Links to relevant documentation.

docguide/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0
1+
2.0

docguide/best_practices.md

Lines changed: 71 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@
55

66
Contents:
77

8-
1. [Minimum viable documentation](#minimum-viable-documentation)
9-
1. [Update docs with code](#update-docs-with-code)
10-
1. [Delete dead documentation](#delete-dead-documentation)
11-
1. [Documentation is the story of your code](#documentation-is-the-story-of-your-code)
8+
1. [Minimum Viable Documentation](#minimum-viable-documentation)
9+
1. [Update Docs with Code](#update-docs-with-code)
10+
1. [Delete Dead Documentation](#delete-dead-documentation)
11+
1. [Prefer the Good Over the Perfect](#prefer-the-good-over-the-perfect)
12+
1. [Documentation is the Story of Your Code](#documentation-is-the-story-of-your-code)
13+
1. [Duplication is Evil](#duplication-is-evil)
1214

13-
## Minimum viable documentation
15+
## Minimum Viable Documentation
1416

15-
A small set of fresh and accurate docs are better than a sprawling, loose
16-
assembly of "documentation" in various states of disrepair.
17+
A small set of fresh and accurate docs is better than a large assembly of
18+
"documentation" in various states of disrepair.
1719

18-
Write short and useful documents. Cut out everything unnecessary, while also
19-
making a habit of continually massaging and improving every doc to suit your
20-
changing needs. **Docs work best when they are alive but frequently trimmed,
21-
like a bonsai tree**.
20+
Write short and useful documents. Cut out everything unnecessary, including
21+
out-of-date, incorrect, or redundant information. Also make a habit of
22+
continually massaging and improving every doc to suit your changing needs.
23+
**Docs work best when they are alive but frequently trimmed, like a bonsai
24+
tree**.
2225

23-
This guide encourages engineers to take ownership of their docs and keep
24-
them up to date with the same zeal we keep our tests in good order. Strive for
25-
this.
26+
See also
27+
[these Agile Documentation best practices](https://www.agilemodeling.com/essays/agileDocumentationBestPractices.htm).
2628

27-
* Identify what you really need: release docs, API docs, testing guidelines.
28-
* Delete cruft frequently and in small batches.
29-
30-
## Update docs with code
29+
## Update Docs with Code
3130

3231
**Change your documentation in the same CL as the code change**. This keeps your
3332
docs fresh, and is also a good place to explain to your reviewer what you're
@@ -36,7 +35,7 @@ doing.
3635
A good reviewer can at least insist that docstrings, header files, README.md
3736
files, and any other docs get updated alongside the CL.
3837

39-
## Delete dead documentation
38+
## Delete Dead Documentation
4039

4140
Dead docs are bad. They misinform, they slow down, they incite despair in
4241
engineers and laziness in team leads. They set a precedent for leaving behind
@@ -54,39 +53,37 @@ docs are in bad shape:
5453
recovered.
5554
* Iterate.
5655

57-
## Prefer the good over the perfect
56+
## Prefer the Good Over the Perfect
5857

59-
Your documentation should be as good as possible within a reasonable time frame.
60-
The standards for a documentation review are different from the
61-
standards for code reviews. Reviewers can and should ask for improvements, but
62-
in general, the author should always be able to invoke the "Good Over Perfect
63-
Rule". It's preferable to allow authors to quickly submit changes that improve
64-
the document, instead of forcing rounds of review until it's "perfect". Docs are
65-
never perfect, and tend to gradually improve as the team learns what they really
66-
need to write down.
58+
Documentation is an art. There is no perfect document, there are only proven
59+
methods and prudent guidelines. See [Better is better than best](./style.md).
6760

68-
## Documentation is the story of your code
61+
## Documentation is the Story of Your Code
6962

70-
Writing excellent code doesn't end when your code compiles or even if your
71-
test coverage reaches 100%. It's easy to write something a computer understands,
72-
it's much harder to write something both a human and a computer understand. Your
63+
Writing excellent code doesn't end when your code compiles or even if your test
64+
coverage reaches 100%. It's easy to write something a computer understands, it's
65+
much harder to write something both a human and a computer understand. Your
7366
mission as a Code Health-conscious engineer is to **write for humans first,
7467
computers second.** Documentation is an important part of this skill.
7568

7669
There's a spectrum of engineering documentation that ranges from terse comments
7770
to detailed prose:
7871

79-
1. **Inline comments**: The primary purpose of inline comments is to provide
72+
1. **Meaningful names**: Good naming allows the code to convey information that
73+
would otherwise be relegated to comments or documentation. This includes
74+
nameable entities at all levels, from local variables to classes, files, and
75+
directories.
76+
77+
2. **Inline comments**: The primary purpose of inline comments is to provide
8078
information that the code itself cannot contain, such as why the code is
8179
there.
8280

83-
2. **Method and class comments**:
81+
3. **Method and class comments**:
8482

85-
* **Method API documentation**: The header / Javadoc / docstring
86-
comments that say what methods do and how to use them. This
87-
documentation is **the contract of how your code must behave**. The
88-
intended audience is future programmers who will use and modify your
89-
code.
83+
* **Method API documentation**: The header / Javadoc / docstring comments
84+
that say what methods do and how to use them. This documentation is
85+
**the contract of how your code must behave**. The intended audience is
86+
future programmers who will use and modify your code.
9087

9188
It is often reasonable to say that any behavior documented here should
9289
have a test verifying it. This documentation details what arguments the
@@ -103,13 +100,42 @@ to detailed prose:
103100
examples of how you might use the class / file.
104101

105102
Examples are particularly relevant when there's several distinct ways to
106-
use the class (some advanced, some simple). Always list the simplest
107-
use case first.
103+
use the class (some advanced, some simple). Always list the simplest use
104+
case first.
108105

109-
3. **README.md**: A good README.md orients the new user to the directory and
106+
4. **README.md**: A good README.md orients the new user to the directory and
110107
points to more detailed explanation and user guides:
111-
* What is this directory intended to hold?
112-
* Which files should the developer look at first? Are some files an API?
113-
* Who maintains this directory and where I can learn more?
108+
109+
* What is this directory intended to hold?
110+
* Which files should the developer look at first? Are some files an API?
111+
* Who maintains this directory and where I can learn more?
114112

115113
See the [README.md guidelines](READMEs.md).
114+
115+
5. **docs**: The contents of a good docs directory explain how to:
116+
117+
* Get started using the relevant API, library, or tool.
118+
* Run its tests.
119+
* Debug its output.
120+
* Release the binary.
121+
122+
6. **Design docs, PRDs**: A good design doc or PRD discusses the proposed
123+
implementation at length for the purpose of collecting feedback on that
124+
design. However, once the code is implemented, design docs should serve as
125+
archives of these decisions, not as half-correct docs (they are often
126+
misused).
127+
128+
7. **Other external docs**: Some teams maintain documentation in other
129+
locations, separate from the code, such as Google Sites, Drive, or wiki.
130+
If you do maintain documentation in
131+
other locations, you should clearly point to those locations from your
132+
project directory (for example, by adding an obvious link to the location
133+
from your project's `README.md`).
134+
135+
## Duplication is Evil
136+
137+
Do not write your own guide to a common Google technology or process. Link to it
138+
instead. If the guide doesn't exist or it's badly out of date, submit your
139+
updates to the appriopriate directory or create a package-level
140+
README.md. **Take ownership and don't be shy**: Other teams will usually welcome
141+
your contributions.

docguide/philosophy.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@
55
*Clay becomes pottery through craft, but it's the emptiness that makes a pot
66
useful.*
77

8-
\- [Laozi](http://ctext.org/dictionary.pl?if=en&id=11602)
8+
\- [Laozi](https://ctext.org/dictionary.pl?if=en&id=11602)
99

1010
Contents:
1111

1212
1. [Radical simplicity](#radical-simplicity)
1313
1. [Readable source text](#readable-source-text)
1414
1. [Minimum viable documentation](#minimum-viable-documentation)
15-
1. [Better is better than perfect](#better-is-better-than-perfect)
15+
1. [Better is better than best](#better-is-better-than-best)
1616

1717
## Radical simplicity
1818

19-
* **Scalability and interoperability** are more important than a menagerie of
20-
unessential features. Scale comes from simplicity, speed, and ease.
21-
Interoperability comes from unadorned, digestible content.
19+
* **Scalability and interoperability** are more important than a menagerie of
20+
unessential features. Scale comes from simplicity, speed, and ease.
21+
Interoperability comes from unadorned, digestible content.
2222

23-
* **Fewer distractions** make for better writing and more productive reading.
23+
* **Fewer distractions** make for better writing and more productive reading.
2424

25-
* **New features should never interfere with the simplest use case** and should
26-
remain invisible to users who don't need them.
25+
* **New features should never interfere with the simplest use case** and
26+
should remain invisible to users who don't need them.
2727

28-
* **This guide is designed for the average engineer** -- the busy,
29-
just-want-to-go-back-to-coding engineer. Large and complex documentation is
30-
possible but not the primary focus.
28+
* **Markdown is designed for the average engineer** -- the busy,
29+
just-want-to-go-back-to-coding engineer. Large and complex documentation is
30+
possible but not the primary focus.
3131

32-
* **Minimizing context switching makes people happier.** Engineers should be
33-
able to interact with documentation using the same tools they use to read and
34-
write code.
32+
* **Minimizing context switching makes people happier.** Engineers should be
33+
able to interact with documentation using the same tools they use to read
34+
and write code.
3535

3636
## Readable source text
3737

@@ -61,11 +61,13 @@ Contents:
6161
majority of users need only a small fraction of the author's total knowledge,
6262
but they need it quickly and often.
6363

64-
## Better is better than perfect
64+
## Better is better than best
6565

66-
* **Incremental improvement is better than prolonged debate**. Patience and
67-
tolerance of imperfection allow projects to evolve organically.
66+
* **Incremental improvement is better than prolonged debate**. Patience and
67+
tolerance of imperfection allow projects to evolve organically.
6868

69-
* **Don't lick the cookie, pass the plate**. We're drowning in potentially
70-
impactful projects. Choose only those you can really handle and release those
71-
you can't.
69+
* **Don't
70+
[lick the cookie](https://community.redhat.com/blog/2018/09/dont-lick-the-cookie/),
71+
pass the plate**. Ideas are cheap. We're drowning in potentially impactful
72+
projects. Choose only those you can really handle and release those you
73+
can't.

docguide/style.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ We seek to balance three goals:
1313

1414
Contents:
1515

16+
1. [Minimum viable documentation](#minimum-viable-documentation)
17+
1. [Better is better than best](#better-is-better-than-best)
1618
1. [Capitalization](#capitalization)
1719
1. [Document layout](#document-layout)
1820
1. [Table of contents](#table-of-contents)
@@ -47,6 +49,43 @@ Contents:
4749
1. [Tables](#tables)
4850
1. [Strongly prefer Markdown to HTML](#strongly-prefer-markdown-to-html)
4951

52+
## Minimum viable documentation
53+
54+
A small set of fresh and accurate docs is better than a sprawling, loose
55+
assembly of "documentation" in various states of disrepair.
56+
57+
The **Markdown way** encourages engineers to take ownership of their docs and
58+
keep them up to date with the same zeal we keep our tests in good order. Strive
59+
for this.
60+
61+
* Identify what you really need: release docs, API docs, testing guidelines.
62+
* Delete cruft frequently and in small batches.
63+
64+
## Better is better than best
65+
66+
The standards for an internal documentation review are different from the
67+
standards for code reviews. Reviewers should ask for improvements, but in
68+
general, the author should always be able to invoke the "Better/Best Rule."
69+
70+
Fast iteration is your friend. To get long-term improvement, **authors must stay
71+
productive** when making short-term improvements. Set lower standards for each
72+
CL, so that **more such CLs** can happen.
73+
74+
As a reviewer of a documentation CL:
75+
76+
1. When reasonable, LGTM immediately and trust that comments will be fixed
77+
appropriately.
78+
2. Prefer to suggest an alternative rather than leaving a vague comment.
79+
3. For substantial changes, start your own follow-up CL instead. Especially try
80+
to avoid comments of the form "You should *also*...".
81+
4. On rare occasions, hold up submission if the CL actually makes the docs
82+
worse. It's okay to ask the author to revert.
83+
84+
As an author:
85+
86+
1. Avoid wasting cycles with trivial argument. Capitulate early and move on.
87+
2. Cite the Better/Best Rule as often as needed.
88+
5089
## Capitalization
5190

5291
Use the original names of products, tools and binaries, preserving the
@@ -453,7 +492,7 @@ backslash at the end of the line:
453492

454493
<pre>
455494
```shell
456-
$ blaze run :target -- --flag --foo=longlonglonglonglongvalue \
495+
$ bazel run :target -- --flag --foo=longlonglonglonglongvalue \
457496
--bar=anotherlonglonglonglonglonglonglonglonglonglongvalue
458497
```
459498
</pre>

0 commit comments

Comments
 (0)