Skip to content

CodeAction to create Haddock comments #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spacekitteh opened this issue Sep 25, 2019 · 7 comments · Fixed by #673
Closed

CodeAction to create Haddock comments #403

spacekitteh opened this issue Sep 25, 2019 · 7 comments · Fixed by #673
Labels

Comments

@spacekitteh
Copy link

This would be super useful.

@ndmitchell
Copy link
Collaborator

What do you imagine it doing? Just inserting -- |? I wouldn't have thought that was that helpful - do you think it is? Or were you thinking of something more? When would this code action appear?

@spacekitteh spacekitteh changed the title CodeAction to create Haddock comment CodeAction to create Haddock comments Sep 29, 2019
@spacekitteh
Copy link
Author

Well, let's take a function definition. It should create a comment for the overall definition; further, it should create a comment for each argument. I wish Haddock had more expressive markup, because I would quite like to automatically insert a bunch of metadata tags too.

@cocreature
Copy link
Contributor

So you would like a code action to turn:

f :: Int -> Int
f = …

into the following

-- | 
f :: Int {- ^ -} -> Int

That sounds doable although I’m not entirely sure it’s super useful since compared to writing the actual docs, inserting the comments seems trivial.

@hazelweakly
Copy link

Turning

data A = A { a :: T, b :: T }

into

data A = A
  { a :: T
    -- ^ ____
  , b :: T
    -- ^ ____
  }

and

f :: ( A a , B b , C c) => a -> b -> c -> (a,b,c)

into

f
  :: ( A a
     , B b
     , C c
     )
  => a -- ^ ____
  -> b -- ^ ____
  -> c -- ^ ____
  -> (a,b,c) -- ^ ____

would save a non trivial amount of typing and would be quite convenient, I think.
Sure writing the docs is effort, but this reduces the inital setup, especially for "trivial" docs.

(The underscores are denoting snippet placeholders that the language server can use to jump you to each spot where comments can be added)

@spacekitteh
Copy link
Author

spacekitteh commented Oct 2, 2019

In addition to what @jared-w said, it would also help provide motivation to write docs. Who wants to see a bunch of useless comments? :D

@jneira
Copy link
Member

jneira commented Sep 15, 2020

I think this could be a plugin in hls, @ndmitchell @cocreature what do you think about translate this to hls?

@ndmitchell
Copy link
Collaborator

Definitely agreed - one for HLS. We should move most suggestions that can be implemented as HLS plugins, and don't reflect things already in Ghcide, over to HLS.

@jneira jneira transferred this issue from haskell/ghcide Sep 15, 2020
@berberman berberman mentioned this issue Dec 15, 2020
3 tasks
pepeiborra pushed a commit that referenced this issue Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants