Skip to content

Commit 8a8468b

Browse files
feat: Add doc comment to documentation generator (#4729)
1 parent f739420 commit 8a8468b

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- Added `prqlc debug json-schema` command to auto-generate JSON Schema
1010
representations of commonly exposed IR types such as PL and RQ. (@kgutwin,
1111
#4698)
12+
- Add documentation comments to the output of the documentation generator.
13+
(@vanillajonathan, #4729)
1214

1315
**Fixes**:
1416

prqlc/prqlc/src/cli/docs_generator.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ use prqlc::pr::{ExprKind, Stmt, StmtKind, TyKind, VarDefKind};
121121
// var_def.name, var_def.name
122122
// ));
123123

124-
// //if let Some(docComment) = vardef.DocComment {
125-
// // docs.push_str(&format!(" <p>{docComment}</p>\n"));
126-
// //}
124+
// if let Some(doc_comment) = stmt.doc_comment {
125+
// docs.push_str(&format!(" <p>{doc_comment}</p>\n"));
126+
// }
127127

128128
// if let Some(expr) = &var_def.value {
129129
// match &expr.kind {
@@ -261,9 +261,9 @@ Generated with [prqlc](https://prql-lang.org/) {}.
261261

262262
docs.push_str(&format!("### {}\n", var_def.name));
263263

264-
//if let Some(docComment) = vardef.DocComment {
265-
// docs.push_str(&format!("{docComment}\n"));
266-
//}
264+
if let Some(doc_comment) = stmt.doc_comment {
265+
docs.push_str(&format!("{}\n", doc_comment.trim_start()));
266+
}
267267
docs.push('\n');
268268

269269
if let Some(expr) = &var_def.value {
@@ -319,6 +319,7 @@ mod tests {
319319
#[test]
320320
fn generate_markdown_docs() {
321321
let input = r"
322+
#! This is the x function.
322323
let x = arg1 arg2 -> c
323324
let fn_returns_array = -> <array> array
324325
let fn_returns_bool = -> <bool> true
@@ -354,6 +355,7 @@ mod tests {
354355
* foo
355356
356357
### x
358+
This is the x function.
357359
358360
#### Parameters
359361
* *arg1*

0 commit comments

Comments
 (0)