Saurabh Nanda
Saurabh Nanda

Reputation: 6793

How to link to a named chunk of documentation in Haddock?

I might be missing something really obvious (or might have developed temporary blindness staring at the Haddock user guide), but I can't seem to find any way to link to a named chunk of documentation in Haddocks

Edit: I'm trying to create an internal hyperlink from one part of the doc to another named chunk of documentation. I've tried the following:

-- You may want to take a look at 'findByPkHelpers' section for
-- variations of this function.
--
-- I even tried putting '$findByPkHelpers' but didn't work
--
-- ... snip ...

-- ** Some heading
-- 
-- $findByPkHelpers

Upvotes: 9

Views: 305

Answers (1)

Tom Ellis
Tom Ellis

Reputation: 9434

You can use the syntax #myanchor to create an anchor, and then you can link to it with [my link text](#myanchor). For example, in my export list I have

    -- | #launchaprocess#

    -- * Launch a process
    , runProcess
    , readProcess

and then in the body of the file I have a link to this anchor

-- | Once you have a @ProcessConfig@ you can launch a process from it
-- using the functions in the section [Launch a process](#launchaprocess).

(N.B. in the case of anchors next to section headers in export lists there must be a blank link between them otherwise the * introducing the header will be interpreted as a Haddock-comment bulleted list!)

[Thanks to @sjakobi for pointing out this functionality]

Upvotes: 2

Related Questions