@@ -73,7 +73,14 @@ export default defineConfig({
7373 }
7474 } ,
7575 transformPageData ( pageData ) {
76- if ( pageData . filePath . startsWith ( "api/" ) || pageData . filePath . startsWith ( "guide/cli/" ) ) {
76+ if ( pageData . filePath . startsWith ( "api/" ) ) {
77+ pageData . frontmatter . editLink = false ;
78+ pageData . frontmatter . lastUpdated = false ;
79+ pageData . frontmatter ||= { }
80+ pageData . frontmatter . outline = [ 2 , 3 ] ;
81+ }
82+
83+ if ( pageData . filePath . startsWith ( "guide/cli/" ) ) {
7784 pageData . frontmatter . editLink = false ;
7885 pageData . frontmatter . lastUpdated = false ;
7986 }
@@ -181,13 +188,20 @@ function getApiReferenceSidebar(): typeof typedocSidebar {
181188}
182189
183190function orderApiReferenceSidebar ( sidebar : typeof typedocSidebar ) : typeof typedocSidebar {
191+ orderClasses ( sidebar ) ;
192+ orderTypes ( sidebar ) ;
193+
194+ return sidebar ;
195+ }
196+
197+ function orderClasses ( sidebar : typeof typedocSidebar ) {
184198 const baseChatPromptWrapper = "ChatPromptWrapper" ;
185199 const chatPromptWrapperItems : DefaultTheme . SidebarItem [ ] = [ ] ;
186200
187201 const classes = sidebar . find ( ( item ) => item . text === "Classes" ) ;
188202
189203 if ( classes == null || ! ( classes . items instanceof Array ) )
190- return sidebar ;
204+ return ;
191205
192206 ( classes . items as DefaultTheme . SidebarItem [ ] ) . unshift ( {
193207 text : "Chat wrappers" ,
@@ -222,7 +236,54 @@ function orderApiReferenceSidebar(sidebar: typeof typedocSidebar): typeof typedo
222236
223237 return aIndex - bIndex ;
224238 } ) ;
225-
226- return sidebar ;
227239}
228240
241+ function orderTypes ( sidebar : typeof typedocSidebar ) {
242+ const types = sidebar . find ( ( item ) => item . text === "Types" ) ;
243+
244+ if ( types == null || ! ( types . items instanceof Array ) )
245+ return ;
246+
247+ function groupGbnfJsonSchema ( ) {
248+ if ( types == null || ! ( types . items instanceof Array ) )
249+ return ;
250+
251+ const gbnfJsonSchemaItemTitle = "GbnfJsonSchema" ;
252+ const gbnfItemsPrefix = "GbnfJson" ;
253+ const gbnfJsonSchemaItems : DefaultTheme . SidebarItem [ ] = [ ] ;
254+
255+ const gbnfJsonSchemaItem = types . items
256+ . find ( ( item ) => item . text === gbnfJsonSchemaItemTitle ) as DefaultTheme . SidebarItem | null ;
257+
258+ if ( gbnfJsonSchemaItem == null )
259+ return ;
260+
261+ gbnfJsonSchemaItem . collapsed = true ;
262+ gbnfJsonSchemaItem . items = gbnfJsonSchemaItems ;
263+
264+ for ( const item of types . items . slice ( ) ) {
265+ if ( item . text === gbnfJsonSchemaItemTitle || ! item . text . startsWith ( gbnfItemsPrefix ) )
266+ continue ;
267+
268+ types . items . splice ( types . items . indexOf ( item ) , 1 ) ;
269+ gbnfJsonSchemaItems . push ( item ) ;
270+ }
271+ }
272+
273+ function moveCollapseItemsToTheEnd ( ) {
274+ if ( types == null || ! ( types . items instanceof Array ) )
275+ return ;
276+
277+ types . items . sort ( ( a , b ) => {
278+ if ( a . collapsed && ! b . collapsed )
279+ return 1 ;
280+ if ( ! a . collapsed && b . collapsed )
281+ return - 1 ;
282+
283+ return 0 ;
284+ } ) ;
285+ }
286+
287+ groupGbnfJsonSchema ( ) ;
288+ moveCollapseItemsToTheEnd ( ) ;
289+ }
0 commit comments