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
22[ ![ npm] ( https://img.shields.io/npm/v/vue-docgen-api.svg )] ( https://www.npmjs.com/package/vue-docgen-api )
33
4- ** This fork adds a ` parseSource ` method to parse plain sources instead of files only**
5-
64` vue-docgen-api ` is a toolbox to help extracting information from [ Vue] [ ] components, and generate documentation from it.
75
86Use [ 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
1210Install the module directly from npm:
1311
1412```
15- npm install git://github.com/Radiergummi/ vue-docgen-api --save-dev
13+ npm install vue-docgen-api --save-dev
1614```
1715
1816## API
1917
2018The tool can be used programmatically to extract component information and customize the extraction process:
2119
2220``` js
23- const vueDocs = require (' vue-docgen-api' );
21+ var vueDocs = require (' vue-docgen-api' );
22+ var componentInfo = vueDocs .parse (filePath);
23+ ```
2424
25- // from file
26- const componentFileInfo = vueDocs .parseFile (filePath);
25+ ### parse(filePath)
26+
27+ | Parameter | Type | Description |
28+ | -------------- | ------ | --------------- |
29+ | filePath | string | The file path |
2730
28- // from source
29- const componentSourceInfo = vueDocs .parseSource (sourceCode, filePath);
30- ```
3131
3232## Using JSDoc tags
3333
Original file line number Diff line number Diff line change 11{
22 "name" : " vue-docgen-api" ,
3- "version" : " 2.2 .6" ,
3+ "version" : " 2.1 .6" ,
44 "description" : " Toolbox to extract information from Vue component files for documentation generation purposes." ,
55 "bugs" : {
66 "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;
33
44describe ( 'parse' , ( ) => {
55 it ( 'should return an function' , ( ) => {
6- expect ( parse . default ) . to . be . an ( 'function' )
6+ expect ( parse . parse ) . to . be . an ( 'function' )
77 } )
88} )
Original file line number Diff line number Diff line change 11import * 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' ;
113
124export {
13- parseFile ,
5+ parse ,
146 parseSource ,
157 utils ,
168} ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import fs from 'fs';
22import * as utils from './utils' ;
33import stateDoc from './utils/stateDoc' ;
44
5- export const parseFile = function ( file ) {
5+ export const parse = function ( file ) {
66 const source = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
77 if ( source === '' ) {
88 throw new Error ( 'The document is empty' ) ;
@@ -18,7 +18,7 @@ export const parseSource = function(source, path) {
1818 if ( source === '' ) {
1919 throw new Error ( 'The document is empty' ) ;
2020 }
21-
21+
2222 stateDoc . file = path ;
2323 stateDoc . saveComponent ( source , path ) ;
2424 const component = utils . getSandbox ( stateDoc . jscodeReqest , path ) . default ;
You can’t perform that action at this time.
0 commit comments