We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Verified Commit acb3beba authored by Camil Staps's avatar Camil Staps 🚀

Add classes and functions

parent 00d1cc7d
......@@ -13,14 +13,32 @@ body, html {
}
#sidebar {
background: white;
border-color: black;
border-style: solid;
border-width: 0 1px 0 0;
height: 100%;
min-width: 200px;
overflow: auto;
position: fixed;
resize: horizontal;
width: 15%;
}
#toc {
height: 70%;
outline: 1px solid black;
overflow: auto;
}
#search {
height: 30%;
overflow: auto;
}
#content {
left: 20%;
padding: 0 1em;
position: absolute;
right: 0;
top: 0;
......
......@@ -2,7 +2,7 @@
/* Highlight Clean code */
var codes = document.getElementsByClassName('clean-code');
for (var i = 0; i < codes.length; i++) {
codes[i].innerHTML = highlightClean(codes[i].innerHTML);
codes[i].innerHTML = highlightClean(codes[i].innerText);
}
/* Resizable sidebar */
......
definition module Clean.Doc.ModuleCollection
from Clean.Doc import :: ModuleDoc, :: TypeDoc
from StdOverloaded import class <
from Clean.Doc import :: ClassDoc, :: FunctionDoc, :: ModuleDoc, :: TypeDoc
from Clean.ModuleFinder import :: ModuleFindingOptions
from Data.Error import :: MaybeError
from Data.Maybe import :: Maybe
......@@ -15,12 +17,20 @@ from System.FilePath import :: FilePath
, doc :: !Maybe doc
}
instance < (Described e d)
:: DescribedModule :== Described ModuleDescription ModuleDoc
:: ModuleDescription =
{ mod_type_defs :: ![DescribedTypeDef]
, mod_classes :: ![DescribedClass]
, mod_functions :: ![DescribedFunction]
}
:: DescribedTypeDef :== Described () TypeDoc
:: DescribedClass :== Described [DescribedFunction] ClassDoc
:: DescribedFunction :== Described () FunctionDoc
collectModule :: !ModuleFindingOptions !FilePath !*World
-> *(!MaybeError String DescribedModule, !*World)
......@@ -2,6 +2,7 @@ implementation module Clean.Doc.ModuleCollection
import StdFile
import StdMisc
import StdString
import Clean.Doc
import Clean.ModuleFinder
......@@ -15,13 +16,20 @@ import Data.Functor
import Data.Maybe
from syntax import
:: ClassDef{class_ident},
:: FunSpecials,
:: Ident{id_name},
:: Module{mod_defs,mod_ident},
:: ParsedDefinition(PD_Type),
:: Optional,
:: ParsedDefinition(PD_Class,PD_Type,PD_TypeSpec),
:: ParsedTypeDef,
:: Priority,
:: RhsDefsOfType,
:: SymbolType,
:: TypeDef{td_ident}
instance < (Described e d) where < a b = a.Described.name < b.Described.name
collectModule :: !ModuleFindingOptions !FilePath !*World
-> *(!MaybeError String DescribedModule, !*World)
collectModule mfo fp w
......@@ -29,17 +37,19 @@ collectModule mfo fp w
# (dcl,w) = readModule fp w
| isError dcl = (Error (fromError dcl), w)
# (dcl,_) = fromOk dcl
# (mod,dcldefs,documentation) = (dcl, dcl.mod_defs, case comments of
# (mod,dcldefs,doc) = (dcl, dcl.mod_defs, case comments of
Error _ -> emptyCollectedComments
Ok comments -> collectComments comments dcl)
# moddoc = case parseDoc <$> getComment mod documentation of
# moddoc = case parseDoc <$> getComment mod doc of
Just (Right (doc,_)) -> Just doc
_ -> Nothing
# moddesc =
{ name = mod.mod_ident.id_name
, repr = Nothing
, elem =
{ mod_type_defs = [collectTypeDef documentation pd \\ pd=:(PD_Type _) <- dcldefs]
{ mod_type_defs = [collectTypeDef doc pd \\ pd=:(PD_Type _) <- dcldefs]
, mod_classes = [collectClass doc pd \\ pd=:(PD_Class _ _) <- dcldefs]
, mod_functions = [collectFunction doc pd \\ pd=:(PD_TypeSpec _ _ _ _ _) <- dcldefs]
}
, doc = moddoc
}
......@@ -54,3 +64,23 @@ where
Just (Right (doc,_)) -> Just doc
_ -> Nothing
}
collectClass :: !CollectedComments !ParsedDefinition -> DescribedClass
collectClass cc pd=:(PD_Class cd members) =
{ name = cd.class_ident.id_name
, repr = Just (cpp pd)
, elem = [collectFunction cc m \\ m <- members]
, doc = case parseDoc <$> getComment pd cc of
Just (Right (doc,_)) -> Just doc
_ -> Nothing
}
collectFunction :: !CollectedComments !ParsedDefinition -> DescribedFunction
collectFunction cc pd=:(PD_TypeSpec _ id _ _ _) =
{ name = id.id_name
, repr = Just (cpp pd)
, elem = ()
, doc = case parseDoc <$> getComment pd cc of
Just (Right (doc,_)) -> Just doc
_ -> Nothing
}
......@@ -4,6 +4,7 @@ import StdArray
import StdBool
import StdFile
import StdList
import StdOrdList
import StdTuple
import Clean.Doc => qualified :: ParamDoc{name}
......@@ -40,8 +41,11 @@ where
]
, BodyTag []
[ DivTag [IdAttr "container"]
[ DivTag [IdAttr "sidebar"] [Text "sidebar"]
, DivTag [IdAttr "content"] [html]
[ DivTag [IdAttr "content"] [html]
, DivTag [IdAttr "sidebar"]
[ DivTag [IdAttr "toc"] [Text "sidebar"]
, DivTag [IdAttr "search"] [Text "(search functionality not implemented yet)"]
]
]
]
]
......@@ -67,20 +71,38 @@ where
typedefs =
[ H1Tag [] [Text "Type definitions"]
: map html m.elem.mod_type_defs
: map html (sort m.elem.mod_type_defs)
]
where
html dtd = DivTag [IdAttr ("td-" +++ dtd.name)] $ catMaybes
[ Just $ H2Tag [] [Text dtd.name]
, DivTag [] <$> pure <$> Text <$> (docDescription =<< dtd.doc)
, Just $ PreTag [ClassAttr "clean-code"] [Text (fromJust dtd.repr)]
, Just $ PreTag [ClassAttr "clean-code"] [Html (fromJust dtd.repr)]
]
classes = []
classes =
[ H1Tag [] [Text "Classes"]
: map html (sort m.elem.mod_classes)
]
where
html dc = DivTag [IdAttr ("class-" +++ dc.name)] $ catMaybes
[ Just $ H2Tag [] [Text dc.name]
, DivTag [] <$> pure <$> Text <$> (docDescription =<< dc.doc)
, Just $ PreTag [ClassAttr "clean-code"] [Html (fromJust dc.repr)]
]
macros = []
functions = []
functions =
[ H1Tag [] [Text "Functions"]
: map html (sort m.elem.mod_functions)
]
where
html df = DivTag [IdAttr ("fun-" +++ df.name)] $ catMaybes
[ Just $ H2Tag [] [Text df.name]
, DivTag [] <$> pure <$> Text <$> (docDescription =<< df.doc)
, Just $ PreTag [ClassAttr "clean-code"] [Html (fromJust df.repr)]
]
writeHTMLSite :: !FilePath !HTMLSite !*World -> *(![String], !*World)
writeHTMLSite root site w
......
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