@@ -20,7 +20,9 @@ use super::rewriter::post_process_html;
20
20
use crate :: cached_readers:: read_sidebar;
21
21
use crate :: error:: DocError ;
22
22
use crate :: helpers;
23
- use crate :: helpers:: subpages:: { list_sub_pages_grouped_internal, list_sub_pages_internal} ;
23
+ use crate :: helpers:: subpages:: {
24
+ list_sub_pages_grouped_internal, list_sub_pages_internal, ListSubPagesContext ,
25
+ } ;
24
26
use crate :: pages:: page:: { Page , PageLike } ;
25
27
use crate :: pages:: types:: doc:: Doc ;
26
28
use crate :: utils:: { is_default, serialize_t_or_vec, t_or_vec} ;
@@ -292,6 +294,8 @@ pub struct SubPageEntry {
292
294
#[ serde( default , skip_serializing_if = "details_is_none" ) ]
293
295
pub details : Details ,
294
296
#[ serde( default , skip_serializing_if = "is_default" ) ]
297
+ pub code : bool ,
298
+ #[ serde( default , skip_serializing_if = "is_default" ) ]
295
299
pub include_parent : bool ,
296
300
}
297
301
@@ -319,8 +323,13 @@ pub enum SidebarEntry {
319
323
#[ derive( Debug , Default ) ]
320
324
pub enum MetaChildren {
321
325
Children ( Vec < SidebarMetaEntry > ) ,
322
- ListSubPages ( String , Vec < PageType > , bool ) ,
323
- ListSubPagesGrouped ( String , Vec < PageType > , bool ) ,
326
+ ListSubPages ( String , Vec < PageType > , bool , bool ) ,
327
+ ListSubPagesGrouped {
328
+ path : String ,
329
+ tags : Vec < PageType > ,
330
+ code : bool ,
331
+ include_parent : bool ,
332
+ } ,
324
333
WebExtApi ,
325
334
#[ default]
326
335
None ,
@@ -424,13 +433,14 @@ impl TryFrom<SidebarEntry> for SidebarMetaEntry {
424
433
hash,
425
434
title,
426
435
path,
436
+ code,
427
437
include_parent,
428
438
} ) => SidebarMetaEntry {
429
439
section : false ,
430
440
details,
431
441
code : false ,
432
442
content : SidebarMetaEntryContent :: from_link_title_hash ( link, title, hash) ,
433
- children : MetaChildren :: ListSubPages ( path, tags, include_parent) ,
443
+ children : MetaChildren :: ListSubPages ( path, tags, code , include_parent) ,
434
444
} ,
435
445
SidebarEntry :: ListSubPagesGrouped ( SubPageEntry {
436
446
details,
@@ -439,13 +449,19 @@ impl TryFrom<SidebarEntry> for SidebarMetaEntry {
439
449
hash,
440
450
title,
441
451
path,
452
+ code,
442
453
include_parent,
443
454
} ) => SidebarMetaEntry {
444
455
section : false ,
445
456
details,
446
457
code : false ,
447
458
content : SidebarMetaEntryContent :: from_link_title_hash ( link, title, hash) ,
448
- children : MetaChildren :: ListSubPagesGrouped ( path, tags, include_parent) ,
459
+ children : MetaChildren :: ListSubPagesGrouped {
460
+ path,
461
+ tags,
462
+ code,
463
+ include_parent,
464
+ } ,
449
465
} ,
450
466
SidebarEntry :: Default ( BasicEntry {
451
467
link,
@@ -565,7 +581,7 @@ impl SidebarMetaEntry {
565
581
child. render ( out, locale, slug, l10n) ?;
566
582
}
567
583
}
568
- MetaChildren :: ListSubPages ( url, page_types, include_parent) => {
584
+ MetaChildren :: ListSubPages ( url, page_types, code , include_parent) => {
569
585
let url = if url. starts_with ( concat ! ( "/" , default_locale( ) . as_url_str( ) , "/" ) ) {
570
586
Cow :: Borrowed ( url)
571
587
} else {
@@ -581,29 +597,40 @@ impl SidebarMetaEntry {
581
597
& url,
582
598
locale,
583
599
Some ( 1 ) ,
584
- None ,
585
- page_types,
586
- * include_parent,
600
+ ListSubPagesContext {
601
+ sorter : None ,
602
+ page_types,
603
+ code : * code,
604
+ include_parent : * include_parent,
605
+ } ,
587
606
) ?
588
607
}
589
- MetaChildren :: ListSubPagesGrouped ( url, page_types, include_parent) => {
590
- let url = if url. starts_with ( concat ! ( "/" , default_locale( ) . as_url_str( ) , "/" ) ) {
591
- Cow :: Borrowed ( url)
608
+ MetaChildren :: ListSubPagesGrouped {
609
+ path,
610
+ tags,
611
+ code,
612
+ include_parent,
613
+ } => {
614
+ let url = if path. starts_with ( concat ! ( "/" , default_locale( ) . as_url_str( ) , "/" ) ) {
615
+ Cow :: Borrowed ( path)
592
616
} else {
593
617
Cow :: Owned ( concat_strs ! (
594
618
"/" ,
595
619
Locale :: default ( ) . as_url_str( ) ,
596
620
"/docs" ,
597
- url
621
+ path
598
622
) )
599
623
} ;
600
624
list_sub_pages_grouped_internal (
601
625
out,
602
626
& url,
603
627
locale,
604
- None ,
605
- page_types,
606
- * include_parent,
628
+ ListSubPagesContext {
629
+ sorter : None ,
630
+ page_types : tags,
631
+ code : * code,
632
+ include_parent : * include_parent,
633
+ } ,
607
634
) ?
608
635
}
609
636
MetaChildren :: WebExtApi => {
0 commit comments