Skip to content

Commit be012a4

Browse files
committed
refactor
1 parent 67b0b85 commit be012a4

File tree

1 file changed

+77
-30
lines changed

1 file changed

+77
-30
lines changed

docs/api_refs/typedoc_plugins/hide_underscore_lc.js

Lines changed: 77 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,82 @@ const VERSION_DROPDOWN_HTML = `<div class="version-select">
4949
</select>
5050
</div>`;
5151

52+
/**
53+
* Checks if the reflection is a property of a chat model class,
54+
* and returns true (to hide the reflection) if it is.
55+
*
56+
* @param {DeclarationReflection} reflection
57+
* @returns {boolean} Whether or not to hide the reflection
58+
*/
59+
function hideChatModelProperties(reflection) {
60+
if (
61+
reflection.kind === ReflectionKind.Property &&
62+
reflection?.parent &&
63+
reflection.parent.kind === ReflectionKind.Class &&
64+
reflection.parent.name.includes("Chat")
65+
) {
66+
return true;
67+
}
68+
return false;
69+
}
70+
71+
/**
72+
* Checks if the reflection is a method on a chat model class,
73+
* and returns true (to hide the reflection) if it is.
74+
*
75+
* @param {DeclarationReflection} reflection
76+
* @returns {boolean} Whether or not to hide the reflection
77+
*/
78+
function hideChatModelMethods(reflection) {
79+
if (
80+
reflection.kind === ReflectionKind.Method &&
81+
reflection?.parent &&
82+
reflection.parent.kind === ReflectionKind.Class &&
83+
reflection.parent.name.includes("Chat")
84+
) {
85+
if (
86+
!WHITELISTED_CHAT_MODEL_INHERITED_METHODS.find(
87+
(n) => n === reflection.name
88+
)
89+
) {
90+
return true;
91+
}
92+
}
93+
return false;
94+
}
95+
96+
/**
97+
* Checks if the reflection is an accessor and is named `callKeys`,
98+
* and returns true (to hide the reflection) if it is.
99+
*
100+
* @param {DeclarationReflection} reflection
101+
* @returns {boolean} Whether or not to hide the reflection
102+
*/
103+
function hideChatModelAccessors(reflection) {
104+
if (
105+
reflection.kind === ReflectionKind.Accessor &&
106+
reflection.name === "callKeys"
107+
) {
108+
return true;
109+
}
110+
return false;
111+
}
112+
113+
/**
114+
* Check if the reflection should be hidden. If it should, it
115+
* returns true.
116+
*
117+
* @param {DeclarationReflection} reflection
118+
* @returns {boolean} Whether or not to hide the reflection
119+
*/
120+
function hideChatModelReflection(reflection) {
121+
return (
122+
hideChatModelProperties(reflection) ||
123+
hideChatModelMethods(reflection) ||
124+
hideChatModelAccessors(reflection)
125+
);
126+
}
127+
52128
/**
53129
* @param {string | undefined} deprecationText
54130
* @returns {string}
@@ -136,36 +212,7 @@ function load(application) {
136212
function resolveReflection(_context, reflection) {
137213
const reflectionKind = reflection.kind;
138214

139-
if (
140-
reflectionKind === ReflectionKind.Method &&
141-
reflection?.parent &&
142-
reflection.parent.kind === ReflectionKind.Class &&
143-
reflection.parent.name.includes("Chat")
144-
) {
145-
if (
146-
!WHITELISTED_CHAT_MODEL_INHERITED_METHODS.find(
147-
(n) => n === reflection.name
148-
)
149-
) {
150-
reflectionsToHide.push(reflection);
151-
}
152-
}
153-
154-
if (
155-
reflectionKind === ReflectionKind.Property &&
156-
reflection?.parent &&
157-
reflection.parent.kind === ReflectionKind.Class &&
158-
reflection.parent.name.includes("Chat")
159-
) {
160-
// Hide all properties of chat models
161-
reflectionsToHide.push(reflection);
162-
}
163-
164-
if (
165-
reflectionKind === ReflectionKind.Accessor &&
166-
reflection.name === "callKeys"
167-
) {
168-
// Hide all `callKeys` accessors
215+
if (hideChatModelReflection(reflection)) {
169216
reflectionsToHide.push(reflection);
170217
}
171218

0 commit comments

Comments
 (0)