Documentation Comments in Quasiquoter#1024
Conversation
|
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 | |||
There was a problem hiding this comment.
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 |
| let [nameField, parentField] = entityFields edef | ||
| fieldComments nameField | ||
| `shouldBe` | ||
| Just "Fields should be documentable.\n" |
| {-# LANGUAGE StandaloneDeriving, UndecidableInstances #-} | ||
| {-# LANGUAGE ViewPatterns #-} | ||
|
|
||
| {-| |
There was a problem hiding this comment.
docs on docs in docs
| removeSpaces | ||
| . filter (not . empty) | ||
| . map tokenize | ||
| . T.lines |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
write moar datatypes
| associateLines :: [Line' NonEmpty] -> [LinesWithComments] | ||
| associateLines lines = | ||
| foldr combine [] $ | ||
| foldr toLinesWithComments [] lines |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
MUH TYPED GUARANTEES
| Nothing -> | ||
| ( maybe id (:) (setFieldComments comments <$> takeColsEx ps x) acc | ||
| , [] | ||
| ) |
There was a problem hiding this comment.
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.
Before submitting your PR, check that you've:
@sincedeclarations to the HaddockAfter submitting your PR:
Fixes #864