From f6e5d57bee5a7bf5d74d26982db64fa8a56f17bd Mon Sep 17 00:00:00 2001 From: Sebastian Meric de Bellefon Date: Sun, 15 May 2016 01:12:28 -0400 Subject: Fix #280. Parsing of module header The initial newlines were counted as indentation spaces, thus disturbing the parsing of next lines --- html-test/ref/Bug280.html | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 html-test/ref/Bug280.html (limited to 'html-test/ref') diff --git a/html-test/ref/Bug280.html b/html-test/ref/Bug280.html new file mode 100644 index 00000000..f154f300 --- /dev/null +++ b/html-test/ref/Bug280.html @@ -0,0 +1,81 @@ + +Bug280

 

CopyrightFoo, + Bar, + Baz
Safe HaskellSafe

Bug280

Description

The module description

Documentation

x :: [Char] #

-- cgit v1.2.3 From 474a0c182d6ef9a7e93e277a2755d04d943059a0 Mon Sep 17 00:00:00 2001 From: Sebastian Meric de Bellefon Date: Tue, 24 May 2016 17:36:34 -0400 Subject: remove framed view of the HTML documentation (see #114 and #274) Frames are a bit broken, ignored by Hackage, and considered obsolete in general. This patch disables frames generation. The mini_*.html files are still used in the synopsis. --- doc/invoking.rst | 8 ++---- haddock-api/haddock-api.cabal | 1 - haddock-api/resources/html/frames.html | 30 --------------------- haddock-api/resources/html/haddock-util.js | 28 -------------------- haddock-api/src/Haddock/Backends/Xhtml.hs | 42 +++--------------------------- haddock-api/src/Haddock/Utils.hs | 12 ++------- html-test/ref/frames.html | 30 --------------------- html-test/ref/haddock-util.js | 28 -------------------- 8 files changed, 7 insertions(+), 172 deletions(-) delete mode 100644 haddock-api/resources/html/frames.html delete mode 100644 html-test/ref/frames.html (limited to 'html-test/ref') diff --git a/doc/invoking.rst b/doc/invoking.rst index 13cb9f1e..83087bac 100644 --- a/doc/invoking.rst +++ b/doc/invoking.rst @@ -100,7 +100,7 @@ The following options are available: ``module.html``; ``mini_module.html`` An HTML page for each module, and a "mini" page for each used - when viewing in frames. + when viewing their synopsis. ``index.html`` The top level page of the documentation: lists the modules @@ -111,17 +111,13 @@ The following options are available: The alphabetic index, possibly split into multiple pages if big enough. - ``frames.html`` - The top level document when viewing in frames. - ``some.css``; ``etc...`` Files needed for the themes used. Specify your themes using the :option:`--theme` option. ``haddock-util.js`` Some JavaScript utilities used to implement some of the dynamic - features like collapsible sections, and switching to frames - view. + features like collapsible sections. .. option:: --latex diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal index 6c98fcfb..d1bbf783 100644 --- a/haddock-api/haddock-api.cabal +++ b/haddock-api/haddock-api.cabal @@ -19,7 +19,6 @@ data-dir: resources data-files: html/solarized.css - html/frames.html html/haddock-util.js html/highlight.js html/Classic.theme/haskell_icon.gif diff --git a/haddock-api/resources/html/frames.html b/haddock-api/resources/html/frames.html deleted file mode 100644 index e86edb66..00000000 --- a/haddock-api/resources/html/frames.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/haddock-api/resources/html/haddock-util.js b/haddock-api/resources/html/haddock-util.js index fc7743fe..92d07d2a 100644 --- a/haddock-api/resources/html/haddock-util.js +++ b/haddock-api/resources/html/haddock-util.js @@ -248,33 +248,6 @@ function addMenuItem(html) { } } -function adjustForFrames() { - var bodyCls; - - if (parent.location.href == window.location.href) { - // not in frames, so add Frames button - addMenuItem("Frames"); - bodyCls = "no-frame"; - } - else { - bodyCls = "in-frame"; - } - addClass(document.body, bodyCls); -} - -function reframe() { - setCookie("haddock-reframe", document.URL); - window.location = "frames.html"; -} - -function postReframe() { - var s = getCookie("haddock-reframe"); - if (s) { - parent.window.main.location = s; - clearCookie("haddock-reframe"); - } -} - function styles() { var i, a, es = document.getElementsByTagName("link"), rs = []; for (i = 0; a = es[i]; i++) { @@ -337,7 +310,6 @@ function styleMenu(show) { function pageLoad() { addStyleMenu(); - adjustForFrames(); resetStyle(); restoreCollapsed(); } diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs index f7284062..8252839c 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml.hs @@ -36,14 +36,13 @@ import Haddock.GhcUtils import Control.Monad ( when, unless ) import Data.Char ( toUpper ) -import Data.List ( sortBy, groupBy, intercalate, isPrefixOf ) +import Data.List ( sortBy, intercalate, isPrefixOf ) import Data.Maybe import System.FilePath hiding ( () ) import System.Directory import Data.Map ( Map ) import qualified Data.Map as Map hiding ( Map ) import qualified Data.Set as Set hiding ( Set ) -import Data.Function import Data.Ord ( comparing ) import DynFlags (Language(..)) @@ -105,7 +104,8 @@ copyHtmlBits odir libdir themes = do copyCssFile f = copyFile f (combine odir (takeFileName f)) copyLibFile f = copyFile (joinPath [libhtmldir, f]) (joinPath [odir, f]) mapM_ copyCssFile (cssFiles themes) - mapM_ copyLibFile [ jsFile, framesFile ] + copyLibFile jsFile + return () headHtml :: String -> Maybe String -> Themes -> Maybe String -> Html @@ -268,9 +268,6 @@ ppHtmlContents dflags odir doctitle _maybe_package createDirectoryIfMissing True odir writeFile (joinPath [odir, contentsHtmlFile]) (renderToString debug html) - -- XXX: think of a better place for this? - ppHtmlContentsFrame odir doctitle themes mathjax_url ifaces debug - ppPrologue :: Qualification -> String -> Maybe (MDoc GHC.RdrName) -> Html ppPrologue _ _ Nothing = noHtml @@ -321,39 +318,6 @@ mkNode qual ss p (Node s leaf pkg srcPkg short ts) = subtree = mkNodeList qual (s:ss) p ts ! collapseSection p True "" --- | Turn a module tree into a flat list of full module names. E.g., --- @ --- A --- +-B --- +-C --- @ --- becomes --- @["A", "A.B", "A.B.C"]@ -flatModuleTree :: [InstalledInterface] -> [Html] -flatModuleTree ifaces = - map (uncurry ppModule' . head) - . groupBy ((==) `on` fst) - . sortBy (comparing fst) - $ mods - where - mods = [ (moduleString mdl, mdl) | mdl <- map instMod ifaces ] - ppModule' txt mdl = - anchor ! [href (moduleHtmlFile mdl), target mainFrameName] - << toHtml txt - - -ppHtmlContentsFrame :: FilePath -> String -> Themes -> Maybe String - -> [InstalledInterface] -> Bool -> IO () -ppHtmlContentsFrame odir doctitle themes maybe_mathjax_url ifaces debug = do - let mods = flatModuleTree ifaces - html = - headHtml doctitle Nothing themes maybe_mathjax_url +++ - miniBody << divModuleList << - (sectionName << "Modules" +++ - ulist << [ li ! [theclass "module"] << m | m <- mods ]) - createDirectoryIfMissing True odir - writeFile (joinPath [odir, frameIndexHtmlFile]) (renderToString debug html) - -------------------------------------------------------------------------------- -- * Generate the index diff --git a/haddock-api/src/Haddock/Utils.hs b/haddock-api/src/Haddock/Utils.hs index 58a7ef90..389aa5ab 100644 --- a/haddock-api/src/Haddock/Utils.hs +++ b/haddock-api/src/Haddock/Utils.hs @@ -21,10 +21,9 @@ module Haddock.Utils ( -- * Filename utilities moduleHtmlFile, moduleHtmlFile', contentsHtmlFile, indexHtmlFile, - frameIndexHtmlFile, moduleIndexFrameName, mainFrameName, synopsisFrameName, subIndexHtmlFile, - jsFile, framesFile, + jsFile, -- * Anchor and URL utilities moduleNameUrl, moduleNameUrl', moduleUrl, @@ -262,12 +261,6 @@ contentsHtmlFile = "index.html" indexHtmlFile = "doc-index.html" --- | The name of the module index file to be displayed inside a frame. --- Modules are display in full, but without indentation. Clicking opens in --- the main window. -frameIndexHtmlFile :: String -frameIndexHtmlFile = "index-frames.html" - moduleIndexFrameName, mainFrameName, synopsisFrameName :: String moduleIndexFrameName = "modules" @@ -333,9 +326,8 @@ makeAnchorId (f:r) = escape isAlpha f ++ concatMap (escape isLegal) r ------------------------------------------------------------------------------- -jsFile, framesFile :: String +jsFile :: String jsFile = "haddock-util.js" -framesFile = "frames.html" ------------------------------------------------------------------------------- diff --git a/html-test/ref/frames.html b/html-test/ref/frames.html deleted file mode 100644 index e86edb66..00000000 --- a/html-test/ref/frames.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/html-test/ref/haddock-util.js b/html-test/ref/haddock-util.js index fc7743fe..92d07d2a 100644 --- a/html-test/ref/haddock-util.js +++ b/html-test/ref/haddock-util.js @@ -248,33 +248,6 @@ function addMenuItem(html) { } } -function adjustForFrames() { - var bodyCls; - - if (parent.location.href == window.location.href) { - // not in frames, so add Frames button - addMenuItem("Frames"); - bodyCls = "no-frame"; - } - else { - bodyCls = "in-frame"; - } - addClass(document.body, bodyCls); -} - -function reframe() { - setCookie("haddock-reframe", document.URL); - window.location = "frames.html"; -} - -function postReframe() { - var s = getCookie("haddock-reframe"); - if (s) { - parent.window.main.location = s; - clearCookie("haddock-reframe"); - } -} - function styles() { var i, a, es = document.getElementsByTagName("link"), rs = []; for (i = 0; a = es[i]; i++) { @@ -337,7 +310,6 @@ function styleMenu(show) { function pageLoad() { addStyleMenu(); - adjustForFrames(); resetStyle(); restoreCollapsed(); } -- cgit v1.2.3 From 5a9c393c8f0f6d24fa185f4acbb39e40a0f534a6 Mon Sep 17 00:00:00 2001 From: Sebastian Meric de Bellefon Date: Thu, 16 Jun 2016 00:46:46 -0400 Subject: Copyright holders shown on several lines. Fix #279 --- haddock-api/src/Haddock/Backends/Xhtml.hs | 18 ++++++++++++++---- html-test/ref/Bug280.html | 8 ++++---- html-test/ref/Test.html | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'html-test/ref') diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs index 8252839c..0958c2cd 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml.hs @@ -35,8 +35,8 @@ import Text.XHtml hiding ( name, title, p, quote ) import Haddock.GhcUtils import Control.Monad ( when, unless ) -import Data.Char ( toUpper ) -import Data.List ( sortBy, intercalate, isPrefixOf ) +import Data.Char ( toUpper, isSpace ) +import Data.List ( sortBy, intercalate, isPrefixOf, intersperse ) import Data.Maybe import System.FilePath hiding ( () ) import System.Directory @@ -201,8 +201,7 @@ moduleInfo iface = field info >>= \a -> return (th << fieldName <-> td << a) entries :: [HtmlTable] - entries = mapMaybe doOneEntry [ - ("Copyright",hmi_copyright), + entries = maybeToList copyrightsTable ++ mapMaybe doOneEntry [ ("License",hmi_license), ("Maintainer",hmi_maintainer), ("Stability",hmi_stability), @@ -216,6 +215,14 @@ moduleInfo iface = Just Haskell98 -> Just "Haskell98" Just Haskell2010 -> Just "Haskell2010" + multilineRow :: String -> [String] -> HtmlTable + multilineRow title xs = (th ! [valign "top"]) << title <-> td << (toLines xs) + where toLines = mconcat . intersperse br . map toHtml + + copyrightsTable :: Maybe HtmlTable + copyrightsTable = fmap (multilineRow "Copyright" . split) (hmi_copyright info) + where split = map (trim . filter (/= ',')) . lines + extsForm | OptShowExtensions `elem` ifaceOptions iface = let fs = map (dropOpt . show) (hmi_extensions info) @@ -648,6 +655,9 @@ processDecl :: Bool -> Html -> Maybe Html processDecl True = Just processDecl False = Just . divTopDecl +trim :: String -> String +trim = f . f + where f = reverse . dropWhile isSpace processDeclOneLiner :: Bool -> Html -> Maybe Html processDeclOneLiner True = Just diff --git a/html-test/ref/Bug280.html b/html-test/ref/Bug280.html index f154f300..92eb61b0 100644 --- a/html-test/ref/Bug280.html +++ b/html-test/ref/Bug280.html @@ -34,12 +34,12 @@ window.onload = function () {pageLoad();setSynopsis("mini_Bug280.html");}; >
Foo
Bar
Baz
CopyrightFoo, - Bar, - Baz
Copyright(c) Simon Marlow 2002