UNPKG

819 BJavaScriptView Raw
1"use strict";
2
3exports.parse = parse;
4
5
6const RX_JSDOC_TAG = /@[a-z]+/;
7
8
9class ParserDesc {
10 constructor( output ) {
11 this.output = output;
12 }
13
14 flush( text ) {
15 this.output.desc += text;
16 }
17
18 close() {
19 this.output = this.output.trim();
20 }
21}
22
23/**
24 * @param {string} comments - Comments with JSDoc tags.
25 * @return {object} `{ desc, returns: {type, desc}, params: [{name, type, desc}, ...], examples: []}`
26 */
27function parse( comments ) {
28 const
29 output = {
30 desc: '',
31 returns: {
32 type: null,
33 desc: ''
34 },
35 params: [],
36 examples: []
37 },
38 parserDesc = new ParserDesc( output ),
39 parser = parserDesc;
40
41 return output;
42}
\No newline at end of file