on master help sign in
Add superclass info to ClassDoc and output it in pprintDocs (:doc command)
commit6669a26010d9555d1ff60ff46938d20ae1eaea7f authorPaul Koerbitz <paul.koerbitz@theppro.com> dateSat 3 May 2014, 09:35 (12 years ago) parentf20f461
2 files changed+21−12
src/Idris/Docs.hs+12−3 src/Idris/IdrisDoc.hs+9−9
src/Idris/Docs.hs+12−3
@@ -29,6 +29,7 @@ data Docs = FunDoc FunDoc
2929 [FunDoc] -- method docs
3030 [(Name, Maybe Docstring)] -- parameters and their docstrings
3131 [PTerm] -- instances
32+ [PTerm] -- superclasses
3233 deriving Show
3334
3435showDoc d | nullDocstring d = empty
@@ -76,7 +77,7 @@ pprintDocs ist (DataDoc t args)
7677 = text "Data type" <+> pprintFD ist t <$>
7778 nest 4 (text "Constructors:" <> line <>
7879 vsep (map (pprintFD ist) args))
79−pprintDocs ist (ClassDoc n doc meths params instances)
80+pprintDocs ist (ClassDoc n doc meths params instances superclasses)
8081 = nest 4 (text "Type class" <+> prettyName imp [] n <>
8182 if nullDocstring doc then empty else line <> renderDocstring doc)
8283 <> line <$>
@@ -92,6 +93,10 @@ pprintDocs ist (ClassDoc n doc meths params instances)
9293 if null subclasses then empty
9394 else line <$> nest 4 (text "Subclasses:" <$>
9495 vsep (map (dumpInstance . prettifySubclasses) subclasses))
96+ <>
97+ if null superclasses then empty
98+ else line <$> nest 4 (text "Default superclass instances:" <$>
99+ vsep (map dumpInstance superclasses))
95100 where
96101 params' = zip pNames (repeat False)
97102
@@ -151,8 +156,12 @@ docClass n ci
151156 docstr = maybe emptyDocstring fst docStrings
152157 params = map (\pn -> (pn, docStrings >>= (lookup pn . snd))) (class_params ci)
153158 instances = map (delabTy i) (class_instances ci)
154− mdocs <- mapM (docFun .fst) (class_methods ci)
155− return $ ClassDoc n docstr mdocs params instances
159+ superclasses = catMaybes $ map getDInst (class_default_superclasses ci)
160+ mdocs <- mapM (docFun . fst) (class_methods ci)
161+ return $ ClassDoc n docstr mdocs params instances superclasses
162+ where
163+ getDInst (PInstance _ _ _ _ _ t _ _) = Just t
164+ getDInst _ = Nothing
156165
157166docFun :: Name -> Idris FunDoc
158167docFun n
src/Idris/IdrisDoc.hs+9−9
@@ -157,9 +157,9 @@ removeOrphans list =
157157 let children = S.fromList $ concatMap (names . (\(_, d, _) -> d)) list
158158 in filter ((`S.notMember` children) . (\(n, _, _) -> n)) list
159159
160− where names (Just (DataDoc _ fds)) = map (\(FD n _ _ _ _) -> n) fds
161− names (Just (ClassDoc _ _ fds _ _)) = map (\(FD n _ _ _ _) -> n) fds
162− names _ = []
160+ where names (Just (DataDoc _ fds)) = map (\(FD n _ _ _ _) -> n) fds
161+ names (Just (ClassDoc _ _ fds _ _ _)) = map (\(FD n _ _ _ _) -> n) fds
162+ names _ = []
163163
164164-- | Whether a Name names something which should be documented
165165filterName :: Name -- ^ Name to check
@@ -207,11 +207,11 @@ referredNss (n, Just d, _) =
207207 names = concatMap (extractPTermNames) ts
208208 in S.map getNs $ S.fromList names
209209
210− where getFunDocs (FunDoc f) = [f]
211− getFunDocs (DataDoc f fs) = f:fs
212− getFunDocs (ClassDoc _ _ fs _ _) = fs
213− types (FD _ _ args t _) = t:(map second args)
214− second (_, x, _, _) = x
210+ where getFunDocs (FunDoc f) = [f]
211+ getFunDocs (DataDoc f fs) = f:fs
212+ getFunDocs (ClassDoc _ _ fs _ _ _) = fs
213+ types (FD _ _ args t _) = t:(map second args)
214+ second (_, x, _, _) = x
215215
216216
217217-- | Returns an NsDict of containing all known namespaces and their contents
@@ -553,7 +553,7 @@ createOtherDoc :: IState -- ^ Needed to determine the types of names
553553 -> H.Html -- ^ Resulting HTML
554554createOtherDoc ist (FunDoc fd) = createFunDoc ist fd
555555
556−createOtherDoc ist (ClassDoc n docstring fds _ _) = do
556+createOtherDoc ist (ClassDoc n docstring fds _ _ _) = do
557557 H.dt ! (A.id $ toValue $ show n) $ do
558558 H.span ! class_ "word" $ do "class"; nbsp
559559 H.span ! class_ "name type"