on master help sign in
Add superclass info to ClassDoc and output it in pprintDocs (:doc command)
6669a26Paul Koerbitz
src/Idris/Docs.hs+12−3
@@ -29,6 +29,7 @@ data Docs = FunDoc FunDoc
29 [FunDoc] -- method docs
29 [FunDoc] -- method docs
30 [(Name, Maybe Docstring)] -- parameters and their docstrings
30 [(Name, Maybe Docstring)] -- parameters and their docstrings
31 [PTerm] -- instances
31 [PTerm] -- instances
32+ [PTerm] -- superclasses
32 deriving Show
33 deriving Show
33
34
34showDoc d | nullDocstring d = empty
35showDoc d | nullDocstring d = empty
@@ -76,7 +77,7 @@ pprintDocs ist (DataDoc t args)
76 = text "Data type" <+> pprintFD ist t <$>
77 = text "Data type" <+> pprintFD ist t <$>
77 nest 4 (text "Constructors:" <> line <>
78 nest 4 (text "Constructors:" <> line <>
78 vsep (map (pprintFD ist) args))
79 vsep (map (pprintFD ist) args))
79−pprintDocs ist (ClassDoc n doc meths params instances)
80+pprintDocs ist (ClassDoc n doc meths params instances superclasses)
80 = nest 4 (text "Type class" <+> prettyName imp [] n <>
81 = nest 4 (text "Type class" <+> prettyName imp [] n <>
81 if nullDocstring doc then empty else line <> renderDocstring doc)
82 if nullDocstring doc then empty else line <> renderDocstring doc)
82 <> line <$>
83 <> line <$>
@@ -92,6 +93,10 @@ pprintDocs ist (ClassDoc n doc meths params instances)
92 if null subclasses then empty
93 if null subclasses then empty
93 else line <$> nest 4 (text "Subclasses:" <$>
94 else line <$> nest 4 (text "Subclasses:" <$>
94 vsep (map (dumpInstance . prettifySubclasses) subclasses))
95 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))
95 where
100 where
96 params' = zip pNames (repeat False)
101 params' = zip pNames (repeat False)
97
102
@@ -151,8 +156,12 @@ docClass n ci
151 docstr = maybe emptyDocstring fst docStrings
156 docstr = maybe emptyDocstring fst docStrings
152 params = map (\pn -> (pn, docStrings >>= (lookup pn . snd))) (class_params ci)
157 params = map (\pn -> (pn, docStrings >>= (lookup pn . snd))) (class_params ci)
153 instances = map (delabTy i) (class_instances ci)
158 instances = map (delabTy i) (class_instances ci)
159+ superclasses = catMaybes $ map getDInst (class_default_superclasses ci)
154− mdocs <- mapM (docFun .fst) (class_methods ci)
160+ mdocs <- mapM (docFun . fst) (class_methods ci)
155− return $ ClassDoc n docstr mdocs params instances
161+ return $ ClassDoc n docstr mdocs params instances superclasses
162+ where
163+ getDInst (PInstance _ _ _ _ _ t _ _) = Just t
164+ getDInst _ = Nothing
156
165
157docFun :: Name -> Idris FunDoc
166docFun :: Name -> Idris FunDoc
158docFun n
167docFun n
src/Idris/IdrisDoc.hs+9−9
@@ -157,9 +157,9 @@ removeOrphans list =
157 let children = S.fromList $ concatMap (names . (\(_, d, _) -> d)) list
157 let children = S.fromList $ concatMap (names . (\(_, d, _) -> d)) list
158 in filter ((`S.notMember` children) . (\(n, _, _) -> n)) list
158 in filter ((`S.notMember` children) . (\(n, _, _) -> n)) list
159
159
160− where names (Just (DataDoc _ fds)) = map (\(FD n _ _ _ _) -> n) fds
160+ where names (Just (DataDoc _ fds)) = map (\(FD n _ _ _ _) -> n) fds
161− names (Just (ClassDoc _ _ fds _ _)) = map (\(FD n _ _ _ _) -> n) fds
161+ names (Just (ClassDoc _ _ fds _ _ _)) = map (\(FD n _ _ _ _) -> n) fds
162− names _ = []
162+ names _ = []
163
163
164-- | Whether a Name names something which should be documented
164-- | Whether a Name names something which should be documented
165filterName :: Name -- ^ Name to check
165filterName :: Name -- ^ Name to check
@@ -207,11 +207,11 @@ referredNss (n, Just d, _) =
207 names = concatMap (extractPTermNames) ts
207 names = concatMap (extractPTermNames) ts
208 in S.map getNs $ S.fromList names
208 in S.map getNs $ S.fromList names
209
209
210− where getFunDocs (FunDoc f) = [f]
210+ where getFunDocs (FunDoc f) = [f]
211− getFunDocs (DataDoc f fs) = f:fs
211+ getFunDocs (DataDoc f fs) = f:fs
212− getFunDocs (ClassDoc _ _ fs _ _) = fs
212+ getFunDocs (ClassDoc _ _ fs _ _ _) = fs
213− types (FD _ _ args t _) = t:(map second args)
213+ types (FD _ _ args t _) = t:(map second args)
214− second (_, x, _, _) = x
214+ second (_, x, _, _) = x
215
215
216
216
217-- | Returns an NsDict of containing all known namespaces and their contents
217-- | Returns an NsDict of containing all known namespaces and their contents
@@ -553,7 +553,7 @@ createOtherDoc :: IState -- ^ Needed to determine the types of names
553 -> H.Html -- ^ Resulting HTML
553 -> H.Html -- ^ Resulting HTML
554createOtherDoc ist (FunDoc fd) = createFunDoc ist fd
554createOtherDoc ist (FunDoc fd) = createFunDoc ist fd
555
555
556−createOtherDoc ist (ClassDoc n docstring fds _ _) = do
556+createOtherDoc ist (ClassDoc n docstring fds _ _ _) = do
557 H.dt ! (A.id $ toValue $ show n) $ do
557 H.dt ! (A.id $ toValue $ show n) $ do
558 H.span ! class_ "word" $ do "class"; nbsp
558 H.span ! class_ "word" $ do "class"; nbsp
559 H.span ! class_ "name type"
559 H.span ! class_ "name type"