Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.

Commit 1198d02

Browse files
committed
Updated parseSource
1 parent 078f8ba commit 1198d02

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
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

86
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
1210
Install 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

2018
The 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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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"

src/__tests__/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ const expect = require("chai").expect;
33

44
describe('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
})

src/main.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
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';
113

124
export {
13-
parseFile,
5+
parse,
146
parseSource,
157
utils,
168
};

src/parse.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs';
22
import * as utils from './utils';
33
import 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;

0 commit comments

Comments
 (0)