@@ -7,7 +7,7 @@ in the JSDoc format.
7
7
** But don't worry! Even though it's embedded in your code, JSDoc is not code. It's a simple and standard
8
8
syntax for writing documentation. You don't need to be a developer to use it.**
9
9
10
- Before you continue, make sure ` documentation ` is on your system (do ` npm install -g documentation ` , if not installed).
10
+ Before you continue, make sure ` documentation ` is on your system. (If it's not installed, run ` npm install -g documentation ` .)
11
11
12
12
Now, let's dive in.
13
13
@@ -31,7 +31,7 @@ function addOne(input) {
31
31
The comment before the ` addOne ` function is a JSDoc comment. Note that it
32
32
begins with ` /** ` instead of ` /* ` . JSDoc requires this.
33
33
34
- If you were to write a comment like
34
+ If you were to write a comment like this:
35
35
36
36
``` js
37
37
// --- INVALID - this is ignored by JSDOC ---
@@ -40,7 +40,7 @@ If you were to write a comment like
40
40
// @returns {number} that number, plus one.
41
41
```
42
42
43
- the comment would be ignored by ` documentation ` because it uses ` // ` syntax instead of ` /** ` .
43
+ ... the comment would be ignored by ` documentation ` , because it uses ` // ` syntax instead of ` /** ` .
44
44
It's not valid JSDoc syntax.
45
45
46
46
Let's break down the earlier JSDoc example:
@@ -64,8 +64,7 @@ On the second line:
64
64
* `{number}` is **a type**. It says that the input to this function is
65
65
a JavaScript "number". It could also say `{string}`,
66
66
`{Object}`, `{Date}`, or any other JavaScript built-in type. And if you
67
- defined a custom class, like `FooClass`, you can use it as a type too by
68
- saying `{FooClass}`.
67
+ defined a custom class, like `FooClass`, you can use it as a type, too! Just say `{FooClass}`.
69
68
* `input` is the name of the input variable. It matches what the code
70
69
says right below it (`function addOne(input)`).
71
70
* `any number` is the description of the input.
@@ -82,22 +81,22 @@ This is the syntax that describes an optional parameter:
82
81
* @param {number} [input= 5 ] any number
83
82
```
84
83
85
- If an input is omitted, the default value of 5 will be passed to the function.
84
+ If an input is omitted, the default value of `5` will be passed to the function.
86
85
87
86
## What `documentation` does, so you don't have to
88
87
89
88
`documentation` does some minor magic to auto-generate documentation. Unless
90
89
you want to read the code for yourself, here's a summary of its magic:
91
90
92
91
**Inference**: JSDoc lets you specify absolutely everything about your code:
93
- use @name to say what something is called, @kind for whether it's a function
94
- or a class, @param for its parameters, and so on. But writing all of that
92
+ use ` @name ` to say what something is called, ` @kind ` for whether it's a function
93
+ or a class, ` @param ` for its parameters, and so on. But writing all of that
95
94
explicitly is tedious, so where it can, `documentation` automatically
96
- populates @name , @kind , and @memberof tags based on its reading of the
95
+ populates ` @name `, ` @kind ` , and ` @memberof ` tags based on its reading of the
97
96
code.
98
97
99
98
**Normalization**: JSDoc has multiple words for the same thing: you can
100
- say @augments or @extends and they'll do the same thing.
99
+ say ` @augments ` or ` @extends ` and they'll do the same thing.
101
100
102
101
## Development Process
103
102
@@ -108,25 +107,26 @@ automated style check.
108
107
109
108
## The Tags
110
109
111
- [usejsdoc.com](http://usejsdoc.org/index.html) covers all available tags in the
112
- JSDoc syntax, and is a great reference. The most commonly used tags
113
- are:
114
-
115
- * @param - input given to a function as an argument
116
- * @returns - output value of a function
117
- * @name - explicitly set the documented name of a function, class, or variable
118
- * @private - you can use @private to document
119
- code and not have it included in the generated documentation,
120
- maybe it's not part of the public API. There's also @public and @protected
121
- * @example - you can use the @example tag to add inline code examples with your
110
+ [**`usejsdoc.com`**](http://usejsdoc.org) covers all available tags in the
111
+ JSDoc syntax, and is a great reference.
112
+
113
+ The most commonly used tags are:
114
+
115
+ * `@param ` - input given to a function as an argument
116
+ * `@returns ` - output value of a function
117
+ * `@name ` - explicitly set the documented name of a function, class, or variable
118
+ * `@private ` - you can use `@private ` to document
119
+ code and not have it included in the generated documentation;
120
+ maybe it's not part of the public API. There's also `@public ` and `@protected `
121
+ * `@example ` - you can use the `@example ` tag to add inline code examples with your
122
122
documentation
123
123
124
124
If your text editor does not highlight JSDoc tags,
125
125
try [using a plugin for JSDoc](https://github.com/documentationjs/documentation/wiki/Text-editor-plugins).
126
126
127
127
## Flow type annotations
128
128
129
- Alternatively, [Flow](https: // flow.org/ ) type annotations allows for a more compact syntax:
129
+ Alternatively, [Flow](https://flow.org) type annotations allows for a more compact syntax:
130
130
131
131
```js
132
132
/**
0 commit comments