Refactor paths using Context.
[hadrian.git] / src / Settings / Builders / Haddock.hs
1 module Settings.Builders.Haddock (haddockBuilderArgs) where
2
3 import Development.Shake.FilePath
4 import Base
5 import GHC
6 import Package
7 import Expression
8 import Oracles.PackageData
9 import Predicates hiding (file)
10 import Settings
11 import Settings.Builders.Ghc
12
13 haddockBuilderArgs :: Args
14 haddockBuilderArgs = builder Haddock ? do
15 output <- getOutput
16 pkg <- getPackage
17 path <- getContextPath
18 version <- getPkgData Version
19 synopsis <- getPkgData Synopsis
20 hidden <- getPkgDataList HiddenModules
21 deps <- getPkgDataList Deps
22 depNames <- getPkgDataList DepNames
23 hVersion <- lift . pkgData . Version $ contextPath (vanillaContext Stage2 haddock)
24 ghcOpts <- fromDiffExpr commonGhcArgs
25 mconcat
26 [ arg $ "--odir=" ++ takeDirectory output
27 , arg "--verbosity=0"
28 , arg "--no-tmp-comp-dir"
29 , arg $ "--dump-interface=" ++ output
30 , arg "--html"
31 , 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 , append $ map ("--hide=" ++) hidden
36 , append $ [ "--read-interface=../" ++ dep
37 ++ ",../" ++ dep ++ "/src/%{MODULE/./-}.html\\#%{NAME},"
38 ++ pkgHaddockFile (vanillaContext Stage1 depPkg)
39 | (dep, depName) <- zip deps depNames
40 , Just depPkg <- [findKnownPackage $ PackageName depName]
41 , depPkg /= rts ]
42 , append [ "--optghc=" ++ opt | opt <- ghcOpts ]
43 , specified HsColour ?
44 arg "--source-module=src/%{MODULE/./-}.html"
45 , specified HsColour ?
46 arg "--source-entity=src/%{MODULE/./-}.html\\#%{NAME}"
47 , append =<< getInputs
48 , arg "+RTS"
49 , arg $ "-t" ++ path -/- "haddock.t"
50 , arg "--machine-readable"
51 , arg "-RTS" ]
52
53 -- From ghc.mk:
54 -- # -----------------------------------------------
55 -- # Haddock-related bits
56
57 -- # Build the Haddock contents and index
58 -- ifeq "$(HADDOCK_DOCS)" "YES"
59 -- libraries/dist-haddock/index.html: $(haddock_INPLACE) $(ALL_HADDOCK_FILES)
60 -- cd libraries && sh gen_contents_index --intree
61 -- ifeq "$(phase)" "final"
62 -- $(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
63 -- endif
64 -- INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
65 -- endif