diff --git a/packages/jsdoc-core/lib/name.js b/packages/jsdoc-core/lib/name.js index f640cff8..2a3f55c8 100644 --- a/packages/jsdoc-core/lib/name.js +++ b/packages/jsdoc-core/lib/name.js @@ -410,7 +410,7 @@ function splitLongname(longname, options) { * ``` * * @param {Array} longnames - The longnames to convert into a tree. - * @param {Object} doclets - The doclets to attach to a tree. + * @param {Object} doclets - The doclets to attach to a tree. * Each property should be the longname of a doclet, and each value should be the doclet for that * longname. * @return {Object} A tree with information about each longname in the format shown above. diff --git a/packages/jsdoc-doclet/index.js b/packages/jsdoc-doclet/index.js index d076e2f3..200908e7 100644 --- a/packages/jsdoc-doclet/index.js +++ b/packages/jsdoc-doclet/index.js @@ -13,10 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. */ +const { combine: combineDoclets, Doclet } = require('./lib/doclet'); const { Package } = require('./lib/package'); const schema = require('./lib/schema'); module.exports = { + combineDoclets, + Doclet, Package, schema, }; diff --git a/packages/jsdoc/lib/jsdoc/doclet.js b/packages/jsdoc-doclet/lib/doclet.js similarity index 95% rename from packages/jsdoc/lib/jsdoc/doclet.js rename to packages/jsdoc-doclet/lib/doclet.js index 42d2c8ff..083a4cd1 100644 --- a/packages/jsdoc/lib/jsdoc/doclet.js +++ b/packages/jsdoc-doclet/lib/doclet.js @@ -13,9 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -/** - * @module jsdoc/doclet - */ const _ = require('lodash'); const { isFunction } = require('@jsdoc/ast').astNode; const { @@ -288,7 +285,7 @@ function removeGlobal(longname) { * Get the full path to the source file that is associated with a doclet. * * @private - * @param {module:jsdoc/doclet.Doclet} The doclet to check for a filepath. + * @param {module:@jsdoc/doclet.Doclet} The doclet to check for a filepath. * @return {string} The path to the doclet's source file, or an empty string if the path is not * available. */ @@ -323,9 +320,9 @@ function clone(source, target, properties) { * the primary doclet over the secondary doclet. * * @private - * @param {module:jsdoc/doclet.Doclet} primary - The primary doclet. - * @param {module:jsdoc/doclet.Doclet} secondary - The secondary doclet. - * @param {module:jsdoc/doclet.Doclet} target - The doclet to which properties will be copied. + * @param {module:@jsdoc/doclet.Doclet} primary - The primary doclet. + * @param {module:@jsdoc/doclet.Doclet} secondary - The secondary doclet. + * @param {module:@jsdoc/doclet.Doclet} target - The doclet to which properties will be copied. * @param {Array.} exclude - The names of properties to exclude from copying. */ function copyMostProperties(primary, secondary, target, exclude) { @@ -345,9 +342,9 @@ function copyMostProperties(primary, secondary, target, exclude) { * doclet. * * @private - * @param {module:jsdoc/doclet.Doclet} primary - The primary doclet. - * @param {module:jsdoc/doclet.Doclet} secondary - The secondary doclet. - * @param {module:jsdoc/doclet.Doclet} target - The doclet to which properties will be copied. + * @param {module:@jsdoc/doclet.Doclet} primary - The primary doclet. + * @param {module:@jsdoc/doclet.Doclet} secondary - The secondary doclet. + * @param {module:@jsdoc/doclet.Doclet} target - The doclet to which properties will be copied. * @param {Array.} include - The names of properties to copy. */ function copySpecificProperties(primary, secondary, target, include) { @@ -367,7 +364,7 @@ function copySpecificProperties(primary, secondary, target, include) { /** * Represents a single JSDoc comment. * - * @alias module:jsdoc/doclet.Doclet + * @alias module:@jsdoc/doclet.Doclet */ class Doclet { /** @@ -657,10 +654,10 @@ exports.Doclet = Doclet; /** * Combine two doclets into a new doclet. * - * @param {module:jsdoc/doclet.Doclet} primary - The doclet whose properties will be used. - * @param {module:jsdoc/doclet.Doclet} secondary - The doclet to use as a fallback for properties + * @param {module:@jsdoc/doclet.Doclet} primary - The doclet whose properties will be used. + * @param {module:@jsdoc/doclet.Doclet} secondary - The doclet to use as a fallback for properties * that the primary doclet does not have. - * @returns {module:jsdoc/doclet.Doclet} A new doclet that combines the primary and secondary + * @returns {module:@jsdoc/doclet.Doclet} A new doclet that combines the primary and secondary * doclets. */ exports.combine = (primary, secondary) => { diff --git a/packages/jsdoc/test/specs/jsdoc/doclet.js b/packages/jsdoc-doclet/test/specs/doclet.js similarity index 86% rename from packages/jsdoc/test/specs/jsdoc/doclet.js rename to packages/jsdoc-doclet/test/specs/doclet.js index fc7089f5..e141700c 100644 --- a/packages/jsdoc/test/specs/jsdoc/doclet.js +++ b/packages/jsdoc-doclet/test/specs/doclet.js @@ -13,10 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ -describe('jsdoc/doclet', () => { +/* global jsdoc */ +describe('@jsdoc/doclet/lib/doclet', () => { // TODO: more tests const _ = require('lodash'); - const doclet = require('jsdoc/doclet'); + const doclet = require('../../lib/doclet'); const Doclet = doclet.Doclet; const { SCOPE } = require('@jsdoc/core').name; @@ -47,9 +48,9 @@ describe('jsdoc/doclet', () => { expect(descriptor.enumerable).toBeFalse(); }); - // TODO(hegemonic): more tests (namespaces, modules, etc.) + // TODO: more tests (namespaces, modules, etc.) describe('name resolution', () => { - // TODO(hegemonic): Load fixtures instead of creating doclets manually + // TODO: Load fixtures instead of creating doclets manually function makeDoclet(tagStrings) { const comment = `/**\n${tagStrings.join('\n')}\n*/`; @@ -57,7 +58,7 @@ describe('jsdoc/doclet', () => { } describe('aliases', () => { - // TODO(hegemonic): This comment implies that we _don't_ need to set doclet.name... + // TODO: This comment implies that we _don't_ need to set doclet.name... // If `doclet.alias` is defined, `doclet.name` will be set to the same value by the // time the test runs. Therefore, we set both `@alias` and `@name` in these tests. it('can resolve aliases that identify instance members', () => { @@ -185,7 +186,7 @@ describe('jsdoc/doclet', () => { expect(newDoclet.longname).toBe('MyClass.event:A'); }); - // TODO(hegemonic): This only works if you resolve the names twice. As it happens, + // TODO: This only works if you resolve the names twice. As it happens, // JSDoc does that, because it calls `Doclet#postProcess` twice, so this works in // practice. But you shouldn't have to resolve the names twice... xit('@event @name MyClass.EventName @memberof somethingelse works', () => { @@ -198,7 +199,7 @@ describe('jsdoc/doclet', () => { }); describe('module members', () => { - // TODO(hegemonic): This only works if you resolve the names twice. As it happens, + // TODO: This only works if you resolve the names twice. As it happens, // JSDoc does that, because it calls `Doclet#postProcess` twice, so this works in // practice. But you shouldn't have to resolve the names twice... xit('@name @function @memberof works', () => { @@ -218,7 +219,7 @@ describe('jsdoc/doclet', () => { }); describe('setScope', () => { - it('should accept the correct scope names', () => { + it('accepts the correct scope names', () => { function setScope(scopeName) { const newDoclet = new Doclet('/** Huzzah, a doclet! */', null, jsdoc.deps); @@ -230,7 +231,7 @@ describe('jsdoc/doclet', () => { }); }); - it('should throw an error for invalid scope names', () => { + it('throws an error for invalid scope names', () => { function setScope() { const newDoclet = new Doclet('/** Woe betide this doclet. */', null, jsdoc.deps); @@ -242,7 +243,7 @@ describe('jsdoc/doclet', () => { }); describe('combine', () => { - it('should override most properties of the secondary doclet', () => { + it('overrides most properties of the secondary doclet', () => { const primaryDoclet = new Doclet( '/** New and improved!\n@version 2.0.0 */', null, @@ -256,7 +257,7 @@ describe('jsdoc/doclet', () => { }); }); - it('should add properties that are missing from the secondary doclet', () => { + it('adds properties from the secondary doclet that are missing', () => { const primaryDoclet = new Doclet('/** Hello!\n@version 2.0.0 */', null, jsdoc.deps); const secondaryDoclet = new Doclet('/** Hello! */', null, jsdoc.deps); const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); @@ -267,27 +268,23 @@ describe('jsdoc/doclet', () => { describe('params and properties', () => { const properties = ['params', 'properties']; - it( - "should use the secondary doclet's params and properties if the primary doclet " + - 'had none', - () => { - const primaryDoclet = new Doclet('/** Hello! */', null, jsdoc.deps); - const secondaryComment = [ - '/**', - ' * @param {string} foo - The foo.', - ' * @property {number} bar - The bar.', - ' */', - ].join('\n'); - const secondaryDoclet = new Doclet(secondaryComment, null, jsdoc.deps); - const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); + it('uses params and properties from the secondary doclet if the primary lacks them', () => { + const primaryDoclet = new Doclet('/** Hello! */', null, jsdoc.deps); + const secondaryComment = [ + '/**', + ' * @param {string} foo - The foo.', + ' * @property {number} bar - The bar.', + ' */', + ].join('\n'); + const secondaryDoclet = new Doclet(secondaryComment, null, jsdoc.deps); + const newDoclet = doclet.combine(primaryDoclet, secondaryDoclet); - properties.forEach((property) => { - expect(newDoclet[property]).toEqual(secondaryDoclet[property]); - }); - } - ); + properties.forEach((property) => { + expect(newDoclet[property]).toEqual(secondaryDoclet[property]); + }); + }); - it("should use the primary doclet's params and properties if the primary doclet has some", () => { + it('uses params and properties from the primary doclet, if present', () => { const primaryComment = [ '/**', ' * @param {number} baz - The baz.', diff --git a/packages/jsdoc-doclet/test/specs/index.js b/packages/jsdoc-doclet/test/specs/index.js index 7d0fa503..80567f8a 100644 --- a/packages/jsdoc-doclet/test/specs/index.js +++ b/packages/jsdoc-doclet/test/specs/index.js @@ -20,6 +20,22 @@ describe('@jsdoc/doclet', () => { expect(doclet).toBeObject(); }); + describe('combineDoclets', () => { + it('is lib/doclet.combine', () => { + const { combine } = require('../../lib/doclet'); + + expect(doclet.combineDoclets).toBe(combine); + }); + }); + + describe('Doclet', () => { + it('is lib/doclet.Doclet', () => { + const { Doclet } = require('../../lib/doclet'); + + expect(doclet.Doclet).toBe(Doclet); + }); + }); + describe('Package', () => { it('is lib/package.Package', () => { const { Package } = require('../../lib/package'); diff --git a/packages/jsdoc/lib/jsdoc/augment.js b/packages/jsdoc/lib/jsdoc/augment.js index 354ecd3a..487eabdc 100644 --- a/packages/jsdoc/lib/jsdoc/augment.js +++ b/packages/jsdoc/lib/jsdoc/augment.js @@ -20,9 +20,7 @@ const _ = require('lodash'); const { fromParts, SCOPE, toParts } = require('@jsdoc/core').name; -const jsdoc = { - doclet: require('jsdoc/doclet'), -}; +const { combineDoclets } = require('@jsdoc/doclet'); function mapDependencies(index, propertyName) { const dependencies = {}; @@ -142,8 +140,8 @@ function staticToInstance(doclet) { * from `Class2#myMethod`. * * @private - * @param {module:jsdoc/doclet.Doclet} doclet - The doclet to be added. - * @param {Array.} additions - An array of doclets that will be added to + * @param {module:@jsdoc/doclet.Doclet} doclet - The doclet to be added. + * @param {Array.} additions - An array of doclets that will be added to * another symbol. * @param {Object.} indexes - A dictionary of indexes into the `additions` array. * Each key is a longname, and each value is the index of the longname's doclet. @@ -164,8 +162,8 @@ function updateAddedDoclets(doclet, additions, indexes) { * Update the index of doclets whose `undocumented` property is not `true`. * * @private - * @param {module:jsdoc/doclet.Doclet} doclet - The doclet to be added to the index. - * @param {Object.>} documented - The index of doclets + * @param {module:@jsdoc/doclet.Doclet} doclet - The doclet to be added to the index. + * @param {Object.>} documented - The index of doclets * whose `undocumented` property is not `true`. * @return {void} */ @@ -181,8 +179,8 @@ function updateDocumentedDoclets(doclet, documented) { * Update the index of doclets with a `memberof` value. * * @private - * @param {module:jsdoc/doclet.Doclet} doclet - The doclet to be added to the index. - * @param {Object.>} memberof - The index of doclets + * @param {module:@jsdoc/doclet.Doclet} doclet - The doclet to be added to the index. + * @param {Object.>} memberof - The index of doclets * with a `memberof` value. * @return {void} */ @@ -263,7 +261,7 @@ function getInheritedAdditions(doclets, docs, { documented, memberof }) { childDoclet = {}; } - member = jsdoc.doclet.combine(childDoclet, parentDoclet); + member = combineDoclets(childDoclet, parentDoclet); if (!member.inherited) { member.inherits = member.longname; @@ -467,7 +465,7 @@ function getImplementedAdditions(implDoclets, allDoclets, { documented, memberof childDoclet = {}; } - implementationDoclet = jsdoc.doclet.combine(childDoclet, parentDoclet); + implementationDoclet = combineDoclets(childDoclet, parentDoclet); reparentDoclet(doclet, implementationDoclet); updateImplements(implementationDoclet, parentDoclet.longname); @@ -549,7 +547,7 @@ function augment(doclets, propertyName, docletFinder, jsdocDeps) { * For example, if `ClassA` has the instance method `myMethod`, and `ClassB` inherits from `ClassA`, * calling this method creates a new doclet for `ClassB#myMethod`. * - * @param {!Array.} doclets - The doclets generated by JSDoc. + * @param {!Array.} doclets - The doclets generated by JSDoc. * @param {!Object} doclets.index - The doclet index. * @return {void} */ @@ -568,7 +566,7 @@ exports.addInherited = (doclets) => { * + If `MixinA` has the static method `myMethod`, and `ClassA` mixes `MixinA`, calling this method * creates a new doclet for the instance method `ClassA#myMethod`. * - * @param {!Array.} doclets - The doclets generated by JSDoc. + * @param {!Array.} doclets - The doclets generated by JSDoc. * @param {!Object} doclets.index - The doclet index. * @return {void} */ @@ -589,7 +587,7 @@ exports.addMixedIn = (doclets) => { * If `ClassA#myMethod` used the `@override` or `@inheritdoc` tag, calling this method would also * generate a new doclet that reflects the interface's documentation for `InterfaceA#myMethod`. * - * @param {!Array.} docs - The doclets generated by JSDoc. + * @param {!Array.} docs - The doclets generated by JSDoc. * @param {!Object} doclets.index - The doclet index. * @return {void} */ diff --git a/packages/jsdoc/lib/jsdoc/src/handlers.js b/packages/jsdoc/lib/jsdoc/src/handlers.js index 34bda6f6..dbded308 100644 --- a/packages/jsdoc/lib/jsdoc/src/handlers.js +++ b/packages/jsdoc/lib/jsdoc/src/handlers.js @@ -16,7 +16,7 @@ /** * @module jsdoc/src/handlers */ -const { Doclet } = require('jsdoc/doclet'); +const { Doclet } = require('@jsdoc/doclet'); const escape = require('escape-string-regexp'); const { log } = require('@jsdoc/util'); const { SCOPE } = require('@jsdoc/core').name; diff --git a/packages/jsdoc/lib/jsdoc/src/parser.js b/packages/jsdoc/lib/jsdoc/src/parser.js index 939a47e4..22c99502 100644 --- a/packages/jsdoc/lib/jsdoc/src/parser.js +++ b/packages/jsdoc/lib/jsdoc/src/parser.js @@ -210,7 +210,7 @@ class Parser extends EventEmitter { // TODO: update docs /** - * @param {module:jsdoc/doclet.Doclet} doclet The parse result to add to the result buffer. + * @param {module:@jsdoc/doclet.Doclet} doclet The parse result to add to the result buffer. */ addResult(doclet) { const index = this._resultBuffer.index; @@ -332,7 +332,7 @@ class Parser extends EventEmitter { * Retrieve the most recently seen doclet that has the given longname. * * @param {string} longname - The longname to search for. - * @return {module:jsdoc/doclet.Doclet?} The most recent doclet for the longname. + * @return {module:@jsdoc/doclet.Doclet?} The most recent doclet for the longname. */ _getDocletByLongname(longname) { return this._byLongname.get(longname); @@ -437,7 +437,7 @@ class Parser extends EventEmitter { * Get the doclet for the lowest-level class, if any, that is in the scope chain for a given node. * * @param {Object} node - The node whose scope chain will be searched. - * @return {module:jsdoc/doclet.Doclet?} The doclet for the lowest-level class in the node's scope + * @return {module:@jsdoc/doclet.Doclet?} The doclet for the lowest-level class in the node's scope * chain. */ _getParentClass({ enclosingScope }) { @@ -559,7 +559,7 @@ class Parser extends EventEmitter { * this method returns multiple doclets (in this case, the doclets for `foo` and `exports.FOO`). * * @param {Object} node - An AST node representing an object property. - * @return {Array.} An array of doclets for the parent object or objects, or + * @return {Array.} An array of doclets for the parent object or objects, or * an empty array if no doclets are found. */ resolvePropertyParents({ parent }) { diff --git a/packages/jsdoc/lib/jsdoc/src/visitor.js b/packages/jsdoc/lib/jsdoc/src/visitor.js index 8549f41c..c09ee667 100644 --- a/packages/jsdoc/lib/jsdoc/src/visitor.js +++ b/packages/jsdoc/lib/jsdoc/src/visitor.js @@ -18,7 +18,7 @@ */ // TODO: consider exporting more stuff so users can override it const { astNode, Syntax } = require('@jsdoc/ast'); -const combineDoclets = require('jsdoc/doclet').combine; +const { combineDoclets } = require('@jsdoc/doclet'); const { getBasename, LONGNAMES } = require('@jsdoc/core').name; /** diff --git a/packages/jsdoc/lib/jsdoc/util/templateHelper.js b/packages/jsdoc/lib/jsdoc/util/templateHelper.js index b9171388..058b0963 100644 --- a/packages/jsdoc/lib/jsdoc/util/templateHelper.js +++ b/packages/jsdoc/lib/jsdoc/util/templateHelper.js @@ -165,7 +165,7 @@ function getFilename(longname, dependencies) { * `module.exports = function() {};`). * * @private - * @param {module:jsdoc/doclet.Doclet} doclet - The doclet for the symbol. + * @param {module:@jsdoc/doclet.Doclet} doclet - The doclet for the symbol. * @return {boolean} `true` if the symbol is the only symbol exported by a module; otherwise, * `false`. */ @@ -720,7 +720,7 @@ exports.getSignatureReturns = ({ yields, returns }, cssClass) => { * * @param {TAFFY} data - The TaffyDB database to search. * @param {Object} doclet - The doclet whose ancestors will be retrieved. - * @return {Array.} A array of ancestor doclets, sorted from most to + * @return {Array.} A array of ancestor doclets, sorted from most to * least distant. */ exports.getAncestors = (data, doclet) => { @@ -867,7 +867,7 @@ exports.prune = (data, dependencies) => { * If a doclet corresponds to a smaller portion of an output file (for example, if the doclet * 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. * @return {string} The URL to the generated documentation for the doclet. */ @@ -923,7 +923,7 @@ exports.createLink = (doclet, dependencies) => { * @function * @see module:@jsdoc/core.name.longnamesToTree * @param {Array} longnames - The longnames to convert into a tree. - * @param {Object} doclets - The doclets to attach to a tree. + * @param {Object} doclets - The doclets to attach to a tree. * Each property should be the longname of a doclet, and each value should be the doclet for that * longname. * @return {Object} A tree with information about each longname. diff --git a/packages/jsdoc/templates/default/publish.js b/packages/jsdoc/templates/default/publish.js index 883814a6..b17f28e8 100644 --- a/packages/jsdoc/templates/default/publish.js +++ b/packages/jsdoc/templates/default/publish.js @@ -299,9 +299,9 @@ function generateSourceFiles(sourceFiles, encoding, outdir, dependencies) { * for display purposes. This function mutates the original arrays. * * @private - * @param {Array.} doclets - The array of classes and functions to + * @param {Array.} doclets - The array of classes and functions to * check. - * @param {Array.} modules - The array of module doclets to search. + * @param {Array.} modules - The array of module doclets to search. */ function attachModuleSymbols(doclets, modules) { const symbols = {}; diff --git a/packages/jsdoc/test/specs/documentation/modules.js b/packages/jsdoc/test/specs/documentation/modules.js index 1fa3e42b..662ee080 100644 --- a/packages/jsdoc/test/specs/documentation/modules.js +++ b/packages/jsdoc/test/specs/documentation/modules.js @@ -40,7 +40,7 @@ describe('module names', () => { // Windows-specific test if (/^win/.test(require('os').platform())) { it('should always use forward slashes when creating a name from the file path', () => { - const { Doclet } = require('jsdoc/doclet'); + const { Doclet } = require('@jsdoc/doclet'); let doclet; env.sourceFiles = [ diff --git a/packages/jsdoc/test/specs/jsdoc/util/templateHelper.js b/packages/jsdoc/test/specs/jsdoc/util/templateHelper.js index 4ada6e83..14d225ad 100644 --- a/packages/jsdoc/test/specs/jsdoc/util/templateHelper.js +++ b/packages/jsdoc/test/specs/jsdoc/util/templateHelper.js @@ -18,7 +18,7 @@ describe('jsdoc/util/templateHelper', () => { const _ = require('lodash'); const { Dependencies } = require('@jsdoc/core'); const { Dictionary } = require('jsdoc/tag/dictionary'); - const doclet = require('jsdoc/doclet'); + const { Doclet } = require('@jsdoc/doclet'); const helper = require('jsdoc/util/templateHelper'); const { taffy } = require('@jsdoc/salty'); @@ -686,7 +686,7 @@ describe('jsdoc/util/templateHelper', () => { let attribs; it('should return an array', () => { - doc = new doclet.Doclet('/** ljklajsdf */', {}, jsdoc.deps); + doc = new Doclet('/** ljklajsdf */', {}, jsdoc.deps); attribs = helper.getAttribs(doc); expect(attribs).toBeEmptyArray(); @@ -698,7 +698,7 @@ describe('jsdoc/util/templateHelper', () => { function doTests(tests, whatNotToContain) { for (const src in tests) { if (Object.hasOwn(tests, src)) { - doc = new doclet.Doclet(`/** ${src} */`, {}, jsdoc.deps); + doc = new Doclet(`/** ${src} */`, {}, jsdoc.deps); attribs = helper.getAttribs(doc); if (tests[src]) { @@ -799,7 +799,7 @@ describe('jsdoc/util/templateHelper', () => { }); it('should detect multiple attributes', () => { - const fdsaFoo = new doclet.Doclet( + const fdsaFoo = new Doclet( '/** @const module:fdsa~FOO\n@readonly\n@private */', {}, jsdoc.deps @@ -835,14 +835,14 @@ describe('jsdoc/util/templateHelper', () => { // returns links to allowed types for a doclet. it('returns an empty array if the doclet has no specified type', () => { - const doc = new doclet.Doclet('/** @const ASDF */', {}, jsdoc.deps); + const doc = new Doclet('/** @const ASDF */', {}, jsdoc.deps); const types = helper.getSignatureTypes(doc); expect(types).toBeEmptyArray(); }); it("returns a string array of the doclet's types", () => { - const doc = new doclet.Doclet('/** @const {number|Array.} ASDF */', {}, jsdoc.deps); + const doc = new Doclet('/** @const {number|Array.} ASDF */', {}, jsdoc.deps); const types = helper.getSignatureTypes(doc); expect(types).toBeArrayOfSize(2); @@ -857,7 +857,7 @@ describe('jsdoc/util/templateHelper', () => { // make some links. helper.longnameToUrl.MyClass = 'MyClass.html'; - doc = new doclet.Doclet('/** @const {MyClass} ASDF */', {}, jsdoc.deps); + doc = new Doclet('/** @const {MyClass} ASDF */', {}, jsdoc.deps); types = helper.getSignatureTypes(doc); expect(types).toBeArrayOfSize(1); @@ -871,7 +871,7 @@ describe('jsdoc/util/templateHelper', () => { // make some links. helper.longnameToUrl.MyClass = 'MyClass.html'; - doc = new doclet.Doclet('/** @const {MyClass} ASDF */', {}, jsdoc.deps); + doc = new Doclet('/** @const {MyClass} ASDF */', {}, jsdoc.deps); types = helper.getSignatureTypes(doc, 'myCSSClass'); expect(types).toBeArrayOfSize(1); @@ -883,14 +883,14 @@ describe('jsdoc/util/templateHelper', () => { // retrieves parameter names. // if css class is provided, optional parameters are wrapped in a with that class. it('returns an empty array if the doclet has no specified type', () => { - const doc = new doclet.Doclet('/** @function myFunction */', {}, jsdoc.deps); + const doc = new Doclet('/** @function myFunction */', {}, jsdoc.deps); const params = helper.getSignatureParams(doc); expect(params).toBeEmptyArray(); }); it("returns a string array of the doclet's parameter names", () => { - const doc = new doclet.Doclet( + const doc = new Doclet( '/** @function myFunction\n @param {string} foo - asdf. */', {}, jsdoc.deps @@ -902,7 +902,7 @@ describe('jsdoc/util/templateHelper', () => { }); it('wraps optional parameters in if optClass is provided', () => { - const doc = new doclet.Doclet( + const doc = new Doclet( '/** @function myFunction\n' + ' * @param {boolean} foo - explanation.\n' + ' * @param {number} [bar=1] - another explanation.\n' + @@ -920,7 +920,7 @@ describe('jsdoc/util/templateHelper', () => { }); it("doesn't wrap optional parameters in if optClass is not provided", () => { - const doc = new doclet.Doclet( + const doc = new Doclet( '/** @function myFunction\n' + ' * @param {boolean} foo - explanation.\n' + ' * @param {number} [bar=1] - another explanation.\n' + @@ -960,14 +960,14 @@ describe('jsdoc/util/templateHelper', () => { }); it('returns an empty array if the doclet has no returns', () => { - const doc = new doclet.Doclet('/** @function myFunction */', {}, jsdoc.deps); + const doc = new Doclet('/** @function myFunction */', {}, jsdoc.deps); const returns = helper.getSignatureReturns(doc); expect(returns).toBeEmptyArray(); }); it('returns an empty array if the doclet has @returns but with no type', () => { - const doc = new doclet.Doclet( + const doc = new Doclet( '/** @function myFunction\n@returns an interesting result.*/', {}, jsdoc.deps @@ -978,14 +978,14 @@ describe('jsdoc/util/templateHelper', () => { }); it('uses the value of the `yields` property', () => { - const doc = new doclet.Doclet('/** @yields {string} A string. */', {}, jsdoc.deps); + const doc = new Doclet('/** @yields {string} A string. */', {}, jsdoc.deps); const html = helper.getSignatureReturns(doc); expect(html).toContain('string'); }); it('prefers `yields` over `returns`', () => { - const doc = new doclet.Doclet('/** @yields {string}\n@returns {number} */', {}, jsdoc.deps); + const doc = new Doclet('/** @yields {string}\n@returns {number} */', {}, jsdoc.deps); const html = helper.getSignatureReturns(doc); expect(html).toContain('string'); @@ -999,7 +999,7 @@ describe('jsdoc/util/templateHelper', () => { // make some links. helper.longnameToUrl.MyClass = 'MyClass.html'; - doc = new doclet.Doclet( + doc = new Doclet( '/** @function myFunction\n@returns {number|MyClass} an interesting result.*/', {}, jsdoc.deps @@ -1018,7 +1018,7 @@ describe('jsdoc/util/templateHelper', () => { // make some links. helper.longnameToUrl.MyClass = 'MyClass.html'; - doc = new doclet.Doclet( + doc = new Doclet( '/** @function myFunction\n@returns {number|MyClass} an interesting result.*/', {}, jsdoc.deps @@ -1037,18 +1037,18 @@ describe('jsdoc/util/templateHelper', () => { describe('getAncestorLinks', () => { // make a hierarchy. - const lackeys = new doclet.Doclet( + const lackeys = new Doclet( '/** @member lackeys\n@memberof module:mafia/gangs.Sharks~Henchman\n@instance*/', {}, jsdoc.deps ); - const henchman = new doclet.Doclet( + const henchman = new Doclet( '/** @class Henchman\n@memberof module:mafia/gangs.Sharks\n@inner */', {}, jsdoc.deps ); - const gang = new doclet.Doclet('/** @namespace module:mafia/gangs.Sharks */', {}, jsdoc.deps); - const mafia = new doclet.Doclet('/** @module mafia/gangs */', {}, jsdoc.deps); + const gang = new Doclet('/** @namespace module:mafia/gangs.Sharks */', {}, jsdoc.deps); + const mafia = new Doclet('/** @module mafia/gangs */', {}, jsdoc.deps); const data = taffy([lackeys, henchman, gang, mafia]); afterEach(() => { diff --git a/packages/jsdoc/test/specs/tags/lendstag.js b/packages/jsdoc/test/specs/tags/lendstag.js index 72d01b79..ccebcb9f 100644 --- a/packages/jsdoc/test/specs/tags/lendstag.js +++ b/packages/jsdoc/test/specs/tags/lendstag.js @@ -15,7 +15,7 @@ */ describe('@lends tag', () => { // see also specs/documentation/lends.js for tests on @lends behaviour. - const { Doclet } = require('jsdoc/doclet'); + const { Doclet } = require('@jsdoc/doclet'); const doc = new Doclet('/** @lends */', {}, jsdoc.deps); const doc2 = new Doclet('/** @lends MyClass# */', {}, jsdoc.deps); diff --git a/packages/jsdoc/test/specs/tags/overviewtag.js b/packages/jsdoc/test/specs/tags/overviewtag.js index 8ccc3d56..f12ea5fc 100644 --- a/packages/jsdoc/test/specs/tags/overviewtag.js +++ b/packages/jsdoc/test/specs/tags/overviewtag.js @@ -57,7 +57,7 @@ describe('@overview tag', () => { 'The name should not include the entire filepath when the source file is outside the ' + 'JSDoc directory', () => { - const Doclet = require('jsdoc/doclet').Doclet; + const { Doclet } = require('@jsdoc/doclet'); let doclet; let docletMeta;