Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,30 @@ export function parse(
filePath: string,
opts?: DocGenOptions | { [alias: string]: string },
): ComponentDoc {
const doc = new Documentation()
const options: ParseOptions = isOptionsObject(opts)
? { ...opts, filePath }
: { filePath, alias: opts }
parseFile(doc, options)
return doc.toObject()
return parsePrimitive((doc, options) => parseFile(doc, options), filePath, opts)
}

export function parseSource(
source: string,
filePath: string,
opts?: DocGenOptions | { [alias: string]: string },
): ComponentDoc {
return parsePrimitive((doc, options) => parseSourceLocal(doc, source, options), filePath, opts)
}

function isOptionsObject(opts: any): opts is DocGenOptions {
return !!opts && !!opts.alias
}

function parsePrimitive(
createDoc: (doc: Documentation, opts: ParseOptions) => void,
filePath: string,
opts?: DocGenOptions | { [alias: string]: string },
): ComponentDoc {
const doc = new Documentation()
const options: ParseOptions = isOptionsObject(opts)
? { ...opts, filePath }
: { filePath, alias: opts }
parseSourceLocal(doc, source, options)
createDoc(doc, options)
return doc.toObject()
}

function isOptionsObject(opts: any): opts is DocGenOptions {
return !!opts && !!opts.alias
}
2 changes: 2 additions & 0 deletions src/script-handlers/extendsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default function extendsHandler(
filePath: fullFilePath,
nameFilter: [extendsFilePath[extendsVariableName].exportName],
})
// make sure that the parent name does not bleed on the new doc
documentation.set('displayName', null)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/script-handlers/mixinsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function mixinsHandler(
parseFile(documentation, { ...opt, filePath: fullFilePath, nameFilter: vars })
}
})
documentation.set('displayName', null)
}

function getMixinsVariableNames(compDef: NodePath): string[] | undefined {
Expand Down
20 changes: 0 additions & 20 deletions tests/components/button-typescript/colorMixin.js

This file was deleted.

21 changes: 0 additions & 21 deletions tests/components/button-typescript/genericMixin.js

This file was deleted.

1 change: 0 additions & 1 deletion tests/components/extended/InputTextDocumented.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Base from './Base.vue'
* Description InputTextDocumented
*/
export default {
name: 'InputTextDocumented',
extends: Base,
props: {
placeholder: {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"declaration": true
"declaration": true,
"sourceMap": false
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/__tests__/**/*.ts"]
Expand Down