git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #435 from purescript/docgen-no-prim
598c113Phil Freeman
docgen/Main.hs+12−4
@@ -135,20 +135,20 @@ renderTypeclassImage name =
135
135
136renderDeclaration :: Int -> Maybe [P.DeclarationRef] -> P.Declaration -> Docs
136renderDeclaration :: Int -> Maybe [P.DeclarationRef] -> P.Declaration -> Docs
137renderDeclaration n _ (P.TypeDeclaration ident ty) =
137renderDeclaration n _ (P.TypeDeclaration ident ty) =
138− atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
138+ atIndent n $ show ident ++ " :: " ++ prettyPrintType' ty
139renderDeclaration n _ (P.ExternDeclaration _ ident _ ty) =
139renderDeclaration n _ (P.ExternDeclaration _ ident _ ty) =
140− atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
140+ atIndent n $ show ident ++ " :: " ++ prettyPrintType' ty
141renderDeclaration n exps (P.DataDeclaration name args ctors) = do
141renderDeclaration n exps (P.DataDeclaration name args ctors) = do
142 let typeName = P.runProperName name ++ (if null args then "" else " " ++ unwords args)
142 let typeName = P.runProperName name ++ (if null args then "" else " " ++ unwords args)
143 let exported = filter (isDctorExported name exps . fst) ctors
143 let exported = filter (isDctorExported name exps . fst) ctors
144 atIndent n $ "data " ++ typeName ++ (if null exported then "" else " where")
144 atIndent n $ "data " ++ typeName ++ (if null exported then "" else " where")
145 forM_ exported $ \(ctor, tys) ->
145 forM_ exported $ \(ctor, tys) ->
146− atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> P.prettyPrintType ty ++ " -> ") tys ++ typeName
146+ atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> prettyPrintType' ty ++ " -> ") tys ++ typeName
147renderDeclaration n _ (P.ExternDataDeclaration name kind) =
147renderDeclaration n _ (P.ExternDataDeclaration name kind) =
148 atIndent n $ "data " ++ P.runProperName name ++ " :: " ++ P.prettyPrintKind kind
148 atIndent n $ "data " ++ P.runProperName name ++ " :: " ++ P.prettyPrintKind kind
149renderDeclaration n _ (P.TypeSynonymDeclaration name args ty) = do
149renderDeclaration n _ (P.TypeSynonymDeclaration name args ty) = do
150 let typeName = P.runProperName name ++ " " ++ unwords args
150 let typeName = P.runProperName name ++ " " ++ unwords args
151− atIndent n $ "type " ++ typeName ++ " = " ++ P.prettyPrintType ty
151+ atIndent n $ "type " ++ typeName ++ " = " ++ prettyPrintType' ty
152renderDeclaration n exps (P.TypeClassDeclaration name args implies ds) = do
152renderDeclaration n exps (P.TypeClassDeclaration name args implies ds) = do
153 let impliesText = case implies of
153 let impliesText = case implies of
154 [] -> ""
154 [] -> ""
@@ -164,6 +164,14 @@ renderDeclaration n exps (P.PositionedDeclaration _ d) =
164 renderDeclaration n exps d
164 renderDeclaration n exps d
165renderDeclaration _ _ _ = return ()
165renderDeclaration _ _ _ = return ()
166
166
167+prettyPrintType' :: P.Type -> String
168+prettyPrintType' = P.prettyPrintType . P.everywhereOnTypes dePrim
169+ where
170+ dePrim ty@(P.TypeConstructor (P.Qualified _ name))
171+ | ty == P.tyBoolean || ty == P.tyNumber || ty == P.tyString =
172+ P.TypeConstructor $ P.Qualified Nothing name
173+ dePrim other = other
174+
167getName :: P.Declaration -> String
175getName :: P.Declaration -> String
168getName (P.TypeDeclaration ident _) = show ident
176getName (P.TypeDeclaration ident _) = show ident
169getName (P.ExternDeclaration _ ident _ _) = show ident
177getName (P.ExternDeclaration _ ident _ _) = show ident