Haddock.hs 2.49 KB
Newer Older
1
2
3
4
5
6
7
module Settings.Builders.Haddock (haddockArgs) where

import Base
import Util
import Builder
import Package
import Expression
8
import Predicates (builder, package, stage1)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import Oracles.PackageData
import Settings.Util
import Settings.Packages
import Settings.Builders.Ghc
import Settings.TargetDirectory

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
29
        , arg "--verbosity=0"
30
31
32
33
34
35
36
37
38
        , 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
39
                     ++ pkgHaddockFile depPkg
40
41
42
                   | (dep, depName) <- zip deps depNames
                   , Just depPkg <- [findKnownPackage depName] ]
        , 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
48
49
        , customPackageArgs
        , append srcs
        , arg "+RTS"
Andrey Mokhov's avatar
Andrey Mokhov committed
50
        , arg $ "-t" ++ path </> "haddock.t"
51
52
53
54
55
56
        , arg "--machine-readable" ]

customPackageArgs :: Args
customPackageArgs = mconcat
    [ package compiler ? stage1 ?
      arg "--optghc=-DSTAGE=2" ]
Andrey Mokhov's avatar
Andrey Mokhov committed
57
    -- TODO: move to getPackageSources
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
    -- , 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