This repository was archived by the owner on Mar 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +16
-24
lines changed Expand file tree Collapse file tree 5 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 1
- # vue-docgen-api (Fork)
1
+ # vue-docgen-api
2
2
[ ![ npm] ( https://img.shields.io/npm/v/vue-docgen-api.svg )] ( https://www.npmjs.com/package/vue-docgen-api )
3
3
4
- ** This fork adds a ` parseSource ` method to parse plain sources instead of files only**
5
-
6
4
` vue-docgen-api ` is a toolbox to help extracting information from [ Vue] [ ] components, and generate documentation from it.
7
5
8
6
Use [ babel] [ ] and [ jsdoc-api] [ ] to compile the code and analyze the contents of the component extracting methods and props. The output is a JavaScript object.
@@ -12,22 +10,24 @@ Use [babel][] and [jsdoc-api][] to compile the code and analyze the contents of
12
10
Install the module directly from npm:
13
11
14
12
```
15
- npm install git://github.com/Radiergummi/ vue-docgen-api --save-dev
13
+ npm install vue-docgen-api --save-dev
16
14
```
17
15
18
16
## API
19
17
20
18
The tool can be used programmatically to extract component information and customize the extraction process:
21
19
22
20
``` js
23
- const vueDocs = require (' vue-docgen-api' );
21
+ var vueDocs = require (' vue-docgen-api' );
22
+ var componentInfo = vueDocs .parse (filePath);
23
+ ```
24
24
25
- // from file
26
- const componentFileInfo = vueDocs .parseFile (filePath);
25
+ ### parse(filePath)
26
+
27
+ | Parameter | Type | Description |
28
+ | -------------- | ------ | --------------- |
29
+ | filePath | string | The file path |
27
30
28
- // from source
29
- const componentSourceInfo = vueDocs .parseSource (sourceCode, filePath);
30
- ```
31
31
32
32
## Using JSDoc tags
33
33
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vue-docgen-api" ,
3
- "version" : " 2.2 .6" ,
3
+ "version" : " 2.1 .6" ,
4
4
"description" : " Toolbox to extract information from Vue component files for documentation generation purposes." ,
5
5
"bugs" : {
6
6
"url" : " https://github.com/vue-styleguidist/vue-docgen-api/issues"
Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ const expect = require("chai").expect;
3
3
4
4
describe ( 'parse' , ( ) => {
5
5
it ( 'should return an function' , ( ) => {
6
- expect ( parse . default ) . to . be . an ( 'function' )
6
+ expect ( parse . parse ) . to . be . an ( 'function' )
7
7
} )
8
8
} )
Original file line number Diff line number Diff line change 1
1
import * as utils from './utils' ;
2
- import { parseFile , parseSource } from './parse' ;
3
-
4
- function parseFile ( path ) {
5
- return parseFile ( path ) ;
6
- }
7
-
8
- function parseSource ( src , path ) {
9
- return parseSource ( src , path ) ;
10
- }
2
+ import { parse , parseSource } from './parse' ;
11
3
12
4
export {
13
- parseFile ,
5
+ parse ,
14
6
parseSource ,
15
7
utils ,
16
8
} ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import fs from 'fs';
2
2
import * as utils from './utils' ;
3
3
import stateDoc from './utils/stateDoc' ;
4
4
5
- export const parseFile = function ( file ) {
5
+ export const parse = function ( file ) {
6
6
const source = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
7
7
if ( source === '' ) {
8
8
throw new Error ( 'The document is empty' ) ;
@@ -18,7 +18,7 @@ export const parseSource = function(source, path) {
18
18
if ( source === '' ) {
19
19
throw new Error ( 'The document is empty' ) ;
20
20
}
21
-
21
+
22
22
stateDoc . file = path ;
23
23
stateDoc . saveComponent ( source , path ) ;
24
24
const component = utils . getSandbox ( stateDoc . jscodeReqest , path ) . default ;
You can’t perform that action at this time.
0 commit comments