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

Also index macros

parent c685684f
Pipeline #14651 failed with stage
in 55 seconds
......@@ -83,7 +83,11 @@ body, html {
}
.icon-generic:before {
color: #602a9e;
content: '\21d2';
content: '\21d2'; /* double arrow */
}
.icon-macro:before {
color: #49b8c6;
content: '\2261'; /* equivalence */
}
.icon-typedef:before {
color: #e3890b;
......@@ -121,6 +125,9 @@ body, html {
.collapsable-head-generic {
border-color: #602a9e;
}
.collapsable-head-macro {
border-color: #49b8c6;
}
.collapsable-head-typedef {
border-color: #e3890b;
}
......
Subproject commit 7a18f6a3295537ebfb0c7bec2f66b31d13baca2a
Subproject commit 29a67d5433511c435da89429cbfe072576533324
......@@ -26,6 +26,7 @@ instance < (Described e d)
, mod_classes :: ![DescribedClass]
, mod_generics :: ![DescribedGeneric]
, mod_functions :: ![DescribedFunction]
, mod_macros :: ![DescribedMacro]
}
:: DescribedTypeDef :== Described TypeDefDescription TypeDoc
......@@ -42,5 +43,8 @@ instance < (Described e d)
:: DescribedFunction :== Described FunctionDescription FunctionDoc
:: FunctionDescription = FunctionDescription
:: DescribedMacro :== Described MacroDescription FunctionDoc
:: MacroDescription = MacroDescription
collectModule :: !ModuleFindingOptions !FilePath !*World
-> *(!MaybeError String DescribedModule, !*World)
implementation module Clean.Doc.ModuleCollection
import StdFile
import StdFunctions
import StdMisc
import StdString
......@@ -9,22 +10,27 @@ import Clean.ModuleFinder
import Clean.Parse
import Clean.Parse.Comments
from Clean.PrettyPrint import class cpp(cpp), instance cpp ParsedDefinition
import Control.Applicative
import Control.Monad
import Data.Either
import Data.Error
from Data.Func import instance Functor ((->) a)
import Data.Functor
import Data.Maybe
from syntax import
:: ClassDef{class_ident},
:: FunKind,
:: FunSpecials,
:: GenericDef{gen_ident},
:: Ident{id_name},
:: Module{mod_defs,mod_ident},
:: Optional,
:: ParsedDefinition(PD_Class,PD_Generic,PD_Type,PD_TypeSpec),
:: Optional(Yes),
:: ParsedDefinition(PD_Class,PD_Function,PD_Generic,PD_Type,PD_TypeSpec),
:: ParsedExpr,
:: ParsedTypeDef,
:: Priority,
:: Rhs,
:: RhsDefsOfType,
:: SymbolType,
:: TypeDef{td_ident}
......@@ -48,10 +54,11 @@ collectModule mfo fp w
{ name = mod.mod_ident.id_name
, repr = Nothing
, elem =
{ mod_type_defs = [collectTypeDef doc pd \\ pd=:(PD_Type _) <- dcldefs]
, mod_classes = [collectClass doc pd \\ pd=:(PD_Class _ _) <- dcldefs]
, mod_generics = [collectGeneric doc pd \\ pd=:(PD_Generic _) <- dcldefs]
, mod_functions = [collectFunction doc pd \\ pd=:(PD_TypeSpec _ _ _ _ _) <- dcldefs]
{ mod_type_defs = [collectTypeDef doc pd \\ pd=:(PD_Type _) <- dcldefs]
, mod_classes = [collectClass doc pd \\ pd=:(PD_Class _ _) <- dcldefs]
, mod_generics = [collectGeneric doc pd \\ pd=:(PD_Generic _) <- dcldefs]
, mod_functions = [collectFunction doc pd \\ pd=:(PD_TypeSpec _ _ _ (Yes _) _) <- dcldefs]
, mod_macros = [collectMacro dcldefs doc pd \\ pd=:(PD_Function _ _ _ _ _ _) <- dcldefs]
}
, doc = moddoc
}
......@@ -98,3 +105,22 @@ where
Just (Right (doc,_)) -> Just doc
_ -> Nothing
}
collectMacro :: ![ParsedDefinition] !CollectedComments !ParsedDefinition -> DescribedMacro
collectMacro allpds cc pd=:(PD_Function _ id _ _ _ _) =
{ name = id.id_name
, repr = Just (fromMaybe "" ((flip (+++) "\n") <$> cpp <$> typespec) +++ cpp pd)
, elem = MacroDescription
, doc = case parseDoc <$> comment of
Just (Right (doc,_)) -> Just doc
_ -> Nothing
}
where
typespec = findTypeSpec id allpds
comment = getComment pd cc <|> (flip getComment cc =<< typespec)
findTypeSpec :: Ident [ParsedDefinition] -> Maybe ParsedDefinition
findTypeSpec _ [] = Nothing
findTypeSpec id [pd=:(PD_TypeSpec _ id` prio _ _):defs]
| id`.id_name == id.id_name = Just pd
findTypeSpec id [_:defs] = findTypeSpec id defs
......@@ -128,7 +128,15 @@ where
, Just $ PreTag [ClassAttr "clean-code"] [Html (fromJust df.repr)]
]
macros = []
macros = if (isEmpty m.elem.mod_macros) []
[ H1Tag [] [Text "Macros"]
: map html (sort m.elem.mod_macros)
]
where
html df = collapsable "macro" ("macro-" +++ df.name) df.name $ catMaybes
[ DivTag [ClassAttr "clean-doc"] <$> pure <$> Text <$> (docDescription =<< df.doc)
, Just $ PreTag [ClassAttr "clean-code"] [Html (fromJust df.repr)]
]
collapsable :: !String !String !String !a -> HtmlTag | html a
collapsable icon id title body = DivTag
......
......@@ -20,6 +20,7 @@ from Clean.Doc.ModuleCollection import :: Described, :: ModuleDescription,
| IIK_Class
| IIK_Generic
| IIK_Function
| IIK_Macro
derive JSONEncode IndexItem
......
......@@ -19,7 +19,8 @@ JSONEncode{|IndexItemKind|} _ iik = [JSONString case iik of
IIK_TypeDef -> "typedef"
IIK_Class -> "class"
IIK_Generic -> "generic"
IIK_Function -> "function"]
IIK_Function -> "function"
IIK_Macro -> "macro"]
JSONEncode{|IndexItem|} _ ii = [JSONObject $ catMaybes
[ Just ("module", JSONString ii.modul)
......@@ -34,6 +35,7 @@ where
IIK_Class -> "class"
IIK_Generic -> "gen"
IIK_Function -> "fun"
IIK_Macro -> "macro"
indexModuleCollection :: ModuleCollection -> [IndexItem]
indexModuleCollection mcoll = concatMap indexModule mcoll
......@@ -48,7 +50,8 @@ indexModule mod =
: map indexTypeDef mod.elem.mod_type_defs ++
map indexClass mod.elem.mod_classes ++
map indexGeneric mod.elem.mod_generics ++
map indexFunction mod.elem.mod_functions
map indexFunction mod.elem.mod_functions ++
map indexMacro mod.elem.mod_macros
]
where
//index :: (Described e d) -> IndexItem
......@@ -63,3 +66,4 @@ where
indexClass dc = {index dc & kind=IIK_Class}
indexGeneric dg = {index dg & kind=IIK_Generic}
indexFunction df = {index df & kind=IIK_Function}
indexMacro dm = {index dm & kind=IIK_Macro}
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