17

When linking to a URL, one can provide a label that specifies what the reader will see; for example, <http://www.haskell.org haskell> will have "haskell" for the link text. Unfortunately the documentation does not provide an obvious way to label links to anchors; the link "Data.FooBar#foo" will have "Data.FooBar" for the link text so that it is not obvious to the reader that this link is going to an anchor.

So my question is: is there a trick to label links to anchors in haddock, or is this impossible?

Gregory Crosswhite
  • 1,457
  • 8
  • 17
  • 4
    There's no official way to do this. You could try to cheat and try to guess what the anchor link will be and put that between the URL tags. This is however not a very good solution and might easily break/not do what you want. I recommend that you make your way to the [Haddock Trac](http://trac.haskell.org/haddock) and make a new ticket for this! – Mateusz Kowalczyk Sep 16 '13 at 02:12
  • I just followed your excellent recommendation --- thanks! :-) – Gregory Crosswhite Sep 17 '13 at 07:44

4 Answers4

2

This is now https://github.com/haskell/haddock/issues/262 (submitted by OP).

As I write this, it is open and has not been commented on.

nh2
  • 24,526
  • 11
  • 79
  • 128
SamB
  • 9,039
  • 5
  • 49
  • 56
2

This has since been added, and the syntax is [label]("Module.Name#anchor").

Morrow
  • 56
  • 2
1

At the moment, when you link to an anchor in haddock using something like "MyModule#anchor", the link on the generated page just says "MyModule". This is very confusing because it looks like the link is taking one to the module page, when really it goes to a specific anchor on that page. It would be great if either the anchor name could be added to the label for the link to make it clear where the links is going, or if there were a way one could manually specify the label of the link --- say, by borrowing the syntax used by URLs to specify the label using a space, such as "MyModule#anchor label goes here".

siva
  • 11
  • 2
  • Hello and welcome to stackoverflow.com. In the answer section you should only post answers. Your post is better suited as a comment. I know you can't comment yet but if you have a question and you can't find an answer for it try posting your own question and be as specific as you can. Thank you :) – Bandreid Feb 21 '14 at 12:43
0

Its appears they offer no direct way even though their documentation seems to advise on a solution.

REF : http://www.haskell.org/haddock/doc/html/ch03s08.html

SamB
  • 9,039
  • 5
  • 49
  • 56
Pogrindis
  • 7,755
  • 5
  • 31
  • 44