docs: improved docs for comments

This commit is contained in:
Wieland Schöbl
2019-07-03 14:06:46 +02:00
parent a5b8d459d9
commit 8e7992046c

View File

@@ -36,6 +36,37 @@ async get<T>(key: string): Promise<T> {
return entry;
}
```
### Inline Comments `//`
* Start inline comments with a lowercase letter and a space after the `//`
* Place the comment above the line that it is referencing
```typescript
// lorem ipsum
const lorem;
```
### Doc Comments `/**`
* Start with a capital letter
* Keep the first line short
* The first line should not end with a period, nor should it consist of multiple sentences
* The first line should be easily scannable
* If you want to comment more than one line, do a short summary in the first line, then continue after a blank line with the more detailed description
* Document all parameters in functions using `@param`
* `@param` must not contain a type annotation, just `@param name description`
* Do not include `@return`, as it is redundant information
```typescript
/**
* Short summary of the function, without a period
*
* This is a very long description, that could never possibly fit on one line, nor could it
* be read in a short amount of time. Because we can use multiple sentences here, we can actually
* use a period.
*
* @param foo This parameter does something
*/
function fun(foo: number): Foo {
```
## `CONTRIBUTING.md`