@@ -427,6 +427,8 @@ class Builder:
427427 The output path of the index file, used to list all API functions.
428428 sidebar:
429429 The output path for a sidebar yaml config (by default no config generated).
430+ css:
431+ The output path for the default css styles.
430432 rewrite_all_pages:
431433 Whether to rewrite all rendered doc pages, or only those with changes.
432434 source_dir:
@@ -486,6 +488,7 @@ def __init__(
486488 renderer : "dict | Renderer | str" = "markdown" ,
487489 out_index : str = None ,
488490 sidebar : "str | None" = None ,
491+ css : "str | None" = None ,
489492 rewrite_all_pages = False ,
490493 source_dir : "str | None" = None ,
491494 dynamic : bool | None = None ,
@@ -502,6 +505,7 @@ def __init__(
502505 self .dir = dir
503506 self .title = title
504507 self .sidebar = sidebar
508+ self .css = css
505509 self .parser = parser
506510
507511 self .renderer = Renderer .from_config (renderer )
@@ -587,6 +591,12 @@ def build(self, filter: str = "*"):
587591 _log .info (f"Writing sidebar yaml to { self .sidebar } " )
588592 self .write_sidebar (blueprint )
589593
594+ # css ----
595+
596+ if self .css :
597+ _log .info (f"Writing css styles to { self .css } " )
598+ self .write_css ()
599+
590600 def write_index (self , blueprint : layout .Layout ):
591601 """Write API index page."""
592602
@@ -685,6 +695,22 @@ def write_sidebar(self, blueprint: layout.Layout):
685695 d_sidebar = self ._generate_sidebar (blueprint )
686696 yaml .dump (d_sidebar , open (self .sidebar , "w" ))
687697
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+
688714 def _page_to_links (self , el : layout .Page ) -> list [str ]:
689715 # if el.flatten:
690716 # links = []
0 commit comments