@playcanvas/attribute-parser 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -4
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/parsers/attribute-parser.js +1 -1
- package/src/parsers/script-parser.js +1 -1
- package/src/utils/ts-utils.js +2 -3
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# PlayCanvas Attribute Parser
|
|
2
2
|
|
|
3
|
-
This the JSDoc attribute parser used in the PlayCanvas editor.
|
|
3
|
+
This the official JSDoc attribute parser used in the PlayCanvas editor.
|
|
4
|
+
|
|
5
|
+
It's used in the PlayCanvas Editor to collect metadata from jsdoc annotated users scripts. This allows special `@attribute` members which can surface contextual data about class members.
|
|
6
|
+
|
|
7
|
+
## A quick examples
|
|
4
8
|
|
|
5
9
|
It takes a script like this...
|
|
6
10
|
|
|
@@ -22,7 +26,7 @@ class Rotator extends ScriptType {
|
|
|
22
26
|
}
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
and turns it into
|
|
29
|
+
and turns it into the following data ...
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
```json
|
|
@@ -53,7 +57,7 @@ and turns it into this...
|
|
|
53
57
|
}
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
JSDocs tags are parsed and values and outputs the metadata in a serializable format.
|
|
57
61
|
|
|
58
62
|
### Usage
|
|
59
63
|
|
|
@@ -65,8 +69,11 @@ await parser.init();
|
|
|
65
69
|
// fetch your program source {[filename: string, contents: string][]}
|
|
66
70
|
const scripts = await fetchScripts([...paths, './playcanvas.d.ts']);
|
|
67
71
|
|
|
72
|
+
// update the progam
|
|
73
|
+
parser.updateProgram(scripts)
|
|
74
|
+
|
|
68
75
|
// Parse the program, starting from the first path
|
|
69
|
-
const [attribute, errors] parser.parseAttributes(
|
|
76
|
+
const [attribute, errors] parser.parseAttributes("./index.js");
|
|
70
77
|
```
|
|
71
78
|
|
|
72
79
|
### Attribute structure
|
|
@@ -74,3 +81,8 @@ const [attribute, errors] parser.parseAttributes(paths[0], scripts);
|
|
|
74
81
|
You can learn more about the special tags [available here ](https://github.com/playcanvas/attribute-parser/tree/main/test/fixtures)
|
|
75
82
|
|
|
76
83
|
|
|
84
|
+
### Tests
|
|
85
|
+
|
|
86
|
+
We provide good coverage
|
|
87
|
+
|
|
88
|
+
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
2
|
import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind, TextRange, TSDocParser } from "@microsoft/tsdoc";
|
|
3
3
|
import { extractTextFromDocNode, getLeadingBlockCommentRanges, getType } from '../utils/ts-utils.js';
|
|
4
4
|
|
package/src/utils/ts-utils.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { DocNodeKind } from '@microsoft/tsdoc';
|
|
2
2
|
import { knownLibFilesForCompilerOptions } from '@typescript/vfs';
|
|
3
|
-
import ts from 'typescript';
|
|
3
|
+
import * as ts from 'typescript';
|
|
4
4
|
import { ParsingError } from '../parsers/parsing-error.js';
|
|
5
5
|
|
|
6
|
-
export function createDefaultMapFromCDN(options,
|
|
6
|
+
export function createDefaultMapFromCDN(options, prefix, ts) {
|
|
7
7
|
var fsMap = new Map();
|
|
8
8
|
var files = knownLibFilesForCompilerOptions(options, ts);
|
|
9
|
-
var prefix = `${basePath}js/jsdoc-parser/types/`;
|
|
10
9
|
|
|
11
10
|
async function uncached() {
|
|
12
11
|
const contentPromises = files.map((lib) => {
|