Skip to content

Commit

Permalink
Fix additional merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Dec 15, 2024
1 parent 72ae5c8 commit 0912452
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 52 deletions.
110 changes: 59 additions & 51 deletions src/lib/debug/debugRendererUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SomeReflection> = {
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<SomeReflection> = {
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,
Expand All @@ -83,8 +92,7 @@ export function debugRendererUrls(
console.log(
refl.id,
refl.getFullName(),
refl.url,
refl.hasOwnDocument,
router.hasUrl(refl) ? router.getFullUrl(refl) : undefined,
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/output/themes/default/partials/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ export const navigation = function navigation(context: DefaultThemeRenderContext
<nav class="tsd-navigation">
<a
href={context.urlTo(props.project)}
class={classNames({ current: props.url === props.model.url && props.model.isProject() })}
class={classNames({
current: props.url === context.router.getFullUrl(props.model) && props.model.isProject(),
})}
>
{getDisplayName(props.project)}
</a>
Expand Down

0 comments on commit 0912452

Please sign in to comment.