Conexio amb la api
This commit is contained in:
parent
207c0ba819
commit
b12369cb47
48513 changed files with 7391639 additions and 7 deletions
12
node_modules/comment-parser/.editorconfig
generated
vendored
Executable file
12
node_modules/comment-parser/.editorconfig
generated
vendored
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_size = 2
|
||||
1
node_modules/comment-parser/.eslintignore
generated
vendored
Executable file
1
node_modules/comment-parser/.eslintignore
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
node_modules/*
|
||||
11
node_modules/comment-parser/.eslintrc.json
generated
vendored
Executable file
11
node_modules/comment-parser/.eslintrc.json
generated
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extends": "standard",
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"camelcase": "off"
|
||||
}
|
||||
}
|
||||
24
node_modules/comment-parser/.github/workflows/node.js.yml
generated
vendored
Executable file
24
node_modules/comment-parser/.github/workflows/node.js.yml
generated
vendored
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
name: test
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [8.x, 10.x, 12.x, 14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
18
node_modules/comment-parser/.vscode/launch.json
generated
vendored
Executable file
18
node_modules/comment-parser/.vscode/launch.json
generated
vendored
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Test this",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}/node_modules/.bin/mocha",
|
||||
"args": ["${file}"]
|
||||
}
|
||||
]
|
||||
}
|
||||
103
node_modules/comment-parser/CHANGELOG.md
generated
vendored
Executable file
103
node_modules/comment-parser/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,103 @@
|
|||
# v0.7.6
|
||||
- distinct non-critical errors by providing `err.warning`
|
||||
|
||||
# v0.7.5
|
||||
- name parsing fixes
|
||||
|
||||
# v0.7.4
|
||||
- node 8 backward compatibility fixes
|
||||
|
||||
# v0.7.3
|
||||
- make stringify result more close to the source
|
||||
|
||||
# v0.7.2
|
||||
- make stringify to start each line with * in multiline comments
|
||||
|
||||
# v0.7.1
|
||||
- ensure non-space characters after asterisk are included in source
|
||||
|
||||
# v0.7.0
|
||||
- allow fenced blocks in tag description, see opts.fence
|
||||
|
||||
# v0.6.2
|
||||
- document TypeScript definitions
|
||||
|
||||
# v0.6.1
|
||||
- adjust strigifier indentation
|
||||
|
||||
# v0.6.0
|
||||
- soft-drop node@6 support
|
||||
- migrate to ES6 syntax
|
||||
- allow to generate comments out of parsed data
|
||||
|
||||
# v0.5.5
|
||||
- allow loose tag names, e.g. @.tag, @-tag
|
||||
|
||||
# v0.5.4
|
||||
- allow quoted literal names, e.g. `@tag "My Var" description`
|
||||
|
||||
# v0.5.3
|
||||
- corrected TypeScript definitions
|
||||
|
||||
# v0.5.2
|
||||
- added TypeScript definitions
|
||||
- removed `readable-stream` dependency
|
||||
|
||||
# v0.5.1
|
||||
- Support for tab as separator between tag components.
|
||||
- Docs: Indicate when `optional` is `true`; `default` property
|
||||
|
||||
# v0.5.0
|
||||
- line wrapping control with `opts.join`
|
||||
|
||||
# v0.4.2
|
||||
- tolerate inconsistent lines alignment within block
|
||||
|
||||
# v0.4.1
|
||||
- refactored parsing, allow to not start lines with "* " inside block
|
||||
|
||||
# v0.3.2
|
||||
- fix RegExp for `description` extraction to allow $ char
|
||||
|
||||
# v0.3.1
|
||||
- use `readable-stream` fro Node 0.8 comatibility
|
||||
- allow to pass optional parameters to `parse.file(path [,opts], done)`
|
||||
- allow `parse.stream` to work with Buffers in addition to strings
|
||||
|
||||
# v0.3.0
|
||||
- `feature` allow to use custom parsers
|
||||
- `feature` always include source, no `raw_value` option needed
|
||||
- `bugfix` always provide `optional` tag property
|
||||
- `refactor` clean up tests
|
||||
|
||||
# v0.2.3
|
||||
|
||||
- `bugfix` Accept `/** one line */` comments
|
||||
- `refactor` Get rid of `lodash` to avoid unnecessary extra size when bundled
|
||||
|
||||
# v0.2.2
|
||||
|
||||
- `feature` allow spaces in default values `@my-tag {my.type} [name=John Doe]`
|
||||
|
||||
# v0.2.1
|
||||
|
||||
- `refactor` make line pasing mechanism more tolerable
|
||||
|
||||
# v0.2.0
|
||||
|
||||
- `feature` include source line numbers in parsed data
|
||||
- `feature` optionally prevent dotten names expanding
|
||||
|
||||
# v0.1.2
|
||||
|
||||
- `bugfix` Allow to build nested tags from `name.subname` even if `name` wasn't d
|
||||
- `bugfix` Preserve indentation when extracting comments
|
||||
|
||||
# v0.1.1
|
||||
|
||||
- `improvement` `parse(source)` returns array of all blocks found in source or an empty array
|
||||
- `bugfix` fixed indented blocks parsing
|
||||
|
||||
# v0.1.0
|
||||
|
||||
Initial implementation
|
||||
21
node_modules/comment-parser/LICENSE
generated
vendored
Executable file
21
node_modules/comment-parser/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Sergii Iavorskyi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
221
node_modules/comment-parser/README.md
generated
vendored
Executable file
221
node_modules/comment-parser/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,221 @@
|
|||
# comment-parser
|
||||
|
||||
Generic JSDoc-like comment parser. This library is not intended to be documentation generator, but rather composite unit for it.
|
||||
|
||||
`npm install comment-parser`
|
||||
|
||||
Module provides `parse(s: string[, opts: object]): object[]` function which takes `/** ... */` comment string and returns array of objects with parsed data.
|
||||
|
||||
It is not trying to detect relations between tags or somehow recognize their meaning. Any tag can be used, as long as it satisfies the format.
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Singleline or multiline description text. Line breaks are preserved.
|
||||
*
|
||||
* @some-tag {Type} name Singleline or multiline description text
|
||||
* @some-tag {Type} name.subname Singleline or multiline description text
|
||||
* @some-tag {Type} name.subname.subsubname Singleline or
|
||||
* multiline description text
|
||||
* @some-tag {Type} [optionalName=someDefault]
|
||||
* @another-tag
|
||||
*/
|
||||
```
|
||||
|
||||
this would be parsed into following
|
||||
|
||||
```json
|
||||
[{
|
||||
"tags": [{
|
||||
"tag": "some-tag",
|
||||
"type": "Type",
|
||||
"name": "name",
|
||||
"optional": false,
|
||||
"description": "Singleline or multiline description text",
|
||||
"line": 3,
|
||||
"source": "@some-tag {Type} name Singleline or multiline description text"
|
||||
}, {
|
||||
"tag": "some-tag",
|
||||
"type": "Type",
|
||||
"name": "name.subname",
|
||||
"optional": false,
|
||||
"description": "Singleline or multiline description text",
|
||||
"line": 4,
|
||||
"source": "@some-tag {Type} name.subname Singleline or multiline description text"
|
||||
}, {
|
||||
"tag": "some-tag",
|
||||
"type": "Type",
|
||||
"name": "name.subname.subsubname",
|
||||
"optional": false,
|
||||
"description": "Singleline or\nmultiline description text",
|
||||
"line": 5,
|
||||
"source": "@some-tag {Type} name.subname.subsubname Singleline or\nmultiline description text"
|
||||
}, {
|
||||
"tag": "some-tag",
|
||||
"type": "Type",
|
||||
"name": "optionalName",
|
||||
"optional": true,
|
||||
"description": "",
|
||||
"line": 7,
|
||||
"default": "someDefault",
|
||||
"source": "@some-tag {Type} [optionalName=someDefault]"
|
||||
}, {
|
||||
"tag": "another-tag",
|
||||
"name": "",
|
||||
"optional": false,
|
||||
"type": "",
|
||||
"description": "",
|
||||
"line": 8,
|
||||
"source": "@another-tag"
|
||||
}],
|
||||
"line": 0,
|
||||
"description": "Singleline or multiline description text. Line breaks are preserved.",
|
||||
"source": "Singleline or multiline description text. Line breaks are preserved.\n\n@some-tag {Type} name Singleline or multiline description text\n@some-tag {Type} name.subname Singleline or multiline description text\n@some-tag {Type} name.subname.subsubname Singleline or\nmultiline description text\n@another-tag"
|
||||
}]
|
||||
```
|
||||
|
||||
Below are examples of acceptable comment formats
|
||||
|
||||
```javascript
|
||||
/** online comment */
|
||||
|
||||
/** first line
|
||||
* second line */
|
||||
|
||||
/**
|
||||
No *s on middle lines is acceptable too
|
||||
which might be convenient for writing big
|
||||
chunks of text.
|
||||
|
||||
* keeping *s on some lines
|
||||
* would work either
|
||||
|
||||
left bound is determined by opening marker position
|
||||
and white space will be trimmed as there was '* '
|
||||
*/
|
||||
|
||||
```
|
||||
|
||||
Comments starting with `/***` and `/*` are ignored.
|
||||
|
||||
Also you can parse entire file with `parse.file('path/to/file', callback)` or acquire an instance of [Transform](http://nodejs.org/api/stream.html#stream_class_stream_transform) stream with `parse.stream()`.
|
||||
|
||||
## Options
|
||||
|
||||
### `dotted_names: boolean`
|
||||
|
||||
By default dotted names like `name.subname.subsubname` will be expanded into
|
||||
nested sections, this can be prevented by passing `opts.dotted_names = false`.
|
||||
|
||||
### `trim: boolean`
|
||||
|
||||
Set this to `false` to avoid the default of trimming whitespace at the start and
|
||||
end of each line.
|
||||
|
||||
### `join: string | number | boolean`
|
||||
|
||||
If the following lines of a multiline comment do not start with a star, `join` will have the following effect on *tag* `source` (and `description`) when joining the lines together:
|
||||
|
||||
1. If a string, use that string in place of the leading whitespace (and avoid newlines).
|
||||
2. If a non-zero number (e.g., `1`), do no trimming and avoid newlines.
|
||||
3. If `undefined`, `false`, or `0`, use the default behavior of not trimming
|
||||
but adding a newline.
|
||||
4. Otherwise (e.g., if `join` is `true`), replace any leading whitespace with a single space and avoid newlines.
|
||||
|
||||
Note that if a multi-line comment has lines that start with a star, these will
|
||||
be appended with initial whitespace as is and with newlines regardless of the
|
||||
`join` setting.
|
||||
|
||||
Note also that the *comment* `source` will not be changed by this setting.
|
||||
|
||||
### `fence: string | RegExp | ((source: string) => boolean)`
|
||||
|
||||
Set to a string or regular expression to toggle state upon finding an
|
||||
odd number of matches within a line. Defaults to \`\`\`.
|
||||
|
||||
If set to a function, it should return `true` to toggle fenced state;
|
||||
upon returning `true` the first time, this will prevent subsequent lines
|
||||
from being interpreted as starting a new jsdoc tag until such time as the
|
||||
function returns `true` again to indicate that the state has toggled
|
||||
back.
|
||||
|
||||
### `parsers: Parser[]` (Custom parsers)
|
||||
|
||||
In case you need to parse tags in different way you can pass `opts.parsers = [parser1, ..., parserN]`, where each parser is `function name(str:String, data:Object):{source:String, data:Object}`.
|
||||
|
||||
Each parser function takes string left after previous parsers applied and data produced by them. And returns `null` or `{source: '', data:{}}` where `source` is consumed substring and `data` is a payload with tag node fields.
|
||||
|
||||
Tag node data is build by merging result bits from all parsers. Here is some example that is not doing actual parsing but is demonstrating the flow:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Source to be parsed below
|
||||
* @tag {type} name Description
|
||||
*/
|
||||
parse(source, {parsers: [
|
||||
// takes entire string
|
||||
function parse_tag(str, data) {
|
||||
return {source: ' @tag', data: {tag: 'tag'}};
|
||||
},
|
||||
// parser throwing exception
|
||||
function check_tag(str, data) {
|
||||
if (allowed_tags.indexOf(data.tag) === -1) {
|
||||
throw new Error('Unrecognized tag "' + data.tag + '"');
|
||||
}
|
||||
},
|
||||
// takes the rest of the string after ' @tag''
|
||||
function parse_name1(str, data) {
|
||||
return {source: ' name', data: {name: 'name1'}};
|
||||
},
|
||||
// alternative name parser
|
||||
function parse_name2(str, data) {
|
||||
return {source: ' name', data: {name: 'name2'}};
|
||||
}
|
||||
]});
|
||||
```
|
||||
|
||||
This would produce following:
|
||||
|
||||
```json
|
||||
[{
|
||||
"tags": [{
|
||||
"tag": "tag",
|
||||
"errors": [
|
||||
"check_tag: Unrecognized tag \"tag\""
|
||||
],
|
||||
"name": "name2",
|
||||
"optional": false,
|
||||
"type": "",
|
||||
"description": "",
|
||||
"line": 2,
|
||||
"source": "@tag {type} name Description"
|
||||
}],
|
||||
"line": 0,
|
||||
"description": "Source to be parsed below",
|
||||
"source": "Source to be parsed below\n@tag {type} name Description"
|
||||
}]
|
||||
```
|
||||
|
||||
## Stringifying
|
||||
|
||||
One may also convert `comment-parser` JSON structures back into strings using
|
||||
the `stringify` method (`stringify(o: (object|Array) [, opts: object]): string`).
|
||||
|
||||
This method accepts the JSON as its first argument and an optional options
|
||||
object with an `indent` property set to either a string or a number that
|
||||
will be used to determine the number of spaces of indent. The indent of the
|
||||
start of the doc block will be one space less than the indent of each line of
|
||||
asterisks for the sake of alignment as per usual practice.
|
||||
|
||||
The `stringify` export delegates to the specialized methods `stringifyBlocks`,
|
||||
`stringifyBlock`, and `stringifyTag`, which are available on the `stringify`
|
||||
function object.
|
||||
|
||||
## Packaging
|
||||
|
||||
`comment-parser` is CommonJS module and was primarely designed to be used with Node. Module `index.js` includes stream and file functionality. Use prser-only module in browser `comment-parser/parse.js`
|
||||
|
||||
## Contributors
|
||||
|
||||
```
|
||||
> npm info --registry https://registry.npmjs.org comment-parser contributors
|
||||
```
|
||||
192
node_modules/comment-parser/index.d.ts
generated
vendored
Executable file
192
node_modules/comment-parser/index.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,192 @@
|
|||
// Type definitions for comment-parser
|
||||
// Project: comment-parser
|
||||
// Definitions by: Javier "Ciberman" Mora <https://github.com/jhm-ciberman/>
|
||||
|
||||
declare namespace parse {
|
||||
|
||||
/**
|
||||
* In case you need to parse tags in a different way you can specify custom parsers here.
|
||||
* Each parser function takes string left after previous parsers were applied and the data produced by them.
|
||||
* It should return either `undefined` or the new object, where `source` is the consumed substring.
|
||||
*/
|
||||
export type Parser = (str: string, data: any) => { source: string, data: any };
|
||||
|
||||
/**
|
||||
* Represents a parsed doc comment.
|
||||
*/
|
||||
export interface Comment {
|
||||
/**
|
||||
* A list of tags that are present in this doc comment.
|
||||
*/
|
||||
tags: Tag[];
|
||||
/**
|
||||
* The starting line in the source code of this doc comment.
|
||||
*/
|
||||
line: number;
|
||||
/**
|
||||
* The description of this doc comment. Empty string if no description was specified.
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The source of this doc comment, exactly as it appeared in the doc comment before parsing.
|
||||
*/
|
||||
source: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a parsed tag. A tag has the following format:
|
||||
* > @tag {type} [name=default] description
|
||||
*/
|
||||
export interface Tag {
|
||||
/**
|
||||
* The tag's kind, eg `param` or `return`.
|
||||
*/
|
||||
tag: string;
|
||||
/**
|
||||
* The name of this tag, ie the first word after the tag. Empty string if no name was specified.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* `true` if the tag is optional (tag name enclosed in brackets), `false` otherwise.
|
||||
*/
|
||||
optional: boolean;
|
||||
/**
|
||||
* The type declaration of this tag that is enclosed in curly braces. Empty string if no type was specified.
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* The description of this tag that comes after the name. Empty string if no description was specified.
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The line number where this tag starts
|
||||
*/
|
||||
line: number;
|
||||
/**
|
||||
* The source of this tag, exactly as it appeared in the doc comment before parsing.
|
||||
*/
|
||||
source: string;
|
||||
/**
|
||||
* The default value for this tag. `undefined` in case no default value was specified.
|
||||
*/
|
||||
default?: string;
|
||||
/**
|
||||
* A list of errors that occurred during the parsing of this tag. `undefined` if not error occurred.
|
||||
*/
|
||||
errors? : string[];
|
||||
/**
|
||||
* If `dotted_names` was set to `true`, a list of sub tags. `undefined` if `dotted_names` was set to `false` or if
|
||||
* no sub tags exist.
|
||||
*/
|
||||
tags?: Tag[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for parsing doc comments.
|
||||
*/
|
||||
export interface Options {
|
||||
/**
|
||||
* In case you need to parse tags in a different way you can specify custom parsers here.
|
||||
* Each parser function takes string left after previous parsers were applied and the data produced by them.
|
||||
* It should return either `undefined` or the new object, where `source` is the consumed substring.
|
||||
*
|
||||
* If you specify custom parsers, the default parsers are overwritten, but you can access them via the constant
|
||||
* `PARSERS`.
|
||||
*/
|
||||
parsers: Parser[];
|
||||
/**
|
||||
* By default dotted names like `name.subname.subsubname` will be expanded into nested sections, this can be
|
||||
* prevented by passing `opts.dotted_names = false`.
|
||||
*/
|
||||
dotted_names: boolean;
|
||||
/**
|
||||
* Impacts behavior of joining non-asterisked multiline comments. Strings,
|
||||
* non-zero numbers, or `true` will collapse newlines. Strings will
|
||||
* additionally replace leading whitespace and `true` will replace with
|
||||
* a single space.
|
||||
*/
|
||||
join: string | number | boolean;
|
||||
/**
|
||||
* `true` to trim whitespace at the start and end of each line, `false` otherwise.
|
||||
*/
|
||||
trim: boolean;
|
||||
/**
|
||||
* Return `true` to toggle fenced state; upon returning `true` the
|
||||
* first time, will prevent subsequent lines from being interpreted as
|
||||
* starting a new jsdoc tag until such time as the function returns
|
||||
* `true` again to indicate that the state has toggled back; can also
|
||||
* be simply set to a string or regular expression which will toggle
|
||||
* state upon finding an odd number of matches within a line.
|
||||
*/
|
||||
fence: string | RegExp | ((source: string) => boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for turning a parsed doc comment back into a string.
|
||||
*/
|
||||
export interface StringifyOptions {
|
||||
/**
|
||||
* Indentation for each line. If a string is passed, that string is used verbatim to indent each line. If a number
|
||||
* is passed, indents each line with that many whitespaces.
|
||||
*/
|
||||
indent: string | number;
|
||||
}
|
||||
|
||||
export interface Stringify {
|
||||
/**
|
||||
* One may also convert comment-parser JSON structures back into strings using this stringify method.
|
||||
*
|
||||
* This method accepts the JSON as its first argument and an optional options object with an indent property set to
|
||||
* either a string or a number that will be used to determine the number of spaces of indent. The indent of the start
|
||||
* of the doc block will be one space less than the indent of each line of asterisks for the sake of alignment as per
|
||||
* usual practice.
|
||||
*
|
||||
* The stringify export delegates to the specialized methods `stringifyBlocks`, `stringifyBlock`, and
|
||||
* `stringifyTag`, which are available on the stringify function object.
|
||||
* @param comment A tag, comment or a list of comments to stringify.
|
||||
* @param options Options to control how the comment or comments are stringified.
|
||||
* @return The stringified doc comment(s).
|
||||
*/
|
||||
(comment: Tag | Comment | Comment[], options?: Partial<StringifyOptions>): string;
|
||||
/**
|
||||
* Similar to `stringify`, but only accepts a list of doc comments.
|
||||
* @param comments A list of comments to stringify.
|
||||
* @param options Options to control how the comments are stringified.
|
||||
* @return The stringified doc comment(s).
|
||||
*/
|
||||
stringifyBlocks(comments: Comment[], options?: Partial<StringifyOptions>): string;
|
||||
/**
|
||||
* Similar to `stringify`, but only accepts a single doc comment.
|
||||
* @param comment A comment to stringify.
|
||||
* @param options Options to control how the comment is stringified.
|
||||
* @return The stringified doc comment(s).
|
||||
*/
|
||||
stringifyBlock(comment: Comment, options?: Partial<StringifyOptions>): string;
|
||||
/**
|
||||
* Similar to `stringify`, but only accepts a single tag.
|
||||
* @param tag A tag to stringify.
|
||||
* @param options Options to control how the tag is stringified.
|
||||
* @return The stringified doc comment(s).
|
||||
*/
|
||||
stringifyTag(tag: Tag, options?: Partial<StringifyOptions>): string;
|
||||
}
|
||||
|
||||
export const stringify: parse.Stringify;
|
||||
|
||||
/**
|
||||
* The default list of parsers that is used to parse comments.
|
||||
*/
|
||||
export const PARSERS: Record<"parse_tag" | "parse_type" | "parse_description" | "parse_name", Parser>
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method of this module which takes comment string and returns an array of objects with parsed data.
|
||||
* It is not trying to detect relations between tags or somehow recognize their meaning. Any tag can be used, as long
|
||||
* as it satisfies the format.
|
||||
* @param str A string with doc comments and source code to parse.
|
||||
* @param opts Options to control how the source string is parsed.
|
||||
* @return The parsed list of doc comments.
|
||||
*/
|
||||
declare function parse(str: string, opts?: Partial<parse.Options>): parse.Comment[];
|
||||
|
||||
export = parse;
|
||||
64
node_modules/comment-parser/index.js
generated
vendored
Executable file
64
node_modules/comment-parser/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs')
|
||||
const stream = require('stream')
|
||||
|
||||
const parse = require('./parser')
|
||||
|
||||
const stringify = require('./stringifier')
|
||||
|
||||
module.exports = parse
|
||||
|
||||
module.exports.stringify = stringify
|
||||
|
||||
/* ------- Transform stream ------- */
|
||||
|
||||
class Parser extends stream.Transform {
|
||||
constructor (opts) {
|
||||
opts = opts || {}
|
||||
super({ objectMode: true })
|
||||
this._extract = parse.mkextract(opts)
|
||||
}
|
||||
|
||||
_transform (data, encoding, done) {
|
||||
let block
|
||||
const lines = data.toString().split(/\n/)
|
||||
|
||||
while (lines.length) {
|
||||
block = this._extract(lines.shift())
|
||||
if (block) {
|
||||
this.push(block)
|
||||
}
|
||||
}
|
||||
|
||||
done()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.stream = function stream (opts) {
|
||||
return new Parser(opts)
|
||||
}
|
||||
|
||||
/* ------- File parser ------- */
|
||||
|
||||
module.exports.file = function file (file_path, done) {
|
||||
let opts = {}
|
||||
const collected = []
|
||||
|
||||
if (arguments.length === 3) {
|
||||
opts = done
|
||||
done = arguments[2]
|
||||
}
|
||||
|
||||
return fs.createReadStream(file_path, { encoding: 'utf8' })
|
||||
.on('error', done)
|
||||
.pipe(new Parser(opts))
|
||||
.on('error', done)
|
||||
.on('data', function (data) {
|
||||
collected.push(data)
|
||||
})
|
||||
.on('finish', function () {
|
||||
done(null, collected)
|
||||
})
|
||||
}
|
||||
128
node_modules/comment-parser/package.json
generated
vendored
Executable file
128
node_modules/comment-parser/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,128 @@
|
|||
{
|
||||
"_from": "comment-parser@^0.7.6",
|
||||
"_id": "comment-parser@0.7.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-GKNxVA7/iuTnAqGADlTWX4tkhzxZKXp5fLJqKTlQLHkE65XDUKutZ3BHaJC5IGcper2tT3QRD1xr4o3jNpgXXg==",
|
||||
"_location": "/comment-parser",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "comment-parser@^0.7.6",
|
||||
"name": "comment-parser",
|
||||
"escapedName": "comment-parser",
|
||||
"rawSpec": "^0.7.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.7.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/eslint-plugin-jsdoc"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.7.6.tgz",
|
||||
"_shasum": "0e743a53c8e646c899a1323db31f6cd337b10f12",
|
||||
"_spec": "comment-parser@^0.7.6",
|
||||
"_where": "/home/jack/Documents/JDA/m14/projecte_janmaroto/node_modules/eslint-plugin-jsdoc",
|
||||
"author": {
|
||||
"name": "Sergii Iavorskyi",
|
||||
"email": "yavorskiy.s@gmail.com",
|
||||
"url": "https://github.com/yavorskiy"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/yavorskiy/comment-parser/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Alexej Yaroshevich",
|
||||
"url": "https://github.com/zxqfox"
|
||||
},
|
||||
{
|
||||
"name": "Andre Wachsmuth",
|
||||
"url": "https://github.com/blutorange"
|
||||
},
|
||||
{
|
||||
"name": "Brett Zamir",
|
||||
"url": "https://github.com/brettz9"
|
||||
},
|
||||
{
|
||||
"name": "Dieter Oberkofler",
|
||||
"url": "https://github.com/doberkofler"
|
||||
},
|
||||
{
|
||||
"name": "Evgeny Reznichenko",
|
||||
"url": "https://github.com/zxcabs"
|
||||
},
|
||||
{
|
||||
"name": "Javier \"Ciberma\" Mora",
|
||||
"url": "https://github.com/jhm-ciberman"
|
||||
},
|
||||
{
|
||||
"name": "Jordan Harband",
|
||||
"url": "https://github.com/ljharb"
|
||||
},
|
||||
{
|
||||
"name": "tengattack",
|
||||
"url": "https://github.com/tengattack"
|
||||
},
|
||||
{
|
||||
"name": "Jayden Seric",
|
||||
"url": "https://github.com/jaydenseric"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Generic JSDoc-like comment parser. ",
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-standard": "^14.1.1",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"mocha": "^7.1.2",
|
||||
"nodemon": "^2.0.3",
|
||||
"nyc": "^15.0.1",
|
||||
"readable-stream": "^3.6.0",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/yavorskiy/comment-parser",
|
||||
"keywords": [
|
||||
"jsdoc",
|
||||
"comments",
|
||||
"parser"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "comment-parser",
|
||||
"nyc": {
|
||||
"branches": 85,
|
||||
"lines": 85,
|
||||
"functions": 85,
|
||||
"statements": 85,
|
||||
"exclude": [
|
||||
"tests"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/yavorskiy/comment-parser.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint:fix": "eslint --fix .",
|
||||
"test": "npm run test:typescript && npm run test:lint && npm run test:unit",
|
||||
"test:lint": "eslint .",
|
||||
"test:typescript": "tsc index.d.ts",
|
||||
"test:unit": "nyc mocha tests",
|
||||
"typescript": "tsc index.d.ts",
|
||||
"watch": "nodemon -q -i node_modules -x npm test"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"version": "0.7.6"
|
||||
}
|
||||
295
node_modules/comment-parser/parser.js
generated
vendored
Executable file
295
node_modules/comment-parser/parser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,295 @@
|
|||
|
||||
'use strict'
|
||||
|
||||
const PARSERS = require('./parsers')
|
||||
|
||||
const MARKER_START = '/**'
|
||||
const MARKER_START_SKIP = '/***'
|
||||
const MARKER_END = '*/'
|
||||
|
||||
/* ------- util functions ------- */
|
||||
|
||||
function find (list, filter) {
|
||||
let i = list.length
|
||||
let matchs = true
|
||||
|
||||
while (i--) {
|
||||
for (const k in filter) {
|
||||
if ({}.hasOwnProperty.call(filter, k)) {
|
||||
matchs = (filter[k] === list[i][k]) && matchs
|
||||
}
|
||||
}
|
||||
if (matchs) { return list[i] }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/* ------- parsing ------- */
|
||||
|
||||
/**
|
||||
* Parses "@tag {type} name description"
|
||||
* @param {string} str Raw doc string
|
||||
* @param {Array<function>} parsers Array of parsers to be applied to the source
|
||||
* @returns {object} parsed tag node
|
||||
*/
|
||||
function parse_tag (str, parsers) {
|
||||
const { data } = parsers.reduce(function (state, parser) {
|
||||
let result
|
||||
|
||||
try {
|
||||
result = parser(state.source, Object.assign({}, state.data))
|
||||
if (result && result.data && result.data.warning) {
|
||||
state.data.warnings = (state.data.warnings || [])
|
||||
.concat(parser.name + ': ' + result.data.warning)
|
||||
delete result.data.warning
|
||||
}
|
||||
} catch (err) {
|
||||
state.data.errors = (state.data.errors || [])
|
||||
.concat(parser.name + ': ' + err.message)
|
||||
}
|
||||
|
||||
if (result) {
|
||||
state.source = state.source.slice(result.source.length)
|
||||
state.data = Object.assign(state.data, result.data)
|
||||
}
|
||||
|
||||
return state
|
||||
}, {
|
||||
source: str,
|
||||
data: {}
|
||||
})
|
||||
|
||||
data.optional = !!data.optional
|
||||
data.type = data.type === undefined ? '' : data.type
|
||||
data.name = data.name === undefined ? '' : data.name
|
||||
data.description = data.description === undefined ? '' : data.description
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses comment block (array of String lines)
|
||||
*/
|
||||
function parse_block (source, opts) {
|
||||
const trim = opts.trim
|
||||
? s => s.trim()
|
||||
: s => s
|
||||
|
||||
const toggleFence = (typeof opts.fence === 'function')
|
||||
? opts.fence
|
||||
: line => line.split(opts.fence).length % 2 === 0
|
||||
|
||||
let source_str = source
|
||||
.map((line) => { return trim(line.source) })
|
||||
.join('\n')
|
||||
|
||||
source_str = trim(source_str)
|
||||
|
||||
const start = source[0].number
|
||||
|
||||
// merge source lines into tags
|
||||
// we assume tag starts with "@"
|
||||
source = source
|
||||
.reduce(function (state, line) {
|
||||
line.source = trim(line.source)
|
||||
|
||||
// start of a new tag detected
|
||||
if (line.source.match(/^\s*@(\S+)/) && !state.isFenced) {
|
||||
state.tags.push({
|
||||
source: [line.source],
|
||||
line: line.number
|
||||
})
|
||||
// keep appending source to the current tag
|
||||
} else {
|
||||
const tag = state.tags[state.tags.length - 1]
|
||||
if (opts.join !== undefined && opts.join !== false && opts.join !== 0 &&
|
||||
!line.startWithStar && tag.source.length > 0) {
|
||||
let source
|
||||
if (typeof opts.join === 'string') {
|
||||
source = opts.join + line.source.replace(/^\s+/, '')
|
||||
} else if (typeof opts.join === 'number') {
|
||||
source = line.source
|
||||
} else {
|
||||
source = ' ' + line.source.replace(/^\s+/, '')
|
||||
}
|
||||
tag.source[tag.source.length - 1] += source
|
||||
} else {
|
||||
tag.source.push(line.source)
|
||||
}
|
||||
}
|
||||
|
||||
if (toggleFence(line.source)) {
|
||||
state.isFenced = !state.isFenced
|
||||
}
|
||||
return state
|
||||
}, {
|
||||
tags: [{ source: [] }],
|
||||
isFenced: false
|
||||
})
|
||||
.tags
|
||||
.map((tag) => {
|
||||
tag.source = trim(tag.source.join('\n'))
|
||||
return tag
|
||||
})
|
||||
|
||||
// Block description
|
||||
const description = source.shift()
|
||||
|
||||
// skip if no descriptions and no tags
|
||||
if (description.source === '' && source.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
const tags = source.reduce(function (tags, tag) {
|
||||
const tag_node = parse_tag(tag.source, opts.parsers)
|
||||
|
||||
tag_node.line = tag.line
|
||||
tag_node.source = tag.source
|
||||
|
||||
if (opts.dotted_names && tag_node.name.includes('.')) {
|
||||
let parent_name
|
||||
let parent_tag
|
||||
let parent_tags = tags
|
||||
const parts = tag_node.name.split('.')
|
||||
|
||||
while (parts.length > 1) {
|
||||
parent_name = parts.shift()
|
||||
parent_tag = find(parent_tags, {
|
||||
tag: tag_node.tag,
|
||||
name: parent_name
|
||||
})
|
||||
|
||||
if (!parent_tag) {
|
||||
parent_tag = {
|
||||
tag: tag_node.tag,
|
||||
line: Number(tag_node.line),
|
||||
name: parent_name,
|
||||
type: '',
|
||||
description: ''
|
||||
}
|
||||
parent_tags.push(parent_tag)
|
||||
}
|
||||
|
||||
parent_tag.tags = parent_tag.tags || []
|
||||
parent_tags = parent_tag.tags
|
||||
}
|
||||
|
||||
tag_node.name = parts[0]
|
||||
parent_tags.push(tag_node)
|
||||
return tags
|
||||
}
|
||||
|
||||
return tags.concat(tag_node)
|
||||
}, [])
|
||||
|
||||
for (const tag of tags) {
|
||||
if (!tag.errors && tag.warnings) {
|
||||
tag.errors = [...tag.warnings]
|
||||
delete tag.warnings
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
tags,
|
||||
line: start,
|
||||
description: description.source,
|
||||
source: source_str
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces `extract` function with internal state initialized
|
||||
*/
|
||||
function mkextract (opts) {
|
||||
let chunk = null
|
||||
let indent = 0
|
||||
let number = 0
|
||||
|
||||
opts = Object.assign({}, {
|
||||
trim: true,
|
||||
dotted_names: false,
|
||||
fence: '```',
|
||||
parsers: [
|
||||
PARSERS.parse_tag,
|
||||
PARSERS.parse_type,
|
||||
PARSERS.parse_name,
|
||||
PARSERS.parse_description
|
||||
]
|
||||
}, opts || {})
|
||||
|
||||
/**
|
||||
* Read lines until they make a block
|
||||
* Return parsed block once fullfilled or null otherwise
|
||||
*/
|
||||
return function extract (line) {
|
||||
let result = null
|
||||
const startPos = line.indexOf(MARKER_START)
|
||||
const endPos = line.indexOf(MARKER_END)
|
||||
|
||||
// if open marker detected and it's not, skip one
|
||||
if (!chunk && startPos !== -1 && line.indexOf(MARKER_START_SKIP) !== startPos) {
|
||||
chunk = []
|
||||
indent = startPos + MARKER_START.length
|
||||
}
|
||||
|
||||
// if we are on middle of comment block
|
||||
if (chunk) {
|
||||
let lineStart = indent
|
||||
let startWithStar = false
|
||||
|
||||
// figure out if we slice from opening marker pos
|
||||
// or line start is shifted to the left
|
||||
const nonSpaceChar = line.match(/\S/)
|
||||
|
||||
// skip for the first line starting with /** (fresh chunk)
|
||||
// it always has the right indentation
|
||||
if (chunk.length > 0 && nonSpaceChar) {
|
||||
if (nonSpaceChar[0] === '*') {
|
||||
const afterNonSpaceCharIdx = nonSpaceChar.index + 1
|
||||
const extraCharIsSpace = line.charAt(afterNonSpaceCharIdx) === ' '
|
||||
lineStart = afterNonSpaceCharIdx + (extraCharIsSpace ? 1 : 0)
|
||||
startWithStar = true
|
||||
} else if (nonSpaceChar.index < indent) {
|
||||
lineStart = nonSpaceChar.index
|
||||
}
|
||||
}
|
||||
|
||||
// slice the line until end or until closing marker start
|
||||
chunk.push({
|
||||
number,
|
||||
startWithStar,
|
||||
source: line.slice(lineStart, endPos === -1 ? line.length : endPos)
|
||||
})
|
||||
|
||||
// finalize block if end marker detected
|
||||
if (endPos !== -1) {
|
||||
result = parse_block(chunk, opts)
|
||||
chunk = null
|
||||
indent = 0
|
||||
}
|
||||
}
|
||||
|
||||
number += 1
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/* ------- Public API ------- */
|
||||
|
||||
module.exports = function parse (source, opts) {
|
||||
const blocks = []
|
||||
const extract = mkextract(opts)
|
||||
const lines = source.split(/\n/)
|
||||
|
||||
lines.forEach((line) => {
|
||||
const block = extract(line)
|
||||
if (block) {
|
||||
blocks.push(block)
|
||||
}
|
||||
})
|
||||
|
||||
return blocks
|
||||
}
|
||||
|
||||
module.exports.PARSERS = PARSERS
|
||||
module.exports.mkextract = mkextract
|
||||
119
node_modules/comment-parser/parsers.js
generated
vendored
Executable file
119
node_modules/comment-parser/parsers.js
generated
vendored
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
'use strict'
|
||||
|
||||
function skipws (str) {
|
||||
let i = 0
|
||||
do {
|
||||
if (str[i] !== ' ' && str[i] !== '\t') { return i }
|
||||
} while (++i < str.length)
|
||||
return i
|
||||
}
|
||||
|
||||
/* ------- default parsers ------- */
|
||||
|
||||
const PARSERS = {}
|
||||
|
||||
PARSERS.parse_tag = function parse_tag (str) {
|
||||
const match = str.match(/^\s*@(\S+)/)
|
||||
if (!match) { throw new SyntaxError('Invalid `@tag`, missing @ symbol') }
|
||||
|
||||
return {
|
||||
source: match[0],
|
||||
data: { tag: match[1] }
|
||||
}
|
||||
}
|
||||
|
||||
PARSERS.parse_type = function parse_type (str, data) {
|
||||
if (data.errors && data.errors.length) { return null }
|
||||
|
||||
let pos = skipws(str)
|
||||
let res = ''
|
||||
let curlies = 0
|
||||
|
||||
if (str[pos] !== '{') { return null }
|
||||
|
||||
while (pos < str.length) {
|
||||
curlies += (str[pos] === '{' ? 1 : (str[pos] === '}' ? -1 : 0))
|
||||
res += str[pos]
|
||||
pos++
|
||||
if (curlies === 0) { break }
|
||||
}
|
||||
|
||||
if (curlies !== 0) { throw new SyntaxError('Invalid `{type}`, unpaired curlies') }
|
||||
|
||||
return {
|
||||
source: str.slice(0, pos),
|
||||
data: { type: res.slice(1, -1) }
|
||||
}
|
||||
}
|
||||
|
||||
PARSERS.parse_name = function parse_name (str, data) {
|
||||
if (data.errors && data.errors.length) { return null }
|
||||
|
||||
let pos = skipws(str)
|
||||
let name = ''
|
||||
let brackets = 0
|
||||
let res = { optional: false }
|
||||
|
||||
// if it starts with quoted group assume it is a literal
|
||||
const quotedGroups = str.slice(pos).split('"')
|
||||
if (quotedGroups.length > 1 && quotedGroups[0] === '' && quotedGroups.length % 2 === 1) {
|
||||
name = quotedGroups[1]
|
||||
pos += name.length + 2
|
||||
// assume name is non-space string or anything wrapped into brackets
|
||||
} else {
|
||||
while (pos < str.length) {
|
||||
brackets += (str[pos] === '[' ? 1 : (str[pos] === ']' ? -1 : 0))
|
||||
name += str[pos]
|
||||
pos++
|
||||
if (brackets === 0 && /\s/.test(str[pos])) { break }
|
||||
}
|
||||
|
||||
if (brackets !== 0) { throw new SyntaxError('Invalid `name`, unpaired brackets') }
|
||||
|
||||
res = { name, optional: false }
|
||||
|
||||
if (name[0] === '[' && name[name.length - 1] === ']') {
|
||||
res.optional = true
|
||||
name = name.slice(1, -1)
|
||||
|
||||
const match = name.match(
|
||||
/^\s*([^=]+?)(?:\s*=\s*(.*?))?\s*(?=$)/
|
||||
)
|
||||
|
||||
if (!match) throw new SyntaxError('Invalid `name`, bad syntax')
|
||||
|
||||
name = match[1]
|
||||
if (match[2]) res.default = match[2]
|
||||
// We will throw this later after processing other tags (so we
|
||||
// will collect enough data for the user to be able to fully recover)
|
||||
else if (match[2] === '') {
|
||||
res.default = match[2]
|
||||
res.warning = 'Empty `name`, bad syntax'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.name = name
|
||||
|
||||
return {
|
||||
source: str.slice(0, pos),
|
||||
data: res
|
||||
}
|
||||
}
|
||||
|
||||
PARSERS.parse_description = function parse_description (str, data) {
|
||||
if (data.errors && data.errors.length) { return null }
|
||||
|
||||
const match = str.match(/^\s+((.|\s)+)?/)
|
||||
|
||||
if (match) {
|
||||
return {
|
||||
source: match[0],
|
||||
data: { description: match[1] === undefined ? '' : match[1] }
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
module.exports = PARSERS
|
||||
64
node_modules/comment-parser/stringifier.js
generated
vendored
Executable file
64
node_modules/comment-parser/stringifier.js
generated
vendored
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
'use strict'
|
||||
|
||||
const getIndent = (indent) => {
|
||||
return typeof indent === 'number' ? ' '.repeat(indent) : indent
|
||||
}
|
||||
|
||||
module.exports = exports = function stringify (arg, opts) {
|
||||
if (Array.isArray(arg)) {
|
||||
return stringifyBlocks(arg, opts)
|
||||
}
|
||||
if (arg && typeof arg === 'object') {
|
||||
if ('tag' in arg) {
|
||||
return stringifyTag(arg, opts)
|
||||
}
|
||||
if ('tags' in arg) {
|
||||
return stringifyBlock(arg, opts)
|
||||
}
|
||||
}
|
||||
throw new TypeError('Unexpected argument passed to `stringify`.')
|
||||
}
|
||||
|
||||
const stringifyBlocks = exports.stringifyBlocks = function stringifyBlocks (
|
||||
blocks, { indent = '' } = {}
|
||||
) {
|
||||
const indnt = getIndent(indent)
|
||||
return blocks.reduce((s, block) => {
|
||||
return s + stringifyBlock(block, { indent })
|
||||
}, (indnt ? indnt.slice(0, -1) : '') + '/**\n') + indnt + '*/'
|
||||
}
|
||||
|
||||
const stringifyBlock = exports.stringifyBlock = function stringifyBlock (
|
||||
block, { indent = '' } = {}
|
||||
) {
|
||||
// block.line
|
||||
const indnt = getIndent(indent)
|
||||
|
||||
return (
|
||||
block.description
|
||||
? block.description.replace(/^\n/, '').replace(/^(.*)\n?/gm, (n0, descLine) => {
|
||||
return `${indnt}*${descLine ? ` ${descLine}` : ''}\n`
|
||||
})
|
||||
: ''
|
||||
) + block.tags.reduce((s, tag) => {
|
||||
return s + stringifyTag(tag, { indent })
|
||||
}, '')
|
||||
}
|
||||
|
||||
const stringifyTag = exports.stringifyTag = function stringifyTag (
|
||||
tag, { indent = '' } = {}
|
||||
) {
|
||||
const indnt = getIndent(indent)
|
||||
const {
|
||||
type, name, optional, description, tag: tagName, default: deflt //, line , source
|
||||
} = tag
|
||||
|
||||
return indnt + `* @${tagName}` +
|
||||
(type ? ` {${type}}` : '') +
|
||||
(name.trim() ? ` ${
|
||||
optional ? '[' : ''
|
||||
}${name.trimRight()}${deflt !== undefined ? `=${deflt}` : ''}${
|
||||
optional ? ']' : ''
|
||||
}` : '') +
|
||||
(description ? ` ${description.replace(/\n/g, '\n' + indnt + '* ')}` : '') + '\n'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue