components/node_modules/vue-docgen-api/dist/parse.js
/**
 * parses the source and returns the doc
 * @param {string} source code whose documentation is parsed
 * @param {string} opt path of the current file against whom to resolve the mixins
 * @returns {object} documentation object
 */
parses the source and returns the doc
@param {string} source code whose documentation is parsed
@param {string} opt path of the current file against whom to resolve the mixins
@returns {object} documentation object
parses the source and returns the doc @param { string } source code whose documentation is parsed @param { string } opt path of the current file against whom to resolve the mixins @returns { object } documentation object
function parseSource(source, opt, documentation) {
    return __awaiter(this, void 0, void 0, function () {
        var singleFileComponent, docs, addScriptHandlers;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    opt.jsx = opt.jsx === undefined ? true : opt.jsx;
                    singleFileComponent = /\.vue$/i.test(path.extname(opt.filePath));
                    if (source === '') {
                        throw new Error(ERROR_EMPTY_DOCUMENT);
                    }
                    if (documentation) {
                        documentation.setOrigin(opt);
                    }
                    if (!singleFileComponent) return [3 , 2];
                    return [4 , parseSFC(documentation, source, opt)];
                case 1:
                    docs = [_a.sent()];
                    return [3 , 4];
                case 2:
                    addScriptHandlers = opt.addScriptHandlers || [];
                    opt.lang = /\.tsx?$/i.test(path.extname(opt.filePath)) ? 'ts' : 'js';
                    return [4 , parse_script_1.default(source, script_handlers_1.preHandlers, __spreadArrays(script_handlers_1.default, addScriptHandlers), opt, documentation)];
                case 3:
                    docs =
                        (_a.sent()) || [];
                    if (docs.length === 1 && !docs[0].get('displayName')) {
                        docs[0].set('displayName', path.basename(opt.filePath).replace(/\.\w+$/, ''));
                    }
                    _a.label = 4;
                case 4:
                    if (documentation) {
                        documentation.setOrigin({});
                    }
                    return [2 , docs];
            }
        });
    });
}
function parseSource ( source , opt , documentation ) { return __awaiter ( this , void 0 , void 0 , function ( ) { var singleFileComponent , docs , addScriptHandlers ; return __generator ( this , function ( _a ) { switch ( _a . label ) { case 0 : opt . jsx = opt . jsx === undefined ? true : opt . jsx ; singleFileComponent = / \.vue$ / i . test ( path . extname ( opt . filePath ) ) ; if ( source === '' ) { throw new Error ( ERROR_EMPTY_DOCUMENT ) ; } if ( documentation ) { documentation . setOrigin ( opt ) ; } if ( ! singleFileComponent ) return [ 3 , 2 ] ; return [ 4 , parseSFC ( documentation , source , opt ) ] ; case 1 : docs = [ _a . sent ( ) ] ; return [ 3 , 4 ] ; case 2 : addScriptHandlers = opt . addScriptHandlers || [ ] ; opt . lang = / \.tsx?$ / i . test ( path . extname ( opt . filePath ) ) ? 'ts' : 'js' ; return [ 4 , parse_script_1 . default ( source , script_handlers_1 . preHandlers , __spreadArrays ( script_handlers_1 . default , addScriptHandlers ) , opt , documentation ) ] ; case 3 : docs = ( _a . sent ( ) ) || [ ] ; if ( docs . length === 1 && ! docs [ 0 ] . get ( 'displayName' ) ) { docs [ 0 ] . set ( 'displayName' , path . basename ( opt . filePath ) . replace ( / \.\w+$ / , '' ) ) ; } _a . label = 4 ; case 4 : if ( documentation ) { documentation . setOrigin ( { } ) ; } return [ 2 , docs ] ; } } ) ; } ) ; }
parses the source and returns the doc
 @param {string} source code whose documentation is parsed
 @param {string} opt path of the current file against whom to resolve the mixins
 @returns {object} documentation object
parses the source and returns the doc @param { string } source code whose documentation is parsed @param { string } opt path of the current file against whom to resolve the mixins @returns { object } documentation object
// if jsx option is not mentionned, parse jsx in components // if the parsed component is the result of a mixin or an extends /*break*/ /*yield*/ /*break*/ /*yield*/ // give a component a display name if we can /*return*/