vue-styleguidist
Version:
Vue components style guide generator
21 lines (19 loc) • 790 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = expandDefaultComponent;
var _vueDocgenApi = require("vue-docgen-api");
var COMPONENT_PLACEHOLDER = '__COMPONENT__';
var COMPONENT_PLACEHOLDER_C = "<".concat(COMPONENT_PLACEHOLDER, " />");
var COMPONENT_PLACEHOLDER_REGEXP = new RegExp(COMPONENT_PLACEHOLDER, 'g');
/**
* Wrap a string with require() statement.
*
* @param {string} source Source code.
* @param {string} componentName Name that will be used instead of a placeholder.
* @returns {string}
*/
function expandDefaultComponent(source, docs) {
return source.replace(COMPONENT_PLACEHOLDER_C, (0, _vueDocgenApi.getDefaultExample)(docs)).replace(COMPONENT_PLACEHOLDER_REGEXP, (0, _vueDocgenApi.cleanName)(docs.displayName));
}