git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2591 from purescript/add-html-rendering

Add modules for rendering HTML documentation

commitbb794209f7139c517b0bf6f484e5af724aa747c7 authorHarry Garrood <harry@garrood.me> dateSun 22 Jan 2017, 23:24 (10 years ago) parentf5de9065c59ba4
4 files changed+696−1
LICENSE+310 purescript.cabal+3 src/Language/PureScript/Docs/AsHtml.hs+299 src/Language/PureScript/Docs/Types.hs+84−1
LICENSE+310
@@ -48,6 +48,7 @@ PureScript uses the following Haskell library packages. Their license files foll
4848 bytestring-builder
4949 case-insensitive
5050 cereal
51+ cheapskate
5152 clock
5253 cmdargs
5354 comonad
@@ -58,7 +59,13 @@ PureScript uses the following Haskell library packages. Their license files foll
5859 contravariant
5960 cookie
6061 cryptonite
62+ css-text
63+ data-default
6164 data-default-class
65+ data-default-instances-base
66+ data-default-instances-containers
67+ data-default-instances-dlist
68+ data-default-instances-old-locale
6269 data-ordlist
6370 deepseq
6471 directory
@@ -142,6 +149,7 @@ PureScript uses the following Haskell library packages. Their license files foll
142149 system-fileio
143150 system-filepath
144151 tagged
152+ tagsoup
145153 template-haskell
146154 temporary
147155 terminfo
@@ -152,6 +160,7 @@ PureScript uses the following Haskell library packages. Their license files foll
152160 transformers-base
153161 transformers-compat
154162 turtle
163+ uniplate
155164 unix
156165 unix-compat
157166 unix-time
@@ -172,6 +181,7 @@ PureScript uses the following Haskell library packages. Their license files foll
172181 x509-store
173182 x509-system
174183 x509-validation
184+ xss-sanitize
175185 zlib
176186
177187Glob LICENSE file:
@@ -1311,6 +1321,39 @@ cereal LICENSE file:
13111321 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
13121322 POSSIBILITY OF SUCH DAMAGE.
13131323
1324+cheapskate LICENSE file:
1325+
1326+ Copyright (c) 2013, John MacFarlane
1327+
1328+ All rights reserved.
1329+
1330+ Redistribution and use in source and binary forms, with or without
1331+ modification, are permitted provided that the following conditions are met:
1332+
1333+ * Redistributions of source code must retain the above copyright
1334+ notice, this list of conditions and the following disclaimer.
1335+
1336+ * Redistributions in binary form must reproduce the above
1337+ copyright notice, this list of conditions and the following
1338+ disclaimer in the documentation and/or other materials provided
1339+ with the distribution.
1340+
1341+ * Neither the name of John MacFarlane nor the names of other
1342+ contributors may be used to endorse or promote products derived
1343+ from this software without specific prior written permission.
1344+
1345+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1346+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1347+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1348+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1349+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1350+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1351+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1352+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1353+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1354+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1355+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1356+
13141357clock LICENSE file:
13151358
13161359 Copyright (c) 2009-2012, Cetin Sert
@@ -1606,6 +1649,63 @@ cryptonite LICENSE file:
16061649 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16071650 SUCH DAMAGE.
16081651
1652+css-text LICENSE file:
1653+
1654+ The following license covers this documentation, and the source code, except
1655+ where otherwise indicated.
1656+
1657+ Copyright 2010, Michael Snoyman. All rights reserved.
1658+
1659+ Redistribution and use in source and binary forms, with or without
1660+ modification, are permitted provided that the following conditions are met:
1661+
1662+ * Redistributions of source code must retain the above copyright notice, this
1663+ list of conditions and the following disclaimer.
1664+
1665+ * Redistributions in binary form must reproduce the above copyright notice,
1666+ this list of conditions and the following disclaimer in the documentation
1667+ and/or other materials provided with the distribution.
1668+
1669+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR
1670+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1671+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
1672+ EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
1673+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1674+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
1675+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1676+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
1677+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
1678+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1679+
1680+data-default LICENSE file:
1681+
1682+ Copyright (c) 2013 Lukas Mai
1683+
1684+ All rights reserved.
1685+
1686+ Redistribution and use in source and binary forms, with or without modification,
1687+ are permitted provided that the following conditions are met:
1688+
1689+ * Redistributions of source code must retain the above copyright notice, this
1690+ list of conditions and the following disclaimer.
1691+ * Redistributions in binary form must reproduce the above copyright notice,
1692+ this list of conditions and the following disclaimer in the documentation
1693+ and/or other materials provided with the distribution.
1694+ * Neither the name of the author nor the names of his contributors
1695+ may be used to endorse or promote products derived from this software
1696+ without specific prior written permission.
1697+
1698+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1699+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1700+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1701+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
1702+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1703+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1704+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1705+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1706+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1707+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1708+
16091709data-default-class LICENSE file:
16101710
16111711 Copyright (c) 2013 Lukas Mai
@@ -1635,6 +1735,122 @@ data-default-class LICENSE file:
16351735 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
16361736 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16371737
1738+data-default-instances-base LICENSE file:
1739+
1740+ Copyright (c) 2013 Lukas Mai
1741+
1742+ All rights reserved.
1743+
1744+ Redistribution and use in source and binary forms, with or without modification,
1745+ are permitted provided that the following conditions are met:
1746+
1747+ * Redistributions of source code must retain the above copyright notice, this
1748+ list of conditions and the following disclaimer.
1749+ * Redistributions in binary form must reproduce the above copyright notice,
1750+ this list of conditions and the following disclaimer in the documentation
1751+ and/or other materials provided with the distribution.
1752+ * Neither the name of the author nor the names of his contributors
1753+ may be used to endorse or promote products derived from this software
1754+ without specific prior written permission.
1755+
1756+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1757+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1758+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1759+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
1760+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1761+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1762+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1763+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1764+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1765+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1766+
1767+data-default-instances-containers LICENSE file:
1768+
1769+ Copyright (c) 2013 Lukas Mai
1770+
1771+ All rights reserved.
1772+
1773+ Redistribution and use in source and binary forms, with or without modification,
1774+ are permitted provided that the following conditions are met:
1775+
1776+ * Redistributions of source code must retain the above copyright notice, this
1777+ list of conditions and the following disclaimer.
1778+ * Redistributions in binary form must reproduce the above copyright notice,
1779+ this list of conditions and the following disclaimer in the documentation
1780+ and/or other materials provided with the distribution.
1781+ * Neither the name of the author nor the names of his contributors
1782+ may be used to endorse or promote products derived from this software
1783+ without specific prior written permission.
1784+
1785+ THIS SOFTWARE IS PROVIDED BY LUKAS MAI AND CONTRIBUTORS "AS IS" AND ANY
1786+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1787+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1788+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
1789+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1790+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1791+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
1792+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1793+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1794+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1795+
1796+data-default-instances-dlist LICENSE file:
1797+
1798+ Copyright (c) 2013 Lukas Mai
1799+
1800+ All rights reserved.
1801+
1802+ Redistribution and use in source and binary forms, with or without modification,
1803+ are permitted provided that the following conditions are met:
1804+
1805+ * Redistributions of source code must retain the above copyright notice, this
1806+ list of conditions and the following disclaimer.
1807+ * Redistributions in binary form must reproduce the above copyright notice,
1808+ this list of conditions and the following disclaimer in the documentation
1809+ and/or other materials provided with the distribution.
1810+ * Neither the name of the author nor the names of his contributors
1811+ may be used to endorse or promote products derived from this software
1812+ without specific prior written permission.
1813+
1814+ THIS SOFTWARE IS PROVIDED BY LUKAS MAI AND CONTRIBUTORS "AS IS" AND ANY
1815+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1816+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1817+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
1818+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1819+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1820+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
1821+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1822+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1823+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1824+
1825+data-default-instances-old-locale LICENSE file:
1826+
1827+ Copyright (c) 2013 Lukas Mai
1828+
1829+ All rights reserved.
1830+
1831+ Redistribution and use in source and binary forms, with or without modification,
1832+ are permitted provided that the following conditions are met:
1833+
1834+ * Redistributions of source code must retain the above copyright notice, this
1835+ list of conditions and the following disclaimer.
1836+ * Redistributions in binary form must reproduce the above copyright notice,
1837+ this list of conditions and the following disclaimer in the documentation
1838+ and/or other materials provided with the distribution.
1839+ * Neither the name of the author nor the names of his contributors
1840+ may be used to endorse or promote products derived from this software
1841+ without specific prior written permission.
1842+
1843+ THIS SOFTWARE IS PROVIDED BY LUKAS MAI AND CONTRIBUTORS "AS IS" AND ANY
1844+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1845+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1846+ DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
1847+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1848+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1849+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
1850+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1851+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1852+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1853+
16381854data-ordlist LICENSE file:
16391855
16401856 Copyright (c) 2009-2010, Melding Monads
@@ -4366,6 +4582,39 @@ tagged LICENSE file:
43664582 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43674583 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43684584
4585+tagsoup LICENSE file:
4586+
4587+ Copyright Neil Mitchell 2006-2016.
4588+ All rights reserved.
4589+
4590+ Redistribution and use in source and binary forms, with or without
4591+ modification, are permitted provided that the following conditions are
4592+ met:
4593+
4594+ * Redistributions of source code must retain the above copyright
4595+ notice, this list of conditions and the following disclaimer.
4596+
4597+ * Redistributions in binary form must reproduce the above
4598+ copyright notice, this list of conditions and the following
4599+ disclaimer in the documentation and/or other materials provided
4600+ with the distribution.
4601+
4602+ * Neither the name of Neil Mitchell nor the names of other
4603+ contributors may be used to endorse or promote products derived
4604+ from this software without specific prior written permission.
4605+
4606+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4607+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4608+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4609+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4610+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4611+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4612+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4613+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4614+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4615+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4616+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4617+
43694618template-haskell LICENSE file:
43704619
43714620
@@ -4649,6 +4898,39 @@ turtle LICENSE file:
46494898 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46504899 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46514900
4901+uniplate LICENSE file:
4902+
4903+ Copyright Neil Mitchell 2006-2013.
4904+ All rights reserved.
4905+
4906+ Redistribution and use in source and binary forms, with or without
4907+ modification, are permitted provided that the following conditions are
4908+ met:
4909+
4910+ * Redistributions of source code must retain the above copyright
4911+ notice, this list of conditions and the following disclaimer.
4912+
4913+ * Redistributions in binary form must reproduce the above
4914+ copyright notice, this list of conditions and the following
4915+ disclaimer in the documentation and/or other materials provided
4916+ with the distribution.
4917+
4918+ * Neither the name of Neil Mitchell nor the names of other
4919+ contributors may be used to endorse or promote products derived
4920+ from this software without specific prior written permission.
4921+
4922+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4923+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4924+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4925+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4926+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4927+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4928+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4929+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4930+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4931+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4932+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4933+
46524934unix LICENSE file:
46534935
46544936 The Glasgow Haskell Compiler License
@@ -5238,6 +5520,34 @@ x509-validation LICENSE file:
52385520 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52395521 SUCH DAMAGE.
52405522
5523+xss-sanitize LICENSE file:
5524+
5525+ The following license covers this documentation, and the source code, except
5526+ where otherwise indicated.
5527+
5528+ Copyright 2010, Greg Weber. All rights reserved.
5529+
5530+ Redistribution and use in source and binary forms, with or without
5531+ modification, are permitted provided that the following conditions are met:
5532+
5533+ * Redistributions of source code must retain the above copyright notice, this
5534+ list of conditions and the following disclaimer.
5535+
5536+ * Redistributions in binary form must reproduce the above copyright notice,
5537+ this list of conditions and the following disclaimer in the documentation
5538+ and/or other materials provided with the distribution.
5539+
5540+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR
5541+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
5542+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
5543+ EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
5544+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5545+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
5546+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
5547+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
5548+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5549+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5550+
52415551zlib LICENSE file:
52425552
52435553 Copyright (c) 2006-2016, Duncan Coutts
purescript.cabal+3
@@ -117,9 +117,11 @@ library
117117 aeson-better-errors >= 0.8,
118118 ansi-terminal >= 0.6.2 && < 0.7,
119119 base-compat >=0.6.0,
120+ blaze-html >= 0.8.1 && < 0.9,
120121 bower-json >= 1.0.0.1 && < 1.1,
121122 boxes >= 0.1.4 && < 0.2.0,
122123 bytestring -any,
124+ cheapskate >= 0.1 && < 0.2,
123125 containers -any,
124126 clock -any,
125127 data-ordlist >= 0.4.7.0,
@@ -270,6 +272,7 @@ library
270272 Language.PureScript.Docs.RenderedCode.RenderType
271273 Language.PureScript.Docs.RenderedCode.RenderKind
272274 Language.PureScript.Docs.AsMarkdown
275+ Language.PureScript.Docs.AsHtml
273276 Language.PureScript.Docs.ParseInPackage
274277 Language.PureScript.Docs.Utils.MonoidExtras
275278
src/Language/PureScript/Docs/AsHtml.hsnew file+299
@@ -0,0 +1,299 @@
1+
2+-- | Functions for rendering generated documentation from PureScript code as
3+-- HTML.
4+
5+module Language.PureScript.Docs.AsHtml (
6+ HtmlOutput(..),
7+ HtmlOutputModule(..),
8+ HtmlRenderContext(..),
9+ nullRenderContext,
10+ declNamespace,
11+ packageAsHtml,
12+ moduleAsHtml,
13+ makeFragment,
14+ renderMarkdown
15+) where
16+
17+import Prelude
18+import Control.Arrow (second)
19+import Control.Category ((>>>))
20+import Control.Monad (unless)
21+import Data.Char (isUpper)
22+import Data.Monoid ((<>))
23+import Data.Foldable (for_)
24+import Data.String (fromString)
25+
26+import Data.Text (Text)
27+import qualified Data.Text as T
28+
29+import Text.Blaze.Html5 as H hiding (map)
30+import qualified Text.Blaze.Html5.Attributes as A
31+import qualified Cheapskate
32+
33+import qualified Language.PureScript as P
34+
35+import Language.PureScript.Docs.Types
36+import Language.PureScript.Docs.RenderedCode hiding (sp)
37+import qualified Language.PureScript.Docs.Render as Render
38+
39+declNamespace :: Declaration -> Namespace
40+declNamespace = declInfoNamespace . declInfo
41+
42+data HtmlOutput a = HtmlOutput
43+ { htmlIndex :: [(Maybe Char, a)]
44+ , htmlModules :: [(P.ModuleName, HtmlOutputModule a)]
45+ }
46+ deriving (Show, Functor)
47+
48+data HtmlOutputModule a = HtmlOutputModule
49+ { htmlOutputModuleLocals :: a
50+ , htmlOutputModuleReExports :: [(InPackage P.ModuleName, a)]
51+ }
52+ deriving (Show, Functor)
53+
54+data HtmlRenderContext = HtmlRenderContext
55+ { currentModuleName :: P.ModuleName
56+ , buildDocLink :: Namespace -> Text -> ContainingModule -> Maybe DocLink
57+ , renderDocLink :: DocLink -> Text
58+ , renderSourceLink :: P.SourceSpan -> Text
59+ }
60+
61+-- |
62+-- An HtmlRenderContext for when you don't want to render any links.
63+nullRenderContext :: P.ModuleName -> HtmlRenderContext
64+nullRenderContext mn = HtmlRenderContext
65+ { currentModuleName = mn
66+ , buildDocLink = const (const (const Nothing))
67+ , renderDocLink = const ""
68+ , renderSourceLink = const ""
69+ }
70+
71+packageAsHtml :: (P.ModuleName -> HtmlRenderContext) -> Package a -> HtmlOutput Html
72+packageAsHtml getHtmlCtx Package{..} =
73+ HtmlOutput indexFile modules
74+ where
75+ indexFile = []
76+ modules = map (\m -> moduleAsHtml (getHtmlCtx (modName m)) m) pkgModules
77+
78+moduleAsHtml :: HtmlRenderContext -> Module -> (P.ModuleName, HtmlOutputModule Html)
79+moduleAsHtml r Module{..} = (modName, HtmlOutputModule modHtml reexports)
80+ where
81+ renderDecl = declAsHtml r
82+ modHtml = do
83+ for_ modComments renderMarkdown
84+ for_ modDeclarations renderDecl
85+ reexports =
86+ map (second (foldMap renderDecl)) modReExports
87+
88+-- renderIndex :: LinksContext -> [(Maybe Char, Html)]
89+-- renderIndex LinksContext{..} = go ctxBookmarks
90+-- where
91+-- go = takeLocals
92+-- >>> groupIndex getIndex renderEntry
93+-- >>> map (second (ul . mconcat))
94+--
95+-- getIndex (_, title_) = do
96+-- c <- textHeadMay title_
97+-- guard (toUpper c `elem` ['A'..'Z'])
98+-- pure c
99+--
100+-- textHeadMay t =
101+-- case T.length t of
102+-- 0 -> Nothing
103+-- _ -> Just (T.index t 0)
104+--
105+-- renderEntry (mn, title_) =
106+-- li $ do
107+-- let url = T.pack (filePathFor mn `relativeTo` "index") <> "#" <> title_
108+-- code $
109+-- a ! A.href (v url) $ text title_
110+-- sp
111+-- text ("(" <> P.runModuleName mn <> ")")
112+--
113+-- groupIndex :: Ord i => (a -> Maybe i) -> (a -> b) -> [a] -> [(Maybe i, [b])]
114+-- groupIndex f g =
115+-- map (second DList.toList) . M.toList . foldr go' M.empty . sortBy (comparing f)
116+-- where
117+-- go' x = insertOrAppend (f x) (g x)
118+-- insertOrAppend idx val m =
119+-- let cur = M.findWithDefault DList.empty idx m
120+-- new = DList.snoc cur val
121+-- in M.insert idx new m
122+
123+declAsHtml :: HtmlRenderContext -> Declaration -> Html
124+declAsHtml r d@Declaration{..} = do
125+ let declFragment = makeFragment (declInfoNamespace declInfo) declTitle
126+ H.div ! A.class_ "decl" ! A.id (v (T.drop 1 declFragment)) $ do
127+ h3 ! A.class_ "decl__title clearfix" $ do
128+ a ! A.class_ "decl__anchor" ! A.href (v declFragment) $ "#"
129+ text declTitle
130+ for_ declSourceSpan (linkToSource r)
131+
132+ H.div ! A.class_ "decl__body" $ do
133+ case declInfo of
134+ AliasDeclaration fixity alias_ ->
135+ renderAlias fixity alias_
136+ _ ->
137+ pre ! A.class_ "decl__signature" $ code $
138+ codeAsHtml r (Render.renderDeclaration d)
139+
140+ for_ declComments renderMarkdown
141+
142+ let (instances, dctors, members) = partitionChildren declChildren
143+
144+ unless (null dctors) $ do
145+ h4 "Constructors"
146+ renderChildren r dctors
147+
148+ unless (null members) $ do
149+ h4 "Members"
150+ renderChildren r members
151+
152+ unless (null instances) $ do
153+ h4 "Instances"
154+ renderChildren r instances
155+ where
156+ linkToSource :: HtmlRenderContext -> P.SourceSpan -> Html
157+ linkToSource ctx srcspan =
158+ H.span ! A.class_ "decl__source" $
159+ a ! A.href (v (renderSourceLink ctx srcspan)) $ text "Source"
160+
161+renderChildren :: HtmlRenderContext -> [ChildDeclaration] -> Html
162+renderChildren _ [] = return ()
163+renderChildren r xs = ul $ mapM_ go xs
164+ where
165+ go decl = item decl . code . codeAsHtml r . Render.renderChildDeclaration $ decl
166+ item decl = let fragment = makeFragment (childDeclInfoNamespace (cdeclInfo decl)) (cdeclTitle decl)
167+ in li ! A.id (v (T.drop 1 fragment))
168+
169+codeAsHtml :: HtmlRenderContext -> RenderedCode -> Html
170+codeAsHtml r = outputWith elemAsHtml
171+ where
172+ elemAsHtml e = case e of
173+ Syntax x ->
174+ withClass "syntax" (text x)
175+ Keyword x ->
176+ withClass "keyword" (text x)
177+ Space ->
178+ text " "
179+ Symbol ns name link_ ->
180+ case link_ of
181+ Link mn ->
182+ let
183+ class_ = if startsWithUpper name then "ctor" else "ident"
184+ in
185+ linkToDecl ns name mn (withClass class_ (text name))
186+ NoLink ->
187+ text name
188+
189+ linkToDecl = linkToDeclaration r
190+
191+ startsWithUpper :: Text -> Bool
192+ startsWithUpper str =
193+ if T.null str
194+ then False
195+ else isUpper (T.index str 0)
196+
197+renderLink :: HtmlRenderContext -> DocLink -> Html -> Html
198+renderLink r link_@DocLink{..} =
199+ a ! A.href (v (renderDocLink r link_ <> fragmentFor link_))
200+ ! A.title (v fullyQualifiedName)
201+ where
202+ fullyQualifiedName = case linkLocation of
203+ SameModule -> fq (currentModuleName r) linkTitle
204+ LocalModule _ modName -> fq modName linkTitle
205+ DepsModule _ _ _ modName -> fq modName linkTitle
206+ BuiltinModule modName -> fq modName linkTitle
207+
208+ fq mn str = P.runModuleName mn <> "." <> str
209+
210+makeFragment :: Namespace -> Text -> Text
211+makeFragment ns = (prefix <>) . escape
212+ where
213+ prefix = case ns of
214+ TypeLevel -> "#t:"
215+ ValueLevel -> "#v:"
216+ KindLevel -> "#k:"
217+
218+ -- TODO
219+ escape = id
220+
221+fragmentFor :: DocLink -> Text
222+fragmentFor l = makeFragment (linkNamespace l) (linkTitle l)
223+
224+linkToDeclaration ::
225+ HtmlRenderContext ->
226+ Namespace ->
227+ Text ->
228+ ContainingModule ->
229+ Html ->
230+ Html
231+linkToDeclaration r ns target containMn =
232+ maybe id (renderLink r) (buildDocLink r ns target containMn)
233+
234+renderAlias :: P.Fixity -> FixityAlias -> Html
235+renderAlias (P.Fixity associativity precedence) alias_ =
236+ p $ do
237+ -- TODO: Render a link
238+ toHtml $ "Operator alias for " <> P.showQualified showAliasName alias_ <> " "
239+ em $
240+ text ("(" <> associativityStr <> " / precedence " <> T.pack (show precedence) <> ")")
241+ where
242+ showAliasName (Left valueAlias) = P.runProperName valueAlias
243+ showAliasName (Right typeAlias) = case typeAlias of
244+ (Left identifier) -> P.runIdent identifier
245+ (Right properName) -> P.runProperName properName
246+ associativityStr = case associativity of
247+ P.Infixl -> "left-associative"
248+ P.Infixr -> "right-associative"
249+ P.Infix -> "non-associative"
250+
251+-- | Render Markdown to HTML. Safe for untrusted input. Relative links are
252+-- | removed.
253+renderMarkdown :: Text -> H.Html
254+renderMarkdown =
255+ H.toMarkup . removeRelativeLinks . Cheapskate.markdown opts
256+ where
257+ opts = Cheapskate.def { Cheapskate.allowRawHtml = False }
258+
259+removeRelativeLinks :: Cheapskate.Doc -> Cheapskate.Doc
260+removeRelativeLinks = Cheapskate.walk go
261+ where
262+ go :: Cheapskate.Inlines -> Cheapskate.Inlines
263+ go = (>>= stripRelatives)
264+
265+ stripRelatives :: Cheapskate.Inline -> Cheapskate.Inlines
266+ stripRelatives (Cheapskate.Link contents_ href _)
267+ | isRelativeURI href = contents_
268+ stripRelatives other = pure other
269+
270+ -- Tests for a ':' character in the first segment of a URI.
271+ --
272+ -- See Section 4.2 of RFC 3986:
273+ -- https://tools.ietf.org/html/rfc3986#section-4.2
274+ --
275+ -- >>> isRelativeURI "http://example.com/" == False
276+ -- >>> isRelativeURI "mailto:me@example.com" == False
277+ -- >>> isRelativeURI "foo/bar" == True
278+ -- >>> isRelativeURI "/bar" == True
279+ -- >>> isRelativeURI "./bar" == True
280+ isRelativeURI :: Text -> Bool
281+ isRelativeURI =
282+ T.takeWhile (/= '/') >>> T.all (/= ':')
283+
284+v :: Text -> AttributeValue
285+v = toValue
286+
287+withClass :: String -> Html -> Html
288+withClass className content = H.span ! A.class_ (fromString className) $ content
289+
290+partitionChildren ::
291+ [ChildDeclaration] ->
292+ ([ChildDeclaration], [ChildDeclaration], [ChildDeclaration])
293+partitionChildren = foldl go ([], [], [])
294+ where
295+ go (instances, dctors, members) rcd =
296+ case cdeclInfo rcd of
297+ ChildInstance _ _ -> (rcd : instances, dctors, members)
298+ ChildDataConstructor _ -> (instances, rcd : dctors, members)
299+ ChildTypeClassMember _ -> (instances, dctors, rcd : members)
src/Language/PureScript/Docs/Types.hs+84−1
@@ -5,7 +5,7 @@ module Language.PureScript.Docs.Types
55 where
66
77import Protolude hiding (to, from)
8−import Prelude (String, unlines)
8+import Prelude (String, unlines, lookup)
99
1010import Control.Arrow ((***))
1111
@@ -353,6 +353,89 @@ ignorePackage :: InPackage a -> a
353353ignorePackage (Local x) = x
354354ignorePackage (FromDep _ x) = x
355355
356+----------------------------------------------------
357+-- Types for links between declarations
358+
359+data LinksContext = LinksContext
360+ { ctxGithub :: (GithubUser, GithubRepo)
361+ , ctxModuleMap :: Map P.ModuleName PackageName
362+ , ctxResolvedDependencies :: [(PackageName, Version)]
363+ , ctxPackageName :: PackageName
364+ , ctxVersion :: Version
365+ , ctxVersionTag :: Text
366+ }
367+ deriving (Show, Eq, Ord)
368+
369+data DocLink = DocLink
370+ { linkLocation :: LinkLocation
371+ , linkTitle :: Text
372+ , linkNamespace :: Namespace
373+ }
374+ deriving (Show, Eq, Ord)
375+
376+data LinkLocation
377+ -- | A link to a declaration in the same module.
378+ = SameModule
379+
380+ -- | A link to a declaration in a different module, but still in the current
381+ -- package; we need to store the current module and the other declaration's
382+ -- module.
383+ | LocalModule P.ModuleName P.ModuleName
384+
385+ -- | A link to a declaration in a different package. We store: current module
386+ -- name, name of the other package, version of the other package, and name of
387+ -- the module in the other package that the declaration is in.
388+ | DepsModule P.ModuleName PackageName Version P.ModuleName
389+
390+ -- | A link to a declaration that is built in to the compiler, e.g. the Prim
391+ -- module. In this case we only need to store the module that the builtin
392+ -- comes from (at the time of writing, this will only ever be "Prim").
393+ | BuiltinModule P.ModuleName
394+ deriving (Show, Eq, Ord)
395+
396+-- | Given a links context, a thing to link to (either a value or a type), and
397+-- its containing module, attempt to create a DocLink.
398+getLink :: LinksContext -> P.ModuleName -> Namespace -> Text -> ContainingModule -> Maybe DocLink
399+getLink LinksContext{..} curMn namespace target containingMod = do
400+ location <- getLinkLocation
401+ return DocLink
402+ { linkLocation = location
403+ , linkTitle = target
404+ , linkNamespace = namespace
405+ }
406+
407+ where
408+ getLinkLocation = normalLinkLocation <|> builtinLinkLocation
409+
410+ normalLinkLocation = do
411+ case containingMod of
412+ ThisModule ->
413+ return SameModule
414+ OtherModule destMn ->
415+ case Map.lookup destMn ctxModuleMap of
416+ Nothing ->
417+ return $ LocalModule curMn destMn
418+ Just pkgName -> do
419+ pkgVersion <- lookup pkgName ctxResolvedDependencies
420+ return $ DepsModule curMn pkgName pkgVersion destMn
421+
422+ builtinLinkLocation = do
423+ let primMn = P.moduleNameFromString "Prim"
424+ guard $ containingMod == OtherModule primMn
425+ -- TODO: ensure the declaration exists in the builtin module too
426+ return $ BuiltinModule primMn
427+
428+getLinksContext :: Package a -> LinksContext
429+getLinksContext Package{..} =
430+ LinksContext
431+ { ctxGithub = pkgGithub
432+ , ctxModuleMap = pkgModuleMap
433+ , ctxResolvedDependencies = pkgResolvedDependencies
434+ , ctxPackageName = bowerName pkgMeta
435+ , ctxVersion = pkgVersion
436+ , ctxVersionTag = pkgVersionTag
437+ }
438+
356439----------------------
357440-- Parsing
358441