haskell / haddock

Haskell Documentation Tool
www.haskell.org/haddock/
BSD 2-Clause "Simplified" License
361 stars 241 forks source link

demo of some haddock hacks #527

Open erantapaa opened 8 years ago

erantapaa commented 8 years ago

Hi all,

I've been hacking on haddock, and I've come up with some mods which enhance the hyperlinked source pages. You can view a demo at:

http://erantapaa.github.io/haddock-demo/src/Data.Compression.Inflate.html#inflate_string

Things to try:

I still consider this at the prototype/proof-of-concept stage. I'm still experimenting with the UI. The most important thing I feel is getting Haddock to emit the requisite information so that the JS can take over.

Note - for this demo I have disabled the standard click action on symbols.

Helkafen commented 8 years ago

Very nice! A few thoughts:

erantapaa commented 8 years ago

Hi Sebastian, thanks for the feedback.

A litte bit more about how things work...

http://erantapaa.github.io/haddock-demo/src/type-spans-Data.Compression.Inflate.js

So the current hightlight.js is compatible with these changes, but it also enables a user to supply their own version and create extra functionality such as what I've shown in the demo. My vision is that by making this information available someone with better JS/HTML skills might come along and make something really cool. Moreover, this additional information might be useful for other purposes.

I have code for both 7.10.x and 8.0.1. Unfortunately because of GHC-API changes there has to be two different versions.

You can view the PR I am in the process of preparing here:

https://github.com/haskell/haddock/compare/master...erantapaa:ghc8

Let me know what your thoughts are. I think it would be a great addition to haddock.

bgamari commented 8 years ago

I left the structure of the hyperlinked-source HTML alone. The only difference is that the anchor tags for imported symbols have an xdef= attribute which holds the module name from which the symbol was imported.

In my understanding you aren't supposed to claim attribute names which aren't defined in the HTML specification. Instead, user-defined attributes should occupy the data- attribute namespace. See this MDN article for details.