jsr icon indicating copy to clipboard operation
jsr copied to clipboard

Suggestion: the jsr.io site URLs should better reflect the module specifier

Open jollytoad opened this issue 1 year ago • 2 comments

Linking into JSR and between packages atm is a bit finickity with it's obscure URL scheme (of <package>/doc/<module>/~)

I'd expect to be able to link directly to a module within a package using a simple URL that reflects the jsr: module specifier.

For example: https://jsr.io/@std/http/file-server - current returns a 404, but it'd be much more helpful esp when linked from other docs/site if it were to redirect to https://jsr.io/@std/http/doc/file-server/~

Or even ditch the /doc/<module>/~ route, why bother having the /doc path, and why does the ~ even need to be there? it's cumbersome, and gets cut-off by the markdown URL parser!

Similarly an exact version, eg: https://jsr.io/@std/[email protected]/file-server -> https://jsr.io/@std/[email protected]/doc/file-server/~

And a fuzzy version could also redirect to the latest it would resolve to, eg: https://jsr.io/@std/http@^0.224.0 -> https://jsr.io/@std/[email protected] and https://jsr.io/@std/http@^0.224.0/file-server -> https://jsr.io/@std/[email protected]/doc/file-server/~ (this currently gives a malformed request, I don't see why it couldn't be more helpful and just redirect as I describe)

jollytoad avatar Jul 04 '24 13:07 jollytoad

I don't remember the exact syntax, but I think you should be able to something like {@link [jsr:@foo/bar].bar} to link between packages without having to specify a JSR URL at all - @crowlKats can you confirm?

lucacasonato avatar Jul 12 '24 15:07 lucacasonato

I tried using {@link [jsr:@core/unknownutil/is/object-of].isObjectOf}, but it didn’t work. However, {@link [is/object-of].isObjectOf} did work, so it seems the syntax only supports a relative path from the export root.

CleanShot 2024-08-22 at 00 17 34
CleanShot 2024-08-22 at 00 17 46

By the way, could you please document this syntax at https://jsr.io/docs/writing-docs? Or, let me know where I can send a PR. I was unaware of this syntax and had been using the {@link URL | text} syntax, which is also undocumented, in my doc comments.

The only related resource I could find is this test case:

  • https://github.com/denoland/deno_doc/blob/b14e8add8d19553399186d73b4a0ee208ea8d902/src/html/jsdoc.rs#L925-L941

lambdalisue avatar Aug 21 '24 15:08 lambdalisue

the {@link [jsr:@foo/bar].bar} (entire package linking9 is currently not supported, but eveything has been wired up to make this possible.

@lambdalisue FYI we have improved documentation related to inline-linking

crowlKats avatar Jan 16 '25 23:01 crowlKats

This issue wasn't specifically about the rendering of link within JSR, but the ability to easily link into JSR from outside.

To reiterate my first example: https://jsr.io/@std/http/file-server - i don't see any reason why this couldn't link to something useful rather than a 404.

jollytoad avatar May 30 '25 10:05 jollytoad

This has gotten better now because you don't have to put ~ at the end of file names anymore for docs to work.

However I think we will not be able to do this because the / right after the package name is for things like /settings, /versions, etc. If we make those redirect, then if we add new pages in the future people's exisitng links may break - that wouldn't be good.

lucacasonato avatar Jun 26 '25 16:06 lucacasonato

Thanks for the follow up @lucacasonato, not having to add ~ is certainly a great improvement.

jollytoad avatar Jun 27 '25 08:06 jollytoad