documentation structure, functions, methods
Sometimes functions that become members of classes or interfaces still end up as functions. This doesn't make a difference to users, as they look and feel equivalent. It does however make the generated documentation harder to understand; eg. see https://cheerio.js.org/classes/Cheerio.html
This page has both Functions - Traversing and Methods - Traversing as categories, which makes it harder to understand the page.
TypeDoc should normalise the children of classes and interfaces to be exclusively methods. TypeDoc already creates copies of them when creating the signatures, meaning this won't lead to actual functions being turned into methods.
I wrote this plugin today to fix the issue:
const td = require('typedoc');
/** @param {td.Application} app - The app. */
exports.load = function (app) {
app.converter.on(td.Converter.EVENT_CREATE_DECLARATION, updateFnsToMethods);
};
/**
* @param {td.Context} context - The context.
* @param {td.DeclarationReflection} reflection - The reflection.
*/
function updateFnsToMethods(context, reflection) {
if (
reflection.kindOf(td.ReflectionKind.Function) &&
reflection.parent?.kindOf(td.ReflectionKind.ClassOrInterface)
) {
// Unset the `Function` flag, set the `Method` flag.
reflection.kind ^= td.ReflectionKind.Function;
reflection.kind |= td.ReflectionKind.Method;
}
}
My suggestion is to include the relevant logic in TypeDoc, as I can't think of a case where this isn't wanted.
Owner Name | TypeStrong |
Repo Name | typedoc |
Full Name | TypeStrong/typedoc |
Language | TypeScript |
Created Date | 2014-05-24 |
Updated Date | 2023-03-19 |
Star Count | 6487 |
Watcher Count | 68 |
Fork Count | 639 |
Issue Count | 48 |
Issue Title | Created Date | Updated Date |
---|