Skip to content

[purs ide] return documentation comments#3138

Merged
kritzcreek merged 1 commit into
purescript:masterfrom
nwolverson:ide-docstrings
Oct 30, 2017
Merged

[purs ide] return documentation comments#3138
kritzcreek merged 1 commit into
purescript:masterfrom
nwolverson:ide-docstrings

Conversation

@nwolverson

@nwolverson nwolverson commented Oct 27, 2017

Copy link
Copy Markdown
Contributor

For #2349.

My first iteration used more docs code but I think this is simpler and works out better.

I'm thinking that markdown, plaintext and html options could be provided since there's already a markdown renderer there.

@kritzcreek

@kritzcreek kritzcreek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you! I've added two requests. Could you also add a test? You can check out the tests that use Test.runIde to see how to test that the resolution process worked out.

Comment thread src/Language/PureScript/Ide/State.hs Outdated
d
where
docs :: P.Name -> Maybe Text
docs ident = convertComments =<< Map.lookup (ident) comments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a fromMaybe "" at the end of this, so it's easier to tell whether or not we've already attempted to resolve documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So returning "" instead of null in the json output if there is no docs? Maybe Maybe Maybe _?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about Maybe Maybe but at that point I'd prefer a custom three valued data type. Also note that convertComments returns Nothing if it sees an empty string.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I see it now the KiName TyName ... stuff is from Docs. Sorry for being a little thick xD

While we're at it, there are redundant parens around ident in this line.

-> [IdeDeclarationAnn]
resolveDocumentationForModule (P.Module _ _ _ sdecls _) decls = map convertDecl decls
where
comments :: Map P.Name [P.Comment]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the namespace here, to tell Kinds from Types from data constructors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that not inherent in Name? KiName | TyName | DctorName etc?

@kritzcreek kritzcreek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Just a few minor things left, then this is good to go for me.

import Language.PureScript.Ide.Completion
import Language.PureScript.Ide.Test
import Language.PureScript.Ide.Test as Test
import Language.PureScript.Ide.Command as Command

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import formatting is inconsistent here, I don't mind leaving space for qualified, but let's apply that formatting on every import in this file then.


-- spec :: Spec
-- spec = describe "Rebuilding single modules" $ do
-- it "rebuilds a correct module without dependencies successfully" $ do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really mind the Type command comment, but this one should be deleted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh I guess I was tired, such half-assery. thanks

@kritzcreek

Copy link
Copy Markdown
Member

Great, Thanks!

@kritzcreek kritzcreek merged commit 3541dd2 into purescript:master Oct 30, 2017
paf31 pushed a commit that referenced this pull request Nov 8, 2017
jutaro pushed a commit to mgmeier/purescript that referenced this pull request Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants