Haddock.hs 2.36 KB
Newer Older
1
2
3
module Settings.Builders.Haddock (haddockArgs) where

import Expression
Andrey Mokhov's avatar
Andrey Mokhov committed
4
import Oracles
Andrey Mokhov's avatar
Andrey Mokhov committed
5
import Predicates hiding (file)
Andrey Mokhov's avatar
Andrey Mokhov committed
6
import Settings
7
8
9
10
import Settings.Builders.Ghc

haddockArgs :: Args
haddockArgs = builder Haddock ? do
11
    output   <- getOutput
12
13
14
15
16
17
18
19
20
    pkg      <- getPackage
    path     <- getTargetPath
    version  <- getPkgData Version
    synopsis <- getPkgData Synopsis
    hidden   <- getPkgDataList HiddenModules
    deps     <- getPkgDataList Deps
    depNames <- getPkgDataList DepNames
    ghcOpts  <- fromDiffExpr commonGhcArgs
    mconcat
21
        [ arg $ "--odir=" ++ takeDirectory output
Andrey Mokhov's avatar
Andrey Mokhov committed
22
        , arg "--verbosity=0"
23
        , arg "--no-tmp-comp-dir"
24
        , arg $ "--dump-interface=" ++ output
25
26
        , arg "--html"
        , arg "--hoogle"
27
        , arg $ "--title=" ++ pkgNameString pkg ++ "-" ++ version ++ ": " ++ synopsis
28
29
30
31
        , arg $ "--prologue=" ++ path -/- "haddock-prologue.txt"
        , append $ map ("--hide=" ++) hidden
        , append $ [ "--read-interface=../" ++ dep
                     ++ ",../" ++ dep ++ "/src/%{MODULE/./-}.html\\#%{NAME},"
Andrey Mokhov's avatar
Andrey Mokhov committed
32
                     ++ pkgHaddockFile depPkg
33
                   | (dep, depName) <- zip deps depNames
34
                   , Just depPkg <- [findKnownPackage $ PackageName depName] ]
35
        , append [ "--optghc=" ++ opt | opt <- ghcOpts ]
Andrey Mokhov's avatar
Andrey Mokhov committed
36
37
38
39
        , specified HsColour ?
          arg "--source-module=src/%{MODULE/./-}.html"
        , specified HsColour ?
          arg "--source-entity=src/%{MODULE/./-}.html\\#%{NAME}"
40
        , customPackageArgs
41
        , append =<< getInputs
42
        , arg "+RTS"
Andrey Mokhov's avatar
Andrey Mokhov committed
43
        , arg $ "-t" ++ path </> "haddock.t"
44
45
46
47
48
49
        , arg "--machine-readable" ]

customPackageArgs :: Args
customPackageArgs = mconcat
    [ package compiler ? stage1 ?
      arg "--optghc=-DSTAGE=2" ]
Andrey Mokhov's avatar
Andrey Mokhov committed
50
    -- TODO: move to getPackageSources
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
    -- , package ghcPrim  ? stage1 ?
    --   arg "libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs" ]

-- 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