-
| Hello! I was wondering if I can output the methods of a class into separate files/pages instead of listing them all on one page. Take this example: https://stackblitz.com/edit/sb1-p69vxax4?file=src%2Findex.ts I'd like to have  webhook-handler/
└── methods/
    ├── subscribe
    └── unsubscribeIs that possible with the router? | 
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
| Yes, you should be able to achieve this with a custom router. The existing routers should be pretty easy to extend to make it happen. | 
Beta Was this translation helpful? Give feedback.
-
| In case anyone is interested, here's how I got it working (most basic version of it): // @ts-check
import * as td from "typedoc";
/** @param {td.Application} app */
export function load(app) {
  app.renderer.defineRouter('custom', CustomRouter)
}
/**
 * @param {td.Reflection} reflection
 */
function isMethod(reflection) {
  return reflection.kind === td.ReflectionKind.Method;
}
class CustomRouter extends td.KindRouter {
  /**
   * @param {td.Reflection} reflection
   */
  getIdealBaseName(reflection) {
    // ADDITION
    if (isMethod(reflection)) {
      const className = reflection.parent ? reflection.parent.name : '';
      const methodName = reflection.name;
      return `classes/${className}/${methodName}`
    }
    
    return super.getIdealBaseName(reflection)
  }
  /**
   * @param {td.RouterTarget} target
   * @return {td.PageKind | undefined}
   */
  getPageKind(target) {
    if (!(target instanceof td.Reflection)) {
        return undefined;
    }
    const pageReflectionKinds = td.ReflectionKind.Class |
        td.ReflectionKind.Interface |
        td.ReflectionKind.Enum |
        td.ReflectionKind.Module |
        td.ReflectionKind.Namespace |
        td.ReflectionKind.TypeAlias |
        td.ReflectionKind.Function |
        td.ReflectionKind.Variable |
        // ADDITION
        td.ReflectionKind.Method;
    const documentReflectionKinds = td.ReflectionKind.Document;
    if (target.kindOf(pageReflectionKinds)) {
        return td.PageKind.Reflection;
    }
    if (target.kindOf(documentReflectionKinds)) {
        return td.PageKind.Document;
    }
  }
}I changed  | 
Beta Was this translation helpful? Give feedback.
In case anyone is interested, here's how I got it working (most basic version of it):