Commit 4470a144 authored by Björn Gohla's avatar Björn Gohla Committed by Marge Bot
Browse files

add Hadrian rule to build user guide as Info book

parent 74631bbc
......@@ -202,9 +202,11 @@ readDocsArg ms = maybe (Left "Cannot parse docs argument") (Right . set) (go =<<
go "no-sphinx-html" = Just (Set.delete SphinxHTML)
go "no-sphinx-pdfs" = Just (Set.delete SphinxPDFs)
go "no-sphinx-man" = Just (Set.delete SphinxMan)
go "no-sphinx-info" = Just (Set.delete SphinxInfo)
go "no-sphinx" = Just (Set.delete SphinxHTML
. Set.delete SphinxPDFs
. Set.delete SphinxMan)
. Set.delete SphinxMan
. Set.delete SphinxInfo)
go _ = Nothing
set :: (DocTargets -> DocTargets) -> CommandLineArgs -> CommandLineArgs
......
......@@ -58,7 +58,7 @@ type DocTargets = Set DocTarget
-- for e.g @sphinx-build@ or @xelatex@ and associated packages
-- while still being able to build a(n almost) complete binary
-- distribution.
data DocTarget = Haddocks | SphinxHTML | SphinxPDFs | SphinxMan
data DocTarget = Haddocks | SphinxHTML | SphinxPDFs | SphinxMan | SphinxInfo
deriving (Eq, Ord, Show, Bounded, Enum)
-- | Turn on -Werror for packages built with the stage1 compiler.
......
......@@ -18,7 +18,7 @@ import Hadrian.Utilities
-- | Sphinx can be used in three different modes to convert reStructuredText
-- documents into HTML, LaTeX or Man pages.
data SphinxMode = Html | Latex | Man deriving (Eq, Generic, Show)
data SphinxMode = Info | Html | Latex | Man deriving (Eq, Generic, Show)
instance Binary SphinxMode
instance Hashable SphinxMode
......@@ -34,6 +34,7 @@ args mode = do
, arg outPath ]
where
modeString = case mode of
Info -> "texinfo"
Html -> "html"
Latex -> "latex"
Man -> "man"
......@@ -34,6 +34,9 @@ htmlRoot = docRoot -/- "html"
pdfRoot :: FilePath
pdfRoot = docRoot -/- "pdfs"
infoRoot :: FilePath
infoRoot = docRoot -/- "info"
archiveRoot :: FilePath
archiveRoot = docRoot -/- "archives"
......@@ -58,6 +61,7 @@ pathArchive path = archiveRoot -/- path <.> "html.tar.xz"
-- TODO: Get rid of this hack.
pathPath :: FilePath -> FilePath
pathPath "GHCUsersGuide" = "docs/users_guide"
pathPath "users_guide" = "docs/users_guide"
pathPath "Haddock" = "utils/haddock/doc"
pathPath _ = ""
......@@ -69,6 +73,7 @@ documentationRules = do
buildHtmlDocumentation
buildManPage
buildPdfDocumentation
buildSphinxInfoGuide
-- a phony rule that runs Haddock for "Haskell Hierarchical Libraries" and
-- the "GHC-API"
......@@ -257,6 +262,21 @@ buildSphinxPdf path = do
build $ target docContext Xelatex [path <.> "tex"] [dir]
copyFileUntracked (dir -/- path <.> "pdf") file
------------------------------------ Info -- -----------------------------------
buildSphinxInfoGuide :: Rules ()
buildSphinxInfoGuide = do
root <- buildRootRules
let path = "GHCUsersGuide"
root -/- infoRoot -/- path <.> "info" %> \ file -> do
withTempDir $ \dir -> do
let rstFilesDir = pathPath path
rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"]
need (map (rstFilesDir -/-) rstFiles)
build $ target docContext (Sphinx Info) [pathPath path] [dir]
cmd_ "make -C " [dir]
copyFileUntracked (dir -/- path <.> "info") file
------------------------------------ Archive -----------------------------------
-- | Build documentation archives.
......
......@@ -253,6 +253,7 @@ defaultBuilderArgs = mconcat
, builder (Sphinx Html ) ? Hadrian.Builder.Sphinx.args Html
, builder (Sphinx Latex) ? Hadrian.Builder.Sphinx.args Latex
, builder (Sphinx Man ) ? Hadrian.Builder.Sphinx.args Man
, builder (Sphinx Info ) ? Hadrian.Builder.Sphinx.args Info
, builder (Tar Create ) ? Hadrian.Builder.Tar.args Create
, builder (Tar Extract ) ? Hadrian.Builder.Tar.args Extract ]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment