Skip to content

Documentation Comments in Quasiquoter#1024

Merged
parsonsmatt merged 18 commits intomasterfrom
matt/doc-comments-quasiquoter
Feb 1, 2020
Merged

Documentation Comments in Quasiquoter#1024
parsonsmatt merged 18 commits intomasterfrom
matt/doc-comments-quasiquoter

Conversation

@parsonsmatt
Copy link
Collaborator

@parsonsmatt parsonsmatt commented Jan 29, 2020

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

Fixes #864

@parsonsmatt
Copy link
Collaborator Author

Well, fudge, I can't actually make these into Haddock comments because of this: https://gitlab.haskell.org/ghc/ghc/issues/5467

@@ -1,5 +1,5 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-} -- FIXME
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is now required by the syntax actually

* https://github.com/lpsmith/postgresql-simple/issues/69
* https://github.com/nikita-volkov/hasql-postgres/issues/1

## Documentation Comments
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

docs on docs

let [nameField, parentField] = entityFields edef
fieldComments nameField
`shouldBe`
Just "Fields should be documentable.\n"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tdd <3

{-# LANGUAGE StandaloneDeriving, UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}

{-|
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

docs on docs in docs

removeSpaces
. filter (not . empty)
. map tokenize
. T.lines
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i experienced confusing behavior so i factored a lot of functions out and wrote many tests

data LinesWithComments = LinesWithComments
{ lwcLines :: NonEmpty (Line' NonEmpty)
, lwcComments :: [Text]
} deriving (Eq, Show)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

write moar datatypes

associateLines :: [Line' NonEmpty] -> [LinesWithComments]
associateLines lines =
foldr combine [] $
foldr toLinesWithComments [] lines
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this has two foldr steps to reduce complexity, and also because it's genuinely easier to work on. happy for refactoring suggestions.

if minIndent < otherIndent then
appendLwc lwc lwc' : lwcs
else
lwc : lwc' : lwcs
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this code is kind of messy. it was developed with TDD so it's whatever i guess

minimumIndentOf = minimum . fmap lineIndent . lwcLines

skipEmpty :: [Line' []] -> [Line' NonEmpty]
skipEmpty = mapMaybe (traverseLine NEL.nonEmpty)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MUH TYPED GUARANTEES

Nothing ->
( maybe id (:) (setFieldComments comments <$> takeColsEx ps x) acc
, []
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a similar thing but fortunately the code here is much simpler. We just collect comments until we hit a FieldDef and then we set the comments and move on.

@parsonsmatt parsonsmatt merged commit c909dcc into master Feb 1, 2020
@parsonsmatt parsonsmatt deleted the matt/doc-comments-quasiquoter branch February 1, 2020 00:03
@parsonsmatt parsonsmatt restored the matt/doc-comments-quasiquoter branch March 31, 2020 15:22
@parsonsmatt parsonsmatt deleted the matt/doc-comments-quasiquoter branch March 31, 2020 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Documentation in Entity Syntax

1 participant