mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
refactor: use env instead of deps or dependencies
This commit is contained in:
parent
1db703c2db
commit
995fdae3d8
@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides methods for augmenting the parse results based on their content.
|
* Provides methods for augmenting the parse results based on their content.
|
||||||
*/
|
*/
|
||||||
@ -458,12 +459,12 @@ function getImplementedAdditions(implDoclets, docletStore) {
|
|||||||
return additions;
|
return additions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function augment(docletStore, propertyName, docletFinder, jsdocDeps) {
|
function augment(docletStore, propertyName, docletFinder, env) {
|
||||||
const dependencies = sort(mapDependencies(docletStore.docletsByLongname, propertyName));
|
const dependencies = sort(mapDependencies(docletStore.docletsByLongname, propertyName));
|
||||||
|
|
||||||
dependencies.forEach((depName) => {
|
dependencies.forEach((depName) => {
|
||||||
const depDoclets = Array.from(docletStore.docletsByLongname.get(depName) || []);
|
const depDoclets = Array.from(docletStore.docletsByLongname.get(depName) || []);
|
||||||
const additions = docletFinder(depDoclets, docletStore, jsdocDeps);
|
const additions = docletFinder(depDoclets, docletStore, env);
|
||||||
|
|
||||||
additions.forEach((addition) => {
|
additions.forEach((addition) => {
|
||||||
docletStore.add(addition);
|
docletStore.add(addition);
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions that resolve `@borrows` tags in JSDoc comments.
|
* Functions that resolve `@borrows` tags in JSDoc comments.
|
||||||
*/
|
*/
|
||||||
@ -32,10 +33,7 @@ function cloneBorrowedDoclets({ borrowed, longname }, docletStore) {
|
|||||||
if (borrowedDoclets) {
|
if (borrowedDoclets) {
|
||||||
borrowedAs = borrowedAs.replace(/^prototype\./, SCOPE.PUNC.INSTANCE);
|
borrowedAs = borrowedAs.replace(/^prototype\./, SCOPE.PUNC.INSTANCE);
|
||||||
borrowedDoclets.forEach((borrowedDoclet) => {
|
borrowedDoclets.forEach((borrowedDoclet) => {
|
||||||
const clone = combineDoclets(
|
const clone = combineDoclets(borrowedDoclet, Doclet.emptyDoclet(borrowedDoclet.env));
|
||||||
borrowedDoclet,
|
|
||||||
Doclet.emptyDoclet(borrowedDoclet.dependencies)
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: this will fail on longnames like '"Foo#bar".baz'
|
// TODO: this will fail on longnames like '"Foo#bar".baz'
|
||||||
parts = borrowedAs.split(SCOPE.PUNC.INSTANCE);
|
parts = borrowedAs.split(SCOPE.PUNC.INSTANCE);
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { dirname, join } from 'node:path';
|
import { dirname, join } from 'node:path';
|
||||||
|
|
||||||
import { name } from '@jsdoc/core';
|
import { name } from '@jsdoc/core';
|
||||||
@ -70,9 +71,9 @@ export class DocletStore {
|
|||||||
DocletStore.#propertiesWithSets.map((prop) => [prop, 'docletsWith' + _.capitalize(prop)])
|
DocletStore.#propertiesWithSets.map((prop) => [prop, 'docletsWith' + _.capitalize(prop)])
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor(dependencies) {
|
constructor(env) {
|
||||||
this.#commonPathPrefix = null;
|
this.#commonPathPrefix = null;
|
||||||
this.#emitter = dependencies.get('emitter');
|
this.#emitter = env.emitter;
|
||||||
this.#isListening = false;
|
this.#isListening = false;
|
||||||
this.#sourcePaths = new Map();
|
this.#sourcePaths = new Map();
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import { astNode, Syntax } from '@jsdoc/ast';
|
import { astNode, Syntax } from '@jsdoc/ast';
|
||||||
@ -410,9 +411,9 @@ function copySpecificProperties(primary, secondary, target, include) {
|
|||||||
* doclets.
|
* doclets.
|
||||||
*/
|
*/
|
||||||
export function combineDoclets(primary, secondary) {
|
export function combineDoclets(primary, secondary) {
|
||||||
const copyMostPropertiesExclude = ['dependencies', 'params', 'properties', 'undocumented'];
|
const copyMostPropertiesExclude = ['env', 'params', 'properties', 'undocumented'];
|
||||||
const copySpecificPropertiesInclude = ['params', 'properties'];
|
const copySpecificPropertiesInclude = ['params', 'properties'];
|
||||||
const target = new Doclet('', null, secondary.dependencies);
|
const target = new Doclet('', null, secondary.env);
|
||||||
|
|
||||||
// First, copy most properties to the target doclet.
|
// First, copy most properties to the target doclet.
|
||||||
copyMostProperties(primary, secondary, target, copyMostPropertiesExclude);
|
copyMostProperties(primary, secondary, target, copyMostPropertiesExclude);
|
||||||
@ -449,23 +450,23 @@ Doclet = class {
|
|||||||
*
|
*
|
||||||
* @param {string} docletSrc - The raw source code of the jsdoc comment.
|
* @param {string} docletSrc - The raw source code of the jsdoc comment.
|
||||||
* @param {object} meta - Properties describing the code related to this comment.
|
* @param {object} meta - Properties describing the code related to this comment.
|
||||||
* @param {object} dependencies - JSDoc dependencies.
|
* @param {object} env - JSDoc environment.
|
||||||
*/
|
*/
|
||||||
constructor(docletSrc, meta, dependencies) {
|
constructor(docletSrc, meta, env) {
|
||||||
const accessConfig = dependencies.get('config')?.opts?.access?.slice() ?? [];
|
const accessConfig = env.config?.opts?.access?.slice() ?? [];
|
||||||
const emitter = dependencies.get('emitter');
|
const emitter = env.emitter;
|
||||||
const boundDefineWatchableProp = defineWatchableProp.bind(null, this);
|
const boundDefineWatchableProp = defineWatchableProp.bind(null, this);
|
||||||
const boundEmitDocletChanged = emitDocletChanged.bind(null, emitter, this);
|
const boundEmitDocletChanged = emitDocletChanged.bind(null, emitter, this);
|
||||||
let newTags = [];
|
let newTags = [];
|
||||||
|
|
||||||
this.#dictionary = dependencies.get('tags');
|
this.#dictionary = env.tags;
|
||||||
|
|
||||||
Object.defineProperty(this, 'accessConfig', {
|
Object.defineProperty(this, 'accessConfig', {
|
||||||
value: accessConfig,
|
value: accessConfig,
|
||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, 'dependencies', {
|
Object.defineProperty(this, 'env', {
|
||||||
value: dependencies,
|
value: env,
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, 'watchableProps', {
|
Object.defineProperty(this, 'watchableProps', {
|
||||||
value: {},
|
value: {},
|
||||||
@ -518,11 +519,11 @@ Doclet = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static clone(doclet) {
|
static clone(doclet) {
|
||||||
return combineDoclets(doclet, Doclet.emptyDoclet(doclet.dependencies));
|
return combineDoclets(doclet, Doclet.emptyDoclet(doclet.env));
|
||||||
}
|
}
|
||||||
|
|
||||||
static emptyDoclet(dependencies) {
|
static emptyDoclet(env) {
|
||||||
return new Doclet('', {}, dependencies);
|
return new Doclet('', {}, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We call this method in the constructor _and_ in `jsdoc/src/handlers`. It appears that
|
// TODO: We call this method in the constructor _and_ in `jsdoc/src/handlers`. It appears that
|
||||||
@ -566,7 +567,7 @@ Doclet = class {
|
|||||||
*/
|
*/
|
||||||
addTag(title, text) {
|
addTag(title, text) {
|
||||||
const tagDef = this.#dictionary.lookUp(title);
|
const tagDef = this.#dictionary.lookUp(title);
|
||||||
const newTag = new Tag(title, text, this.meta, this.dependencies);
|
const newTag = new Tag(title, text, this.meta, this.env);
|
||||||
|
|
||||||
if (tagDef && tagDef.onTagged) {
|
if (tagDef && tagDef.onTagged) {
|
||||||
tagDef.onTagged(this, newTag);
|
tagDef.onTagged(this, newTag);
|
||||||
|
|||||||
@ -79,10 +79,10 @@ function getLicenses(packageInfo) {
|
|||||||
export class Package {
|
export class Package {
|
||||||
/**
|
/**
|
||||||
* @param {string} json - The contents of the `package.json` file.
|
* @param {string} json - The contents of the `package.json` file.
|
||||||
* @param {Object} deps - The JSDoc dependencies.
|
* @param {Object} env - The JSDoc environment.
|
||||||
*/
|
*/
|
||||||
constructor(json, deps) {
|
constructor(json, env) {
|
||||||
const log = deps.get('log');
|
const log = env.log;
|
||||||
let packageInfo;
|
let packageInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -59,7 +59,7 @@ describe('@jsdoc/doclet/lib/doclet-store', () => {
|
|||||||
expect(() => new DocletStore()).toThrow();
|
expect(() => new DocletStore()).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is constructable when dependencies are passed in', () => {
|
it('is constructable when JSDoc environment is passed in', () => {
|
||||||
expect(() => new DocletStore(jsdoc.env)).not.toThrow();
|
expect(() => new DocletStore(jsdoc.env)).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Tag dictionary for Google Closure Compiler.
|
// Tag dictionary for Google Closure Compiler.
|
||||||
|
|
||||||
import { getTags as getCoreTags } from './core.js';
|
import { getTags as getCoreTags } from './core.js';
|
||||||
@ -24,8 +25,8 @@ const NOOP_TAG = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTags = (deps) => {
|
export const getTags = (env) => {
|
||||||
const coreTags = getCoreTags(deps);
|
const coreTags = getCoreTags(env);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
const: {
|
const: {
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { astNode, Syntax } from '@jsdoc/ast';
|
import { astNode, Syntax } from '@jsdoc/ast';
|
||||||
import { name } from '@jsdoc/core';
|
import { name } from '@jsdoc/core';
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ function stripModuleNamespace(docletName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Core JSDoc tags that are shared with other tag dictionaries.
|
// Core JSDoc tags that are shared with other tag dictionaries.
|
||||||
export const getTags = (deps) => ({
|
export const getTags = (env) => ({
|
||||||
abstract: {
|
abstract: {
|
||||||
mustNotHaveValue: true,
|
mustNotHaveValue: true,
|
||||||
onTagged(doclet) {
|
onTagged(doclet) {
|
||||||
@ -296,12 +297,12 @@ export const getTags = (deps) => ({
|
|||||||
},
|
},
|
||||||
inner: {
|
inner: {
|
||||||
onTagged(doclet, tag) {
|
onTagged(doclet, tag) {
|
||||||
util.setDocletScopeToTitle(doclet, tag, deps);
|
util.setDocletScopeToTitle(doclet, tag, env);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
instance: {
|
instance: {
|
||||||
onTagged(doclet, tag) {
|
onTagged(doclet, tag) {
|
||||||
util.setDocletScopeToTitle(doclet, tag, deps);
|
util.setDocletScopeToTitle(doclet, tag, env);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
interface: {
|
interface: {
|
||||||
@ -495,7 +496,7 @@ export const getTags = (deps) => ({
|
|||||||
},
|
},
|
||||||
static: {
|
static: {
|
||||||
onTagged(doclet, tag) {
|
onTagged(doclet, tag) {
|
||||||
util.setDocletScopeToTitle(doclet, tag, deps);
|
util.setDocletScopeToTitle(doclet, tag, env);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
|
|||||||
@ -74,13 +74,10 @@ export function setDocletKindToTitle(doclet, { title }) {
|
|||||||
doclet.addTag('kind', title);
|
doclet.addTag('kind', title);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setDocletScopeToTitle(doclet, { title }, deps) {
|
export function setDocletScopeToTitle(doclet, { title }, { log }) {
|
||||||
let log;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
doclet.setScope(title);
|
doclet.setScope(title);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log = deps.get('log');
|
|
||||||
log.error(e.message);
|
log.error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,8 +120,7 @@ export function setNameToFile(doclet) {
|
|||||||
let docletName;
|
let docletName;
|
||||||
|
|
||||||
if (doclet.meta.filename) {
|
if (doclet.meta.filename) {
|
||||||
docletName =
|
docletName = filepathMinusPrefix(doclet.meta.path, doclet.env) + doclet.meta.filename;
|
||||||
filepathMinusPrefix(doclet.meta.path, doclet.dependencies.get('env')) + doclet.meta.filename;
|
|
||||||
doclet.addTag('name', docletName);
|
doclet.addTag('name', docletName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +149,7 @@ export function setDocletNameToFilename(doclet) {
|
|||||||
let docletName = '';
|
let docletName = '';
|
||||||
|
|
||||||
if (doclet.meta.path) {
|
if (doclet.meta.path) {
|
||||||
docletName = filepathMinusPrefix(doclet.meta.path, doclet.dependencies.get('env'));
|
docletName = filepathMinusPrefix(doclet.meta.path, doclet.env);
|
||||||
}
|
}
|
||||||
// TODO: Drop the file extension regardless of what it is.
|
// TODO: Drop the file extension regardless of what it is.
|
||||||
docletName += doclet.meta.filename.replace(/\.js$/i, '');
|
docletName += doclet.meta.filename.replace(/\.js$/i, '');
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { name } from '@jsdoc/core';
|
import { name } from '@jsdoc/core';
|
||||||
import { inline } from '@jsdoc/tag';
|
import { inline } from '@jsdoc/tag';
|
||||||
import catharsis from 'catharsis';
|
import catharsis from 'catharsis';
|
||||||
@ -60,8 +61,8 @@ function getNamespace(kind, dictionary) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatNameForLink(doclet, dependencies) {
|
function formatNameForLink(doclet, env) {
|
||||||
const dictionary = dependencies.get('tags');
|
const dictionary = env.tags;
|
||||||
let newName =
|
let newName =
|
||||||
getNamespace(doclet.kind, dictionary) + (doclet.name || '') + (doclet.variation || '');
|
getNamespace(doclet.kind, dictionary) + (doclet.name || '') + (doclet.variation || '');
|
||||||
const scopePunc = SCOPE_TO_PUNC[doclet.scope] || '';
|
const scopePunc = SCOPE_TO_PUNC[doclet.scope] || '';
|
||||||
@ -112,11 +113,11 @@ function makeUniqueFilename(filename, str) {
|
|||||||
*
|
*
|
||||||
* @function
|
* @function
|
||||||
* @param {string} str The string to convert.
|
* @param {string} str The string to convert.
|
||||||
* @param {Object} dependencies The JSDoc dependency container.
|
* @param {Object} env The JSDoc environment.
|
||||||
* @return {string} The filename to use for the string.
|
* @return {string} The filename to use for the string.
|
||||||
*/
|
*/
|
||||||
export function getUniqueFilename(str, dependencies) {
|
export function getUniqueFilename(str, env) {
|
||||||
const dictionary = dependencies.get('tags');
|
const dictionary = env.tags;
|
||||||
const namespaces = dictionary.getNamespaces().join('|');
|
const namespaces = dictionary.getNamespaces().join('|');
|
||||||
let basename = (str || '')
|
let basename = (str || '')
|
||||||
// use - instead of : in namespace prefixes
|
// use - instead of : in namespace prefixes
|
||||||
@ -145,13 +146,13 @@ export function getUniqueFilename(str, dependencies) {
|
|||||||
* register the filename.
|
* register the filename.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function getFilename(longname, dependencies) {
|
function getFilename(longname, env) {
|
||||||
let fileUrl;
|
let fileUrl;
|
||||||
|
|
||||||
if (Object.hasOwn(longnameToUrl, longname)) {
|
if (Object.hasOwn(longnameToUrl, longname)) {
|
||||||
fileUrl = longnameToUrl[longname];
|
fileUrl = longnameToUrl[longname];
|
||||||
} else {
|
} else {
|
||||||
fileUrl = getUniqueFilename(longname, dependencies);
|
fileUrl = getUniqueFilename(longname, env);
|
||||||
registerLink(longname, fileUrl);
|
registerLink(longname, fileUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,9 +380,9 @@ export function linkto(longname, linkText, cssClass, fragmentId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function useMonospace(tag, text, dependencies) {
|
function useMonospace(tag, text, env) {
|
||||||
let cleverLinks;
|
let cleverLinks;
|
||||||
const config = dependencies.get('config');
|
const config = env.config;
|
||||||
let monospaceLinks;
|
let monospaceLinks;
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
@ -434,8 +435,8 @@ function splitLinkText(text) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldShortenLongname(dependencies) {
|
function shouldShortenLongname(env) {
|
||||||
const config = dependencies.get('config');
|
const config = env.config;
|
||||||
|
|
||||||
if (config && config.templates && config.templates.useShortNamesInLinks) {
|
if (config && config.templates && config.templates.useShortNamesInLinks) {
|
||||||
return true;
|
return true;
|
||||||
@ -448,10 +449,10 @@ function shouldShortenLongname(dependencies) {
|
|||||||
* Find `{@link ...}` inline tags and turn them into HTML links.
|
* Find `{@link ...}` inline tags and turn them into HTML links.
|
||||||
*
|
*
|
||||||
* @param {string} str - The string to search for `{@link ...}` tags.
|
* @param {string} str - The string to search for `{@link ...}` tags.
|
||||||
* @param {object} dependencies - The JSDoc dependencies container.
|
* @param {object} env - The JSDoc environment.
|
||||||
* @return {string} The linkified text.
|
* @return {string} The linkified text.
|
||||||
*/
|
*/
|
||||||
export function resolveLinks(str, dependencies) {
|
export function resolveLinks(str, env) {
|
||||||
let replacers;
|
let replacers;
|
||||||
|
|
||||||
function extractLeadingText(string, completeTag) {
|
function extractLeadingText(string, completeTag) {
|
||||||
@ -490,14 +491,14 @@ export function resolveLinks(str, dependencies) {
|
|||||||
target = split.target;
|
target = split.target;
|
||||||
linkText = linkText || split.linkText;
|
linkText = linkText || split.linkText;
|
||||||
|
|
||||||
monospace = useMonospace(tag, text, dependencies);
|
monospace = useMonospace(tag, text, env);
|
||||||
|
|
||||||
return string.replace(
|
return string.replace(
|
||||||
completeTag,
|
completeTag,
|
||||||
buildLink(target, linkText, {
|
buildLink(target, linkText, {
|
||||||
linkMap: longnameToUrl,
|
linkMap: longnameToUrl,
|
||||||
monospace: monospace,
|
monospace: monospace,
|
||||||
shortenName: shouldShortenLongname(dependencies),
|
shortenName: shouldShortenLongname(env),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -832,11 +833,11 @@ export function addEventListeners(data) {
|
|||||||
* + Members tagged `@private`, unless the `private` option is enabled.
|
* + Members tagged `@private`, unless the `private` option is enabled.
|
||||||
* + Members tagged with anything other than specified by the `access` options.
|
* + Members tagged with anything other than specified by the `access` options.
|
||||||
* @param {TAFFY} data The TaffyDB database to prune.
|
* @param {TAFFY} data The TaffyDB database to prune.
|
||||||
* @param {object} dependencies The JSDoc dependencies container.
|
* @param {object} env The JSDoc environment.
|
||||||
* @return {TAFFY} The pruned database.
|
* @return {TAFFY} The pruned database.
|
||||||
*/
|
*/
|
||||||
export function prune(data, dependencies) {
|
export function prune(data, env) {
|
||||||
const options = dependencies.get('options');
|
const options = env.options;
|
||||||
|
|
||||||
data({ undocumented: true }).remove();
|
data({ undocumented: true }).remove();
|
||||||
data({ ignore: true }).remove();
|
data({ ignore: true }).remove();
|
||||||
@ -876,10 +877,10 @@ export function prune(data, dependencies) {
|
|||||||
* represents a method), the URL will consist of a filename and a fragment ID.
|
* represents a method), the URL will consist of a filename and a fragment ID.
|
||||||
*
|
*
|
||||||
* @param {module:@jsdoc/doclet.Doclet} doclet - The doclet that will be used to create the URL.
|
* @param {module:@jsdoc/doclet.Doclet} doclet - The doclet that will be used to create the URL.
|
||||||
* @param {Object} dependencies - The JSDoc dependency container.
|
* @param {Object} env - The JSDoc environment.
|
||||||
* @return {string} The URL to the generated documentation for the doclet.
|
* @return {string} The URL to the generated documentation for the doclet.
|
||||||
*/
|
*/
|
||||||
export function createLink(doclet, dependencies) {
|
export function createLink(doclet, env) {
|
||||||
let fakeContainer;
|
let fakeContainer;
|
||||||
let filename;
|
let filename;
|
||||||
let fileUrl;
|
let fileUrl;
|
||||||
@ -900,21 +901,21 @@ export function createLink(doclet, dependencies) {
|
|||||||
|
|
||||||
// the doclet gets its own HTML file
|
// the doclet gets its own HTML file
|
||||||
if (containers.includes(doclet.kind) || isModuleExports(doclet)) {
|
if (containers.includes(doclet.kind) || isModuleExports(doclet)) {
|
||||||
filename = getFilename(longname, dependencies);
|
filename = getFilename(longname, env);
|
||||||
}
|
}
|
||||||
// mistagged version of a doclet that gets its own HTML file
|
// mistagged version of a doclet that gets its own HTML file
|
||||||
else if (!containers.includes(doclet.kind) && fakeContainer) {
|
else if (!containers.includes(doclet.kind) && fakeContainer) {
|
||||||
filename = getFilename(doclet.memberof || longname, dependencies);
|
filename = getFilename(doclet.memberof || longname, env);
|
||||||
if (doclet.name !== doclet.longname) {
|
if (doclet.name !== doclet.longname) {
|
||||||
fragment = formatNameForLink(doclet, dependencies);
|
fragment = formatNameForLink(doclet, env);
|
||||||
fragment = getId(longname, fragment);
|
fragment = getId(longname, fragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// the doclet is within another HTML file
|
// the doclet is within another HTML file
|
||||||
else {
|
else {
|
||||||
filename = getFilename(doclet.memberof || globalName, dependencies);
|
filename = getFilename(doclet.memberof || globalName, env);
|
||||||
if (doclet.name !== doclet.longname || doclet.scope === SCOPE.NAMES.GLOBAL) {
|
if (doclet.name !== doclet.longname || doclet.scope === SCOPE.NAMES.GLOBAL) {
|
||||||
fragment = formatNameForLink(doclet, dependencies);
|
fragment = formatNameForLink(doclet, env);
|
||||||
fragment = getId(longname, fragment);
|
fragment = getId(longname, fragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1588,7 +1588,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
describe('createLink', () => {
|
describe('createLink', () => {
|
||||||
it('should create a url for a simple global.', () => {
|
it('should create a url for a simple global.', () => {
|
||||||
const mockDoclet = {
|
const mockDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'foo',
|
longname: 'foo',
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
@ -1601,7 +1601,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should create a url for a namespace.', () => {
|
it('should create a url for a namespace.', () => {
|
||||||
const mockDoclet = {
|
const mockDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'namespace',
|
kind: 'namespace',
|
||||||
longname: 'foo',
|
longname: 'foo',
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
@ -1613,7 +1613,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should create a url for a member of a namespace.', () => {
|
it('should create a url for a member of a namespace.', () => {
|
||||||
const mockDoclet = {
|
const mockDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'ns.foo',
|
longname: 'ns.foo',
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
@ -1625,7 +1625,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const nestedNamespaceDoclet = {
|
const nestedNamespaceDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'ns1.ns2.foo',
|
longname: 'ns1.ns2.foo',
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
@ -1647,7 +1647,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should create a url for a name with invalid characters.', () => {
|
it('should create a url for a name with invalid characters.', () => {
|
||||||
const mockDoclet = {
|
const mockDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'ns1."!"."*foo"',
|
longname: 'ns1."!"."*foo"',
|
||||||
name: '"*foo"',
|
name: '"*foo"',
|
||||||
@ -1660,7 +1660,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should create a url for a function that is the only symbol exported by a module.', () => {
|
it('should create a url for a function that is the only symbol exported by a module.', () => {
|
||||||
const mockDoclet = {
|
const mockDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'module:bar',
|
longname: 'module:bar',
|
||||||
name: 'module:bar',
|
name: 'module:bar',
|
||||||
@ -1672,13 +1672,13 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should create a url for a doclet with the wrong kind (caused by incorrect JSDoc tags', () => {
|
it('should create a url for a doclet with the wrong kind (caused by incorrect JSDoc tags', () => {
|
||||||
const moduleDoclet = {
|
const moduleDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'module',
|
kind: 'module',
|
||||||
longname: 'module:baz',
|
longname: 'module:baz',
|
||||||
name: 'module:baz',
|
name: 'module:baz',
|
||||||
};
|
};
|
||||||
const badDoclet = {
|
const badDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'member',
|
kind: 'member',
|
||||||
longname: 'module:baz',
|
longname: 'module:baz',
|
||||||
name: 'module:baz',
|
name: 'module:baz',
|
||||||
@ -1692,13 +1692,13 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should create a url for a function that is a member of a doclet with the wrong kind', () => {
|
it('should create a url for a function that is a member of a doclet with the wrong kind', () => {
|
||||||
const badModuleDoclet = {
|
const badModuleDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'member',
|
kind: 'member',
|
||||||
longname: 'module:qux',
|
longname: 'module:qux',
|
||||||
name: 'module:qux',
|
name: 'module:qux',
|
||||||
};
|
};
|
||||||
const memberDoclet = {
|
const memberDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
name: 'frozzle',
|
name: 'frozzle',
|
||||||
memberof: 'module:qux',
|
memberof: 'module:qux',
|
||||||
@ -1714,7 +1714,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should include the scope punctuation in the fragment ID for static members', () => {
|
it('should include the scope punctuation in the fragment ID for static members', () => {
|
||||||
const functionDoclet = {
|
const functionDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'Milk.pasteurize',
|
longname: 'Milk.pasteurize',
|
||||||
name: 'pasteurize',
|
name: 'pasteurize',
|
||||||
@ -1728,7 +1728,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should include the scope punctuation in the fragment ID for inner members', () => {
|
it('should include the scope punctuation in the fragment ID for inner members', () => {
|
||||||
const functionDoclet = {
|
const functionDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'Milk~removeSticksAndLeaves',
|
longname: 'Milk~removeSticksAndLeaves',
|
||||||
name: 'removeSticksAndLeaves',
|
name: 'removeSticksAndLeaves',
|
||||||
@ -1742,7 +1742,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should omit the scope punctuation from the fragment ID for instance members', () => {
|
it('should omit the scope punctuation from the fragment ID for instance members', () => {
|
||||||
const propertyDoclet = {
|
const propertyDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'member',
|
kind: 'member',
|
||||||
longname: 'Milk#calcium',
|
longname: 'Milk#calcium',
|
||||||
name: 'calcium',
|
name: 'calcium',
|
||||||
@ -1756,7 +1756,7 @@ describe('@jsdoc/template-legacy/lib/templateHelper', () => {
|
|||||||
|
|
||||||
it('should include the variation, if present, in the fragment ID', () => {
|
it('should include the variation, if present, in the fragment ID', () => {
|
||||||
const variationDoclet = {
|
const variationDoclet = {
|
||||||
dependencies: jsdoc.env,
|
env: jsdoc.env,
|
||||||
kind: 'function',
|
kind: 'function',
|
||||||
longname: 'Milk#fat(percent)',
|
longname: 'Milk#fat(percent)',
|
||||||
name: 'fat',
|
name: 'fat',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user