A collection of functions relating to JSDoc symbol name manipulation.
Members
staticconstantLONGNAMES string
Longnames that have a special meaning in JSDoc.
Properties:
Name | Type | Description |
---|---|---|
ANONYMOUS |
string | Longname used for doclets that do not have a longname, such as anonymous functions. |
GLOBAL |
string | Longname that represents global scope. |
staticconstantSCOPE string
Names and punctuation marks that identify doclet scopes.
Properties:
Name | Type | Description |
---|---|---|
NAMES |
string | |
PUNC |
string |
Methods
staticapplyNamespace(longname, ns) → string
Parameters:
Name | Type | Description |
---|---|---|
longname
|
string | The full longname of the symbol. |
ns
|
string | The namespace to be applied. |
Returns:
The longname with the namespace applied.
- Type:
- string
staticgetBasename(name) → string
Parameters:
Name | Type | Description |
---|---|---|
name
|
string | The symbol's longname. |
Returns:
The symbol's basename.
- Type:
- string
statichasAncestor(parent, child) → boolean
Check whether a parent longname is an ancestor of a child longname.
Parameters:
Name | Type | Description |
---|---|---|
parent
|
string | The parent longname. |
child
|
string | The child longname. |
Returns:
true
if the parent is an ancestor of the child; otherwise, false
.
- Type:
- boolean
staticlongnamesToTree(longnames, doclets) → Object
Convert an array of doclet longnames into a tree structure, optionally attaching doclets to the
tree.
Each level of the tree is an object with the following properties:
longname {string}
: The longname.memberof {string?}
: The memberof.scope {string?}
: The longname's scope, represented as a punctuation mark (for example,#
for instance and.
for static).name {string}
: The short name.doclet {Object?}
: The doclet associated with the longname, ornull
if the doclet was not
provided.children {Object?}
: The children of the current longname. Not present if there are no
children.
For example, suppose you have the following array of doclet longnames:
[
"module:a",
"module:a/b",
"myNamespace",
"myNamespace.Foo",
"myNamespace.Foo#bar"
]
This method converts these longnames to the following tree:
{
"module:a": {
"longname": "module:a",
"memberof": "",
"scope": "",
"name": "module:a",
"doclet": null,
"children": {
"/b": {
"longname": "module:a/b",
"memberof": "module:a",
"scope": "/",
"name": "b",
"doclet": null
}
}
},
"myNamespace": {
"longname": "myNamespace",
"memberof": "",
"scope": "",
"name": "myNamespace",
"doclet": null,
"children": {
".Foo": {
"longname": "myNamespace.Foo",
"memberof": "myNamespace",
"scope": ".",
"name": "Foo",
"doclet": null,
"children": {
"#bar": {
"longname": "myNamespace.Foo#bar",
"memberof": "myNamespace.Foo",
"scope": "#",
"name": "bar",
"doclet": null
}
}
}
}
}
}
Parameters:
Name | Type | Description |
---|---|---|
longnames
|
string[] | The longnames to convert into a tree. |
doclets
|
Object.<string, module:jsdoc/doclet.Doclet> | The doclets to attach to a tree. |
Returns:
A tree with information about each longname in the format shown above.
- Type:
- Object
staticresolve(doclet)
Resolves the longname, memberof, variation and name values of the given doclet.
Parameters:
Name | Type | Description |
---|---|---|
doclet
|
module:jsdoc/doclet.Doclet |
staticshorten(longname, forcedMemberof) → object
Given a longname like "a.b#c(2)", slice it up into an object containing the memberof, the scope,
the name, and variation.
Parameters:
Name | Type | Description |
---|---|---|
longname
|
string | |
forcedMemberof
|
string |
Returns:
Representing the properties of the given name.
- Type:
- object
staticsplitName(nameDesc) → object
Split a string that starts with a name and ends with a description into its parts.
Parameters:
Name | Type | Description |
---|---|---|
nameDesc
|
string |
Returns:
Hash with "name" and "description" properties.
- Type:
- object
innersplitNameMatchingBrackets(nameDesc) → object
Split a string that starts with a name and ends with a description into its parts. Allows the
defaultvalue (if present) to contain brackets. If the name is found to have mismatched brackets,
null is returned.
Parameters:
Name | Type | Description |
---|---|---|
nameDesc
|
string |
Returns:
Hash with "name" and "description" properties.
- Type:
- object