-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: AIP-192 – Documentation #25
Open
lukesneeringer
wants to merge
1
commit into
main
Choose a base branch
from
aip-192
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+129
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Documentation | ||
|
||
Documentation is one of the most critical aspects of API design. Users of your | ||
API are unable to dig into the implementation to understand the API better; | ||
often, the API surface definition and its corresponding documentation will be | ||
the only things a user has. Therefore, it is important that documentation be as | ||
clear, complete, and unambiguous as possible. | ||
|
||
## Guidance | ||
|
||
In APIs defined in protocol buffers, public comments **must** be included over | ||
every component (service, method, message, field, enum, and enum value) using | ||
the comment format provided by your IDL. This is important even in cases where | ||
the comment is terse and uninteresting, as numerous tools read these comments | ||
and use them. | ||
|
||
Services, in particular, **should** have descriptive comments that explain what | ||
the service is and what users are able to do with it. | ||
|
||
**Note:** Many readers will not be native English speakers. Comments **should** | ||
avoid jargon, slang, complex metaphors, pop culture references, or anything | ||
else that will not easily translate. Additionally, many readers will have | ||
different backgrounds and viewpoints; if writing examples involving people, | ||
comments **should** use people who are non-controversial and no longer alive. | ||
|
||
### Style | ||
|
||
Comments **should** be in grammatically correct American English. However, the | ||
first sentence of each operation comment **should** omit the subject and be in | ||
the third-person present tense: | ||
|
||
```typescript | ||
// An API for managing the inventory for a library: Users may create, read, | ||
// and otherwise manipulate the library's inventory of books. | ||
interface Library { | ||
// Creates a book under the given publisher. | ||
createBook(request: CreateBookRequest): Book; | ||
} | ||
``` | ||
|
||
### Descriptions | ||
|
||
Descriptions of messages and fields **should** be brief but complete. Sometimes | ||
comments are necessarily perfunctory because there is little to be said; | ||
however, before jumping to that conclusion, consider whether some of the | ||
following questions are relevant: | ||
|
||
- What is it? | ||
- How do you use it? | ||
- What does it do if it succeeds? What does it do if it fails? | ||
- Is it idempotent? | ||
- What are the units? (Examples: meters, degrees, pixels) | ||
- What are the side effects? | ||
- What are common errors that may break it? | ||
- What is the expected input format? | ||
- What range of values does it accept? (Examples: `[0.0, 1.0)`, `[1, 10]`) | ||
- Is the range inclusive or exclusive? | ||
- For strings, what is the minimum and maximum length, and what characters | ||
are allowed? | ||
- If a value is above the maximum length, do you truncate or send an error? | ||
- Is it always present? (Example: "Container for voting information. Present | ||
only when voting information is recorded.") | ||
- Does it have a default setting? (Example: "If `page_size` is omitted, the | ||
default is 50.") | ||
|
||
### Formatting | ||
|
||
Any formatting in comments **must** be in [CommonMark][]. Headings and tables | ||
**must not** be used, as these cause problems for several tools, and are | ||
unsuitable for client library reference documentation. | ||
|
||
Comments **should** use `code font` for property names and for literals (such | ||
as `true`). | ||
|
||
Raw HTML **must not** be used. | ||
|
||
### External links | ||
|
||
Comments **may** link to external pages to provide background information | ||
beyond what is described in the public comments themselves. External links | ||
**must** use absolute (rather than relative) URLs, including the protocol | ||
(usually `https`), and **should not** assume the documentation is located on | ||
any particular host. For example: | ||
`[Spanner Documentation](https://cloud.google.com/spanner/docs)` | ||
|
||
### Trademarked names | ||
|
||
When referring to the proper, trademarked names of companies or products in | ||
comments, acronyms **should not** be used, unless the acronym is such dominant | ||
colloquial use that avoiding it would obscure the reference (example: [IBM][]). | ||
|
||
Comments **should** spell and capitalize trademarked names consistent with the | ||
trademark owner's current branding. | ||
|
||
### Internal comments | ||
|
||
<!-- TODO: This does not work outside of Google. | ||
We should probably try to get that fixed. --> | ||
|
||
Comments **may** be explicitly marked as internal by wrapping internal content | ||
in `(--` and `--)`. | ||
|
||
Non-public links, internal implementation notes (such as `TODO` and `FIXME` | ||
directives), and other such material **must** be marked as internal. | ||
|
||
**Note:** In IDLs using code comment syntax, comments **should** use only | ||
leading comments (not trailing comments or detached comments). In particular, | ||
comments **must not** use both a leading and trailing comment to describe any | ||
component, because this is a common source of inadvertent omissions of the | ||
internal content annotation. | ||
Comment on lines
+95
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest that we remove this -- it apparently doesn't work outside Google and there is no OAS analog. |
||
|
||
[commonmark]: https://commonmark.org/ | ||
[ibm]: https://en.wikipedia.org/wiki/IBM | ||
|
||
## Changelog | ||
|
||
- **2020-04-01**: Added guidance requiring absolute URLs for external links. | ||
- **2020-02-14**: Added guidance around the use of trademarked names. | ||
- **2019-09-23**: Added guidance about not using both leading and trailing | ||
comments. | ||
- **2019-08-01**: Changed the examples from "shelves" to "publishers", to | ||
present a better example of resource ownership. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
id: 192 | ||
state: approved | ||
created: 2019-07-25 | ||
placement: | ||
category: polish | ||
order: 20 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not restrict this to protocol buffers.