...
 
Commits (83)
{
"project.name" : "haddock",
"repository.callsign" : "HADDOCK",
"phabricator.uri" : "https://phabricator.haskell.org"
}
{
"linters": {
"filename": {
"type": "filename"
},
"generated": {
"type": "generated"
},
"merge-conflict": {
"type": "merge-conflict"
},
"nolint": {
"type": "nolint"
},
"haskell": {
"type": "text",
"include": ["(\\.(l?hs(-boot)?|x|y\\.pp)(\\.in)?$)"],
"severity": {
"5": "disabled",
"2": "warning"
}
}
}
}
Simon Marlow <simonmar@microsoft.com>, marlowsd@gmail.com, simonmar
Simon Hengel <simon.hengel@wiktory.org>
David Waern <david.waern@gmail.com>, davve@dtek.chalmers.se, david.waern@gmail.com, David Waern
Sven Panne <sven.panne@aedion.de>, panne
Neil Mitchell <http://www.cs.york.ac.uk/~ndm/>, Neil Mitchell
Ross Paterson <ross@soi.city.ac.uk>, ross
Simon Peyton-Jones <simonpj@microsoft.com>
Wolfgang Jeltsch <g9ks157k@acme.softbase.org>, wolfgang
Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk>
Benjamin Franksen <benjamin.franksen@bessy.de>
:set -isrc -itest -idist/build -idist/build/autogen -packageghc -optP-include -optPdist/build/autogen/cabal_macros.h
:set --itest -idist/build -idist/build/autogen -packageghc -optP-include -optPdist/build/autogen/cabal_macros.h
/dist/
/haddock-library/dist
/haddock-api/dist/
/haddock-library/dist/
/html-test/out/
/latex-test/out/
......
language: haskell
notifications:
email:
on_success: never
on_failure: change
env:
- GHCVER=7.4.1
- GHCVER=7.4.2
- GHCVER=7.6.3
- GHCVER=7.8.1
- GHCVER=7.8.2
- GHCVER=7.8.3
- GHCVER=head
# - GHCVER=7.8.2
# - GHCVER=7.8.3
before_install:
- sudo add-apt-repository -y ppa:hvr/ghc
- sudo apt-get update
- sudo apt-get install ghc-$GHCVER
- export PATH=/opt/ghc/$GHCVER/bin:$PATH
install:
- case "$GHCVER" in
"head") (cd haddock-library/ && cabal install --enable-tests
&& cd .. && cabal install --only-dependencies --enable-tests) ;;
*)
(cd haddock-library/ && cabal install --only-dependencies --enable-tests) ;;
esac
- cd haddock-library
- cabal install --only-dependencies --enable-tests
- cabal install doctest
- cabal configure --enable-tests --ghc-options=-Werror && cabal build && cabal test
- doctest -isrc -i$(echo vendor/attoparsec-*) -optP-include -optPdist/build/autogen/cabal_macros.h src/Documentation/Haddock/Parser.hs
- cabal install
- cd ..
- (cd haddock-api/ && cabal install --only-dependencies --enable-tests && cabal configure --enable-tests --ghc-options=-Werror && cabal build && cabal test && cabal install)
script:
# Yes, in case of HEAD we do end up building haddock-library twice
# but we want to see the test results.
- (cd haddock-library/ && cabal configure --enable-tests --ghc-options=-Werror
&& cabal build && cabal test && cabal install && cabal install doctest
&& doctest -isrc -ivendor/attoparsec-0.10.4.0 -optP-include -optPdist/build/autogen/cabal_macros.h src/Documentation/Haddock/Parser.hs)
- case "$GHCVER" in
"head") (cabal configure --enable-tests --ghc-options=-Werror && cabal build && cabal test) ;;
*) ;;
esac
- cabal configure --enable-tests --ghc-options=-Werror && cabal build && cabal test
--------------------------------------------
-- Haddock 2.13.1
--------------------------------------------
A new versions of Haddock has been uploaded to Hackage.
--------------------------------------------
-- Changes in version 2.13.1
--------------------------------------------
* Hide instances that are "internal" to a module
* Add support for properties in documentation
* Fix a bug with spurious superclass constraints
* Fix and extend the Haddock API
--------------------------------------------
-- Links
--------------------------------------------
Homepage:
http://www.haskell.org/haddock
Hackage page:
http://hackage.haskell.org/package/haddock
Bugtracker and wiki:
http://trac.haskell.org/haddock
Mailing list:
haddock@projects.haskell.org
Code repository:
http://darcs.haskell.org/haddock.git
--------------------------------------------
-- Contributors
--------------------------------------------
The following people contributed patches to this release:
Kazu Yamamoto
Roman Cheplyaka
David Waern
Simon Hengel
--------------------------------------------
-- Get Involved
--------------------------------------------
We would be very happy to get more contributors. To get involved, start by
grabbing the code:
http://darcs.haskell.org/haddock.git
Then take a look at the bug and feature tracker for things to work on:
http://trac.haskell.org/haddock
Changes in version 2.16.0
* Experimental collapsible header support (#335)
* Add support for markdown links and images
* Allow an optional colon after the closing bracket of definition lists.
This is to disambiguate them from markdown links and will be require with a
future release.
* Fix re-exports of built-in type families (#310)
* Fix parsing of infix identifiers such as ``elem``.
Changes in version 2.15.0
* Always read in prologue files as UTF8 (#286 and Cabal #1721)
......@@ -6,6 +20,28 @@ Changes in version 2.15.0
* parser: don't mangle append order for nested lists (pandoc #1346)
* parser: preserve list ordering in certain scenarios (#313)
* parser: update the attoparsec version used internally giving slight
parsing performance boost.
* Move development to be against latest GHC release and not GHC HEAD.
* Further split up the package to separate the executable from the
library, necessary by things like GHCJS. We now have
haddock-library which are the parts that don't use GHC API,
‘haddock-api’ which are (some of) the parts that do use GHC API and
‘haddock’ which merely provides the executable.
* Export few extra functions in the API.
* Add compatibility with GHC 7.8.2.
* Omit unnecessary ‘forall’s (#315 and #86)
* Remove some files which were really old or did not belong in the
repository in the first place.
Changes in version 2.14.3
* Fix parsing of identifiers with ^ or ⋆ in them (#298)
......
If you're filing an issue, here are the things which will help us a lot:
* State your GHC version.
* State your platform, OS and distribution if applicable.
* State your cabal version if applicable.
* Tell us how to replicate the problem. If we can't replicate it, we
can't fix it.
* If the problem involves running Haddock on some source, please
include the sample on which we can replicate, the smaller/cleaner
the better. Include some images if you think it will help us.
* Include any other info you think might be relevant (sandbox? unusual
setup?).
......@@ -5,11 +5,11 @@ modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
......
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY nbsp '&#160;'>
<!ENTITY frac12 '&#189;'>
<!ENTITY mdash '&#8212;'>
<!ENTITY lsquo '&#8217;'>
<!ENTITY rsquo '&#8218;'>
<!ENTITY ldquo '&#8220;'>
<!ENTITY rdquo '&#8221;'>
] >
<book id="haddock">
<bookinfo>
......@@ -21,7 +29,7 @@
<holder>Simon Marlow, David Waern</holder>
</copyright>
<abstract>
<para>This document describes Haddock version 2.15.0, a Haskell
<para>This document describes Haddock version 2.15.1, a Haskell
documentation tool.</para>
</abstract>
</bookinfo>
......@@ -1033,6 +1041,18 @@ $ pdflatex <replaceable>package</replaceable>.tex</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<indexterm><primary><option>--print-missing-docs</option></primary></indexterm>
<option>--print-missing-docs</option>
</term>
<listitem>
<para>
Print extra information about any undocumented entities.
</para>
</listitem>
</varlistentry>
</variablelist>
<section id="cpp">
......@@ -1877,7 +1897,9 @@ module A where
<para>Nothing special is needed to hyperlink identifiers which
contain apostrophes themselves: to hyperlink
<literal>foo'</literal> one would simply type
<literal>'foo''</literal>.</para>
<literal>'foo''</literal>. To hyperlink identifiers written in
infix form, simply put them in quotes as always:
<literal>'`elem`'</literal>.</para>
<para>For compatibility with other systems, the following
alternative form of markup is accepted<footnote><para>
......@@ -2018,9 +2040,9 @@ This belongs to the list above!
<programlisting>
-- | This is a definition list:
--
-- [@foo@] The description of @foo@.
-- [@foo@]: The description of @foo@.
--
-- [@bar@] The description of @bar@.
-- [@bar@]: The description of @bar@.
</programlisting>
<para>To produce output something like this:</para>
......@@ -2041,13 +2063,8 @@ This belongs to the list above!
</variablelist>
<para>Each paragraph should be preceded by the
&ldquo;definition term&rdquo; enclosed in square brackets.
The square bracket characters have no special meaning outside
the beginning of a definition paragraph. That is, if a
paragraph begins with a <literal>[</literal> character, then
it is assumed to be a definition paragraph, and the next
<literal>]</literal> character found will close the definition
term. Other markup operators may be used freely within the
&ldquo;definition term&rdquo; enclosed in square brackets and followed by a colon.
Other markup operators may be used freely within the
definition term. You can escape <literal>]</literal> with a backslash as usual.</para>
<para>Same rules about nesting and no newline separation as for bulleted and numbered lists apply.
......@@ -2058,37 +2075,60 @@ This belongs to the list above!
<section>
<title>URLs</title>
<para>A URL can be included in a documentation comment by
surrounding it in angle brackets:
<literal>&lt;...&gt;</literal>. If the output format supports
it, the URL will be turned into a hyperlink when
rendered.</para>
<para>
A URL can be included in a documentation comment by surrounding it in
angle brackets, for example:
</para>
<para>The URL can be followed by an optional label:</para>
<programlisting>
&lt;http://example.com label&gt;
&lt;http://example.com&gt;
</programlisting>
<para>The label is then used as a descriptive text for the hyperlink, if the
output format supports it.</para>
<para>If Haddock sees something that looks like a URL (such as something starting with
<literal>http://</literal> or <literal>ssh://</literal>) where the URL markup is valid,
it will automatically make it a hyperlink.</para>
<para>
If the output format supports it, the URL will be turned into a
hyperlink when rendered.
</para>
<para>If Haddock sees something that looks like a URL (such as something starting with
<literal>http://</literal> or <literal>ssh://</literal>) where the URL markup is valid,
it will automatically make it a hyperlink.</para>
</section>
<section>
<title>Images</title>
<title>Links</title>
<para>An image can be included in a documentation comment by
surrounding it in double angle brackets:
<literal>&lt;&lt;...&gt;&gt;</literal>. If the output format supports
it, the image will be rendered inside the documentation.</para>
<para>
Haddock supports Markdown syntax for inline links. A link consists
of a link text and a URL. The link text is enclosed in square
brackets and followed by the URL enclosed in regular parentheses, for
example:
</para>
<para>Title text can be included using an optional label:</para>
<programlisting>
&lt;&lt;pathtoimage.png title&gt;&gt;
[some link](http://example.com)
</programlisting>
<para>
The link text is used as a descriptive text for the URL, if the
output format supports it.
</para>
</section>
<section>
<title>Images</title>
<para>
Haddock supports Markdown syntax for inline images. This resembles
the syntax for links, but starts with an exclamation mark. An
example looks like this:
</para>
<programlisting>
![image description](pathtoimage.png)
</programlisting>
<para>
If the output format supports it, the image will be rendered inside
the documentation. The image description is used as relpacement text
and/or image title.
</para>
</section>
<section>
......@@ -2123,7 +2163,7 @@ This belongs to the list above!
<programlisting>
-- |
-- = Heading level 1 with some __bold__
-- = Heading level 1 with some /emphasis/
-- Something underneath the heading.
--
-- == /Subheading/
......@@ -2147,6 +2187,25 @@ This belongs to the list above!
--
-- === Subsubheading
-- >>> examples are only allowed at the start of paragraphs
</programlisting>
<para>As of 2.15.1, there's experimental (read: subject to
change or get removed) support for collapsible headers: simply
wrap your existing header title in underscores, as per bold
syntax. The collapsible section will stretch until the end of
the comment or until a header of equal or smaller number of
<literal>=</literal>s.</para>
<programlisting>
-- |
-- === __Examples:__
-- >>> Some very long list of examples
--
-- ==== This still falls under the collapse
-- Some specialised examples
--
-- === This is does not go into the collapsable section.
-- More content.
</programlisting>
</section>
......
......@@ -26,11 +26,11 @@ $(INPLACE_BIN)/$(utils/haddock_dist_PROG): $(INPLACE_LIB)/html $(INPLACE_LIB)/la
$(INPLACE_LIB)/html:
$(call removeTrees,$@)
"$(CP)" -RL utils/haddock/resources/html $@
"$(CP)" -RL utils/haddock/haddock-api/resources/html $@
$(INPLACE_LIB)/latex:
$(call removeTrees,$@)
"$(CP)" -RL utils/haddock/resources/latex $@
"$(CP)" -RL utils/haddock/haddock-api/resources/latex $@
endif
......@@ -48,7 +48,7 @@ install_utils/haddock_data:
$(foreach i,$(sort $(dir $(utils/haddock_dist_DATA_FILES))), \
$(call make-command,$(call INSTALL_DIR,"$(DESTDIR)$(ghclibdir)/$i")))
$(foreach i,$(utils/haddock_dist_DATA_FILES), \
$(call make-command,$(call INSTALL_DATA,$(INSTALL_OPTS),utils/haddock/resources/$i,"$(DESTDIR)$(ghclibdir)/$(dir $i)")))
$(call make-command,$(call INSTALL_DATA,$(INSTALL_OPTS),utils/haddock/haddock-api/resources/$i,"$(DESTDIR)$(ghclibdir)/$(dir $i)")))
.PHONY: install_utils/haddock_link
install_utils/haddock_link:
......@@ -56,4 +56,3 @@ install_utils/haddock_link:
$(LN_S) $(utils/haddock_dist_INSTALL_SHELL_WRAPPER_NAME) "$(DESTDIR)$(bindir)/haddock"
BINDIST_EXTRAS += $(addprefix utils/haddock/resources/,$(utils/haddock_dist_DATA_FILES))
:set -isrc -idist/build -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
Copyright 2002-2010, Simon Marlow. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#!/usr/bin/env runhaskell
> import Distribution.Simple
> main = defaultMain
name: haddock-api
version: 2.16.0
synopsis: A documentation-generation tool for Haskell libraries
description: Haddock is a documentation-generation tool for Haskell
libraries
license: BSD3
license-file: LICENSE
author: Simon Marlow, David Waern
maintainer: Simon Hengel <sol@typeful.net>, Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>
homepage: http://www.haskell.org/haddock/
bug-reports: https://github.com/haskell/haddock/issues
copyright: (c) Simon Marlow, David Waern
category: Documentation
build-type: Simple
cabal-version: >= 1.10
stability: experimental
data-dir:
resources
data-files:
html/frames.html
html/haddock-util.js
html/Classic.theme/haskell_icon.gif
html/Classic.theme/minus.gif
html/Classic.theme/plus.gif
html/Classic.theme/xhaddock.css
html/Ocean.std-theme/hslogo-16.png
html/Ocean.std-theme/minus.gif
html/Ocean.std-theme/ocean.css
html/Ocean.std-theme/plus.gif
html/Ocean.std-theme/synopsis.png
latex/haddock.sty
library
default-language:
Haskell2010
build-depends:
base >= 4.3 && < 4.9
, bytestring
, filepath
, directory
, containers
, deepseq
, array
, xhtml >= 3000.2 && < 3000.3
, Cabal >= 1.10
, ghc == 7.9.*
, ghc-paths
, haddock-library == 1.20.0.*
hs-source-dirs:
src
ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2
exposed-modules:
Documentation.Haddock
other-modules:
Haddock
Haddock.Interface
Haddock.Interface.Rename
Haddock.Interface.Create
Haddock.Interface.AttachInstances
Haddock.Interface.LexParseRn
Haddock.Interface.ParseModuleHeader
Haddock.Parser
Haddock.Utils
Haddock.Backends.Xhtml
Haddock.Backends.Xhtml.Decl
Haddock.Backends.Xhtml.DocMarkup
Haddock.Backends.Xhtml.Layout
Haddock.Backends.Xhtml.Names
Haddock.Backends.Xhtml.Themes
Haddock.Backends.Xhtml.Types
Haddock.Backends.Xhtml.Utils
Haddock.Backends.LaTeX
Haddock.Backends.HaddockDB
Haddock.Backends.Hoogle
Haddock.ModuleTree
Haddock.Types
Haddock.Doc
Haddock.Version
Haddock.InterfaceFile
Haddock.Options
Haddock.GhcUtils
Haddock.Convert
Paths_haddock_api
source-repository head
type: git
location: https://github.com/haskell/haddock.git
......@@ -57,8 +57,14 @@ module Documentation.Haddock (
Flag(..),
DocOption(..),
-- * Error handling
HaddockException(..),
-- * Program entry point
haddock,
haddockWithGhc,
getGhcDirs,
withGhc
) where
......@@ -79,5 +85,5 @@ createInterfaces
-> [String] -- ^ File or module names
-> IO [Interface] -- ^ Resulting list of interfaces
createInterfaces flags modules = do
(_, ifaces, _) <- withGhc' flags (readPackagesAndProcessModules flags modules)
(_, ifaces, _) <- withGhc flags (readPackagesAndProcessModules flags modules)
return ifaces
{-# OPTIONS_GHC -Wwarn #-}
{-# LANGUAGE CPP, ScopedTypeVariables #-}
{-# LANGUAGE CPP, ScopedTypeVariables, Rank2Types #-}
{-# LANGUAGE LambdaCase #-}
-----------------------------------------------------------------------------
-- |
......@@ -17,8 +17,13 @@
--
-- Program entry point and top-level code.
-----------------------------------------------------------------------------
module Haddock (haddock, readPackagesAndProcessModules, withGhc') where
module Haddock (
haddock,
haddockWithGhc,
getGhcDirs,
readPackagesAndProcessModules,
withGhc
) where
import Haddock.Backends.Xhtml
import Haddock.Backends.Xhtml.Themes (getThemes)
......@@ -42,7 +47,6 @@ import Data.IORef
import qualified Data.Map as Map
import System.IO
import System.Exit
import System.Directory
#if defined(mingw32_HOST_OS)
import Foreign
......@@ -54,7 +58,7 @@ import Data.Int
import System.FilePath
#else
import qualified GHC.Paths as GhcPaths
import Paths_haddock
import Paths_haddock_api (getDataDir)
#endif
import GHC hiding (verbosity)
......@@ -63,6 +67,8 @@ import DynFlags hiding (verbosity)
import StaticFlags (discardStaticFlags)
import Panic (handleGhcException)
import Module
import PackageConfig
import FastString
--------------------------------------------------------------------------------
-- * Exception handling
......@@ -129,7 +135,10 @@ handleGhcExceptions =
--
-- > main = getArgs >>= haddock
haddock :: [String] -> IO ()
haddock args = handleTopExceptions $ do
haddock args = haddockWithGhc withGhc args
haddockWithGhc :: (forall a. [Flag] -> Ghc a -> IO a) -> [String] -> IO ()
haddockWithGhc ghc args = handleTopExceptions $ do
-- Parse command-line flags and handle some of them initially.
-- TODO: unify all of this (and some of what's in the 'render' function),
......@@ -140,7 +149,7 @@ haddock args = handleTopExceptions $ do
qual <- case qualification flags of {Left msg -> throwE msg; Right q -> return q}
-- inject dynamic-too into flags before we proceed
flags' <- withGhc' flags $ do
flags' <- ghc flags $ do
df <- getDynFlags
case lookup "GHC Dynamic" (compilerInfo df) of
Just "YES" -> return $ Flag_OptGhc "-dynamic-too" : flags
......@@ -150,7 +159,7 @@ haddock args = handleTopExceptions $ do
forM_ (warnings args) $ \warning -> do
hPutStrLn stderr warning
withGhc' flags' $ do
ghc flags' $ do
dflags <- getDynFlags
......@@ -184,8 +193,8 @@ warnings = map format . filter (isPrefixOf "-optghc")
format arg = concat ["Warning: `", arg, "' means `-o ", drop 2 arg, "', did you mean `-", arg, "'?"]
withGhc' :: [Flag] -> Ghc a -> IO a
withGhc' flags action = do
withGhc :: [Flag] -> Ghc a -> IO a
withGhc flags action = do
libDir <- fmap snd (getGhcDirs flags)
-- Catches all GHC source errors, then prints and re-throws them.
......@@ -193,7 +202,7 @@ withGhc' flags action = do
printException err
liftIO exitFailure
withGhc libDir (ghcFlags flags) (\_ -> handleSrcErrors action)
withGhc' libDir (ghcFlags flags) (\_ -> handleSrcErrors action)
readPackagesAndProcessModules :: [Flag] -> [String]
......@@ -242,7 +251,7 @@ render dflags flags qual ifaces installedIfaces srcMap = do
pkgMod = ifaceMod (head ifaces)
pkgKey = modulePackageKey pkgMod
pkgStr = Just (packageKeyString pkgKey)
(pkgName,pkgVer) = modulePackageInfo pkgMod
(pkgName,pkgVer) = modulePackageInfo dflags pkgMod
(srcBase, srcModule, srcEntity, srcLEntity) = sourceUrls flags
srcMap' = maybe srcMap (\path -> Map.insert pkgKey path srcMap) srcEntity
......@@ -261,29 +270,34 @@ render dflags flags qual ifaces installedIfaces srcMap = do
copyHtmlBits odir libDir themes
when (Flag_GenContents `elem` flags) $ do
ppHtmlContents odir title pkgStr
ppHtmlContents dflags odir title pkgStr
themes opt_index_url sourceUrls' opt_wiki_urls
allVisibleIfaces True prologue pretty
(makeContentsQual qual)
copyHtmlBits odir libDir themes
when (Flag_Html `elem` flags) $ do
ppHtml title pkgStr visibleIfaces odir
ppHtml dflags title pkgStr visibleIfaces odir
prologue
themes sourceUrls' opt_wiki_urls
opt_contents_url opt_index_url unicode qual
pretty
copyHtmlBits odir libDir themes
-- TODO: we throw away Meta for both Hoogle and LaTeX right now,
-- might want to fix that if/when these two get some work on them
when (Flag_Hoogle `elem` flags) $ do
let pkgName2 = if pkgName == "main" && title /= [] then title else pkgName
ppHoogle dflags pkgName2 pkgVer title prologue visibleIfaces odir
let pkgNameStr | unpackFS pkgNameFS == "main" && title /= []
= title
| otherwise = unpackFS pkgNameFS
where PackageName pkgNameFS = pkgName
ppHoogle dflags pkgNameStr pkgVer title (fmap _doc prologue) visibleIfaces
odir
when (Flag_LaTeX `elem` flags) $ do
ppLaTeX title pkgStr visibleIfaces odir prologue opt_latex_style
ppLaTeX title pkgStr visibleIfaces odir (fmap _doc prologue) opt_latex_style
libDir
-------------------------------------------------------------------------------
-- * Reading and dumping interface files
-------------------------------------------------------------------------------
......@@ -314,8 +328,8 @@ readInterfaceFiles name_cache_accessor pairs = do
-- | Start a GHC session with the -haddock flag set. Also turn off
-- compilation and linking. Then run the given 'Ghc' action.
withGhc :: String -> [String] -> (DynFlags -> Ghc a) -> IO a
withGhc libDir flags ghcActs = runGhc (Just libDir) $ do
withGhc' :: String -> [String] -> (DynFlags -> Ghc a) -> IO a
withGhc' libDir flags ghcActs = runGhc (Just libDir) $ do
dynflags <- getSessionDynFlags
dynflags' <- parseGhcFlags (gopt_set dynflags Opt_Haddock) {
hscTarget = HscNothing,
......@@ -441,14 +455,14 @@ updateHTMLXRefs packages = do
mapping' = [ (moduleName m, html) | (m, html) <- mapping ]
getPrologue :: DynFlags -> [Flag] -> IO (Maybe (Doc RdrName))
getPrologue :: DynFlags -> [Flag] -> IO (Maybe (MDoc RdrName))
getPrologue dflags flags =
case [filename | Flag_Prologue filename <- flags ] of
[] -> return Nothing
[filename] -> withFile filename ReadMode $ \h -> do
hSetEncoding h utf8
str <- hGetContents h
return . Just $ parseParas dflags str
return . Just $! parseParas dflags str
_ -> throwE "multiple -p/--prologue options"
......
......@@ -17,7 +17,7 @@ module Haddock.Backends.Hoogle (
import Haddock.GhcUtils
import Haddock.Types
import Haddock.Types hiding (Version)
import Haddock.Utils hiding (out)
import GHC
import Outputable
......@@ -25,6 +25,7 @@ import Outputable
import Data.Char
import Data.List
import Data.Maybe
import Data.Version
import System.FilePath
import System.IO
......@@ -34,13 +35,14 @@ prefix = ["-- Hoogle documentation, generated by Haddock"
,""]
ppHoogle :: DynFlags -> String -> String -> String -> Maybe (Doc RdrName) -> [Interface] -> FilePath -> IO ()
ppHoogle :: DynFlags -> String -> Version -> String -> Maybe (Doc RdrName) -> [Interface] -> FilePath -> IO ()
ppHoogle dflags package version synopsis prologue ifaces odir = do
let filename = package ++ ".txt"
contents = prefix ++
docWith dflags (drop 2 $ dropWhile (/= ':') synopsis) prologue ++
["@package " ++ package] ++
["@version " ++ version | version /= ""] ++
["@version " ++ showVersion version
| not (null (versionBranch version)) ] ++
concat [ppModule dflags i | i <- ifaces, OptHide `notElem` ifaceOptions i]
h <- openFile (odir </> filename) WriteMode
hSetEncoding h utf8
......@@ -62,7 +64,7 @@ dropHsDocTy :: HsType a -> HsType a
dropHsDocTy = f
where
g (L src x) = L src (f x)
f (HsForAllTy a b c d) = HsForAllTy a b c (g d)
f (HsForAllTy a b c d e) = HsForAllTy a b c d (g e)
f (HsBangTy a b) = HsBangTy a (g b)
f (HsAppTy a b) = HsAppTy (g a) (g b)
f (HsFunTy a b) = HsFunTy (g a) (g b)
......@@ -80,7 +82,7 @@ outHsType dflags = out dflags . dropHsDocTy
makeExplicit :: HsType a -> HsType a
makeExplicit (HsForAllTy _ a b c) = HsForAllTy Explicit a b c
makeExplicit (HsForAllTy _ a b c d) = HsForAllTy Explicit a b c d
makeExplicit x = x
makeExplicitL :: LHsType a -> LHsType a
......@@ -118,20 +120,21 @@ ppExport dflags ExportDecl { expItemDecl = L _ decl
f (TyClD d@DataDecl{}) = ppData dflags d subdocs
f (TyClD d@SynDecl{}) = ppSynonym dflags d
f (TyClD d@ClassDecl{}) = ppClass dflags d
f (ForD (ForeignImport name typ _ _)) = ppSig dflags $ TypeSig [name] typ
f (ForD (ForeignExport name typ _ _)) = ppSig dflags $ TypeSig [name] typ
f (ForD (ForeignImport name typ _ _)) = ppSig dflags $ TypeSig [name] typ []
f (ForD (ForeignExport name typ _ _)) = ppSig dflags $ TypeSig [name] typ []
f (SigD sig) = ppSig dflags sig
f _ = []
ppExport _ _ = []
ppSig :: DynFlags -> Sig Name -> [String]
ppSig dflags (TypeSig names sig)
ppSig dflags (TypeSig names sig _)
= [operator prettyNames ++ " :: " ++ outHsType dflags typ]
where
prettyNames = intercalate ", " $ map (out dflags) names
typ = case unL sig of
HsForAllTy Explicit a b c -> HsForAllTy Implicit a b c
HsForAllTy Explicit a b c d -> HsForAllTy Implicit a b c d
HsForAllTy Qualified a b c d -> HsForAllTy Implicit a b c d
x -> x
ppSig _ _ = []
......@@ -141,12 +144,12 @@ ppClass :: DynFlags -> TyClDecl Name -> [String]
ppClass dflags x = out dflags x{tcdSigs=[]} :
concatMap (ppSig dflags . addContext . unL) (tcdSigs x)
where
addContext (TypeSig name (L l sig)) = TypeSig name (L l $ f sig)
addContext (TypeSig name (L l sig) nwcs) = TypeSig name (L l $ f sig) nwcs
addContext (MinimalSig sig) = MinimalSig sig
addContext _ = error "expected TypeSig"
f (HsForAllTy a b con d) = HsForAllTy a b (reL (context : unLoc con)) d
f t = HsForAllTy Implicit emptyHsQTvs (reL [context]) (reL t)
f (HsForAllTy a b c con d) = HsForAllTy a b c (reL (context : unLoc con)) d
f t = HsForAllTy Implicit Nothing emptyHsQTvs (reL [context]) (reL t)
context = nlHsTyConApp (tcdName x)
(map (reL . HsTyVar . hsTyVarName . unL) (hsQTvBndrs (tyClDeclTyVars x)))
......@@ -181,21 +184,21 @@ lookupCon dflags subdocs (L _ name) = case lookup name subdocs of
_ -> []
ppCtor :: DynFlags -> TyClDecl Name -> [(Name, DocForDecl Name)] -> ConDecl Name -> [String]
ppCtor dflags dat subdocs con = lookupCon dflags subdocs (con_name con)
++ f (con_details con)
ppCtor dflags dat subdocs con
= concatMap (lookupCon dflags subdocs) (con_names con) ++ f (con_details con)
where
f (PrefixCon args) = [typeSig name $ args ++ [resType]]
f (InfixCon a1 a2) = f $ PrefixCon [a1,a2]
f (RecCon recs) = f (PrefixCon $ map cd_fld_type recs) ++ concat
[lookupCon dflags subdocs (cd_fld_name r) ++
[out dflags (unL $ cd_fld_name r) `typeSig` [resType, cd_fld_type r]]
| r <- recs]
f (RecCon recs) = f (PrefixCon $ map cd_fld_type (map unLoc recs)) ++ concat
[(concatMap (lookupCon dflags subdocs) (cd_fld_names r)) ++
[out dflags (map unL $ cd_fld_names r) `typeSig` [resType, cd_fld_type r]]
| r <- map unLoc recs]
funs = foldr1 (\x y -> reL $ HsFunTy (makeExplicitL x) (makeExplicitL y))
apps = foldl1 (\x y -> reL $ HsAppTy x y)
typeSig nm flds = operator nm ++ " :: " ++ outHsType dflags (makeExplicit $ unL $ funs flds)
name = out dflags $ unL $ con_name con
name = out dflags $ map unL $ con_names con
resType = case con_res con of
ResTyH98 -> apps $ map (reL . HsTyVar) $
......@@ -207,18 +210,20 @@ ppCtor dflags dat subdocs con = lookupCon dflags subdocs (con_name con)
-- DOCUMENTATION
ppDocumentation :: Outputable o => DynFlags -> Documentation o -> [String]
ppDocumentation dflags (Documentation d w) = doc dflags d ++ doc dflags w
ppDocumentation dflags (Documentation d w) = mdoc dflags d ++ doc dflags w
doc :: Outputable o => DynFlags -> Maybe (Doc o) -> [String]
doc dflags = docWith dflags ""
mdoc :: Outputable o => DynFlags -> Maybe (MDoc o) -> [String]
mdoc dflags = docWith dflags "" . fmap _doc
docWith :: Outputable o => DynFlags -> String -> Maybe (Doc o) -> [String]
docWith _ [] Nothing = []
docWith dflags header d
= ("":) $ zipWith (++) ("-- | " : repeat "-- ") $
[header | header /= ""] ++ ["" | header /= "" && isJust d] ++
lines header ++ ["" | header /= "" && isJust d] ++
maybe [] (showTags . markup (markupTag dflags)) d
......
......@@ -26,6 +26,7 @@ import OccName
import Name ( nameOccName )
import RdrName ( rdrNameOcc )
import FastString ( unpackFS, unpackLitString, zString )
import Outputable ( panic)
import qualified Data.Map as Map
import System.Directory
......@@ -211,7 +212,7 @@ processExports (e : es) =
isSimpleSig :: ExportItem DocName -> Maybe ([DocName], HsType DocName)
isSimpleSig ExportDecl { expItemDecl = L _ (SigD (TypeSig lnames (L _ t)))
isSimpleSig ExportDecl { expItemDecl = L _ (SigD (TypeSig lnames (L _ t) _))
, expItemMbDoc = (Documentation Nothing Nothing, argDocs) }
| Map.null argDocs = Just (map unLoc lnames, t)
isSimpleSig _ = Nothing
......@@ -234,7 +235,7 @@ processExport (ExportNoDecl y subs)
processExport (ExportModule mdl)
= declWithDoc (text "module" <+> text (moduleString mdl)) Nothing
processExport (ExportDoc doc)
= docToLaTeX doc
= docToLaTeX $ _doc doc
ppDocGroup :: Int -> LaTeX -> LaTeX
......@@ -248,7 +249,7 @@ ppDocGroup lev doc = sec lev <> braces doc
declNames :: LHsDecl DocName -> [DocName]
declNames (L _ decl) = case decl of
TyClD d -> [tcdName d]
SigD (TypeSig lnames _) -> map unLoc lnames
SigD (TypeSig lnames _ _) -> map unLoc lnames
SigD (PatSynSig lname _ _ _ _) -> [unLoc lname]
ForD (ForeignImport (L _ n) _ _ _) -> [n]
ForD (ForeignExport (L _ n) _ _ _) -> [n]
......@@ -292,9 +293,9 @@ ppDecl (L loc decl) (doc, fnArgsDoc) instances subdocs _fixities = case decl of
-- | Just _ <- tcdTyPats d -> ppTyInst False loc doc d unicode
-- Family instances happen via FamInst now
TyClD d@(ClassDecl {}) -> ppClassDecl instances loc doc subdocs d unicode
SigD (TypeSig lnames (L _ t)) -> ppFunSig loc (doc, fnArgsDoc) (map unLoc lnames) t unicode
SigD (PatSynSig lname args ty prov req) ->
ppLPatSig loc (doc, fnArgsDoc) lname args ty prov req unicode
SigD (TypeSig lnames (L _ t) _) -> ppFunSig loc (doc, fnArgsDoc) (map unLoc lnames) t unicode
SigD (PatSynSig lname qtvs prov req ty) ->
ppLPatSig loc (doc, fnArgsDoc) lname qtvs prov req ty unicode
ForD d -> ppFor loc (doc, fnArgsDoc) d unicode
InstD _ -> empty
_ -> error "declaration not supported by ppDecl"
......@@ -350,32 +351,28 @@ ppFunSig loc doc docnames typ unicode =
names = map getName docnames
ppLPatSig :: SrcSpan -> DocForDecl DocName -> Located DocName
-> HsPatSynDetails (LHsType DocName) -> LHsType DocName
-> (HsExplicitFlag, LHsTyVarBndrs DocName)
-> LHsContext DocName -> LHsContext DocName
-> LHsType DocName
-> Bool -> LaTeX
ppLPatSig loc doc docname args typ prov req unicode =
ppPatSig loc doc (unLoc docname) (fmap unLoc args) (unLoc typ) (unLoc prov) (unLoc req) unicode
ppPatSig :: SrcSpan -> DocForDecl DocName -> DocName
-> HsPatSynDetails (HsType DocName) -> HsType DocName
-> HsContext DocName -> HsContext DocName
-> Bool -> LaTeX
ppPatSig _loc (doc, _argDocs) docname args typ prov req unicode = declWithDoc pref1 (documentationToLaTeX doc)
ppLPatSig _loc (doc, _argDocs) (L _ name) (expl, qtvs) lprov lreq (L _ ty) unicode
= declWithDoc pref1 (documentationToLaTeX doc)
where
pref1 = hsep [ keyword "pattern"
, pp_ctx prov
, pp_head
, ppDocBinder name
, dcolon unicode
, pp_ctx req
, ppType unicode typ
, ppLTyVarBndrs expl qtvs unicode
, ctx
, ppType unicode ty
]
pp_head = case args of
PrefixPatSyn typs -> hsep $ ppDocBinder docname : map pp_type typs
InfixPatSyn left right -> hsep [pp_type left, ppDocBinderInfix docname, pp_type right]
ctx = case (ppLContextMaybe lprov unicode, ppLContextMaybe lreq unicode) of
(Nothing, Nothing) -> empty
(Nothing, Just req) -> parens empty <+> darr <+> req <+> darr
(Just prov, Nothing) -> prov <+> darr
(Just prov, Just req) -> prov <+> darr <+> req <+> darr
pp_type = ppParendType unicode
pp_ctx ctx = ppContext ctx unicode
darr = darrow unicode
ppTypeOrFunSig :: SrcSpan -> [DocName] -> HsType DocName
-> DocForDecl DocName -> (LaTeX, LaTeX, LaTeX)
......@@ -393,16 +390,18 @@ ppTypeOrFunSig _ _ typ (doc, argDocs) (pref1, pref2, sep0)
where
do_largs n leader (L _ t) = do_args n leader t
arg_doc n = rDoc (Map.lookup n argDocs)
arg_doc n = rDoc . fmap _doc $ Map.lookup n argDocs
do_args :: Int -> LaTeX -> (HsType DocName) -> LaTeX
do_args n leader (HsForAllTy Explicit tvs lctxt ltype)
do_args n leader (HsForAllTy Explicit _ tvs lctxt ltype)
= decltt leader <->
decltt (hsep (forallSymbol unicode : ppTyVars tvs ++ [dot]) <+>
ppLContextNoArrow lctxt unicode) <+> nl $$
do_largs n (darrow unicode) ltype
do_args n leader (HsForAllTy Implicit _ lctxt ltype)
do_args n leader (HsForAllTy Qualified e a lctxt ltype)
= do_args n leader (HsForAllTy Implicit e a lctxt ltype)
do_args n leader (HsForAllTy Implicit _ _ lctxt ltype)