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**: 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*