Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"name": "type",
"value": "type",
"string": "this.type"
},
"value": "this.type = type;\r",
"line": 44,
"loc": { "start": { "line": 44, "column": 1424 }, "end": { "line": 44, "column": 1442 } }
}
},
*/
for (var i = 0; i < blocks.length; i++)
{
var block = blocks[i];
comments.push(doctrine.parse(block.value, doctrineOptions));
}
// comments = JSON.stringify(comments);
comments = beautify(comments, null, 2, 100); // just for debugging really
// comments = beautify(blocks, null, 2, 100); // just for debugging really
fs.writeFile(dest, comments, { encoding: 'utf8', flag: 'w' }, function (error) {
if (error)
{
throw error;
}
else
{
console.log('Comments written');
}
return comments.filter(comment => {
if (isCommentBlock(comment) && /^\*/.test(comment.value)) {
const jsdoc = doctrine.parse(`/* ${comment.value}*/`, { unwrap: true });
return (
jsdoc.tags.some(tag => tag.title === "typedef") &&
!jsdoc.tags.some(tag => tag.title === "private")
);
}
return false;
});
};
function generateDescription(required, description, type) {
let deprecated = '';
if (type.name === 'custom') {
const deprecatedInfo = getDeprecatedInfo(type);
if (deprecatedInfo) {
deprecated = `*Deprecated*. ${deprecatedInfo.explanation}<br><br>`;
}
}
const parsed = parseDoctrine(description);
// two new lines result in a newline in the table. all other new lines
// must be eliminated to prevent markdown mayhem.
const jsDocText = parsed.description.replace(/\n\n/g, '<br>').replace(/\n/g, ' ');
if (parsed.tags.some((tag) => tag.title === 'ignore')) return null;
let signature = '';
if (type.name === 'func' && parsed.tags.length > 0) {
// Remove new lines from tag descriptions to avoid markdown errors.
parsed.tags.forEach((tag) => {
if (tag.description) {
tag.description = tag.description.replace(/\n/g, ' ');
}
});
export function parseJsdoc(docs: string): doctrine.Annotation {
docs = removeLeadingAsterisks(docs);
const d = doctrine.parse(docs, {
unwrap: false,
// lineNumbers: true,
preserveWhitespace: true,
});
// Strip any leading and trailing newline characters in the
// description of multiline comments for readibility.
// TODO(rictic): figure out if we can trim() here or not. Something something
// markdown?
const description = d.description && d.description.replace(/^\n+|\n+$/g, '');
return {description, tags: parseCustomTags(d.tags)};
}
function generateDescription(required, description, type) {
let deprecated = '';
if (type.name === 'custom') {
const deprecatedInfo = getDeprecatedInfo(type);
if (deprecatedInfo) {
deprecated = `*Deprecated*. ${deprecatedInfo.explanation}<br><br>`;
}
}
const parsed = parseDoctrine(description);
// two new lines result in a newline in the table. all other new lines
// must be eliminated to prevent markdown mayhem.
const jsDocText = parsed.description.replace(/\n\n/g, '<br>').replace(/\n/g, ' ');
if (parsed.tags.some(tag => tag.title === 'ignore')) return null;
let signature = '';
if (type.name === 'func' && parsed.tags.length > 0) {
// Remove new lines from tag descriptions to avoid markdown errors.
parsed.tags = parsed.tags.map((tag) => {
if (tag.description) {
return tag.description.replace(/\n/g, ' ');
}
return tag;
function generatePropDescription(prop) {
const { description } = prop;
const type = prop.flowType || prop.type;
let deprecated = '';
if (type.name === 'custom') {
const deprecatedInfo = getDeprecatedInfo(type);
if (deprecatedInfo) {
deprecated = `*Deprecated*. ${deprecatedInfo.explanation}<br><br>`;
}
}
const parsed = parseDoctrine(description, {
sloppy: true,
});
// Two new lines result in a newline in the table.
// All other new lines must be eliminated to prevent markdown mayhem.
const jsDocText = escapeCell(parsed.description)
.replace(/(\r?\n){2}/g, '<br>')
.replace(/\r?\n/g, ' ');
if (parsed.tags.some(tag => tag.title === 'ignore')) {
return null;
}
let signature = '';
if (type.name === 'func' && parsed.tags.length > 0) {
Object.keys(doc.props).forEach(propName => {
const prop = doc.props[propName];
const doclets = getDocletsObject(prop.description);
// When a prop is listed in defaultProps but not in props the prop.description is undefined
const documentation = doctrine.parse(prop.description || '');
// documentation.description is the description without tags
doc.props[propName].description = documentation.description;
doc.props[propName].tags = getDoctrineTags(documentation);
// Remove ignored props
if (doclets && doclets.ignore) {
delete doc.props[propName];
}
});
}
function Prop(props) {
const {prop, prefix} = props;
const {description, tags} = doctrine.parse(prop.description || '');
const isPublic = tags.some(tag => tag.title === 'public');
if (!isPublic) {
return null;
}
const defines = tags.find(tag => tag.title === 'defines');
const typeNames = defines ? defines.description.split(' ') : [];
const shapes = getShapes(prop.type, prop.name);
const namedTypes = typeNames.map((name, i) => ({
name,
type: shapes[i].type,
}));
tree.comments.forEach(function (comment) {
if (isFileOrClassScopeComment(comment, topLevelCodeUnitLines)) {
var jsdoc = doctrine.parse(comment.value, { unwrap: true });
jsdoc.tags.forEach(function (tag) {
switch(tag.title) {
case 'ignore':
atHints.ignore = atHints.ignore.concat(getClassesFromTagDesc(tag.description));
break;
case 'require':
atHints.require = atHints.require.concat(getClassesFromTagDesc(tag.description));
break;
case 'use':
atHints.use = atHints.use.concat(getClassesFromTagDesc(tag.description));
break;
case 'asset':
atHints.asset = atHints.asset.concat(getResourcesFromTagDesc(tag.description));
break;
case 'cldr':
atHints.cldr = true;
static loadBitMeta(name: string, bitContents: string) {
const ast = esprima.parse(bitContents, {
loc: true,
tolerant: true,
attachComment: true
});
const rawDocs = ast.body[0].leadingComments[0].value;
const docs = doctrine
.parse(rawDocs, { unwrap: true })
.tags.reduce(function (previousValue, currentValue) {
previousValue[currentValue.title] = currentValue.description || currentValue.name;
return previousValue;
}, {});
return {
name: docs.name,
version: docs.version,
env: docs.env,
dependencies: docs.dependencies,
sig: docs.sig,
examples: docs.example
};
}