Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional index description functionality #313

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion quartodoc/autosummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand All @@ -499,6 +502,7 @@ def __init__(
self.version = None
self.dir = dir
self.title = title
self.description = description
self.sidebar = sidebar
self.parser = parser

Expand Down Expand Up @@ -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)
Expand Down