-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(doc): error on comment undefined
- Loading branch information
1 parent
83011d6
commit c9883e5
Showing
4 changed files
with
56 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
const td = require("typedoc"); | ||
const td = require('typedoc'); | ||
const ts = td.TypeScript; | ||
|
||
/** @param {td.Application} app */ | ||
exports.load = function (app) { | ||
// Add decorator info to reflections | ||
// if you need parameters, you need app.converter.on(td.Converter.EVENT_CREATE_PARAMETER) | ||
app.converter.on(td.Converter.EVENT_CREATE_DECLARATION, addDecoratorInfo); | ||
// Add decorator info to reflections | ||
// if you need parameters, you need app.converter.on(td.Converter.EVENT_CREATE_PARAMETER) | ||
app.converter.on(td.Converter.EVENT_CREATE_DECLARATION, addDecoratorInfo); | ||
|
||
// Add decorator info to serialized json | ||
app.serializer.addSerializer({ | ||
priority: 0, | ||
supports(item) { | ||
return item instanceof td.DeclarationReflection; | ||
}, | ||
toObject(item, obj, _ser) { | ||
if (item.decorators) { | ||
obj.decorators = item.decorators; | ||
} | ||
return obj; | ||
}, | ||
}); | ||
// Add decorator info to serialized json | ||
app.serializer.addSerializer({ | ||
priority: 0, | ||
supports(item) { | ||
return item instanceof td.DeclarationReflection; | ||
}, | ||
toObject(item, obj, _ser) { | ||
if (item.decorators) { | ||
obj.decorators = item.decorators; | ||
} | ||
return obj; | ||
}, | ||
}); | ||
}; | ||
|
||
/** | ||
* @param {td.Context} context | ||
* @param {td.DeclarationReflection} decl | ||
*/ | ||
function addDecoratorInfo(context, decl) { | ||
const symbol = context.project.getSymbolFromReflection(decl); | ||
if (!symbol) { | ||
return; | ||
} | ||
const declaration = symbol.valueDeclaration; | ||
if (!declaration) { | ||
return; | ||
} | ||
if (!ts.isPropertyDeclaration(declaration) && !ts.isMethodDeclaration(declaration)) { | ||
return; | ||
} | ||
const symbol = context.project.getSymbolFromReflection(decl); | ||
if (!symbol) { | ||
return; | ||
} | ||
const declaration = symbol.valueDeclaration; | ||
if (!declaration) { | ||
return; | ||
} | ||
if (!ts.isPropertyDeclaration(declaration) && !ts.isMethodDeclaration(declaration)) { | ||
return; | ||
} | ||
|
||
const decorators = declaration.modifiers?.filter(ts.isDecorator); | ||
decl.decorators = decorators?.map((d) => { | ||
return { | ||
expression: d.getText(), | ||
escapedText: d.expression.expression.escapedText, | ||
}; | ||
}); | ||
} | ||
const decorators = declaration.modifiers?.filter(ts.isDecorator); | ||
decl.decorators = decorators?.map((d) => { | ||
return { | ||
expression: d.getText(), | ||
escapedText: d.expression.expression.escapedText, | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters