Idris2 icon indicating copy to clipboard operation
Idris2 copied to clipboard

Add source link for individual declaration on documentation

Open scarf005 opened this issue 1 year ago • 4 comments

  • [x] I have read CONTRIBUTING.md.
  • [x] I have checked that there is no existing PR/issue about my proposal.

Summary

image

Add source link for each declaration like Hackage.

Motivation

Hackage [Idris2]
hackage-img idris2-img

As a beginner, one of the pain point of learning Idris2 (compared to Haskell) was that I had to either clone the repo or search thru github to find out how a function works.

The proposal

For each definitions, also add source link on the right (like how Hackage does).

Technical implementation

As it is already possible to link to specific source lines like https://test.idris-lang.org/Idris2/base/source/Data.List.html#line11-line15,

Alternatives considered

image

kotlin documentation provides multiple link to source definition. Maybe we could provide two links, one pointing to source hosted on test.idris-lang, and the other github as well:

image

Conclusion

This will make documentation more approachable.

scarf005 avatar Jul 12 '23 01:07 scarf005

The main problem here is that docs generation is part of idris2 but source highlighting is done using katla

When we generate the docs we cannot assume that a highlighted source file is available. We do get the big (source) on the top RHS (visible on your screenshot) on the official server through a bit of sed magic. But doing so for each and every definition would be a lot harder.

gallais avatar Jul 12 '23 08:07 gallais

would it be possible for idris2 to also include filename and line range in metadata when generating documentation? then katla could figure out which code to highlight such as {FILENAME}.html#line{A}-line{B}

scarf005 avatar Jul 12 '23 08:07 scarf005

Katla does not touch the docs at all, it only generates the highlighted sources.

gallais avatar Jul 12 '23 08:07 gallais

Even though what I am about to say is a step in another direction, it still might be useful to you:

Idris2 LSP has jump-to-definition functionality which lets you hover over arbitrary top-level definition name in your type-checked source code and jump to its source. It works for definitions local to your project and definitions that reside in libraries.

Russoul avatar Jul 15 '23 06:07 Russoul