You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It uses the TypeScript compiler API instead of
JSDoc-api JSDoc is outdated and its meant for
JavaScript projects.
We use this to parse everything thats not a
React component or a Markdown file.
(the utilities menu in the sidebar).
It gets type information for functions from the
TypeScript types, so it can be deleted in the
jsdoc (the {Object} part in @param {Object} bla).
For non-function or complex utilities
it gets the info from the JSDoc so we need to
keep it (e.g. withStyle, contains).
Removed DateTime and conversions and some
custom PropTypes from the doc since they were
parsed in a special way and contained no useful
info.
note that it cannot parse types if the jsdoc is
at the export statement
Copy file name to clipboardExpand all lines: docs/contributor-docs/writing-docs.md
+34-9Lines changed: 34 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,40 @@ This page documents how to add and maintain documentation.
12
12
13
13
The documentation site is generated from the **source code** and the `.md` files. There are two types of `.md` files: `README.md` and `named-md-files.md`, under the `docs folder`.
14
14
15
-
The **source code** is parsed with [JSDoc](https://jsdoc.app/) with the exeption of react components, which are parsed by [react-docgen](https://react-docgen.dev/) and it provides `type` information for the docs.
15
+
The **source code** is parsed with the [TypeScript compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API) with the exception of React components, which are parsed by [react-docgen](https://react-docgen.dev/). These tools parse out JSDoc comments, type information of React component props and types for functions.
16
+
17
+
## Utility functions
18
+
19
+
These are in the "utilities" menu in the left navigation bar. Their JSDoc needs to be above an exported function and needs to have a `@module` annotation to be included in the docs. Our parser can handle 1 export/file. No need to define types in JSDoc, they will be parsed from the function itself.
20
+
21
+
The gray-matter YAML defines meta information like which part of the side navigation this will be in (`category`).
22
+
23
+
```typescript
24
+
---
25
+
type: code
26
+
---
27
+
/**
28
+
* ---
29
+
* category: utilities/a11y
30
+
* ---
31
+
* @module
32
+
* Documentation goes here
33
+
* @paramp1 the param
34
+
*/
35
+
function myFunc(p1:int) {}
36
+
37
+
export {myFunc}
38
+
```
39
+
40
+
## Markdown files
16
41
17
42
The docs can be written in `markdown`, with some added flavor, so the docs can handle special code-display cases.
18
43
19
-
## Special Mardown Rules
44
+
###Special Markdown Rules
20
45
21
46
The only special markdown part is the `codeblock`. It can be displayed in several different ways.
22
47
23
-
### 1. code
48
+
####1. code
24
49
25
50
If a code example is needed with syntax highlighting:
26
51
@@ -48,7 +73,7 @@ console.log("my js example comes here")
48
73
49
74
Most common languages can be used for syntax highlight, such as `jsx`, `bash` or `md`
50
75
51
-
### 2. embed
76
+
####2. embed
52
77
53
78
The `type: embed` will render the containing code into the page. It must be valid `javascript`
54
79
@@ -76,7 +101,7 @@ type: embed
76
101
77
102
**_Note:_** you can use any instUI components in the examples
78
103
79
-
### 3. example
104
+
####3. example
80
105
81
106
The most complex type is the `type: example`. It will render as the `embed` did, but it also provides access to the code, which is editable and the changes reflect on the rendered view immediately.
82
107
@@ -216,7 +241,7 @@ render(<Example />);
216
241
217
242
**_Note:_** you can use `funcional React` as well.
218
243
219
-
### 4. Multi example
244
+
####4. Multi example
220
245
221
246
If an example should be shown in `class` and `function` form as well, it needs to be written as a `list` with two items. The first item will be the `class`, the second the `function`.
222
247
@@ -312,7 +337,7 @@ The above code will display like this:
312
337
313
338
**_Note:_** beacuse of this feature, code examples can not be displayed by `lists`
314
339
315
-
### 5. comment examples
340
+
####5. comment examples
316
341
317
342
`JSDoc` can parse `markdown` even in the comments of `js/ts files`. These `comment-based examples` can not contain `front-matter`:
318
343
@@ -348,7 +373,7 @@ type: code
348
373
349
374
The compiler will strip the postfix and calculate the language and type from it as well.
350
375
351
-
##Named files
376
+
### Purely documentation files
352
377
353
378
Under the docs folder, there are additional folders, which are containing `.md` files, which are for general documentation. These need a `frontmatter`:
354
379
@@ -378,7 +403,7 @@ The `category` is the category under which the doc will be palced in the menu tr
378
403
379
404
## Additional information
380
405
381
-
There are automatically generated parts of the documentation, such as:
406
+
These are automatically generated parts of the documentation, such as:
0 commit comments