blob: 88619474c1f651601ade6dbc7122e7c4cef58cf0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
module Haddock.Backends.Hyperlinker (ppHyperlinkedSource) where
import Haddock.Types
import Haddock.Backends.Hyperlinker.Renderer
import GHC
import Text.XHtml hiding ((</>))
import System.Directory
import System.FilePath
ppHyperlinkedSource :: FilePath -> FilePath -> Maybe FilePath -> [Interface]
-> IO ()
ppHyperlinkedSource outdir libdir mstyle ifaces = do
createDirectoryIfMissing True (outdir </> "src")
mapM_ (ppHyperlinkedModuleSource outdir mstyle) ifaces
ppHyperlinkedModuleSource :: FilePath -> Maybe FilePath -> Interface -> IO ()
ppHyperlinkedModuleSource outdir mstyle iface = case ifaceTokenizedSrc iface of
Just tokens -> writeFile path $ showHtml . render mstyle $ tokens
Nothing -> return ()
where
path = outdir </> "src" </> moduleSourceFile (ifaceMod iface)
moduleSourceFile :: Module -> FilePath
moduleSourceFile = (++ ".html") . moduleNameString . moduleName
|