-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Haddocks from entity documentation comments (#1503)
* Include Haddock documentation in entity data type declarations * Mention partial Haddock support in Quasi module documentation * Configure Haddock generation using MkPersistSettings flag * Determine withDecDoc availability using MIN_VERSION_template_haskell * Generate Haddocks from field documentation comments * Add spec testing Haddock generation * Remove th-lift dependency * Process field Haddocks independently of model Haddocks Previously, field Haddocks would only be processed if a documentation comment was present on the model. This commit also uses putDoc for both field and model Haddocks, removing the withDecDoc import. * Add changelog entry and bump persistent version to 2.14.6.0
- Loading branch information
1 parent
c3c0145
commit 98ee544
Showing
7 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: persistent | ||
version: 2.14.5.1 | ||
version: 2.14.6.0 | ||
license: MIT | ||
license-file: LICENSE | ||
author: Michael Snoyman <[email protected]> | ||
|
@@ -173,6 +173,7 @@ test-suite test | |
Database.Persist.TH.CompositeKeyStyleSpec | ||
Database.Persist.TH.DiscoverEntitiesSpec | ||
Database.Persist.TH.EmbedSpec | ||
Database.Persist.TH.EntityHaddockSpec | ||
Database.Persist.TH.ForeignRefSpec | ||
Database.Persist.TH.ImplicitIdColSpec | ||
Database.Persist.TH.JsonEncodingSpec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Database.Persist.TH.EntityHaddockSpec (spec) where | ||
|
||
import TemplateTestImports | ||
|
||
#if MIN_VERSION_template_haskell(2,18,0) | ||
import Database.Persist.TH.CommentSpec (CommentModel (..)) | ||
import Language.Haskell.TH (DocLoc (DeclDoc), getDoc) | ||
import Language.Haskell.TH.Syntax (lift) | ||
|
||
[d| | ||
commentModelDoc :: Maybe String | ||
commentModelDoc = $(lift =<< getDoc (DeclDoc ''CommentModel)) | ||
|
||
commentFieldDoc :: Maybe String | ||
commentFieldDoc = $(lift =<< getDoc (DeclDoc 'commentModelName)) | ||
|] | ||
|
||
spec :: Spec | ||
spec = describe "EntityHaddockSpec" $ do | ||
it "generates entity Haddock" $ do | ||
let expected = unlines [ "Doc comments work." | ||
, "Has multiple lines." | ||
] | ||
commentModelDoc `shouldBe` Just expected | ||
it "generates field Haddock" $ do | ||
let expected = unlines [ "First line of comment on column." | ||
, "Second line of comment on column." | ||
] | ||
commentFieldDoc `shouldBe` Just expected | ||
#else | ||
spec :: Spec | ||
spec = pure () | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters