Haddock.hs 2.42 KB
Newer Older
1
module Settings.Builders.Haddock (haddockBuilderArgs) where
2

Ben Gamari's avatar
Ben Gamari committed
3
4
import Development.Shake.FilePath
import Base
5
import GHC
Ben Gamari's avatar
Ben Gamari committed
6
import Package
7
import Expression
Andrey Mokhov's avatar
Andrey Mokhov committed
8
import Oracles.PackageData
Andrey Mokhov's avatar
Andrey Mokhov committed
9
import Predicates hiding (file)
Andrey Mokhov's avatar
Andrey Mokhov committed
10
import Settings
11
12
import Settings.Builders.Ghc

13
14
haddockBuilderArgs :: Args
haddockBuilderArgs = builder Haddock ? do
15
    output   <- getOutput
16
    pkg      <- getPackage
Andrey Mokhov's avatar
Andrey Mokhov committed
17
    path     <- getContextPath
18
19
20
21
22
    version  <- getPkgData Version
    synopsis <- getPkgData Synopsis
    hidden   <- getPkgDataList HiddenModules
    deps     <- getPkgDataList Deps
    depNames <- getPkgDataList DepNames
Andrey Mokhov's avatar
Andrey Mokhov committed
23
    hVersion <- lift . pkgData . Version $ contextPath (vanillaContext Stage2 haddock)
24
25
    ghcOpts  <- fromDiffExpr commonGhcArgs
    mconcat
26
        [ arg $ "--odir=" ++ takeDirectory output
Andrey Mokhov's avatar
Andrey Mokhov committed
27
        , arg "--verbosity=0"
28
        , arg "--no-tmp-comp-dir"
29
        , arg $ "--dump-interface=" ++ output
30
31
        , arg "--html"
        , arg "--hoogle"
32
        , arg $ "--title=" ++ pkgNameString pkg ++ "-" ++ version ++ ": " ++ synopsis
33
        , arg $ "--prologue=" ++ path -/- "haddock-prologue.txt"
34
        , arg $ "--optghc=-D__HADDOCK_VERSION__=" ++ show (versionToInt hVersion)
35
36
37
        , append $ map ("--hide=" ++) hidden
        , append $ [ "--read-interface=../" ++ dep
                     ++ ",../" ++ dep ++ "/src/%{MODULE/./-}.html\\#%{NAME},"
Andrey Mokhov's avatar
Andrey Mokhov committed
38
                     ++ pkgHaddockFile (vanillaContext Stage1 depPkg)
39
                   | (dep, depName) <- zip deps depNames
40
41
                   , Just depPkg <- [findKnownPackage $ PackageName depName]
                   , depPkg /= rts ]
42
        , append [ "--optghc=" ++ opt | opt <- ghcOpts ]
Andrey Mokhov's avatar
Andrey Mokhov committed
43
44
45
46
        , specified HsColour ?
          arg "--source-module=src/%{MODULE/./-}.html"
        , specified HsColour ?
          arg "--source-entity=src/%{MODULE/./-}.html\\#%{NAME}"
47
        , append =<< getInputs
48
        , arg "+RTS"
49
        , arg $ "-t" ++ path -/- "haddock.t"
50
51
        , arg "--machine-readable"
        , arg "-RTS" ]
52
53
54
55
56
57
58
59
60
61
62
63
64
65

-- From ghc.mk:
-- # -----------------------------------------------
-- # Haddock-related bits

-- # Build the Haddock contents and index
-- ifeq "$(HADDOCK_DOCS)" "YES"
-- libraries/dist-haddock/index.html: $(haddock_INPLACE) $(ALL_HADDOCK_FILES)
--     cd libraries && sh gen_contents_index --intree
-- ifeq "$(phase)" "final"
-- $(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
-- endif
-- INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
-- endif