22
22
from .renderers import Renderer
23
23
from .validation import fmt_all
24
24
from ._pydantic_compat import ValidationError
25
+ from .pandoc .blocks import Blocks , Header
26
+ from .pandoc .components import Attr
25
27
26
28
27
29
from typing import Any
@@ -463,6 +465,8 @@ class Builder:
463
465
title : str
464
466
465
467
renderer : Renderer
468
+ items : list [layout .Item ]
469
+ """Documented items by this builder"""
466
470
467
471
def __init_subclass__ (cls , ** kwargs ):
468
472
super ().__init_subclass__ (** kwargs )
@@ -553,7 +557,7 @@ def build(self, filter: str = "*"):
553
557
blueprint = blueprint (self .layout , dynamic = self .dynamic , parser = self .parser )
554
558
555
559
_log .info ("Collecting pages and inventory items." )
556
- pages , items = collect (blueprint , base_dir = self .dir )
560
+ pages , self . items = collect (blueprint , base_dir = self .dir )
557
561
558
562
# writing pages ----
559
563
@@ -562,11 +566,12 @@ def build(self, filter: str = "*"):
562
566
563
567
_log .info ("Writing docs pages" )
564
568
self .write_doc_pages (pages , filter )
569
+ self .renderer ._pages_written (self )
565
570
566
571
# inventory ----
567
572
568
573
_log .info ("Creating inventory file" )
569
- inv = self .create_inventory (items )
574
+ inv = self .create_inventory (self . items )
570
575
if self ._fast_inventory :
571
576
# dump the inventory file directly as text
572
577
# TODO: copied from __main__.py, should add to inventory.py
@@ -591,7 +596,9 @@ def write_index(self, blueprint: layout.Layout):
591
596
content = self .renderer .summarize (blueprint )
592
597
_log .info (f"Writing index to directory: { self .dir } " )
593
598
594
- final = f"# { self .title } \n \n { content } "
599
+ final = str (
600
+ Blocks ([Header (1 , self .title , Attr (classes = ["doc" , "doc-index" ])), content ])
601
+ )
595
602
596
603
p_index = Path (self .dir ) / self .out_index
597
604
p_index .parent .mkdir (exist_ok = True , parents = True )
0 commit comments