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

Commit c4f1d52

Browse files
authored
fix: naming mixup (#112)
* remove useless files * fix: make sure that name of mixins do not overload components fixes #110 * fix compiler error * remove sourcemaps from published version
1 parent 58f1318 commit c4f1d52

File tree

7 files changed

+19
-54
lines changed

7 files changed

+19
-54
lines changed

src/main.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,30 @@ export function parse(
77
filePath: string,
88
opts?: DocGenOptions | { [alias: string]: string },
99
): ComponentDoc {
10-
const doc = new Documentation()
11-
const options: ParseOptions = isOptionsObject(opts)
12-
? { ...opts, filePath }
13-
: { filePath, alias: opts }
14-
parseFile(doc, options)
15-
return doc.toObject()
10+
return parsePrimitive((doc, options) => parseFile(doc, options), filePath, opts)
1611
}
1712

1813
export function parseSource(
1914
source: string,
2015
filePath: string,
2116
opts?: DocGenOptions | { [alias: string]: string },
17+
): ComponentDoc {
18+
return parsePrimitive((doc, options) => parseSourceLocal(doc, source, options), filePath, opts)
19+
}
20+
21+
function isOptionsObject(opts: any): opts is DocGenOptions {
22+
return !!opts && !!opts.alias
23+
}
24+
25+
function parsePrimitive(
26+
createDoc: (doc: Documentation, opts: ParseOptions) => void,
27+
filePath: string,
28+
opts?: DocGenOptions | { [alias: string]: string },
2229
): ComponentDoc {
2330
const doc = new Documentation()
2431
const options: ParseOptions = isOptionsObject(opts)
2532
? { ...opts, filePath }
2633
: { filePath, alias: opts }
27-
parseSourceLocal(doc, source, options)
34+
createDoc(doc, options)
2835
return doc.toObject()
2936
}
30-
31-
function isOptionsObject(opts: any): opts is DocGenOptions {
32-
return !!opts && !!opts.alias
33-
}

src/script-handlers/extendsHandler.ts

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export default function extendsHandler(
4444
filePath: fullFilePath,
4545
nameFilter: [extendsFilePath[extendsVariableName].exportName],
4646
})
47+
// make sure that the parent name does not bleed on the new doc
48+
documentation.set('displayName', null)
4749
}
4850
}
4951

src/script-handlers/mixinsHandler.ts

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default function mixinsHandler(
5050
parseFile(documentation, { ...opt, filePath: fullFilePath, nameFilter: vars })
5151
}
5252
})
53+
documentation.set('displayName', null)
5354
}
5455

5556
function getMixinsVariableNames(compDef: NodePath): string[] | undefined {

tests/components/button-typescript/colorMixin.js

-20
This file was deleted.

tests/components/button-typescript/genericMixin.js

-21
This file was deleted.

tests/components/extended/InputTextDocumented.vue

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Base from './Base.vue'
1111
* Description InputTextDocumented
1212
*/
1313
export default {
14-
name: 'InputTextDocumented',
1514
extends: Base,
1615
props: {
1716
placeholder: {

tsconfig.build.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "./tsconfig",
33
"compilerOptions": {
4-
"declaration": true
4+
"declaration": true,
5+
"sourceMap": false
56
},
67
"include": ["src/**/*.ts"],
78
"exclude": ["src/**/__tests__/**/*.ts"]

0 commit comments

Comments
 (0)