Skip to content

Commit c6b30ad

Browse files
committed
refactor: remove jsdoc-api from the docs app
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
1 parent 66e222c commit c6b30ad

File tree

34 files changed

+574
-811
lines changed

34 files changed

+574
-811
lines changed

docs/contributor-docs/writing-docs.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,40 @@ This page documents how to add and maintain documentation.
1212

1313
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`.
1414

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+
* @param p1 the param
34+
*/
35+
function myFunc(p1: int) {}
36+
37+
export {myFunc}
38+
```
39+
40+
## Markdown files
1641

1742
The docs can be written in `markdown`, with some added flavor, so the docs can handle special code-display cases.
1843

19-
## Special Mardown Rules
44+
### Special Markdown Rules
2045

2146
The only special markdown part is the `codeblock`. It can be displayed in several different ways.
2247

23-
### 1. code
48+
#### 1. code
2449

2550
If a code example is needed with syntax highlighting:
2651

@@ -48,7 +73,7 @@ console.log("my js example comes here")
4873

4974
Most common languages can be used for syntax highlight, such as `jsx`, `bash` or `md`
5075

51-
### 2. embed
76+
#### 2. embed
5277

5378
The `type: embed` will render the containing code into the page. It must be valid `javascript`
5479

@@ -76,7 +101,7 @@ type: embed
76101

77102
**_Note:_** you can use any instUI components in the examples
78103

79-
### 3. example
104+
#### 3. example
80105

81106
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.
82107

@@ -216,7 +241,7 @@ render(<Example />);
216241

217242
**_Note:_** you can use `funcional React` as well.
218243

219-
### 4. Multi example
244+
#### 4. Multi example
220245

221246
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`.
222247

@@ -312,7 +337,7 @@ The above code will display like this:
312337

313338
**_Note:_** beacuse of this feature, code examples can not be displayed by `lists`
314339

315-
### 5. comment examples
340+
#### 5. comment examples
316341

317342
`JSDoc` can parse `markdown` even in the comments of `js/ts files`. These `comment-based examples` can not contain `front-matter`:
318343

@@ -348,7 +373,7 @@ type: code
348373

349374
The compiler will strip the postfix and calculate the language and type from it as well.
350375

351-
## Named files
376+
### Purely documentation files
352377

353378
Under the docs folder, there are additional folders, which are containing `.md` files, which are for general documentation. These need a `frontmatter`:
354379

@@ -378,7 +403,7 @@ The `category` is the category under which the doc will be palced in the menu tr
378403

379404
## Additional information
380405

381-
There are automatically generated parts of the documentation, such as:
406+
These are automatically generated parts of the documentation, such as:
382407

383408
- Table of content
384409
- Properties

0 commit comments

Comments
 (0)