Verified Commit 7e8f1b69 authored by Camil Staps's avatar Camil Staps 🚀

Theoretically add constructor/field documentation to type def representations...

Theoretically add constructor/field documentation to type def representations (#5 -- though there is no functionality in platform yet to collect the comments of these elements into the TypeDoc)
parent 5ca29d3b
......@@ -3,6 +3,7 @@ implementation module Clean.Doc.ModuleCollection.HTML
import StdArray
import StdBool
import StdFile
import StdFunctions
import StdList
import StdOrdList
import StdString
......@@ -109,7 +110,18 @@ where
where
html dtd = collapsable thisfp "typedef" ("td-" +++ dtd.name) dtd.name dtd.pos $ catMaybes
[ DivTag [ClassAttr "clean-doc"] <$> pure <$> Text <$> (docDescription =<< dtd.doc)
, Just $ PreTag [ClassAttr "clean-code"] [Text (fromJust dtd.repr)]
, itemizedDoc "Type variable" =<< docVars <$> dtd.doc
, Just $ PreTag [ClassAttr "clean-code"] [Text $ case childdocs of
Nothing -> fromJust dtd.repr
Just cd -> intersperseDoc cd $ fromJust dtd.repr]
]
where
childdocs = (docFields =<< dtd.doc) <|> (map ((=<<) docDescription) <$> (docConstructors =<< dtd.doc))
intersperseDoc :: [Maybe String] String -> String
intersperseDoc cds repr = let [hd:tl] = split "\n" repr in join "\n"
[ hd
: [c +++ fromMaybe "" ((+++) " //* " <$> cd) \\ c <- tl & cd <- cds]
]
classes = if (isEmpty m.elem.mod_classes) []
......@@ -131,20 +143,20 @@ where
html df = collapsable thisfp kind (slug +++ "-" +++ df.name) df.name df.pos $ catMaybes
[ DivTag [ClassAttr "clean-doc"] <$> pure <$> Text <$> (docDescription =<< df.doc)
, PTag [ClassAttr "clean-doc"] <$> pure <$> Text <$> (docComplexity =<< df.doc)
, itemDocumentation "Type variable" =<< docVars <$> df.doc
, itemDocumentation "Parameter" =<< docParams <$> df.doc
, itemDocumentation "Result" =<< docResults <$> df.doc
, itemDocumentation "May throw exception" =<< docThrows <$> df.doc
, itemizedDoc "Type variable" =<< docVars <$> df.doc
, itemizedDoc "Parameter" =<< docParams <$> df.doc
, itemizedDoc "Result" =<< docResults <$> df.doc
, itemizedDoc "May throw exception" =<< docThrows <$> df.doc
, Just $ PreTag [ClassAttr "clean-code"] [Text $ case docType =<< df.doc of
Nothing -> fromJust df.repr
Just t -> df.name +++ " :: " +++ t <+ "\n" +++ fromJust df.repr]
]
itemDocumentation :: !String ![a] -> Maybe HtmlTag | toString a
itemDocumentation name [] = Nothing
itemDocumentation name [x] = Just $ PTag [ClassAttr "clean-doc"] [Text $ name +++ ": " <+ x]
itemDocumentation name xs = Just $ DivTag []
[ PTag [] [Text $ pluralise English name]
itemizedDoc :: !String ![a] -> Maybe HtmlTag | toString a
itemizedDoc name [] = Nothing
itemizedDoc name [x] = Just $ PTag [ClassAttr "clean-doc"] [Text $ name +++ ": " <+ x]
itemizedDoc name xs = Just $ DivTag []
[ PTag [] [Text $ pluralise English name +++ ":"]
, UlTag [] [LiTag [ClassAttr "clean-doc"] [Text $ toString x] \\ x <- xs]
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment