deno_doc icon indicating copy to clipboard operation
deno_doc copied to clipboard

Generated document `@throws` section missing `}`

Open typed-sigterm opened this issue 9 months ago • 1 comments

Describe the bug

I found that generated @throws document section of @std/async.deadline is missing }:

Throws DOMException & { name: "TimeoutError" DOMException & { name: "AbortError" AbortSignal["reason"]
If the optional signal is aborted with a custom reason before resolving or timing out.

Steps to Reproduce

https://jsr.io/@std/[email protected]/doc/deadline/~/deadline#throws

Expected behavior

-DOMException & { name: "TimeoutError"
-DOMException & { name: "AbortError"
+DOMException & { name: "TimeoutError" }
+DOMException & { name: "AbortError" }

This may not be the reason for @std/async. Since I'm not familiar with the architecture behind it, I'm only submitting it here.

Environment

N/A

typed-sigterm avatar Mar 15 '25 13:03 typed-sigterm

Changing a certain regex in deno_doc from ...\{([^}]+)\}... to ...\{(.+)\}... (allowing } between the braces) does fix this.

https://github.com/denoland/deno_doc/blob/aef1632661cd6681f471e615e8c415c3b987b4b3/src/js_doc.rs#L27

Unfortunately, that's not a permanent solution, since the performance of .+ has the potential to be much worse than [^}]+. Also it probably breaks if there are any more }s later in the string. I suspect the best solution would be to count braces, but that seems like a relatively large investment.

As a note, it's not just the } that's missing, it's everything after the }. Seen:

DOMException & { name: "TimeoutError"
DOMException & { name: "AbortError"

Expected:

DOMException & { name: "TimeoutError" }
If the provided duration runs out before resolving.
DOMException & { name: "AbortError" }

WWRS avatar Mar 17 '25 20:03 WWRS