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
5
6
import Predicates hiding (file)
import Oracles
import Settings
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Settings.Builders.Ghc

haddockArgs :: Args
haddockArgs = builder Haddock ? do
    file     <- getFile
    srcs     <- getSources
    pkg      <- getPackage
    path     <- getTargetPath
    version  <- getPkgData Version
    synopsis <- getPkgData Synopsis
    hidden   <- getPkgDataList HiddenModules
    deps     <- getPkgDataList Deps
    depNames <- getPkgDataList DepNames
    ghcOpts  <- fromDiffExpr commonGhcArgs
    mconcat
        [ arg $ "--odir=" ++ takeDirectory file
Andrey Mokhov's avatar
Andrey Mokhov committed
23
        , arg "--verbosity=0"
24
25
26
27
28
29
30
31
32
        , arg "--no-tmp-comp-dir"
        , arg $ "--dump-interface=" ++ file
        , arg "--html"
        , arg "--hoogle"
        , arg $ "--title=" ++ pkgName pkg ++ "-" ++ version ++ ": " ++ synopsis
        , 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
33
                     ++ pkgHaddockFile depPkg
34
35
36
                   | (dep, depName) <- zip deps depNames
                   , Just depPkg <- [findKnownPackage depName] ]
        , append [ "--optghc=" ++ opt | opt <- ghcOpts ]
Andrey Mokhov's avatar
Andrey Mokhov committed
37
38
39
40
        , specified HsColour ?
          arg "--source-module=src/%{MODULE/./-}.html"
        , specified HsColour ?
          arg "--source-entity=src/%{MODULE/./-}.html\\#%{NAME}"
41
42
43
        , customPackageArgs
        , append srcs
        , arg "+RTS"
Andrey Mokhov's avatar
Andrey Mokhov committed
44
        , arg $ "-t" ++ path </> "haddock.t"
45
46
47
48
49
50
        , arg "--machine-readable" ]

customPackageArgs :: Args
customPackageArgs = mconcat
    [ package compiler ? stage1 ?
      arg "--optghc=-DSTAGE=2" ]
Andrey Mokhov's avatar
Andrey Mokhov committed
51
    -- TODO: move to getPackageSources
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    -- , 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