specta_typescript/
comments.rs

1use crate::typescript::{CommentFormatterArgs, CommentFormatterFn};
2
3use super::js_doc;
4
5// Assert that the function signature matches the expected type.
6const _: CommentFormatterFn = js_doc;
7
8/// Converts Typescript comments into JSDoc comments.
9pub fn js_doc(arg: CommentFormatterArgs) -> String {
10    js_doc_builder(arg).build()
11}
12
13pub(crate) fn js_doc_builder(arg: CommentFormatterArgs) -> js_doc::Builder {
14    let mut builder = js_doc::Builder::default();
15
16    if !arg.docs.is_empty() {
17        builder.extend(arg.docs.split('\n'));
18    }
19
20    if let Some(deprecated) = arg.deprecated {
21        builder.push_deprecated(deprecated);
22    }
23
24    builder
25}