Skip to content

Commit

Permalink
feat: Add doc comment to documentation generator (PRQL#4729)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanillajonathan authored Jul 14, 2024
1 parent f739420 commit 8a8468b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:

Expand Down
14 changes: 8 additions & 6 deletions prqlc/prqlc/src/cli/docs_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(" <p>{docComment}</p>\n"));
// //}
// if let Some(doc_comment) = stmt.doc_comment {
// docs.push_str(&format!(" <p>{doc_comment}</p>\n"));
// }

// if let Some(expr) = &var_def.value {
// match &expr.kind {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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> array
let fn_returns_bool = -> <bool> true
Expand Down Expand Up @@ -354,6 +355,7 @@ mod tests {
* foo
### x
This is the x function.
#### Parameters
* *arg1*
Expand Down

0 comments on commit 8a8468b

Please sign in to comment.