packages feed

gendocs 0.1.0.0 → 0.1.1

raw patch · 4 files changed

+25/−11 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Data.Docs: [enumeratedValues] :: Documentation -> [Text]
+ Data.Docs: genDocsWithValues :: forall a. (Generic a, GTypeName (Rep a), Selectors (Rep a), Bounded a, Enum a, Show a) => Text -> Proxy a -> Documentation
+ Data.Docs.Docs: [enumeratedValues] :: Documentation -> [Text]
+ Data.Docs.Docs: genDocsWithValues :: forall a. (Generic a, GTypeName (Rep a), Selectors (Rep a), Bounded a, Enum a, Show a) => Text -> Proxy a -> Documentation
+ Data.Docs.ToMarkdown: section :: [[Text]] -> Text
- Data.Docs: Documentation :: TypeName -> [Field] -> Text -> Documentation
+ Data.Docs: Documentation :: TypeName -> [Field] -> Text -> [Text] -> Documentation
- Data.Docs.Docs: Documentation :: TypeName -> [Field] -> Text -> Documentation
+ Data.Docs.Docs: Documentation :: TypeName -> [Field] -> Text -> [Text] -> Documentation
- Data.Docs.ToMarkdown: header :: Documentation -> [Text]
+ Data.Docs.ToMarkdown: header :: Text -> [Text]
- Data.Docs.ToMarkdown: valuesTable :: [Value] -> [Text]
+ Data.Docs.ToMarkdown: valuesTable :: [Text] -> [Text]

Files

gendocs.cabal view
@@ -1,5 +1,5 @@ name:                gendocs-version:             0.1.0.0+version:             0.1.1 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,7 @@   , Field(..)   , Docs(..)   , genDocs+  , genDocsWithValues   , genValues   , genFields   , Sample(..)
src/Data/Docs/Docs.hs view
@@ -9,6 +9,7 @@   , Field(..)   , Docs(..)   , genDocs+  , genDocsWithValues   , genValues   , genFields   ) where@@ -37,6 +38,7 @@     { typeName :: TypeName     , fields :: [Field]     , description :: Text+    , enumeratedValues :: [Text]     } deriving (Show, Eq)  -- | Documentation for a record field@@ -53,7 +55,13 @@     { typeName = pack $ TypeName.typeName p     , description = d     , fields = genFields p+    , enumeratedValues = []     }++genDocsWithValues :: forall a. (Generic a, GTypeName (Rep a), Selectors (Rep a), Bounded a, Enum a, Show a) => Text -> Proxy a -> Documentation+genDocsWithValues d p =+    (genDocs d p)+      { enumeratedValues = genValues p }   genFields :: forall a. (Selectors (Rep a)) => Proxy a -> [Field]
src/Data/Docs/ToMarkdown.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Data.Docs.ToMarkdown where -import Data.Aeson (ToJSON, toJSON, Value, encode)+import Data.Aeson (ToJSON) import Data.Aeson.Encode.Pretty (encodePretty', defConfig, Config(..)) import Data.Char (isAlphaNum) import Data.Data (Proxy(..))@@ -21,22 +21,27 @@ markdown p =   let d = docs p       s = sample p-      vs =  allValues p-  in Text.intercalate "\n\n" $ map (Text.intercalate "\n") $ filter (not . List.null)-  [ header d+  in section $ filter (not . List.null)+  [ header (typeName d)   , desc (description d)   , fieldTable (fields d)-  , valuesTable (map toJSON vs)+  , valuesTable (enumeratedValues d)   , example s   ] ++section :: [[Text]] -> Text+section = Text.intercalate "\n\n" . map Text.unlines++ desc :: Text -> [Text] desc "" = [] desc d = [d] -header :: Documentation -> [Text]-header d =-  [ typeName d++header :: Text -> [Text]+header t =+  [ t   , "---------------------"   ] @@ -76,12 +81,12 @@         else "(optional)"  -valuesTable :: [Value] -> [Text]+valuesTable :: [Text] -> [Text] valuesTable [] = [] valuesTable vs =   table ["Values"] (map row vs)   where-    row t = [ Text.decodeUtf8 $ BSL.toStrict $ encode t ]+    row t = [ t ]   -- | Tables