summaryrefslogtreecommitdiff
path: root/hadrian
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-06 15:06:01 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-08 05:12:58 -0400
commit98c094227c7738a65dfc5908b3397d7275e56ea1 (patch)
tree65f27374fa2a9c89142c48426615d42c8c2da475 /hadrian
parentca4791dba46b0c285763d3dd76a9c8a61b279a35 (diff)
downloadhaskell-98c094227c7738a65dfc5908b3397d7275e56ea1.tar.gz
users-guide: Run sphinx in nit-picky mode
This ensure that it blurts an error on missing references.
Diffstat (limited to 'hadrian')
-rw-r--r--hadrian/src/Hadrian/Builder/Sphinx.hs2
-rw-r--r--hadrian/src/Rules/Documentation.hs14
2 files changed, 16 insertions, 0 deletions
diff --git a/hadrian/src/Hadrian/Builder/Sphinx.hs b/hadrian/src/Hadrian/Builder/Sphinx.hs
index 7e2401d0d5..07bd941fe7 100644
--- a/hadrian/src/Hadrian/Builder/Sphinx.hs
+++ b/hadrian/src/Hadrian/Builder/Sphinx.hs
@@ -30,6 +30,8 @@ args mode = do
outPath <- getOutput
mconcat [ arg "-b", arg modeString
, arg "-d", arg $ outPath -/- (".doctrees-" ++ modeString)
+ , arg "-n" -- nit-picky mode to ensure missing references are caught
+ , arg "-w", arg $ outPath -/- ".log" -- dump warnings to log file
, arg =<< getInput
, arg outPath ]
where
diff --git a/hadrian/src/Rules/Documentation.hs b/hadrian/src/Rules/Documentation.hs
index 1326cb5a89..2671c921e2 100644
--- a/hadrian/src/Rules/Documentation.hs
+++ b/hadrian/src/Rules/Documentation.hs
@@ -114,6 +114,16 @@ documentationRules = do
where archiveTarget "libraries" = Haddocks
archiveTarget _ = SphinxHTML
+-- | Check Sphinx log for undefined reference target errors. Ideally we would
+-- use sphinx's @-W@ flag here but unfortunately it also turns syntax
+-- highlighting warnings into errors which is undesirable.
+checkSphinxWarnings :: FilePath -- ^ output directory
+ -> Action ()
+checkSphinxWarnings out = do
+ log <- liftIO $ readFile (out -/- ".log")
+ when ("reference target not found" `isInfixOf` log)
+ $ fail "Undefined reference targets found in Sphinx log."
+
------------------------------------- HTML -------------------------------------
@@ -147,6 +157,7 @@ buildSphinxHtml path = do
rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"]
need (map (rstFilesDir -/-) rstFiles)
build $ target docContext (Sphinx Html) [pathPath path] [dest]
+ checkSphinxWarnings dest
------------------------------------ Haddock -----------------------------------
@@ -259,6 +270,7 @@ buildSphinxPdf path = do
rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"]
need (map (rstFilesDir -/-) rstFiles)
build $ target docContext (Sphinx Latex) [pathPath path] [dir]
+ checkSphinxWarnings dir
build $ target docContext Xelatex [path <.> "tex"] [dir]
copyFileUntracked (dir -/- path <.> "pdf") file
@@ -275,6 +287,7 @@ buildSphinxInfoGuide = do
rstFiles <- getDirectoryFiles rstFilesDir ["**/*.rst"]
need (map (rstFilesDir -/-) rstFiles)
build $ target docContext (Sphinx Info) [pathPath path] [dir]
+ checkSphinxWarnings dir
-- Sphinx outputs texinfo source and a makefile, the
-- default target of which actually produces the target
-- for this build rule.
@@ -306,6 +319,7 @@ buildManPage = do
need ["docs/users_guide/ghc.rst"]
withTempDir $ \dir -> do
build $ target docContext (Sphinx Man) ["docs/users_guide"] [dir]
+ checkSphinxWarnings dir
copyFileUntracked (dir -/- "ghc.1") file
-- | Find the Haddock files for the dependencies of the current library.