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

Commit 7240b69

Browse files
Lysxiamattaudessempilgremguiboupepeiborra
authored
Add dangling changes from branches ghc-8.6 and ghc-8.8 (#1243)
* Fix multiple typos and inconsistencies in doc/markup.rst Note: I noticed some overlap with #1112 from @wygulmage and #1081 from @parsonsmatt after creating these proposed changes - mea culpa for not looking at the open PRs sooner. * Fix #1113 If no Signatures, no section of index.html * Change the formatting of missing link destinations The current formatting of the missing link destination does not really help user to understand the reasons of the missing link. To address this, I've changed the formatting in two ways: - the missing link symbol name is now fully qualified. This way you immediately know which haskell module cannot be linked. It is then easier to understand why this module does not have documentation (hidden module or broken documentation). - one line per missing link, that's more readable now that symbol name can be longer due to qualification. For example, before haddock was listing missing symbol such as: ``` could not find link destinations for: Word8 Word16 mapMaybe ``` Now it is listed as: ``` could not find link destinations for: - Data.Word.Word8 - Data.Word.Word16 - Data.Maybe.mapMaybe ``` * Add `--ignore-link-symbol` command line argument This argument can be used multiples time. A missing link to a symbol listed by `--ignore-link-symbol` won't trigger "missing link" warning. * Forbid spaces in anchors (#1148) * Improve error messages with context information (#1060) Co-authored-by: Matt Audesse <[email protected]> Co-authored-by: Mike Pilgrem <[email protected]> Co-authored-by: Guillaume Bouchard <[email protected]> Co-authored-by: Pepe Iborra <[email protected]>
1 parent 1bedd20 commit 7240b69

File tree

10 files changed

+111
-57
lines changed

10 files changed

+111
-57
lines changed

doc/markup.rst

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ or like this: ::
131131
b -- ^ This is the documentation for the argument of type 'b'
132132

133133
There is one edge case that is handled differently: only one ``-- ^``
134-
annotation occuring after the constructor and all its arguments is
134+
annotation occurring after the constructor and all its arguments is
135135
applied to the constructor, not its last argument: ::
136136

137137
data T a b
@@ -156,16 +156,16 @@ Alternative layout styles are generally accepted by Haddock - for
156156
example doc comments can appear before or after the comma in separated
157157
lists such as the list of record fields above.
158158

159-
In case that more than one constructor exports a field with the same
160-
name, the documentation attached to the first occurence of the field
159+
In cases where more than one constructor exports a field with the same
160+
name, the documentation attached to the first occurrence of the field
161161
will be used, even if a comment is not present. ::
162162

163163
data T a = A { someField :: a -- ^ Doc for someField of A
164164
}
165165
| B { someField :: a -- ^ Doc for someField of B
166166
}
167167

168-
In the above example, all occurences of ``someField`` in the
168+
In the above example, all occurrences of ``someField`` in the
169169
documentation are going to be documented with
170170
``Doc for someField of A``. Note that Haddock versions 2.14.0 and before
171171
would join up documentation of each field and render the result. The
@@ -238,7 +238,7 @@ module documentation example and then talk about the fields. ::
238238

239239
All fields are optional but they must be in order if they do appear.
240240
Multi-line fields are accepted but the consecutive lines have to start
241-
indented more than their label. If your label is indented one space as
241+
indented more than their label. If your label is indented one space, as
242242
is often the case with the ``--`` syntax, the consecutive lines have
243243
to start at two spaces at the very least. For example, above we saw a
244244
multiline ``Copyright`` field: ::
@@ -250,22 +250,22 @@ multiline ``Copyright`` field: ::
250250
...
251251
-}
252252

253-
That could equivalently be written as ::
253+
That could equivalently be written as: ::
254254

255255
-- | ...
256256
-- Copyright:
257257
-- (c) Some Person, 2013
258258
-- Someone Else, 2014
259259
-- ...
260260

261-
or as ::
261+
or as: ::
262262

263263
-- | ...
264264
-- Copyright: (c) Some Person, 2013
265265
-- Someone Else, 2014
266266
-- ...
267267

268-
but not as ::
268+
but not as: ::
269269

270270
-- | ...
271271
-- Copyright: (c) Some Person, 2013
@@ -352,7 +352,7 @@ Documentation Structure Examples
352352

353353
We now give several examples that produce similar results and
354354
illustrate most of the structural markup features. The first two
355-
example use an export list, but the third example does not.
355+
examples use an export list, but the third example does not.
356356

357357
The first example, using an export list with :ref:`section-headings`
358358
and inline section descriptions: ::
@@ -362,7 +362,7 @@ and inline section descriptions: ::
362362
--
363363
-- | There is a "smart" importer, 'readImage', that determines
364364
-- the image format from the file extension, and several
365-
-- "dumb" format-specific importers that decode the file at
365+
-- "dumb" format-specific importers that decode the file as
366366
-- the specified type.
367367
readImage
368368
, readPngImage
@@ -417,7 +417,7 @@ defined elsewhere (the ``$imageImporters``; see :ref:`named-chunks`):
417417
--
418418
-- There is a "smart" importer, 'readImage', that determines the
419419
-- image format from the file extension, and several "dumb"
420-
-- format-specific importers that decode the file at the specified
420+
-- format-specific importers that decode the file as the specified
421421
-- type.
422422

423423
-- | Read an image, guessing the format from the file name.
@@ -450,7 +450,7 @@ The third example, without an export list: ::
450450
--
451451
-- There is a "smart" importer, 'readImage', that determines the
452452
-- image format from the file extension, and several "dumb"
453-
-- format-specific importers that decode the file at the specified
453+
-- format-specific importers that decode the file as the specified
454454
-- type.
455455

456456
-- | Read an image, guessing the format from the file name.
@@ -522,11 +522,11 @@ create stable links, you can add an explicit anchor (see
522522
This will create an HTML anchor ``#g:classes`` to the section.
523523

524524
The alternative style of placing the commas at the beginning of each
525-
line is also supported. e.g.: ::
525+
line is also supported, e.g.: ::
526526

527527
module Foo (
528528
-- * Classes
529-
, C(..)
529+
C(..)
530530
-- * Types
531531
-- ** A data type
532532
, T
@@ -539,7 +539,7 @@ line is also supported. e.g.: ::
539539

540540
When not using an export list, you may insert section headers in the
541541
module body. Such section headers associate with all entities
542-
declaried up until the next section header. For example: ::
542+
declared up until the next section header. For example: ::
543543

544544
module Foo where
545545

@@ -614,7 +614,7 @@ re-exporting module.
614614
It is often desirable to include a chunk of documentation which is not
615615
attached to any particular Haskell declaration, for example, when
616616
giving summary documentation for a group of related definitions (see
617-
:ref:`structure-examples`). In addition to including such documenation
617+
:ref:`structure-examples`). In addition to including such documentation
618618
chunks at the top of the file, as part of the
619619
:ref:`module-description`, you can also associate them with
620620
:ref:`section-headings`.
@@ -668,14 +668,14 @@ headings, depending on whether you are using an export list or not:
668668
-- Here is a large chunk of documentation which may be referred to by
669669
-- the name $doc.
670670

671-
Just like with entity declariations when not using an export list,
671+
Just like with entity declarations when not using an export list,
672672
named chunks of documentation are associated with the preceding
673673
section header here, or with the implicit top-level documentation
674674
section if there is no preceding section header.
675675

676676
**Warning**: the form used in the first bullet above, where the
677677
chunk is not named, *does not work* when you aren't using an
678-
export list. For example ::
678+
export list. For example: ::
679679

680680
module Foo where
681681

@@ -686,7 +686,7 @@ headings, depending on whether you are using an export list or not:
686686
-- | The fooifier.
687687
foo :: ...
688688

689-
will result in ``Some documentation not ...`` being attached to
689+
will result in ``Some documentation not ...`` being attached to the
690690
*next* entity declaration, here ``foo``, in addition to any other
691691
documentation that next entity already has!
692692

@@ -756,7 +756,7 @@ type in ``C`` will therefore point locally to ``C.T``.
756756
Module Attributes
757757
-----------------
758758

759-
Certain attributes may be specified for each module which affects the
759+
Certain attributes may be specified for each module which affect the
760760
way that Haddock generates documentation for that module. Attributes are
761761
specified in a comma-separated list in an
762762
``{-# OPTIONS_HADDOCK ... #-}`` pragma at the top of the module, either
@@ -807,7 +807,7 @@ Markup
807807

808808
Haddock understands certain textual cues inside documentation
809809
annotations that tell it how to render the documentation. The cues (or
810-
“markup”) have been designed to be simple and mnemonic in ASCII so that
810+
“markup”) have been designed to be simple and mnemonic in ASCII so
811811
the programmer doesn't have to deal with heavyweight annotations when
812812
editing documentation comments.
813813

@@ -820,8 +820,8 @@ comment.
820820
Special Characters
821821
~~~~~~~~~~~~~~~~~~
822822

823-
The following characters have special meanings in documentation
824-
comments: ``\``, ``/``, ``'``, `````, ``"``, ``@``, ``<``, ``$``, ``#``. To insert a
823+
The following characters have special meanings in documentation comments:
824+
``\``, ``/``, ``'``, `````, ``"``, ``@``, ``<``, ``$``, ``#``. To insert a
825825
literal occurrence of one of these special characters, precede it with a
826826
backslash (``\``).
827827

@@ -839,7 +839,7 @@ Character References
839839

840840
Although Haskell source files may contain any character from the Unicode
841841
character set, the encoding of these characters as bytes varies between
842-
systems, so that only source files restricted to the ASCII character set
842+
systems. Consequently, only source files restricted to the ASCII character set
843843
are portable. Other characters may be specified in character and string
844844
literals using Haskell character escapes. To represent such characters
845845
in documentation comments, Haddock supports SGML-style numeric character
@@ -926,10 +926,11 @@ If ``M.T`` is not otherwise in scope, then Haddock will simply emit a
926926
link pointing to the entity ``T`` exported from module ``M`` (without
927927
checking to see whether either ``M`` or ``M.T`` exist).
928928

929-
Since values and types live in different namespaces in Haskell, it is
930-
possible for a reference such as ``'X'`` to be ambiguous. In such a case,
931-
Haddock defaults to pointing to the type. The ambiguity can be overcome by explicitly specifying a namespace, by way of a ``v`` (for value) or ``t``
932-
(for type) immediately before the link: ::
929+
Since values and types live in different namespaces in Haskell, it is possible
930+
for a reference such as ``'X'`` to be ambiguous. In such a case, Haddock
931+
defaults to pointing to the type. The ambiguity can be overcome by explicitly
932+
specifying a namespace, by way of a ``v`` (for value) or ``t`` (for type)
933+
immediately before the link: ::
933934

934935
-- | An implicit reference to 'X', the type constructor
935936
-- An explicit reference to v'X', the data constructor
@@ -986,7 +987,7 @@ Itemized and Enumerated Lists
986987

987988
A bulleted item is represented by preceding a paragraph with either
988989
“``*``” or “``-``”. A sequence of bulleted paragraphs is rendered as an
989-
itemized list in the generated documentation, eg.: ::
990+
itemized list in the generated documentation, e.g.: ::
990991

991992
-- | This is a bulleted list:
992993
--
@@ -1025,7 +1026,7 @@ You can have more than one line of content in a list element: ::
10251026

10261027
You can even nest whole paragraphs inside of list elements. The rules
10271028
are 4 spaces for each indentation level. You're required to use a
1028-
newline before such nested paragraph: ::
1029+
newline before such nested paragraphs: ::
10291030

10301031
{-|
10311032
* Beginning of list
@@ -1112,7 +1113,7 @@ followed by the URL enclosed in regular parentheses, for example: ::
11121113

11131114
[some link](http://example.com)
11141115

1115-
The link text is used as a descriptive text for the URL, if the output
1116+
The link text is used as a description for the URL if the output
11161117
format supports it.
11171118

11181119
Images
@@ -1125,8 +1126,8 @@ like this: ::
11251126
![image description](pathtoimage.png)
11261127

11271128
If the output format supports it, the image will be rendered inside the
1128-
documentation. The image description is used as relpacement text and/or
1129-
image title.
1129+
documentation. The image description is used as replacement text and/or
1130+
an image title.
11301131

11311132
Mathematics / LaTeX
11321133
~~~~~~~~~~~~~~~~~~~
@@ -1146,7 +1147,13 @@ the mathematics via `MathJax <https://www.mathjax.org>`__.
11461147
Grid Tables
11471148
~~~~~~~~~~~
11481149

1149-
Inspired by reSTs grid tables Haddock supports a complete table representation via a grid-like "ASCII art". Grid tables are described with a visual grid made up of the characters "-", "=", "|", and "+". The hyphen ("-") is used for horizontal lines (row separators). The equals sign ("=") may be used to separate optional header rows from the table body. The vertical bar ("|") is used for vertical lines (column separators). The plus sign ("+") is used for intersections of horizontal and vertical lines. ::
1150+
Inspired by reSTs grid tables, Haddock supports a complete table representation
1151+
via grid-like "ASCII art". Grid tables are described with a visual grid made
1152+
up of the characters "-", "=", "|", and "+". The hyphen ("-") is used for
1153+
horizontal lines (row separators). The equals sign ("=") may be used to
1154+
separate optional header rows from the table body. The vertical bar ("|") is
1155+
used for vertical lines (column separators). The plus sign ("+") is used for
1156+
intersections of horizontal and vertical lines. ::
11501157

11511158
-- | This is a grid table:
11521159
--
@@ -1240,7 +1247,7 @@ Since
12401247
^^^^^
12411248

12421249
``@since`` annotation can be used to convey information about when the
1243-
function was introduced or when it has changed in the way significant to
1250+
function was introduced or when it has changed in a way significant to
12441251
the user. ``@since`` is a paragraph-level element. While multiple such
12451252
annotations are not an error, only the one to appear in the comment last
12461253
will be used. ``@since`` has to be followed with a version number, no

haddock-api/src/Haddock/Backends/Xhtml.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ ppPrologue pkg qual title (Just doc) =
307307

308308

309309
ppSignatureTree :: Maybe Package -> Qualification -> [ModuleTree] -> Html
310+
ppSignatureTree _ _ [] = mempty
310311
ppSignatureTree pkg qual ts =
311312
divModuleList << (sectionName << "Signatures" +++ mkNodeList pkg qual [] "n" ts)
312313

haddock-api/src/Haddock/Interface.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ processModules verbosity modules flags extIfaces = do
111111
let warnings = Flag_NoWarnings `notElem` flags
112112
dflags <- getDynFlags
113113
let (interfaces'', msgs) =
114-
runWriter $ mapM (renameInterface dflags links warnings) interfaces'
114+
runWriter $ mapM (renameInterface dflags (ignoredSymbols flags) links warnings) interfaces'
115115
liftIO $ mapM_ putStrLn msgs
116116

117117
return (interfaces'', homeLinks)

haddock-api/src/Haddock/Interface/Create.hs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import Data.Ord
3939
import Control.Applicative
4040
import Control.Monad
4141
import Data.Traversable
42+
import GHC.Stack (HasCallStack)
4243

4344
import Avail hiding (avail)
4445
import qualified Avail
@@ -58,16 +59,21 @@ import FastString ( unpackFS, bytesFS )
5859
import BasicTypes ( StringLiteral(..), SourceText(..), PromotionFlag(..) )
5960
import qualified Outputable as O
6061

62+
mkExceptionContext :: TypecheckedModule -> String
63+
mkExceptionContext =
64+
("creating Haddock interface for " ++) . moduleNameString . ms_mod_name . pm_mod_summary . tm_parsed_module
6165

6266
-- | Use a 'TypecheckedModule' to produce an 'Interface'.
6367
-- To do this, we need access to already processed modules in the topological
6468
-- sort. That's what's in the 'IfaceMap'.
65-
createInterface :: TypecheckedModule
69+
createInterface :: HasCallStack
70+
=> TypecheckedModule
6671
-> [Flag] -- Boolean flags
6772
-> IfaceMap -- Locally processed modules
6873
-> InstIfaceMap -- External, already installed interfaces
6974
-> ErrMsgGhc Interface
70-
createInterface tm flags modMap instIfaceMap = do
75+
createInterface tm flags modMap instIfaceMap =
76+
withExceptionContext (mkExceptionContext tm) $ do
7177

7278
let ms = pm_mod_summary . tm_parsed_module $ tm
7379
mi = moduleInfo tm
@@ -207,7 +213,6 @@ createInterface tm flags modMap instIfaceMap = do
207213
, ifaceDynFlags = dflags
208214
}
209215

210-
211216
-- | Given all of the @import M as N@ declarations in a package,
212217
-- create a mapping from the module identity of M, to an alias N
213218
-- (if there are multiple aliases, we pick the last one.) This
@@ -652,7 +657,8 @@ collectDocs = go Nothing []
652657
-- We create the export items even if the module is hidden, since they
653658
-- might be useful when creating the export items for other modules.
654659
mkExportItems
655-
:: Bool -- is it a signature
660+
:: HasCallStack
661+
=> Bool -- is it a signature
656662
-> IfaceMap
657663
-> Maybe Package -- this package
658664
-> Module -- this module
@@ -711,7 +717,8 @@ mkExportItems
711717
availExportItem is_sig modMap thisMod semMod warnings exportedNames
712718
maps fixMap splices instIfaceMap dflags avail
713719

714-
availExportItem :: Bool -- is it a signature
720+
availExportItem :: HasCallStack
721+
=> Bool -- is it a signature
715722
-> IfaceMap
716723
-> Module -- this module
717724
-> Module -- semantic module
@@ -804,7 +811,7 @@ availExportItem is_sig modMap thisMod semMod warnings exportedNames
804811
Just synifiedDecl -> pure synifiedDecl
805812
Nothing -> O.pprPanic "availExportItem" (O.text err)
806813

807-
availExportDecl :: AvailInfo -> LHsDecl GhcRn
814+
availExportDecl :: HasCallStack => AvailInfo -> LHsDecl GhcRn
808815
-> (DocForDecl Name, [(Name, DocForDecl Name)])
809816
-> ErrMsgGhc [ ExportItem GhcRn ]
810817
availExportDecl avail decl (doc, subs)
@@ -1075,7 +1082,8 @@ fullModuleContents is_sig modMap pkgName thisMod semMod warnings gre exportedNam
10751082
-- This function looks through the declarations in this module to try to find
10761083
-- the one with the right name.
10771084
extractDecl
1078-
:: DeclMap -- ^ all declarations in the file
1085+
:: HasCallStack
1086+
=> DeclMap -- ^ all declarations in the file
10791087
-> Name -- ^ name of the declaration to extract
10801088
-> LHsDecl GhcRn -- ^ parent declaration
10811089
-> Either ErrMsg (LHsDecl GhcRn)
@@ -1159,10 +1167,11 @@ extractDecl declMap name decl
11591167
_ -> Left "internal: extractDecl (ClsInstD)"
11601168
_ -> Left ("extractDecl: Unhandled decl for " ++ getOccString name)
11611169

1162-
extractPatternSyn :: Name -> Name -> [LHsTypeArg GhcRn] -> [LConDecl GhcRn] -> Either ErrMsg (LSig GhcRn)
1170+
extractPatternSyn :: HasCallStack => Name -> Name -> [LHsTypeArg GhcRn] -> [LConDecl GhcRn] -> Either ErrMsg (LSig GhcRn)
11631171
extractPatternSyn nm t tvs cons =
11641172
case filter matches cons of
1165-
[] -> Left "extractPatternSyn: constructor pattern not found"
1173+
[] -> Left . O.showSDocUnsafe $
1174+
O.text "constructor pattern " O.<+> O.ppr nm O.<+> O.text "not found in type" O.<+> O.ppr t
11661175
con:_ -> pure (extract <$> con)
11671176
where
11681177
matches :: LConDecl GhcRn -> Bool

0 commit comments

Comments
 (0)