Skip to content

Commit 847d22c

Browse files
committed
Update: Change XDocASTVisitor's API.
Pass a documentation context to XDocASTVisitor's constructor instead of its method, visit. BREAKING CHANGE: Changes to XDocASTVisitor's API.
1 parent 35ab026 commit 847d22c

File tree

12 files changed

+36
-30
lines changed

12 files changed

+36
-30
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ You may also access the core parser class (or other classes) and simply parse th
6060

6161
```js
6262
const xdoc = require('xdoc-parser')
63-
const XDocASTParser = xdoc.core.XDocASTParser;
6463
const XDocASTGenerator = xdoc.core.XDocASTGenerator;
64+
const XDocASTVisitor = xdoc.core.XDocASTVisitor;
6565

66-
const generate = (source) => new XDocASTParser(source).generate();
67-
const parse = (source) => new XDocASTGenerator().visit(generate(source));
66+
const generate = (source) => new XDocASTGenerator(source).generate();
67+
const parse = (source: string) => new XDocASTVisitor(generate(source)).visit();
6868
const ast = parse('@tag id: type - description {@inline description}');
6969
console.log(JSON.stringify(ast, null, 2));
7070
```

build/src/XDocASTGenerator.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { XDocSyntaxParser, DocumentationContext } from "./XDocSyntaxParser";
88
* @class XDocASTParser
99
* ```
1010
*/
11-
export default class XDocASTParser {
11+
export default class XDocASTGenerator {
1212
private parser_;
1313
/**
1414
* Creates a XDocASTParser object.

build/src/XDocASTGenerator.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/src/XDocASTVisitor.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ export interface XDocASTVisitorOptions {
1515
* ```
1616
*/
1717
export default class XDocASTVisitor {
18+
private documentation;
1819
private options;
19-
constructor(options?: XDocASTVisitorOptions);
20+
constructor(documentation: Parser.DocumentationContext, options?: XDocASTVisitorOptions);
2021
/**
2122
* Converts the Antlr parse tree into a JavaScript tree object.
2223
*
@@ -34,7 +35,7 @@ export default class XDocASTVisitor {
3435
* }[]
3536
* ```
3637
*/
37-
visit: (context: Parser.DocumentationContext) => DocumentationNode;
38+
visit: () => DocumentationNode;
3839
visitDocumentation: (context: Parser.DocumentationContext) => DocumentationNode;
3940
visitBody: (context: Parser.BodyContext) => BodyNode;
4041
visitAnnotations: (context: Parser.AnnotationsContext, options: XDocASTVisitorOptions) => AnnotationsNode;

build/src/XDocASTVisitor.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)