summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorBjörn Gohla <b.gohla@gmx.de>2019-08-27 00:05:45 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-09-23 17:53:23 -0400
commit4470a144d03e331656002f6ad70fd6a8d78d25bf (patch)
treecbb4abb5e4c023dbd0ffc0084e305a86112c5e0d /hadrian
parent74631bbcc9cd7926d75e3cd0ed2b8d766de2868c (diff)
downloadhaskell-4470a144d03e331656002f6ad70fd6a8d78d25bf.tar.gz
add Hadrian rule to build user guide as Info book
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/src/CommandLine.hs4
-rw-r--r--hadrian/src/Flavour.hs2
-rw-r--r--hadrian/src/Hadrian/Builder/Sphinx.hs3
-rw-r--r--hadrian/src/Rules/Documentation.hs20
-rw-r--r--hadrian/src/Settings/Default.hs1
5 files changed, 27 insertions, 3 deletions
diff --git a/hadrian/src/CommandLine.hs b/hadrian/src/CommandLine.hs
index a62062130b..dcb42b8a32 100644
--- a/hadrian/src/CommandLine.hs
+++ b/hadrian/src/CommandLine.hs
@@ -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
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 230272ec62..e78aa5b9a1 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -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.
diff --git a/hadrian/src/Hadrian/Builder/Sphinx.hs b/hadrian/src/Hadrian/Builder/Sphinx.hs
index 44b522c4d3..7e2401d0d5 100644
--- a/hadrian/src/Hadrian/Builder/Sphinx.hs
+++ b/hadrian/src/Hadrian/Builder/Sphinx.hs
@@ -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"
diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs
index 9991f01708..e7cbf229e8 100644
--- a/hadrian/src/Rules/Documentation.hs
+++ b/hadrian/src/Rules/Documentation.hs
@@ -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.
diff --git a/hadrian/src/Settings/Default.hs b/hadrian/src/Settings/Default.hs
index 5963a7687c..83a3a9905e 100644
--- a/hadrian/src/Settings/Default.hs
+++ b/hadrian/src/Settings/Default.hs
@@ -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 ]