git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Only make image if necessary.
4982c01joneshf
docgen/Main.hs+16−12
@@ -14,17 +14,17 @@
14
14
15module Main where
15module Main where
16
16
17−import qualified Language.PureScript as P
18−import System.Console.CmdTheLine
19import Control.Applicative
17import Control.Applicative
20import Control.Monad
18import Control.Monad
21import Control.Monad.Writer
19import Control.Monad.Writer
22−import System.Exit (exitSuccess, exitFailure)
23−import qualified System.IO.UTF8 as U
24−import qualified Paths_purescript as Paths
25−import Data.Version (showVersion)
26−import Data.List
27import Data.Function (on)
20import Data.Function (on)
21+import Data.List
22+import Data.Version (showVersion)
23+import qualified Language.PureScript as P
24+import qualified Paths_purescript as Paths
25+import qualified System.IO.UTF8 as U
26+import System.Console.CmdTheLine
27+import System.Exit (exitSuccess, exitFailure)
28
28
29docgen :: FilePath -> IO ()
29docgen :: FilePath -> IO ()
30docgen input = do
30docgen input = do
@@ -61,6 +61,7 @@ renderModules ms = do
61renderModule :: P.Module -> Docs
61renderModule :: P.Module -> Docs
62renderModule (P.Module moduleName ds exps) =
62renderModule (P.Module moduleName ds exps) =
63 let exported = filter (isExported exps) ds
63 let exported = filter (isExported exps) ds
64+ hasTypeclasses = any isTypeClassDeclaration ds
64 in do
65 in do
65 headerLevel 2 $ "Module " ++ P.runModuleName moduleName
66 headerLevel 2 $ "Module " ++ P.runModuleName moduleName
66 spacer
67 spacer
@@ -70,8 +71,9 @@ renderModule (P.Module moduleName ds exps) =
70 spacer
71 spacer
71 headerLevel 3 "Type Classes"
72 headerLevel 3 "Type Classes"
72 spacer
73 spacer
74+ when hasTypeclasses $ do
73− renderTypeclassImage
75+ renderTypeclassImage moduleName
74− spacer
76+ spacer
75 renderTopLevel exps (filter isTypeClassDeclaration exported)
77 renderTopLevel exps (filter isTypeClassDeclaration exported)
76 spacer
78 spacer
77 headerLevel 3 "Type Class Instances"
79 headerLevel 3 "Type Class Instances"
@@ -85,7 +87,7 @@ renderModule (P.Module moduleName ds exps) =
85
87
86isExported :: Maybe [P.DeclarationRef] -> P.Declaration -> Bool
88isExported :: Maybe [P.DeclarationRef] -> P.Declaration -> Bool
87isExported Nothing _ = True
89isExported Nothing _ = True
88−isExported _ (P.TypeInstanceDeclaration _ _ _ _ _) = True
90+isExported _ P.TypeInstanceDeclaration{} = True
89isExported exps (P.PositionedDeclaration _ d) = isExported exps d
91isExported exps (P.PositionedDeclaration _ d) = isExported exps d
90isExported (Just exps) decl = any (matches decl) exps
92isExported (Just exps) decl = any (matches decl) exps
91 where
93 where
@@ -110,8 +112,10 @@ renderTopLevel exps decls = forM_ (sortBy (compare `on` getName) decls) $ \decl
110 renderDeclaration 4 exps decl
112 renderDeclaration 4 exps decl
111 spacer
113 spacer
112
114
113−renderTypeclassImage :: Docs
115+renderTypeclassImage :: P.ModuleName -> Docs
114−renderTypeclassImage = tell ["![typeclasses](typeclasses.png)"]
116+renderTypeclassImage name =
117+ let name' = P.runModuleName name
118+ in tell ["![" ++ name' ++ "](images/" ++ name' ++ ".png)"]
115
119
116renderDeclaration :: Int -> Maybe [P.DeclarationRef] -> P.Declaration -> Docs
120renderDeclaration :: Int -> Maybe [P.DeclarationRef] -> P.Declaration -> Docs
117renderDeclaration n _ (P.TypeDeclaration ident ty) =
121renderDeclaration n _ (P.TypeDeclaration ident ty) =
docs/source/prelude.rst+3−31
@@ -17,10 +17,10 @@ Types
17Type Classes
17Type Classes
18~~~~~~~~~~~~
18~~~~~~~~~~~~
19
19
20−.. figure:: typeclasses.png
20+.. figure:: images/Prelude.png
21− :alt: typeclasses
21+ :alt: Prelude
22
22
23− typeclasses
23+ Prelude
24::
24::
25
25
26 class Alternative f where
26 class Alternative f where
@@ -215,10 +215,6 @@ Types
215Type Classes
215Type Classes
216~~~~~~~~~~~~
216~~~~~~~~~~~~
217
217
218−.. figure:: typeclasses.png
219− :alt: typeclasses
220−
221− typeclasses
222Type Class Instances
218Type Class Instances
223~~~~~~~~~~~~~~~~~~~~
219~~~~~~~~~~~~~~~~~~~~
224
220
@@ -243,10 +239,6 @@ Types
243Type Classes
239Type Classes
244~~~~~~~~~~~~
240~~~~~~~~~~~~
245
241
246−.. figure:: typeclasses.png
247− :alt: typeclasses
248−
249− typeclasses
250Type Class Instances
242Type Class Instances
251~~~~~~~~~~~~~~~~~~~~
243~~~~~~~~~~~~~~~~~~~~
252
244
@@ -270,10 +262,6 @@ Types
270Type Classes
262Type Classes
271~~~~~~~~~~~~
263~~~~~~~~~~~~
272
264
273−.. figure:: typeclasses.png
274− :alt: typeclasses
275−
276− typeclasses
277Type Class Instances
265Type Class Instances
278~~~~~~~~~~~~~~~~~~~~
266~~~~~~~~~~~~~~~~~~~~
279
267
@@ -299,10 +287,6 @@ Types
299Type Classes
287Type Classes
300~~~~~~~~~~~~
288~~~~~~~~~~~~
301
289
302−.. figure:: typeclasses.png
303− :alt: typeclasses
304−
305− typeclasses
306Type Class Instances
290Type Class Instances
307~~~~~~~~~~~~~~~~~~~~
291~~~~~~~~~~~~~~~~~~~~
308
292
@@ -346,10 +330,6 @@ Types
346Type Classes
330Type Classes
347~~~~~~~~~~~~
331~~~~~~~~~~~~
348
332
349−.. figure:: typeclasses.png
350− :alt: typeclasses
351−
352− typeclasses
353Type Class Instances
333Type Class Instances
354~~~~~~~~~~~~~~~~~~~~
334~~~~~~~~~~~~~~~~~~~~
355
335
@@ -373,10 +353,6 @@ Types
373Type Classes
353Type Classes
374~~~~~~~~~~~~
354~~~~~~~~~~~~
375
355
376−.. figure:: typeclasses.png
377− :alt: typeclasses
378−
379− typeclasses
380Type Class Instances
356Type Class Instances
381~~~~~~~~~~~~~~~~~~~~
357~~~~~~~~~~~~~~~~~~~~
382
358
@@ -406,10 +382,6 @@ Types
406Type Classes
382Type Classes
407~~~~~~~~~~~~
383~~~~~~~~~~~~
408
384
409−.. figure:: typeclasses.png
410− :alt: typeclasses
411−
412− typeclasses
413Type Class Instances
385Type Class Instances
414~~~~~~~~~~~~~~~~~~~~
386~~~~~~~~~~~~~~~~~~~~
415
387
hierarchy/Main.hs+1−1
@@ -57,7 +57,7 @@ compile input mOutput = do
57 let hier = "digraph Prelude {\n" ++ intercalate "\n" (concatMap (fmap ((" " ++) . (++ ";") . show)) supers) ++ "\n}"
57 let hier = "digraph Prelude {\n" ++ intercalate "\n" (concatMap (fmap ((" " ++) . (++ ";") . show)) supers) ++ "\n}"
58 case mOutput of
58 case mOutput of
59 Just output -> U.writeFile output hier
59 Just output -> U.writeFile output hier
60− Nothing -> U.putStrLn hier
60+ Nothing -> U.putStrLn hier
61 exitSuccess
61 exitSuccess
62
62
63superClasses :: P.Declaration -> [SuperMap]
63superClasses :: P.Declaration -> [SuperMap]
prelude/README.md+1−15
@@ -11,7 +11,7 @@
11
11
12### Type Classes
12### Type Classes
13
13
14−![typeclasses](typeclasses.png)
14+![Prelude](images/Prelude.png)
15
15
16 class Alternative f where
16 class Alternative f where
17 empty :: forall a. f a
17 empty :: forall a. f a
@@ -200,8 +200,6 @@
200
200
201### Type Classes
201### Type Classes
202
202
203−![typeclasses](typeclasses.png)
204−
205
203
206### Type Class Instances
204### Type Class Instances
207
205
@@ -221,8 +219,6 @@
221
219
222### Type Classes
220### Type Classes
223
221
224−![typeclasses](typeclasses.png)
225−
226
222
227### Type Class Instances
223### Type Class Instances
228
224
@@ -241,8 +237,6 @@
241
237
242### Type Classes
238### Type Classes
243
239
244−![typeclasses](typeclasses.png)
245−
246
240
247### Type Class Instances
241### Type Class Instances
248
242
@@ -263,8 +257,6 @@
263
257
264### Type Classes
258### Type Classes
265
259
266−![typeclasses](typeclasses.png)
267−
268
260
269### Type Class Instances
261### Type Class Instances
270
262
@@ -303,8 +295,6 @@
303
295
304### Type Classes
296### Type Classes
305
297
306−![typeclasses](typeclasses.png)
307−
308
298
309### Type Class Instances
299### Type Class Instances
310
300
@@ -323,8 +313,6 @@
323
313
324### Type Classes
314### Type Classes
325
315
326−![typeclasses](typeclasses.png)
327−
328
316
329### Type Class Instances
317### Type Class Instances
330
318
@@ -349,8 +337,6 @@
349
337
350### Type Classes
338### Type Classes
351
339
352−![typeclasses](typeclasses.png)
353−
354
340
355### Type Class Instances
341### Type Class Instances
356
342
prelude/typeclasses.png → prelude/images/Prelude.pngrenamed

Binary file not shown.

prelude/updateDocs.sh+2−1
@@ -1,3 +1,4 @@
1../dist/build/docgen/docgen prelude.purs > README.md
1../dist/build/docgen/docgen prelude.purs > README.md
2+mkdir -p images
2−../dist/build/hierarchy/hierarchy prelude.purs | dot -Tpng -o typeclasses.png
3+../dist/build/hierarchy/hierarchy prelude.purs | dot -Tpng -o images/Prelude.png
3pandoc -o ../docs/source/prelude.rst README.md
4pandoc -o ../docs/source/prelude.rst README.md