1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

fix(doc): handle comments at the top of the file (#5891)

This commit is contained in:
Matt Dumler 2020-05-27 16:38:36 -05:00 committed by GitHub
parent f8c6500eef
commit f6e58b076c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -530,7 +530,7 @@ impl DocParser {
pub fn js_doc_for_span(&self, span: Span) -> Option<String> {
let comments = self.ast_parser.get_span_comments(span);
let js_doc_comment = comments.iter().find(|comment| {
let js_doc_comment = comments.iter().rev().find(|comment| {
comment.kind == CommentKind::Block && comment.text.starts_with('*')
})?;

View file

@ -44,6 +44,10 @@ impl DocFileLoader for TestLoader {
#[tokio::test]
async fn export_fn() {
let source_code = r#"/**
* @module foo
*/
/**
* Hello there, this is a multiline JSdoc.
*
* It has many lines
@ -51,6 +55,9 @@ async fn export_fn() {
* Or not that many?
*/
export function foo(a: string, b?: number, cb: (...cbArgs: unknown[]) => void, ...args: unknown[]): void {
/**
* @todo document all the things.
*/
console.log("Hello world");
}
"#;
@ -143,7 +150,7 @@ export function foo(a: string, b?: number, cb: (...cbArgs: unknown[]) => void, .
"location": {
"col": 0,
"filename": "test.ts",
"line": 8,
"line": 12,
},
"name": "foo",
});