From 86631b4e2ba225c84783e0293cdcdcf993fd8352 Mon Sep 17 00:00:00 2001 From: Henry Wilde Date: Wed, 6 Dec 2023 16:03:24 +0000 Subject: [PATCH] Add description functionality. --- quartodoc/autosummary.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/quartodoc/autosummary.py b/quartodoc/autosummary.py index c1b6635..c4160fd 100644 --- a/quartodoc/autosummary.py +++ b/quartodoc/autosummary.py @@ -419,6 +419,8 @@ class Builder: Name of API directory. title: Title of the API index page. + description: + Description of the API index page. Defaults to no description. renderer: Renderer The renderer used to convert docstrings (e.g. to markdown). options: @@ -481,6 +483,7 @@ def __init__( version: "str | None" = None, dir: str = "reference", title: str = "Function reference", + description: str = None, renderer: "dict | Renderer | str" = "markdown", out_index: str = None, sidebar: "str | None" = None, @@ -499,6 +502,7 @@ def __init__( self.version = None self.dir = dir self.title = title + self.description = description self.sidebar = sidebar self.parser = parser @@ -591,7 +595,11 @@ def write_index(self, blueprint: layout.Layout): content = self.renderer.summarize(blueprint) _log.info(f"Writing index to directory: {self.dir}") - final = f"# {self.title}\n\n{content}" + description = ( + f"description: {self.description}" if self.description is not None else "" + ) + header = "\n".join(("---", f"title: {self.title}", description, "---")) + final = f"{header}\n\n{content}" p_index = Path(self.dir) / self.out_index p_index.parent.mkdir(exist_ok=True, parents=True)