Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const typeMarkdown = getTypeMarkdown(localType, typeReferences, { type });
let title;
if (type === 'state-return') {
title = 'Return Values';
}
if (type === 'state-api') {
title = 'API';
}
if (type === 'props') {
title = 'Props';
}
try {
const tree = ast.parse(mdContents);
const merged = inject(`${componentSection} ${title}`, tree, ast.parse(typeMarkdown));
const markdown = toMarkdown(merged).trimLeft();
writeFileSync(docPath, markdown);
console.log(`Injected ${componentSection} props into ${docPath}`);
} catch (e) {
// do nothing
}
});
}
}
const typeMarkdown = getTypeMarkdown(localType, typeReferences, { type });
let title;
if (type === 'state-return') {
title = 'Return Values';
}
if (type === 'state-api') {
title = 'API';
}
if (type === 'props') {
title = 'Props';
}
try {
const tree = ast.parse(mdContents);
const merged = inject(`${componentSection} ${title}`, tree, ast.parse(typeMarkdown));
const markdown = toMarkdown(merged).trimLeft();
writeFileSync(docPath, markdown);
console.log(`Injected ${componentSection} props into ${docPath}`);
} catch (e) {
// do nothing
}
});
}
return extractText(x);
}
else if (x.type === md.Syntax.Image) {
// Images (at least on GitHub, untested elsewhere) are given a hyphen
// in the slug. We can achieve this behavior by adding an '*' to the
// TOC entry. Think of it as a "magic char" that represents the iamge.
return '*';
}
else {
return x.raw;
}
})
.join('')
}
return md.parse(lines.join('\n')).children
.filter(function (x) {
return x.type === md.Syntax.Header;
})
.map(function (x) {
return !maxHeaderLevel || x.depth <= maxHeaderLevel
? { rank : x.depth
, name : extractText(x)
, line : x.loc.start.line
}
: null;
})
.filter(notNull)
}
var go = module.exports = function (lines, maxHeaderLevel) {
var source = md.parse(lines.join('\n'))
.children
.filter(function(node) {
return node.type === md.Syntax.HtmlBlock || node.type === md.Syntax.Html;
})
.map(function (node) {
return node.raw;
})
.join('\n');
//var headers = [], grabbing = null, text = [];
var headers = [], grabbing = [], text = [];
var parser = new htmlparser.Parser({
onopentag: function (name, attr) {
// Short circuit if we're already inside a pre
if (grabbing[grabbing.length - 1] === 'pre') return;
.map(function (x) {
if (x.type === md.Syntax.Link) {
return extractText(x);
}
else if (x.type === md.Syntax.Image) {
// Images (at least on GitHub, untested elsewhere) are given a hyphen
// in the slug. We can achieve this behavior by adding an '*' to the
// TOC entry. Think of it as a "magic char" that represents the iamge.
return '*';
}
else {
return x.raw;
}
})
.join('')
readmePaths.forEach(readmePath => {
const mdContents = readFileSync(readmePath, { encoding: "utf-8" });
if (/#\s?Props/.test(mdContents)) {
const dir = dirname(readmePath);
const tree = ast.parse(mdContents);
const publicPaths = Object.values(getPublicFiles(dir));
const sourceFiles = project.addExistingSourceFiles(publicPaths);
project.resolveSourceFileDependencies();
const types = {};
sortSourceFiles(sourceFiles).forEach(sourceFile => {
sourceFile.forEachChild(node => {
if (isStateReturnDeclaration(node)) {
const propTypes = createPropTypeObjects(rootPath, node);
stateTypes.push(...propTypes.map(prop => prop.name));
}
if (isPropsDeclaration(node)) {
const moduleName = getModuleName(node);
const propTypes = createPropTypeObjects(rootPath, node);
if (isInitialStateDeclaration(node)) {
const parseMdLine = (line, existingEntities, extraStyles = {}) => {
const inlineStyles = { ...defaultInlineStyles, ...extraStyles.inlineStyles };
const blockStyles = { ...defaultBlockStyles, ...extraStyles.blockStyles };
const astString = mdToAst.parse(line);
let text = '';
const inlineStyleRanges = [];
const entityRanges = [];
const data = {};
const entityMap = existingEntities;
const addInlineStyleRange = (offset, length, style) => {
inlineStyleRanges.push({ offset, length, style });
};
const getRawLength = children =>
children.reduce((prev, current) => prev + (current.value ? current.value.length : 0), 0);
const addObject = child => {
const entityKey = Object.keys(entityMap).length;
const urlParts = child.url.split('/');
const parseMdLine = (line, existingEntities, extraStyles = {}) => {
const inlineStyles = { ...defaultInlineStyles, ...extraStyles.inlineStyles };
const blockStyles = { ...defaultBlockStyles, ...extraStyles.blockStyles };
const astString = parse(line);
let text = '';
const inlineStyleRanges = [];
const entityRanges = [];
const entityMap = existingEntities;
const addInlineStyleRange = (offset, length, style) => {
inlineStyleRanges.push({ offset, length, style });
};
const getRawLength = children =>
children.reduce((prev, current) => {
if (current.value) {
return prev + current.value.length;
} else if (current.children && current.children.length) {
return prev + getRawLength(current.children);
}
preProcess(text, filePath) {
return parse(text);
},
postProcess(messages, filePath) {
.filter(function (x) {
return x.type === md.Syntax.Header;
})
.map(function (x) {