diff options
author | Zubin Duggal <zubin@cmi.ac.in> | 2022-03-12 00:07:56 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-23 13:39:39 -0400 |
commit | b91798be48d9fa02610b419ccea15a7dfd663823 (patch) | |
tree | fb87654ccd4a1e92e8c7a15bf454a867460869a3 /ghc | |
parent | 52ffd38c610f418ee1d1a549cfdfdaa11794ea40 (diff) | |
download | haskell-b91798be48d9fa02610b419ccea15a7dfd663823.tar.gz |
hi haddock: Lex and store haddock docs in interface files
Names appearing in Haddock docstrings are lexed and renamed like any other names
appearing in the AST. We currently rename names irrespective of the namespace,
so both type and constructor names corresponding to an identifier will appear in
the docstring. Haddock will select a given name as the link destination based on
its own heuristics.
This patch also restricts the limitation of `-haddock` being incompatible with
`Opt_KeepRawTokenStream`.
The export and documenation structure is now computed in GHC and serialised in
.hi files. This can be used by haddock to directly generate doc pages without
reparsing or renaming the source. At the moment the operation of haddock
is not modified, that's left to a future patch.
Updates the haddock submodule with the minimum changes needed.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 4043f3e247..76d714c3e6 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1902,9 +1902,9 @@ docCmd s = do data DocComponents = DocComponents - { docs :: Maybe HsDocString -- ^ subject's haddocks + { docs :: Maybe [HsDoc GhcRn] -- ^ subject's haddocks , sigAndLoc :: Maybe SDoc -- ^ type signature + category + location - , argDocs :: IntMap HsDocString -- ^ haddocks for arguments + , argDocs :: IntMap (HsDoc GhcRn) -- ^ haddocks for arguments } buildDocComponents :: GHC.GhcMonad m => String -> Name -> m DocComponents @@ -1945,7 +1945,7 @@ pprDocs docs | otherwise = pprDoc <$> nonEmptyDocs where empty DocComponents{docs = mb_decl_docs, argDocs = arg_docs} - = isNothing mb_decl_docs && null arg_docs + = maybe True null mb_decl_docs && null arg_docs nonEmptyDocs = filter (not . empty) docs -- TODO: also print arg docs. @@ -1958,7 +1958,7 @@ pprDoc DocComponents{sigAndLoc = mb_sig_loc, docs = mb_decl_docs} = where formatDoc doc = vcat [ fromMaybe empty mb_sig_loc -- print contextual info (#19055) - , text $ unpackHDS doc + , pprHsDocStrings $ map hsDocString doc ] handleGetDocsFailure :: GHC.GhcMonad m => GetDocsFailure -> m a |