Skip to content

Commit 72c741e

Browse files
committed
directory structure change, example and readme added
1 parent 80d0c84 commit 72c741e

File tree

9 files changed

+87
-7
lines changed

9 files changed

+87
-7
lines changed

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,77 @@
1-
# vue-script-parser
1+
# vue-script-parser
2+
3+
This package can be used to parse vue script section.
4+
5+
6+
## Installation
7+
8+
```
9+
npm install vue-script-ast-parser
10+
```
11+
12+
13+
## Usage
14+
15+
```
16+
<script>
17+
18+
import parser from 'vue-script-ast-parser';
19+
20+
export default {
21+
data() {
22+
return {}
23+
},
24+
methods: {
25+
parseCode() {
26+
let code = `
27+
import Vue from 'vue
28+
import myComponent from 'myComponent'
29+
export default {
30+
data() {
31+
return {
32+
name: 'Kunal'
33+
}
34+
},
35+
methods: {
36+
test() {
37+
console.log('this is test method')
38+
},
39+
},
40+
}`
41+
let instance = new VueScriptParser(code)
42+
console.log(instance)
43+
}
44+
}
45+
}
46+
47+
</script>
48+
```
49+
50+
## Output
51+
52+
```
53+
{
54+
"imports": [
55+
"import Vue from 'vue",
56+
"import myComponent from 'myComponent'"
57+
],
58+
"data": [
59+
{
60+
"key": "name",
61+
"value": "Kunal"
62+
}
63+
],
64+
"mounted": "\n console.log('this is mounted')\n ",
65+
"methods": [
66+
{
67+
"name": "test",
68+
"body": "\n console.log('this is test method')\n ",
69+
"arguments": [
70+
"args1",
71+
"args2"
72+
]
73+
}
74+
]
75+
}
76+
```
77+

src/Demo.vue renamed to example/Demo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</template>
1313

1414
<script>
15-
import VueScriptParser from './plugin/index'
15+
import VueScriptParser from '../index'
1616
export default {
1717
data() {
1818
return {
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import Data from './data'
2-
import Methods from './methods'
3-
import Mounted from './mounted'
4-
import Imports from './imports'
1+
import Data from './modules/data'
2+
import Methods from './modules/methods'
3+
import Mounted from './modules/mounted'
4+
import Imports from './modules/imports'
5+
56
class VueScriptParser {
67
constructor(vueScript = '') {
78
//load imports
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "vue-script-parser",
2+
"name": "vue-script-ast-parser",
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
@@ -12,7 +12,10 @@
1212
},
1313
"keywords": [
1414
"vue",
15+
"ast",
16+
"vue-script-ast-parser",
1517
"vue-parser",
18+
"vue-script-parser",
1619
"vue-script",
1720
"vue",
1821
"script",

0 commit comments

Comments
 (0)