-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23ed054
commit bdf1662
Showing
8 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<div> | ||
<!-- 表单头部 --> | ||
<slot name="header"> | ||
<!-- `<th>title</th>` --> | ||
<th>title</th> | ||
</slot> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
// 表单的名称,最多8个字符 | ||
name: { | ||
type: [String, Number], | ||
required: true, | ||
validator () {} | ||
} | ||
}, | ||
methods: { | ||
// @vuese | ||
// 用来手动清空表单 | ||
clear () { | ||
// 清空表单时触发 | ||
// @arg 参数是一个布尔值,代表xxx | ||
this.$emit('onclear', true) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`The generated document matches the expected results 1`] = ` | ||
"|Name|Description|Type|Required|Default| | ||
|---|---|---|---|---| | ||
|name|表单的名称,最多8个字符|\`String\` / \`Number\`|\`true\`|-| | ||
|Event Name|Description|Parameters| | ||
|---|---|---| | ||
|onclear|清空表单时触发| 参数是一个布尔值,代表xxx| | ||
|Name|Description|Default Slot Content| | ||
|---|---|---| | ||
|header|表单头部|\`<th>title</th>\`| | ||
|Method|Description|Parameters| | ||
|---|---|---| | ||
|clear|用来手动清空表单| 参数是一个布尔值,代表xxx| | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import vuese from '../index' | ||
import * as path from 'path' | ||
import * as fs from 'fs' | ||
|
||
function getSource(fileName: string): string { | ||
const p = path.resolve(__dirname, `../../__fixtures__/${fileName}`) | ||
const source = fs.readFileSync(p, 'utf-8') | ||
return source | ||
} | ||
|
||
test('The generated document matches the expected results', () => { | ||
const source = getSource('all.vue') | ||
expect(vuese(source)).toMatchSnapshot() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import parser, { ParserResult } from './parser' | ||
import Render, { RenderResult } from './render' | ||
|
||
export default function(source: string): string { | ||
const pr: ParserResult = parser(source) | ||
const r = new Render(pr) | ||
const renderRes: RenderResult = r.render() | ||
let mdString = '' | ||
if (renderRes.props) { | ||
mdString += renderRes.props + '\n' | ||
} | ||
if (renderRes.events) { | ||
mdString += renderRes.events + '\n' | ||
} | ||
if (renderRes.slots) { | ||
mdString += renderRes.slots + '\n' | ||
} | ||
if (renderRes.methods) { | ||
mdString += renderRes.methods + '\n' | ||
} | ||
|
||
return mdString | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters