denoland / deno_doc

Documentation generator for Deno
MIT License
253 stars 54 forks source link

[HTML] example "usage" imports are syntactically incorrect #591

Open nberlette opened 3 months ago

nberlette commented 3 months ago

The generated example usage code (for importing symbols from the modules) have been erroneous for quite a while now.

First off, none of the paths are incorrectly formatted, and always appear as just the filename without any relative ./ prefix or anything. For example, import { titleCase } from "title-case.ts";. Copy and paste that into the REPL and see how it goes.

It'd be great if there was a way for deno_doc to pick up on the JSR configuration in the deno.json file, and format imports accordingly. Like import { isString } from "jsr:@type/is/string"; (wishful thinking for the future). But in the mean time, I think at the very least it should be formatting relative paths properly.

Now, for default exports (as I mentioned in #590), the generated import seems to get really funky. The identifier it uses always ends up being... a single dot. Yup, when viewing a default export, the suggested usage code I get is import . from "capitalize.ts";.

For context, I run canary releases of Deno 99% of the time. I make sure to stay on top of upgrading to the latest build regularly (sometimes several times a day 😅). On the latest build, this erroroneous behavior is still persisting.