diff --git a/src/lib/debug/debugRendererUrls.ts b/src/lib/debug/debugRendererUrls.ts index 067782c73..4ccc45470 100644 --- a/src/lib/debug/debugRendererUrls.ts +++ b/src/lib/debug/debugRendererUrls.ts @@ -8,67 +8,76 @@ import { } from "../models/index.js"; import type { SerializerComponent } from "../serialization/components.js"; import type { JSONOutput } from "../serialization/index.js"; +import type { Router } from "../output/index.js"; -const serializer: SerializerComponent = { - priority: 0, - supports(x) { - return x instanceof Reflection; - }, - toObject(item, obj: any) { - obj.url = item.url; - obj.hasOwnDocument = item.hasOwnDocument; - // obj.anchor = item.anchor; - delete obj.sources; - delete obj.groups; - delete obj.categories; - delete obj.readme; - delete obj.content; - obj.kind = ReflectionKind[obj.kind]; - delete obj.flags; - delete obj.defaultValue; - delete obj.symbolIdMap; - delete obj.files; - delete obj.packageName; - delete obj.variant; - delete obj.extendedTypes; - delete obj.inheritedFrom; - if (!["reflection", "reference"].includes(obj.type?.type)) { - delete obj.type; - } +function makeSerializer(router: Router) { + const serializer: SerializerComponent = { + priority: 0, + supports(x) { + return x instanceof Reflection; + }, + toObject(item, obj: any) { + if (router.hasUrl(item)) { + obj.url = router.getFullUrl(item); + obj.hasOwnDocument = router.hasOwnDocument(item); + } + delete obj.sources; + delete obj.groups; + delete obj.categories; + delete obj.readme; + delete obj.content; + obj.kind = ReflectionKind[obj.kind]; + delete obj.flags; + delete obj.defaultValue; + delete obj.symbolIdMap; + delete obj.files; + delete obj.packageName; + delete obj.variant; + delete obj.extendedTypes; + delete obj.inheritedFrom; + if (!["reflection", "reference"].includes(obj.type?.type)) { + delete obj.type; + } - if (obj.comment) { - obj.comment.summary = obj.comment.summary.filter( - (part: JSONOutput.CommentDisplayPart) => - part.kind === "inline-tag", - ); - obj.comment.blockTags = obj.comment.blockTags?.filter( - (tag: JSONOutput.CommentTag) => { - tag.content = tag.content.filter( - (part) => part.kind === "inline-tag", - ); - return tag.content.length; - }, - ); + if (obj.comment) { + obj.comment.summary = obj.comment.summary.filter( + (part: JSONOutput.CommentDisplayPart) => + part.kind === "inline-tag", + ); + obj.comment.blockTags = obj.comment.blockTags?.filter( + (tag: JSONOutput.CommentTag) => { + tag.content = tag.content.filter( + (part) => part.kind === "inline-tag", + ); + return tag.content.length; + }, + ); - if ( - !obj.comment.summary.length && - !obj.comment.blockTags?.length && - !obj.comment.modifierTags - ) { - delete obj.comment; + if ( + !obj.comment.summary.length && + !obj.comment.blockTags?.length && + !obj.comment.modifierTags + ) { + delete obj.comment; + } } - } - return obj; - }, -}; + return obj; + }, + }; + + return serializer; +} export function debugRendererUrls( app: Application, { json = false, logs = false } = { logs: true }, ) { app.renderer.postRenderAsyncJobs.push(async (evt) => { + const router = app.renderer.router!; + if (json) { + const serializer = makeSerializer(router); app.serializer.addSerializer(serializer); await app.generateJson( evt.project, @@ -83,8 +92,7 @@ export function debugRendererUrls( console.log( refl.id, refl.getFullName(), - refl.url, - refl.hasOwnDocument, + router.hasUrl(refl) ? router.getFullUrl(refl) : undefined, ); } } diff --git a/src/lib/output/themes/default/partials/navigation.tsx b/src/lib/output/themes/default/partials/navigation.tsx index 54e64b3f5..083e1b6d7 100644 --- a/src/lib/output/themes/default/partials/navigation.tsx +++ b/src/lib/output/themes/default/partials/navigation.tsx @@ -127,7 +127,9 @@ export const navigation = function navigation(context: DefaultThemeRenderContext