From 4eabf817600d6ce83f72189ce70c089b157ab57a Mon Sep 17 00:00:00 2001 From: famfo Date: Wed, 28 May 2025 22:49:14 +0200 Subject: [PATCH 1/4] allow for linebreaks in the brief --- src/comment.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/comment.rs b/src/comment.rs index 322bf79..3faa245 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -17,16 +17,26 @@ pub fn parse_comment(string: String) -> Comment { let mut lines = string.lines(); - if let Some(line) = lines.next() { + let mut brief = String::new(); + while let Some(line) = lines.next() { let trimmed = line.trim(); + if trimmed.is_empty() { + break; + } + + if !brief.is_empty() { + brief.push(' '); + } if trimmed.starts_with("///<") { - ret.brief = remove_prefix_and_clean(trimmed, "///<"); + brief.push_str(&remove_prefix_and_clean(trimmed, "///<")); } else { - ret.brief = remove_prefix_and_clean(trimmed, "///"); + brief.push_str(&remove_prefix_and_clean(trimmed, "///")); } } + ret.brief = brief; + let description = lines.fold(String::new(), |mut acc, line| { let cleaned_up = remove_prefix_and_clean(line.trim(), "///"); From 812a39693ec9dce80a450569bdfed205914304b9 Mon Sep 17 00:00:00 2001 From: famfo Date: Wed, 28 May 2025 22:50:12 +0200 Subject: [PATCH 2/4] add option to disable or bundle js --- CONFIG.md | 3 +++ src/config.rs | 10 ++++++++++ src/templates/page.html | 8 +++++++- src/templates/search.html | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CONFIG.md b/CONFIG.md index 01c5bf7..782388a 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -14,6 +14,9 @@ The configuration file is a TOML file named `cppdoc.toml` with the following sec - `path`: Path to the output directory. - `root_namespace` (optional): Namespace to use as the root, this is useful for libraries that only globally expose one namespace and want the index to be based on that namespace. - `base_url`: Base URL to prepend all paths with. +- `enable_mermaid`: Weather to enable mermaid, default: `true` +- `bundle_mermaid`: Weather to bundle mermaid (`mermaid.mjs` in the static directory), otherwise it is fetched from a release online, default: `false` +- `bundle_minisearch`: Weather to bundle minisearch (`minisearch.js` in the static directory), otherwise it is fetched from a release online, default `false` ## `pages` - `index` (optional): Markdown file to use as the index file, if an index page is not specified, the root namespace's comment will be used instead. diff --git a/src/config.rs b/src/config.rs index dcc900d..e5cb6eb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -34,6 +34,16 @@ pub struct Output { pub path: String, pub root_namespace: Option, pub base_url: String, + #[serde(default = "bool_true")] + pub enable_mermaid: bool, + #[serde(default)] + pub bundle_mermaid: bool, + #[serde(default)] + pub bundle_minisearch: bool, +} + +fn bool_true() -> bool { + true } #[derive(Deserialize, Serialize, Clone, Debug)] diff --git a/src/templates/page.html b/src/templates/page.html index 1855af4..199c9b5 100644 --- a/src/templates/page.html +++ b/src/templates/page.html @@ -8,9 +8,15 @@ {% block title %}{% endblock title %} + {% if config.output.enable_mermaid %} + {% endif %} {% endblock head %} diff --git a/src/templates/search.html b/src/templates/search.html index 8194cfb..8c7cd4b 100644 --- a/src/templates/search.html +++ b/src/templates/search.html @@ -4,7 +4,11 @@ Search - {{ project.name }} +{% if config.output.bundle_minisearch %} + +{% else %} +{% endif %}