Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit 1ad8a10

Browse files
authored
Merge pull request #1021 from harpocrates/merged-convert-fixes
Merge ghc-head into wip/hi-haddock
2 parents cff4abf + 282f174 commit 1ad8a10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+9723
-5511
lines changed

.travis.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# NOTE: manually changes were made to an otherwise autogenerated script. This is to
2+
# query GHC CI artifacts instead of going via Herbert's PPA
3+
#
14
# This Travis job script has been generated by a script via
25
#
36
# make_travis_yml_2.hs 'haddock.cabal'
@@ -28,46 +31,50 @@ before_cache:
2831

2932
matrix:
3033
include:
31-
- compiler: "ghc-head"
32-
env: GHCHEAD=true
33-
# env: TEST=--disable-tests BENCH=--disable-benchmarks
34-
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-head], sources: [hvr-ghc]}}
34+
- os: linux
35+
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head], sources: [hvr-ghc]}}
36+
env:
37+
- GHC_ZIP='https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/download?job=validate-x86_64-linux-deb8'
3538

3639
before_install:
37-
- HC=${CC}
40+
# Manually install GHC validate artifact
41+
- travis_retry curl -L $GHC_ZIP --output artifact.zip
42+
- unzip artifact.zip
43+
- tar xpf ghc.tar.xz --strip-components 1
44+
- ./configure
45+
- sudo make V=1 install
46+
47+
# Set up some vars
48+
- HC=ghc
3849
- HCPKG=${HC/ghc/ghc-pkg}
39-
- unset CC
40-
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
50+
- PATH=/usr/local/bin:/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
4151
- PKGNAME='haddock'
4252

4353
install:
4454
- cabal --version
4555
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
46-
- BENCH=${BENCH---enable-benchmarks}
47-
- TEST=${TEST---enable-tests}
48-
- GHCHEAD=${GHCHEAD-false}
56+
- BENCH=--enable-benchmarks
57+
- TEST=--enable-tests
4958
- travis_retry cabal update -v
5059
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
5160
- rm -fv cabal.project.local
5261
- rm -f cabal.project.freeze
5362
# Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
5463
- |
55-
if $GHCHEAD; then
56-
sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config
57-
for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done
64+
sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config
65+
for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done
5866
59-
echo 'repository head.hackage' >> ${HOME}/.cabal/config
60-
echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config
61-
echo ' secure: True' >> ${HOME}/.cabal/config
62-
echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config
63-
echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config
64-
echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config
65-
echo ' key-threshold: 3' >> ${HOME}/.cabal.config
67+
echo 'repository head.hackage' >> ${HOME}/.cabal/config
68+
echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config
69+
echo ' secure: True' >> ${HOME}/.cabal/config
70+
echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config
71+
echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config
72+
echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config
73+
echo ' key-threshold: 3' >> ${HOME}/.cabal.config
6674
67-
grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
75+
grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
6876
69-
cabal new-update head.hackage -v
70-
fi
77+
cabal new-update head.hackage -v
7178
- travis_retry cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 --allow-newer --constraint 'setup.Cabal installed' all
7279
- travis_retry cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 --allow-newer --constraint 'setup.Cabal installed' all
7380

@@ -76,8 +83,8 @@ install:
7683
script:
7784
- if [ -f configure.ac ]; then autoreconf -i; fi
7885
- rm -rf dist/
79-
- cabal sdist # test that a source-distribution can be generated
80-
- cd dist/
86+
- cabal new-sdist # test that a source-distribution can be generated
87+
- cd dist-newstyle/sdist/
8188
- SRCTAR=(${PKGNAME}-*.tar.gz)
8289
- SRC_BASENAME="${SRCTAR/%.tar.gz}"
8390
- tar -xvf "./$SRC_BASENAME.tar.gz"

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
* Support inline markup in markdown-style links (#875)
88

9+
* The hyperlinker backend has been re-engineered to use HIE files
10+
and display type annotations on expressions (#977)
11+
12+
* The hyperlinker backend lexer is now more incremental, faster, and
13+
more memory efficient (#977)
14+
915
## Changes in version 2.22.0
1016

1117
* Make `--package-version` optional for `--hoogle` (#899)

doc/invoking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ The following options are available:
504504

505505
.. option:: --bypass-interface-version-check
506506

507-
**DANGEROUS** Causes Haddock to ignore the interface verions of
507+
**DANGEROUS** Causes Haddock to ignore the interface versions of
508508
binary Haddock interface files. This can make Haddock crash during
509509
deserialization of interface files.
510510

haddock-api/haddock-api.cabal

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ library
4646
, Cabal ^>= 2.4.0
4747
, ghc ^>= 8.7
4848
, ghc-paths ^>= 0.1.0.9
49-
, haddock-library ^>= 1.7.0
49+
, haddock-library ^>= 1.8.0
5050
, xhtml ^>= 3000.2.2
5151

5252
-- Versions for the dependencies below are transitively pinned by
@@ -59,6 +59,7 @@ library
5959
, directory
6060
, filepath
6161
, ghc-boot
62+
, ghc-boot-th
6263
, transformers
6364

6465
hs-source-dirs: src
@@ -97,7 +98,6 @@ library
9798
Haddock.Backends.HaddockDB
9899
Haddock.Backends.Hoogle
99100
Haddock.Backends.Hyperlinker
100-
Haddock.Backends.Hyperlinker.Ast
101101
Haddock.Backends.Hyperlinker.Parser
102102
Haddock.Backends.Hyperlinker.Renderer
103103
Haddock.Backends.Hyperlinker.Types
@@ -130,7 +130,6 @@ test-suite spec
130130
Haddock
131131
Haddock.Backends.Hoogle
132132
Haddock.Backends.Hyperlinker
133-
Haddock.Backends.Hyperlinker.Ast
134133
Haddock.Backends.Hyperlinker.Renderer
135134
Haddock.Backends.Hyperlinker.Utils
136135
Haddock.Backends.LaTeX
@@ -171,7 +170,7 @@ test-suite spec
171170
build-depends: Cabal ^>= 2.4
172171
, ghc ^>= 8.7
173172
, ghc-paths ^>= 0.1.0.9
174-
, haddock-library ^>= 1.7.0
173+
, haddock-library ^>= 1.8.0
175174
, xhtml ^>= 3000.2.2
176175
, hspec >= 2.4.4 && < 2.6
177176
, QuickCheck ^>= 2.11
@@ -187,6 +186,7 @@ test-suite spec
187186
, directory
188187
, filepath
189188
, ghc-boot
189+
, ghc-boot-th
190190
, transformers
191191

192192
build-tool-depends:

haddock-api/resources/html/solarized.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,45 @@ a:link, a:visited {
5353
a:hover, a.hover-highlight {
5454
background-color: #eee8d5;
5555
}
56+
57+
span.annot{
58+
position:relative;
59+
color:#000;
60+
text-decoration:none
61+
}
62+
63+
span.annot:hover{z-index:25; background-color:#ff0}
64+
65+
span.annot span.annottext{
66+
display: none;
67+
border-radius: 5px 5px;
68+
69+
-moz-border-radius: 5px;
70+
-webkit-border-radius: 5px;
71+
72+
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1);
73+
-webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
74+
-moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
75+
76+
position: absolute;
77+
left: 1em; top: 2em;
78+
z-index: 99;
79+
margin-left: 5;
80+
background: #FFFFAA;
81+
border: 2px solid #FFAD33;
82+
padding: 0.8em 1em;
83+
}
84+
85+
span.annot:hover span.annottext{
86+
display:block;
87+
}
88+
89+
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
90+
span.annot span.annottext:before{
91+
content: "";
92+
position: absolute;
93+
left: -1em; top: -1em;
94+
background: #FFFFFF00;
95+
z-index:-1;
96+
padding: 2em 2em;
97+
}

haddock-api/src/Haddock.hs

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import Haddock.Version
3939
import Haddock.InterfaceFile
4040
import Haddock.Options
4141
import Haddock.Utils
42+
import Haddock.GhcUtils (modifySessionDynFlags, setOutputDir)
4243

4344
import Control.Monad hiding (forM_)
4445
import Data.Foldable (forM_, foldl')
@@ -66,6 +67,8 @@ import qualified GHC.Paths as GhcPaths
6667
import Paths_haddock_api (getDataDir)
6768
import System.Directory (doesDirectoryExist)
6869
#endif
70+
import System.Directory (getTemporaryDirectory)
71+
import System.FilePath ((</>))
6972

7073
import Text.ParserCombinators.ReadP (readP_to_S)
7174
import GHC hiding (verbosity)
@@ -164,14 +167,23 @@ haddockWithGhc ghc args = handleTopExceptions $ do
164167
-- bypass the interface version check
165168
let noChecks = Flag_BypassInterfaceVersonCheck `elem` flags
166169

170+
-- Create a temporary directory and redirect GHC output there (unless user
171+
-- requested otherwise).
172+
--
173+
-- Output dir needs to be set before calling 'depanal' since 'depanal' uses it
174+
-- to compute output file names that are stored in the 'DynFlags' of the
175+
-- resulting 'ModSummary's.
176+
let withDir | Flag_NoTmpCompDir `elem` flags = id
177+
| otherwise = withTempOutputDir
178+
167179
unless (Flag_NoWarnings `elem` flags) $ do
168180
hypSrcWarnings flags
169181
forM_ (warnings args) $ \warning -> do
170182
hPutStrLn stderr warning
171183
when noChecks $
172184
hPutStrLn stderr noCheckWarning
173185

174-
ghc flags' $ do
186+
ghc flags' $ withDir $ do
175187
dflags <- getDynFlags
176188

177189
forM_ (optShowInterfaceFile flags) $ \path -> liftIO $ do
@@ -202,6 +214,15 @@ haddockWithGhc ghc args = handleTopExceptions $ do
202214
-- Render even though there are no input files (usually contents/index).
203215
liftIO $ renderStep dflags flags sinceQual qual packages []
204216

217+
-- | Run the GHC action using a temporary output directory
218+
withTempOutputDir :: Ghc a -> Ghc a
219+
withTempOutputDir action = do
220+
tmp <- liftIO getTemporaryDirectory
221+
x <- liftIO getProcessID
222+
let dir = tmp </> ".haddock-" ++ show x
223+
modifySessionDynFlags (setOutputDir dir)
224+
withTempDir dir action
225+
205226
-- | Create warnings about potential misuse of -optghc
206227
warnings :: [String] -> [String]
207228
warnings = map format . filter (isPrefixOf "-optghc")
@@ -221,8 +242,9 @@ withGhc flags action = do
221242
let handleSrcErrors action' = flip handleSourceError action' $ \err -> do
222243
printException err
223244
liftIO exitFailure
245+
needHieFiles = Flag_HyperlinkedSource `elem` flags
224246

225-
withGhc' libDir (ghcFlags flags) (\_ -> handleSrcErrors action)
247+
withGhc' libDir needHieFiles (ghcFlags flags) (\_ -> handleSrcErrors action)
226248

227249

228250
readPackagesAndProcessModules :: [Flag] -> [String]
@@ -444,24 +466,10 @@ readInterfaceFiles name_cache_accessor pairs bypass_version_check = do
444466

445467
-- | Start a GHC session with the -haddock flag set. Also turn off
446468
-- compilation and linking. Then run the given 'Ghc' action.
447-
withGhc' :: String -> [String] -> (DynFlags -> Ghc a) -> IO a
448-
withGhc' libDir flags ghcActs = runGhc (Just libDir) $ do
449-
dynflags <- getSessionDynFlags
450-
dynflags' <- parseGhcFlags
451-
(foldl' gopt_set dynflags
452-
[ -- Include docstrings in .hi-files.
453-
Opt_Haddock
454-
455-
-- Ignore any aspects of .hi-files except docs.
456-
, Opt_SkipIfaceVersionCheck
457-
458-
-- If we can't use an old .hi-file, save the new one.
459-
, Opt_WriteInterface
460-
]) {
461-
hscTarget = HscNothing,
462-
ghcMode = CompManager,
463-
ghcLink = NoLink
464-
}
469+
withGhc' :: String -> Bool -> [String] -> (DynFlags -> Ghc a) -> IO a
470+
withGhc' libDir needHieFiles flags ghcActs = runGhc (Just libDir) $ do
471+
dynflags' <- parseGhcFlags =<< getSessionDynFlags
472+
465473
-- We disable pattern match warnings because than can be very
466474
-- expensive to check
467475
let dynflags'' = unsetPatternMatchWarnings $
@@ -492,11 +500,30 @@ withGhc' libDir flags ghcActs = runGhc (Just libDir) $ do
492500
parseGhcFlags dynflags = do
493501
-- TODO: handle warnings?
494502

495-
let flags' = filterRtsFlags flags
496-
(dynflags', rest, _) <- parseDynamicFlags dynflags (map noLoc flags')
503+
let extra_opts =
504+
[ Opt_Haddock
505+
-- Include docstrings in .hi-files.
506+
507+
, Opt_SkipIfaceVersionCheck
508+
-- Ignore any aspects of .hi-files except docs.
509+
510+
, Opt_WriteInterface
511+
-- If we can't use an old .hi-file, save the new one.
512+
] ++
513+
[ Opt_WriteHie | needHieFiles
514+
-- Generate .hie-files
515+
]
516+
dynflags' = (foldl' gopt_set dynflags extra_opts)
517+
{ hscTarget = HscNothing
518+
, ghcMode = CompManager
519+
, ghcLink = NoLink
520+
}
521+
flags' = filterRtsFlags flags
522+
523+
(dynflags'', rest, _) <- parseDynamicFlags dynflags' (map noLoc flags')
497524
if not (null rest)
498525
then throwE ("Couldn't parse GHC options: " ++ unwords flags')
499-
else return dynflags'
526+
else return dynflags''
500527

501528
unsetPatternMatchWarnings :: DynFlags -> DynFlags
502529
unsetPatternMatchWarnings dflags =

0 commit comments

Comments
 (0)