Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.publish = function(taffyData, opts, tutorials) {
data = taffyData
var conf = env.conf.templates || {}
conf.default = conf.default || {}
var templatePath = path.normalize(opts.template)
view = new template.Template(path.join(templatePath, "tmpl"))
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
// doesn't try to hand them out later
// var indexUrl = helper.getUniqueFilename("index")
// don't call registerLink() on this one! 'index' is also a valid longname
var globalUrl = helper.getUniqueFilename("global")
helper.registerLink("global", globalUrl)
// set up templating
view.layout = conf.default.layoutFile
? path.getResourcePath(
exports.load = filepath => {
let content;
let current;
const files = lsSync(filepath, {
depth: env.opts.recurse ? env.conf.recurseDepth : 0
});
let name;
let match;
let type;
// tutorials handling
files.forEach(file => {
match = file.match(finder);
// any filetype that can apply to tutorials
if (match) {
name = path.basename(match[1]);
content = fs.readFileSync(file, env.opts.encoding);
switch (match[2].toLowerCase()) {
// HTML type
///
/**
* @overview Generates a TypeScript definition file from assembled JSDoc doclets
* @module plugins/typescript
* @author Jackie Ng
*/
'use strict';
var CLS_DESC_PLACEHOLDER = "%TYPENAME%";
var fs = require('fs');
var env = require('jsdoc/env');
var config = env.conf.typescript || {};
var moduleName = env.conf.typescript.rootModuleName || "generated";
var outDir = env.conf.typescript.outDir || ".";
var defaultCtorDesc = env.conf.typescript.defaultCtorDesc || ("Constructor for " + CLS_DESC_PLACEHOLDER);
var fileName = outDir + "/" + moduleName + ".d.ts";
var indentLevel = 0;
/**
* JS -> TypeScript type aliases. Any such types encountered in the JSDoc
* annotations will be replaced with the specified replacement here
*/
var TS_ALIASES = {
"Object": "any",
"function": "Function"
};
/**
* Filter function for JSON.stringify calls on doclet instances
*/
function buildSourceList() {
var fs = require('jsdoc/fs');
var Readme = require('jsdoc/readme');
var packageJson;
var readmeHtml;
var sourceFile;
var sourceFiles = env.opts._ ? env.opts._.slice(0) : [];
if (env.conf.source && env.conf.source.include) {
sourceFiles = sourceFiles.concat(env.conf.source.include);
}
// load the user-specified package/README files, if any
if (env.opts.package) {
packageJson = readPackageJson(env.opts.package);
}
if (env.opts.readme) {
readmeHtml = new Readme(env.opts.readme).html;
}
// source files named `package.json` or `README.md` get special treatment, unless the user
// explicitly specified a package and/or README file
for (var i = 0, l = sourceFiles.length; i < l; i++) {
sourceFile = sourceFiles[i];
exports.validate = ({title, text, value}, tagDef, meta) => {
const allowUnknownTags = env.conf.tags.allowUnknownTags;
// handle cases where the tag definition does not exist
if (!tagDef) {
// log an error if unknown tags are not allowed
if (!allowUnknownTags ||
(Array.isArray(allowUnknownTags) &&
!allowUnknownTags.includes(title))) {
logger.error( buildMessage(title, meta, 'is not a known tag') );
}
// stop validation, since there's nothing to validate against
return;
}
// check for errors that make the tag useless
if (!text && tagDef.mustHaveValue) {
describe('lib/config', () => {
const config = require('../../../lib/config');
const env = require('jsdoc/env');
const logger = require('jsdoc/util/logger');
const path = require('path');
const baselineConfigPath = env.conf.templates.baseline;
const templatePath = env.opts.template;
afterEach(() => {
env.conf.templates.baseline = baselineConfigPath;
env.opts.template = templatePath;
config.reset();
});
it('should be an object', () => {
expect(config).toBeObject();
});
it('should export a "defaultConfig" object', () => {
expect(config.defaultConfig).toBeObject();
});
describe('@dict tag', () => {
const env = require('jsdoc/env');
const logger = require('jsdoc/util/logger');
const allowUnknownTags = Boolean(env.conf.tags.allowUnknownTags);
beforeEach(() => {
env.conf.tags.allowUnknownTags = false;
spyOn(logger, 'error');
});
afterEach(() => {
jsdoc.restoreTagDictionary();
env.conf.tags.allowUnknownTags = allowUnknownTags;
});
describe('JSDoc tags', () => {
beforeEach(() => {
jsdoc.replaceTagDictionary('jsdoc');
});
items.forEach(item => {
let displayName;
if ( !hasOwnProp.call(item, 'longname') ) {
itemsNav += `<li>${linktoFn('', item.name)}</li>`;
}
else if ( !hasOwnProp.call(itemsSeen, item.longname) ) {
if (env.conf.templates.default.useLongnameInNav) {
displayName = item.longname;
} else {
displayName = item.name;
}
itemsNav += `<li>${linktoFn(item.longname, displayName.replace(/\b(module|event):/g, ''))}</li>`;
itemsSeen[item.longname] = true;
}
});
items.forEach(function(item) {
if ( !hasOwnProp.call(item, 'longname') ) {
itemsNav += '<li>' + linktoFn('', item.name) + '</li>';
}
else if ( !hasOwnProp.call(itemsSeen, item.longname) ) {
var displayName;
if (env.conf.templates.default.useLongnameInNav) {
displayName = item.longname;
} else {
displayName = item.name;
}
itemsNav += '<li>' + linktoFn(item.longname, displayName.replace(/\b(module|event):/g, '')) + '</li>';
itemsSeen[item.longname] = true;
}
});
function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) {
var nav = '';
if (items.length) {
var itemsNav = '';
var className = itemHeading === tutorialsName ? 'lnb-examples hidden' : 'lnb-api hidden';
var makeHtml = env.conf.templates.useCollapsibles ? makeCollapsibleItemHtmlInNav : makeItemHtmlInNav;
items.forEach(function(item) {
var linkHtml;
if ( !hasOwnProp.call(item, 'longname') ) {
itemsNav += '<li>' + linktoFn('', item.name) + buildSubNav(item) + '</li>';
}
else if ( !hasOwnProp.call(itemsSeen, item.longname) ) {
var displayName;
if (env.conf.templates.default.useLongnameInNav || item.kind === 'namespace') {
displayName = item.longname;
} else {
displayName = item.name;
}
linkHtml = linktoFn(item.longname, displayName.replace(/\b(module|event):/g, ''));