atom-haskell-archive / haskell-ghc-mod

haskell-ghc-mod atom package
https://atom.io/packages/haskell-ghc-mod
MIT License
69 stars 20 forks source link

Haddock experiment (WIP) #166

Open kostmo opened 8 years ago

kostmo commented 8 years ago

I would like to implement support for showing Haddock docstrings in tooltips alongside "info" or "type" information.

I'm hoping for some guidance both overall in the design and specifics of using the API and interfacing with the existing code. I am totally new to Coffeescript and Atom package development.

One of the outputs of the stack haddock --no-haddock-deps command is a text file for each package that says the following at the top:

-- Hoogle documentation, generated by Haddock

The contents of the file are pretty straightforward to parse. I wrote a function in haddock.js that generates a dictionary with symbol names as keys and haddock docstrings as values. Actually it's a nested dictionary with module names as the outer key.

For starters, the plugin could request that the user manually run the stack haddock command before documentation can be shown. Having even this basic functionality would be valuable for users that just need to browse through a Haskell codebase. Perhaps later the plugin could automatically run stack in the background, but I've noticed that it takes a long time (~1:30 in my project, or ~30s with --fast option).

I was able to get the Haddock strings to print to the console when mousing over a symbol, but somehow I was not able to propagate the same string all the way to the tooltip display. I think a short chat on IRC or something could clear up a lot of details for me.

lierdakil commented 8 years ago

Thanks for your efforts, that's appreciated.

You can usually find me on #ghc-mod at freenode (irc.freenode.net) -- nick's Lierdakil. Ping me and if I'm near IRC client, I'll try to answer. Bear in mind I'm on UTC+3 and usually busy in the afternoon, so 16 to 19 UTC would probably be the best time to catch me.