From cabe219d10492e376fcfbfa514ae8a722d5e21e2 Mon Sep 17 00:00:00 2001 From: Alec Theriault Date: Thu, 14 Dec 2017 01:32:53 -0800 Subject: Clickable anchors for headings (#716) See #579. This just adds an tag around the heading, pointing to the heading itself. --- haddock-api/src/Haddock/Backends/Xhtml.hs | 3 +- html-test/ref/Bug387.html | 16 ++++--- html-test/ref/BugExportHeadings.html | 36 ++++++++++------ html-test/ref/DeprecatedReExport.html | 12 ++++-- html-test/ref/Hash.html | 30 +++++++------ html-test/ref/Test.html | 72 ++++++++++++++++++++----------- 6 files changed, 110 insertions(+), 59 deletions(-) diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs index 55175163..01c08f7a 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml.hs @@ -697,7 +697,8 @@ processDeclOneLiner True = Just processDeclOneLiner False = Just . divTopDecl . declElem groupHeading :: Int -> String -> Html -> Html -groupHeading lev id0 = groupTag lev ! [identifier (groupId id0)] +groupHeading lev id0 = linkedAnchor grpId . groupTag lev ! [identifier grpId] + where grpId = groupId id0 groupTag :: Int -> Html -> Html groupTag lev diff --git a/html-test/ref/Bug387.html b/html-test/ref/Bug387.html index 23faa420..e6228cad 100644 --- a/html-test/ref/Bug387.html +++ b/html-test/ref/Bug387.html @@ -73,10 +73,12 @@ >

Section1

Section1

Section2

Section2

Two

Two

Three

Three

Re-exported from an other module

Re-exported from an other module

Re-exported from an other package

Re-exported from an other package

Not yet working, see

The HashTable type

The HashTable type

.

Operations on HashTables

Operations on HashTables

otherwise.

The Hash class

The Hash class

Type declarations

Data types

Type declarations

Data types

Records

Records

test that we can export record selectors on their own:

Class declarations

Class declarations

method

Function types

Function types

we can export foreign declarations too

Auxiliary stuff

Auxiliary stuff

This is some documentation that is attached to a name ($aux1) @@ -1916,8 +1928,10 @@ test2 each line must begin with > (which isn't significant unless it is at the beginning of the line).

A hidden module

A hidden module

#

A visible module

A visible module

module

nested-style doc comments

Existential / Universal types

Existential / Universal types

Type signatures with argument docs

Type signatures with argument docs

A foreign import with argument docs

A section

A subsection

A section

A subsection

a literal line