mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
fix(jsdoc-name): don't mangle names like prototypeMethod
This commit is contained in:
parent
13cdfd18b7
commit
053ace645b
@ -114,7 +114,8 @@ export function prototypeToPunc(name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
return name.replace(/(?:^|\.)prototype\.?/g, SCOPE.PUNC.INSTANCE);
|
||||
// If there's a trailing open bracket ([), as in `Foo.prototype['bar']`, keep it.
|
||||
return name.replace(/(?:^|\.)prototype(?:$|\.|(\[))/g, `${SCOPE.PUNC.INSTANCE}$1`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
3
packages/jsdoc/test/fixtures/specialnames.js
vendored
3
packages/jsdoc/test/fixtures/specialnames.js
vendored
@ -12,3 +12,6 @@ var prototype = {
|
||||
|
||||
/** document me */
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
/** document me */
|
||||
function prototypeMethod() {}
|
||||
|
||||
@ -20,6 +20,7 @@ describe('documenting symbols with special names', () => {
|
||||
const hasOwnProp = docSet.getByLongname('hasOwnProperty')[0];
|
||||
const proto = docSet.getByLongname('prototype')[0];
|
||||
const protoValueOf = docSet.getByLongname('prototype.valueOf')[0];
|
||||
const protoMethod = docSet.getByLongname('prototypeMethod')[0];
|
||||
|
||||
it('When a symbol is named "constructor", the symbol should appear in the docs.', () => {
|
||||
expect(construct).toBeObject();
|
||||
@ -40,4 +41,8 @@ describe('documenting symbols with special names', () => {
|
||||
it('When a symbol is named "prototype", its members are resolved correctly.', () => {
|
||||
expect(protoValueOf).toBeObject();
|
||||
});
|
||||
|
||||
it('preserves names that start with `prototype`', () => {
|
||||
expect(protoMethod).toBeObject();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user