From 1b6bcd62e7f5534be45a0d5737b76d181c2d934b Mon Sep 17 00:00:00 2001 From: Phil Ruffwind Date: Wed, 30 Sep 2015 02:22:43 -0400 Subject: Move the permalinks to "#" on the right side Since pull request #407, the identifiers have been permalinked to themselves, but this makes it difficult to copy the identifier by double-clicking. To work around this usability problem, the permalinks are now placed on the far right adjacent to "Source", indicated by "#". Also, 'namedAnchor' now uses 'id' instead of 'name' (which is obsolete). --- haddock-api/resources/html/Ocean.std-theme/ocean.css | 13 ++++--------- haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 11 +++++++---- haddock-api/src/Haddock/Backends/Xhtml/Names.hs | 6 +++--- haddock-api/src/Haddock/Backends/Xhtml/Utils.hs | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/haddock-api/resources/html/Ocean.std-theme/ocean.css b/haddock-api/resources/html/Ocean.std-theme/ocean.css index 139335ac..fcf23810 100644 --- a/haddock-api/resources/html/Ocean.std-theme/ocean.css +++ b/haddock-api/resources/html/Ocean.std-theme/ocean.css @@ -381,21 +381,16 @@ div#style-menu-holder { #interface h5 + div.top { margin-top: 1em; } -#interface p.src .link { +#interface .src .selflink, +#interface .src .link { float: right; color: #919191; - border-left: 1px solid #919191; background: #f0f0f0; padding: 0 0.5em 0.2em; - margin: 0 -0.5em 0 0.5em; + margin: 0 -0.5em 0 0; } - -#interface td.src .link { - float: right; - color: #919191; +#interface .src .selflink { border-left: 1px solid #919191; - background: #f0f0f0; - padding: 0 0.5em 0.2em; margin: 0 -0.5em 0 0.5em; } diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs index 98df09fe..26aeaff8 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs @@ -43,12 +43,13 @@ import Haddock.Backends.Xhtml.DocMarkup import Haddock.Backends.Xhtml.Types import Haddock.Backends.Xhtml.Utils import Haddock.Types -import Haddock.Utils (makeAnchorId) +import Haddock.Utils (makeAnchorId, nameAnchorId) import qualified Data.Map as Map import Text.XHtml hiding ( name, title, p, quote ) import FastString ( unpackFS ) import GHC +import Name (nameOccName) -------------------------------------------------------------------------------- -- * Sections of the document @@ -256,9 +257,11 @@ topDeclElem lnks loc splice names html = -- | Adds a source and wiki link at the right hand side of the box. -- Name must be documented, otherwise we wouldn't get here. links :: LinksInfo -> SrcSpan -> Bool -> DocName -> Html -links ((_,_,sourceMap,lineMap), (_,_,maybe_wiki_url)) loc splice (Documented n mdl) = - (srcLink <+> wikiLink) - where srcLink = let nameUrl = Map.lookup origPkg sourceMap +links ((_,_,sourceMap,lineMap), (_,_,maybe_wiki_url)) loc splice docName@(Documented n mdl) = + srcLink <+> wikiLink <+> (selfLink ! [theclass "selflink"] << "#") + where selfLink = linkedAnchor (nameAnchorId (nameOccName (getName docName))) + + srcLink = let nameUrl = Map.lookup origPkg sourceMap lineUrl = Map.lookup origPkg lineMap mUrl | splice = lineUrl -- Use the lineUrl as a backup diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Names.hs b/haddock-api/src/Haddock/Backends/Xhtml/Names.hs index c69710d1..5492178b 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Names.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Names.hs @@ -120,11 +120,11 @@ ppBinderWith :: Notation -> Bool -> OccName -> Html -- the documentation or is the actual definition; in the latter case, we also -- set the 'id' and 'class' attributes. ppBinderWith notation isRef n = - linkedAnchor name ! attributes << ppBinder' notation n + makeAnchor << ppBinder' notation n where name = nameAnchorId n - attributes | isRef = [] - | otherwise = [identifier name, theclass "def"] + makeAnchor | isRef = linkedAnchor name + | otherwise = namedAnchor name ! [theclass "def"] ppBinder' :: Notation -> OccName -> Html ppBinder' notation n = wrapInfix notation n $ ppOccName n diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs b/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs index 98ff4007..1d49807d 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Utils.hs @@ -195,7 +195,7 @@ dot = toHtml "." -- | Generate a named anchor namedAnchor :: String -> Html -> Html -namedAnchor n = anchor ! [XHtml.name n] +namedAnchor n = anchor ! [XHtml.identifier n] linkedAnchor :: String -> Html -> Html -- cgit v1.2.3 From 8410dd341a1730f708af3f0d96d13f2b5f7b9df5 Mon Sep 17 00:00:00 2001 From: Phil Ruffwind Date: Wed, 30 Sep 2015 03:22:14 -0400 Subject: Update tests for previous commit --- html-test/ref/A.html | 24 +- html-test/ref/B.html | 14 +- html-test/ref/Bold.html | 6 +- html-test/ref/Bug1.html | 6 +- html-test/ref/Bug195.html | 22 +- html-test/ref/Bug2.html | 4 +- html-test/ref/Bug201.html | 12 +- html-test/ref/Bug253.html | 6 +- html-test/ref/Bug26.html | 28 +- html-test/ref/Bug294.html | 32 +- html-test/ref/Bug298.html | 30 +- html-test/ref/Bug3.html | 4 +- html-test/ref/Bug308.html | 18 +- html-test/ref/Bug308CrossModule.html | 6 +- html-test/ref/Bug310.html | 4 +- html-test/ref/Bug313.html | 12 +- html-test/ref/Bug335.html | 12 +- html-test/ref/Bug387.html | 12 +- html-test/ref/Bug4.html | 4 +- html-test/ref/Bug6.html | 36 +- html-test/ref/Bug7.html | 16 +- html-test/ref/Bug8.html | 34 +- html-test/ref/Bug85.html | 18 +- html-test/ref/BugDeprecated.html | 24 +- html-test/ref/BugExportHeadings.html | 24 +- html-test/ref/Bugs.html | 8 +- html-test/ref/DeprecatedClass.html | 20 +- html-test/ref/DeprecatedData.html | 16 +- html-test/ref/DeprecatedFunction.html | 8 +- html-test/ref/DeprecatedFunction2.html | 4 +- html-test/ref/DeprecatedFunction3.html | 4 +- html-test/ref/DeprecatedModule.html | 4 +- html-test/ref/DeprecatedModule2.html | 4 +- html-test/ref/DeprecatedNewtype.html | 12 +- html-test/ref/DeprecatedReExport.html | 4 +- html-test/ref/DeprecatedRecord.html | 10 +- html-test/ref/DeprecatedTypeFamily.html | 8 +- html-test/ref/DeprecatedTypeSynonym.html | 8 +- html-test/ref/Examples.html | 4 +- html-test/ref/Extensions.html | 6 +- html-test/ref/FunArgs.html | 20 +- html-test/ref/GADTRecords.html | 16 +- html-test/ref/Hash.html | 44 ++- html-test/ref/HiddenInstances.html | 32 +- html-test/ref/HiddenInstancesB.html | 14 +- html-test/ref/Hyperlinks.html | 4 +- html-test/ref/IgnoreExports.html | 8 +- html-test/ref/ImplicitParams.html | 22 +- html-test/ref/Instances.html | 434 +++++++++++++++++------ html-test/ref/Math.html | 4 +- html-test/ref/Minimal.html | 138 ++++--- html-test/ref/ModuleWithWarning.html | 4 +- html-test/ref/Nesting.html | 48 ++- html-test/ref/NoLayout.html | 4 +- html-test/ref/NonGreedy.html | 6 +- html-test/ref/Operators.html | 72 ++-- html-test/ref/OrphanInstances.html | 4 + html-test/ref/OrphanInstancesClass.html | 8 +- html-test/ref/OrphanInstancesType.html | 6 +- html-test/ref/PatternSyns.html | 40 ++- html-test/ref/PromotedTypes.html | 32 +- html-test/ref/Properties.html | 4 +- html-test/ref/QuasiExpr.html | 56 ++- html-test/ref/QuasiQuote.html | 4 +- html-test/ref/SpuriousSuperclassConstraints.html | 34 +- html-test/ref/TH.html | 6 +- html-test/ref/TH2.html | 6 +- html-test/ref/Test.html | 286 +++++++++------ html-test/ref/Threaded.html | 4 +- html-test/ref/Threaded_TH.html | 6 +- html-test/ref/Ticket112.html | 6 +- html-test/ref/Ticket61.html | 10 +- html-test/ref/Ticket75.html | 12 +- html-test/ref/TitledPicture.html | 8 +- html-test/ref/TypeFamilies.html | 182 ++++++++-- html-test/ref/TypeFamilies2.html | 32 +- html-test/ref/TypeOperators.html | 64 ++-- html-test/ref/Unicode.html | 4 +- html-test/ref/Visible.html | 4 +- html-test/ref/ocean.css | 15 +- 80 files changed, 1586 insertions(+), 645 deletions(-) diff --git a/html-test/ref/A.html b/html-test/ref/A.html index 73534dc7..b58845e5 100644 --- a/html-test/ref/A.html +++ b/html-test/ref/A.html @@ -89,8 +89,10 @@ window.onload = function () {pageLoad();setSynopsis("mini_A.html");}; >

data A #

A

test2 :: Bool #

data X #

X

reExport :: Int #

test :: Int #

reExport :: Int #

data X #

XDocumentation

foo :: a

:: a #

Some

data T #

T

data T #

data A #

data TP A = = ProblemCtorA#

problemField :: TO A -> A #

problemField' :: DO A -> A #

gadtField :: ({..} -> GADT A) -> A #

data family DP t :: * #

Documentation

(<^>) :: (a -> a) -> a -> a

:: (a -> a) -> a -> a #

(<^) :: a -> a -> a

:: a -> a -> a #

(^>) :: a -> a -> a

:: a -> a -> a #

(⋆^) :: a -> a -> a

:: a -> a -> a #

f :: ()

:: () #

Links to Documentation

foo :: Int #

Documentation

f :: ()

:: () #

startstart followed by middle followed by middle and end and end

g :: ()

:: () #

start Documentation

h :: ()

:: () #

start

type family a a + b :: Natinfixl 6 #

Documentation

a :: a

:: a #

Some text.

b :: a

:: a #

Some text.

Documentation

f :: ()

:: () #

ExF:

g :: ()

:: () #

ExG:

Section1Section1

Section2Section2

Documentation

foo :: Int #

data A #

A
B
C
  • someField :: ()
  • someOtherField :: ()
    Documentation

    x :: A #

    Documentation

    f :: ()

    :: () #

    This leading whitespace
    @@ -73,9 +75,11 @@ should be dropped
     	  >

    g :: ()

    :: () #

     But this one
    diff --git a/html-test/ref/Bug253.html b/html-test/ref/Bug253.html
    index 2d78880b..36640332 100644
    --- a/html-test/ref/Bug253.html
    +++ b/html-test/ref/Bug253.html
    @@ -73,9 +73,11 @@ window.onload = function () {pageLoad();setSynopsis("mini_Bug253.html"
     	>Documentation

    foo :: ()

    :: () #

    This link should generate Documentation

    f :: ()

    :: () #

    Foo

    g :: ()

    :: () #

    Bar

    class C a where #

    Methods

    c_f :: a

    :: a #

    C () #

c_f :: ()

:: () #

A Int

data B #

B