@@ -427,6 +427,8 @@ class Builder:
427
427
The output path of the index file, used to list all API functions.
428
428
sidebar:
429
429
The output path for a sidebar yaml config (by default no config generated).
430
+ css:
431
+ The output path for the default css styles.
430
432
rewrite_all_pages:
431
433
Whether to rewrite all rendered doc pages, or only those with changes.
432
434
source_dir:
@@ -486,6 +488,7 @@ def __init__(
486
488
renderer : "dict | Renderer | str" = "markdown" ,
487
489
out_index : str = None ,
488
490
sidebar : "str | None" = None ,
491
+ css : "str | None" = None ,
489
492
rewrite_all_pages = False ,
490
493
source_dir : "str | None" = None ,
491
494
dynamic : bool | None = None ,
@@ -502,6 +505,7 @@ def __init__(
502
505
self .dir = dir
503
506
self .title = title
504
507
self .sidebar = sidebar
508
+ self .css = css
505
509
self .parser = parser
506
510
507
511
self .renderer = Renderer .from_config (renderer )
@@ -587,6 +591,12 @@ def build(self, filter: str = "*"):
587
591
_log .info (f"Writing sidebar yaml to { self .sidebar } " )
588
592
self .write_sidebar (blueprint )
589
593
594
+ # css ----
595
+
596
+ if self .css :
597
+ _log .info (f"Writing css styles to { self .css } " )
598
+ self .write_css ()
599
+
590
600
def write_index (self , blueprint : layout .Layout ):
591
601
"""Write API index page."""
592
602
@@ -685,6 +695,22 @@ def write_sidebar(self, blueprint: layout.Layout):
685
695
d_sidebar = self ._generate_sidebar (blueprint )
686
696
yaml .dump (d_sidebar , open (self .sidebar , "w" ))
687
697
698
+ def write_css (self ):
699
+ """Write default css styles to a file."""
700
+ from importlib_resources import files
701
+ from importlib_metadata import version
702
+
703
+ v = version ("quartodoc" )
704
+
705
+ note = (
706
+ f"/*\n This file generated automatically by quartodoc version { v } .\n "
707
+ "Modifications may be overwritten by quartodoc build. If you want to\n "
708
+ "customize styles, create a new .css file to avoid losing changes.\n "
709
+ "*/\n \n \n "
710
+ )
711
+ with open (files ("quartodoc.static" ) / "styles.css" ) as f :
712
+ Path (self .css ).write_text (note + f .read ())
713
+
688
714
def _page_to_links (self , el : layout .Page ) -> list [str ]:
689
715
# if el.flatten:
690
716
# links = []
0 commit comments