Stream: ideas

Topic: Links to source code from docs


view this post on Zulip Aurélien Geron (Jul 31 2026 at 06:21):

Wouldn't it be nice if we could jump straight to the source code from the documentation?

For example, Scikit-Learn's documentation (my favorite tech docs) contains [source] links for every function or class, such as for load_wine.

view this post on Zulip Aurélien Geron (Jul 31 2026 at 06:26):

Many others do this, for example PyTorch, TensorFlow, Zig, etc.

view this post on Zulip Anton (Jul 31 2026 at 11:54):

Agreed, @Richard Feldman did not want to tie us to github for this but perhaps it's easy to pick up the git repo for the URL and gradually add support for more platforms like codeberg etc. Or we can re-use the syntax highlighting Richard recently wrote for the website and display the source like that. Personally I like going directly to the repo website, that makes it convenient to make an issue when you see something in the source code.

view this post on Zulip Jasper Woudenberg (Jul 31 2026 at 16:00):

My initial reaction was a bit averse to this idea, as you'd make it easier to peek behind the private API. But I have liked this kind of functionality in other languages, and in terms of responsibly taking on dependencies it makes a ton of sense to easily be able to see the code of the dependency. I also like the idea of quickly jumping to a project's issue trackers to file a bug.

A lot is happening at the moment in the space of source code control and code forges, so I do think it'd be good to avoid adding special support for specific forges, or you might end up adding (and maintaining) a lot of them in the years to come. But maybe package documentation could contain some optional metadata about, for instance, where to find a project's issue tracker?

Another thing I'd love is if Roc were able to serve a documentation site for my project containing the combined documentation of builtins and all my dependencies, so I don't need to check a bunch of different project sites at the same time, lookup the right version of the documentation for a package, etc. roc --watch might even opportunistically serve such a site at a standard port. Or since it's all static content maybe there's no need for a webserver at all.

The reason I bring this up is that such a local copy of the docs might want to do something different for source links, like open those files on your local machine, in your editor. There could be a button "Vendor" to pull a package in your source tree. Code examples could be opened in a local REPL. Lots of cool possibilities.

view this post on Zulip Richard Feldman (Jul 31 2026 at 16:05):

yeah if we want to link to a specific one, one idea for how to do it is to let you do like roc docs --src-url-prefix=... --src-line-prefix=#L

view this post on Zulip Richard Feldman (Jul 31 2026 at 16:06):

so then if we have Foo.roc line 250, we can prefix the url before Foo.roc and then add #L250 on the end

view this post on Zulip Richard Feldman (Jul 31 2026 at 16:06):

I assume that format (or something similar) should work for like...almost all of them?

view this post on Zulip Richard Feldman (Jul 31 2026 at 16:08):

and then if you want it to be a specific release tag or whatever, you can just put that in the URL, and if you want to host it on your own server etc. that also works


Last updated: Aug 12 2026 at 12:35 UTC