gendocs 0.1.2 → 0.1.3
raw patch · 3 files changed
+29/−9 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Data.Docs: genDocsWith :: forall a. (Generic a, GTypeName (Rep a), Selectors (Rep a)) => FieldModifier -> Text -> Proxy a -> Documentation
+ Data.Docs: type FieldModifier = String -> String
+ Data.Docs.Docs: genDocsWith :: forall a. (Generic a, GTypeName (Rep a), Selectors (Rep a)) => FieldModifier -> Text -> Proxy a -> Documentation
+ Data.Docs.Docs: type FieldModifier = String -> String
- Data.Docs: genFields :: forall a. (Selectors (Rep a)) => Proxy a -> [Field]
+ Data.Docs: genFields :: forall a. (Selectors (Rep a)) => FieldModifier -> Proxy a -> [Field]
- Data.Docs.Docs: genFields :: forall a. (Selectors (Rep a)) => Proxy a -> [Field]
+ Data.Docs.Docs: genFields :: forall a. (Selectors (Rep a)) => FieldModifier -> Proxy a -> [Field]
Files
- gendocs.cabal +1/−1
- src/Data/Docs.hs +2/−0
- src/Data/Docs/Docs.hs +26/−8
gendocs.cabal view
@@ -1,5 +1,5 @@ name: gendocs-version: 0.1.2+version: 0.1.3 synopsis: Library for generating interface documentation from types description: Please see README.md homepage: https://github.com/seanhess/gendocs#readme
src/Data/Docs.hs view
@@ -3,6 +3,8 @@ , Field(..) , Docs(..) , genDocs+ , genDocsWith+ , FieldModifier , genDocsEnum , genValues , genFields
src/Data/Docs/Docs.hs view
@@ -9,9 +9,11 @@ , Field(..) , Docs(..) , genDocs+ , genDocsWith , genDocsEnum , genValues , genFields+ , FieldModifier ) where import Data.Text (Text, pack)@@ -54,28 +56,44 @@ genDocs d p = Documentation { typeName = pack $ TypeName.typeName p , description = d- , fields = genFields p+ , fields = genFields id p , enumeratedValues = [] } ++genDocsWith :: forall a. (Generic a, GTypeName (Rep a), Selectors (Rep a)) => FieldModifier -> Text -> Proxy a -> Documentation+genDocsWith fieldModifier d p = Documentation+ { typeName = pack $ TypeName.typeName p+ , description = d+ , fields = genFields fieldModifier p+ , enumeratedValues = []+ }++ genDocsEnum :: forall a. (Generic a, GTypeName (Rep a), Selectors (Rep a), Bounded a, Enum a, Show a) => Text -> Proxy a -> Documentation genDocsEnum d p = (genDocs d p) { enumeratedValues = genValues p } -genFields :: forall a. (Selectors (Rep a)) => Proxy a -> [Field]-genFields _ = map (uncurry toField . selectorToText) $ selectors (Proxy :: Proxy (Rep a))+type FieldModifier = String -> String +genFields :: forall a. (Selectors (Rep a)) => FieldModifier -> Proxy a -> [Field]+genFields fieldModifier _ = map (uncurry toField . selectorToText fieldModifier) $ selectors (Proxy :: Proxy (Rep a))++ genValues :: forall a. (Enum a, Bounded a, Show a) => Proxy a -> [Text] genValues _ = map (pack . show) ([minBound..] :: [a]) -selectorToText :: (String, TypeRep) -> (Text, [Text])-selectorToText (s, t) = (pack s, T.words $ pack $ show t)+selectorToText :: FieldModifier -> (String, TypeRep) -> (String, [String])+selectorToText fieldModifier (s, t) = (fieldModifier s, words $ show t) -toField :: Text -> [Text] -> Field-toField s ("Maybe":t) = Field s (T.concat t) False-toField s t = Field s (T.concat t) True+toField :: String -> [String] -> Field+toField s ("Maybe":t) = field s (concat t) False+toField s t = field s (concat t) True++field :: String -> String -> Bool -> Field+field n t o = Field (T.pack n) (T.pack t) o