-
Notifications
You must be signed in to change notification settings - Fork 3
Create style guide #103
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
Open
makahmad
wants to merge
11
commits into
main
Choose a base branch
from
style_guide
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.
Open
Create style guide #103
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8f2f167
adopt google's style guide
18ff74c
Update aip/general/0008/aip.md
makahmad 5c9974a
Update aip/general/0008/aip.md
makahmad dcacfe1
Update aip/general/0008/aip.md
makahmad 27b5f90
Update aip/general/0008/aip.md
makahmad 17a6c70
updated guide based on comments
c98923f
updated guide based on comments
cd6f8ed
Update aip/general/0008/aip.md
rofrankel db9cf2d
Update aip/general/0008/aip.md
rofrankel de79a0b
changed formatting
c9cac0d
updated redirect_from
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 hidden or 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,175 @@ | ||
# AIP Style guide | ||
|
||
AIP stands for **API Improvement Proposal**, which is a design document | ||
providing high-level, concise documentation for API development. The goal is | ||
for these documents to serve as the source of truth for API-related | ||
documentation and the way API teams discuss and come to consensus on | ||
API guidance. | ||
|
||
AIPs are most useful when they are clear and concise, and cover a single topic | ||
or inquiry well. In the same way that AIPs describe consistent patterns and | ||
style for use in APIs, they also _follow_ consistent patterns and style. | ||
|
||
## Guidance | ||
|
||
AIPs **must** cover a single, discrete topic, and **should** fundamentally | ||
answer the question, "What do I do?" with actionable guidance. AIPs **may** | ||
also cover what _not_ to do, but **should not** cover _only_ anti-patterns. | ||
|
||
While the length of AIPs will necessarily vary based on the complexity of the | ||
question, most AIPs **should** be able to cover their content in roughly two | ||
printed pages. | ||
|
||
### File structure | ||
|
||
AIPs **must** be written in Markdown, and **must** be placed in corresponding directory using their | ||
four-digit number (example: `0008/aip.md`). AIPs that serve a specific scope | ||
**must** be in the subdirectory for that scope. | ||
|
||
AIPs **must** have appropriate front matter that lives in the `aip.yaml` file. | ||
|
||
```yaml | ||
--- | ||
aip: | ||
id: 8 | ||
state: reviewing | ||
created: 2019-05-28 | ||
permalink: /8 | ||
--- | ||
|
||
``` | ||
|
||
Front matter for AIPs **must** include: | ||
|
||
- The `aip` key: | ||
- `id`: Required. The ID for the given AIP, as an integer. | ||
- `state`: Required. The current state of the AIP, in all lower-case. The | ||
valid states are listed in [AIP-1][], and common states are `draft`, | ||
`reviewing`, and `approved`. | ||
- `created`: Required. The ISO-8601 date (`yyyy-mm-dd`) when the AIP was | ||
originally drafted, with no quotes. | ||
- `updated`: The ISO-8601 date (`yyyy-mm-dd`) when the AIP was last revised. | ||
- `scope`: The scope for the AIP. This **must** match the directory name for | ||
that scope. Required for AIPs with IDs >= 1000, prohibited otherwise. | ||
- The `permalink` key (required): This **must** be set to | ||
`/{aip.scope}/{aip.id}`. If there is no scope, use `/{aip.id}` instead. | ||
- The `redirect_from` key: This should include one path | ||
that a reader would be likely to enter, including: | ||
- `/{aip.id}` (for AIPs where the permalink includes the scope) | ||
- AIP IDs with zero-padding, for each level of zero-padding up to four digits | ||
(for example: `/08`, `/008`, `/0008`). | ||
makahmad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Document structure | ||
|
||
AIPs **must** begin with a top-level heading with the AIP's title (`# Title`). | ||
The title **should** be a noun (not an imperative). For example, "Bad API | ||
precedents" not "Avoid breaking API precedent". | ||
|
||
AIPs **should** then begin with an introduction (with no additional heading), | ||
followed by a `## Guidance` heading. If necessary, the AIP **may** include any | ||
of the following after the guidance, in the following order: | ||
|
||
- "Further reading" is a bulleted list of links to other AIPs that are useful | ||
to fully understand the current AIP. | ||
- "Appendices" covering further explanation in the same AIP. These are | ||
relatively rare but are important in cases where an AIP requires a lot of | ||
justification for the decision. Often this is primarily an explanation of | ||
alternatives considered to help explain the guidance. | ||
- "Changelog" is a bulleted list of changes made to the AIP since the first | ||
writing. | ||
|
||
The guidance section **should** include subsections that elaborate further on | ||
details. Subsections will automatically create an entry in the table of | ||
contents, and an anchor for citations. | ||
The guidance section **may** include abstract descriptions of structures and wherever possible these should use TypeScript syntax. TypeScript is easy to follow for anyone familiar with either dynamic languages (like JavaScript or Python) or static languages (like Java or C++). These descriptions are intended as pseudo-code and are not intended to represent the actual implementation of the API in a TypeScript library. | ||
|
||
makahmad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Below is an example AIP shell that uses each major section: | ||
|
||
```md | ||
# AIP title | ||
|
||
The introductory text explains the background and reason why the AIP exists. It | ||
lays out the basic question, but does not tell the reader what to do. | ||
|
||
## Guidance | ||
|
||
The "guidance" section helps the reader know what to do. A common format for | ||
the guidance section is a high-level imperative, followed by an example, | ||
followed by a bulleted list explaining the example. | ||
|
||
### Subsection | ||
|
||
Individual subsections can be cited individually, and further elaborate | ||
details. | ||
|
||
## Further reading | ||
|
||
A bulleted list of (usually) other AIPs, in the following format: | ||
|
||
- [AIP-1](./0001.md): AIP purpose and guidelines | ||
|
||
## Appendix | ||
|
||
An appendix is appropriate when a non-trivial side discussion is necessary. It | ||
may explain historical reasons for the guidance, alternatives considered, or | ||
other issues potentially of interest to the reader. | ||
|
||
## Changelog | ||
|
||
A bulleted list of changes in reverse chronological order, using the following | ||
format: | ||
|
||
- **2020-02-18**: Specified ordering. | ||
- **2019-07-01**: Added a subsection clarifying XYZ. | ||
``` | ||
|
||
AIPs **should** attempt to follow this overall format if possible, but AIPs | ||
**may** deviate from it if necessary (in particular, if the AIP would be more | ||
difficult to understand, even for a reader already accustomed to reading AIPs | ||
in the usual format). | ||
|
||
**Note:** Except for the title, AIPs **must** only use the second heading level | ||
(`##`) and above. AIPs **should** only use the second and third heading levels | ||
(`##`, `###`). | ||
|
||
### Requirement keywords | ||
|
||
AIPs **should** use the following requirement level keywords: "MUST", "MUST | ||
NOT", "SHOULD", "SHOULD NOT", and "MAY", which are to be interpreted as | ||
described in [RFC 2119][]. | ||
|
||
When using these terms in AIPs, they **must** be lower-case and **bold**. These | ||
terms **should not** be used in other ways. | ||
|
||
**Important:** If an appendix is used, it exists to provide background and a | ||
more complete understanding, but **must not** contain guidance (and RFC-2119 | ||
terms **must not** be used). | ||
|
||
### Code examples | ||
|
||
API design examples in AIPs **should** use both [OpenAPI]{} and [protocol buffers][] in tabs. Examples | ||
**should** cover only enough syntax to explain the concept. When using RPCs in | ||
examples, a `google.api.http` annotation **should** be included. | ||
|
||
### Referencing AIPs | ||
|
||
When AIPs reference other AIPs, the prosaic text **must** use the format | ||
`AIP-XXXX` without zero-padding (e.g., `AIP-8`, not `AIP-0008`), and **must** | ||
link to the relevant AIP. AIP links **may** point to a particular section of | ||
the AIP if appropriate. | ||
|
||
**Important:** AIP links **must** use the relative path to the file in the | ||
repository (such as `./0008.md` for core AIPs, or `../0008.md` for AIPs in a | ||
subdirectory); this ensures that the link works both on the AIP site, when | ||
viewing the Markdown file on GitHub, using the local development server, or a | ||
branch. | ||
|
||
[aip-1]: ./0001.md | ||
[OpenAPI]: https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.3.md | ||
[protocol buffers]: https://developers.google.com/protocol-buffers/ | ||
makahmad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[rfc 2119]: https://www.ietf.org/rfc/rfc2119.txt | ||
|
||
## Changelog | ||
|
||
- **2020-02-18**: Specified reverse chronological ordering for changelog items. | ||
- **2019-08-23**: Added guidance for internal AIP links. |
This file contains hidden or 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: 8 | ||
state: draft | ||
created: 2022-11-14 | ||
placement: | ||
category: meta | ||
order: 10 |
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.
Uh oh!
There was an error while loading. Please reload this page.