From 5549572bb4b8aeaed9a317911aebe186f1363bd0 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 14 Jul 2024 15:46:18 +0200 Subject: [PATCH 1/2] feat: Add doc comment to documentation generator --- prqlc/prqlc/src/cli/docs_generator.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/prqlc/prqlc/src/cli/docs_generator.rs b/prqlc/prqlc/src/cli/docs_generator.rs index 250ef5ff5211..4af6f5c43525 100644 --- a/prqlc/prqlc/src/cli/docs_generator.rs +++ b/prqlc/prqlc/src/cli/docs_generator.rs @@ -121,9 +121,9 @@ use prqlc::pr::{ExprKind, Stmt, StmtKind, TyKind, VarDefKind}; // var_def.name, var_def.name // )); -// //if let Some(docComment) = vardef.DocComment { -// // docs.push_str(&format!("

{docComment}

\n")); -// //} +// if let Some(doc_comment) = stmt.doc_comment { +// docs.push_str(&format!("

{doc_comment}

\n")); +// } // if let Some(expr) = &var_def.value { // match &expr.kind { @@ -261,9 +261,9 @@ Generated with [prqlc](https://prql-lang.org/) {}. docs.push_str(&format!("### {}\n", var_def.name)); - //if let Some(docComment) = vardef.DocComment { - // docs.push_str(&format!("{docComment}\n")); - //} + if let Some(doc_comment) = stmt.doc_comment { + docs.push_str(&format!("{}\n", doc_comment.trim_start())); + } docs.push('\n'); if let Some(expr) = &var_def.value { @@ -319,6 +319,7 @@ mod tests { #[test] fn generate_markdown_docs() { let input = r" + #! This is the x function. let x = arg1 arg2 -> c let fn_returns_array = -> array let fn_returns_bool = -> true @@ -354,6 +355,7 @@ mod tests { * foo ### x + This is the x function. #### Parameters * *arg1* From a13f60b6d2bb74712f805cf6d720c3bcd727dbde Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 14 Jul 2024 16:01:10 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 895205328bb6..56a3f28acd1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - Added `prqlc debug json-schema` command to auto-generate JSON Schema representations of commonly exposed IR types such as PL and RQ. (@kgutwin, #4698) +- Add documentation comments to the output of the documentation generator. + (@vanillajonathan, #4729) **Fixes**: