8

The coding guidelines of programming language limit the line length, e.g. to 80 characters. How can I add a URL that is longer than that limit to Doxygen comments? How do I tell Doxygen that multiple lines are to be joined to form the actual link?

Example:

##
# @file  mycode.py
# @sa    See the documentation: http://some.host.some.domain/and_here
#        _we_have_a_very_long_URL_that_can_not_be_written_in_one_line
#        _because_it_would_exceed_the_line_length_limit

The example above doesn't work, and it doesn't work either to end the lines with a backslash (the backslash is just copied to the documentation).

holger
  • 415
  • 4
  • 14
  • Just a thought, no real answer: Use a URL shortening service :) – Nippey Jun 19 '13 at 07:41
  • To use a URL shortening service is an excellent idea. Would be interesting if Doxygen can do something, though. – holger Jun 19 '13 at 09:00
  • 1
    URL shortening services have the disadvantage of making where is ultimately being linked to unclear in the source documentation and to the casual reader. – Donal Fellows Sep 01 '20 at 13:14

3 Answers3

3

You can try it this way. It worked for me. However I'm not a 100% sure its going to work for you. Our IDE use whitespaces as indentation and not tabs. So when you break the line, hence the link, it might not work.

<a href="http://stackoverflow.com/questions/9098680/
doxygen-link-to-a-url-doesnt-generate-the-link-correctly">
link
</a>

aldr
  • 838
  • 2
  • 19
  • 33
  • 1
    That breaks the URL in the resulting HTML document, but it works with the browsers that I tested. I'm not sure about the other output formats like LaTeX and PDF. – holger Jul 03 '13 at 12:08
  • yes, you should definitly do some testing, I usually only look at the HTML output, maybe there are some pitfalls for LaTex and/or PDF – aldr Jul 03 '13 at 12:24
  • 1
    This is the only option that worked correctly (including generating a _correct_ link) when I tested it. It's horrible, but it works. I also wish that the third-party docs in question had shorter links, but can't fix that… – Donal Fellows Sep 01 '20 at 13:11
2

You could use an alias to abbreviate the long URL, i.e.

##
# @file  mycode.py
# @sa    See the documentation: @longurl

and in the Doxyfile define

ALIASES = longurl="http://some.host.some.domain/and_here/..."
doxygen
  • 14,341
  • 2
  • 43
  • 37
  • 1
    I'd prefer to have the URL in the code. I was hoping for a line continuation mechanism (backslash at end of line in most programming languages). With the alias the programmer has to find Doxyfile to look up the URL if the code is edited. The link works only in the code documentation. – holger Jun 24 '13 at 07:19
2

This is performing necromancy an old question. I am answering for C++ style comments. But, if you make you link in the form:

/** 
 * [link_text](http://foo.com/bar/baz/qux/wibble/flob?id=deadbeef123456789abcdefghijklmnopqrstuvwxyz)
 */

You can wrap that URL in the following ways and the generated HTML output will still contain a working anchor tag:

/**
 * [link_
text]
(http://foo.com/bar/baz/qux/wibble/
flob?id=deadbeef123456789abcdefghijklmnopqrstuvwxyz)
 */

Obviously this might make the comment block less readable. But this gives you an idea of what is possible. The main things that are advantagious here are being able to put the URL on a separate line from the link text, and then being able to wrap it at least once after a /.

Nick
  • 1,361
  • 1
  • 14
  • 42
  • 1
    @DonalFellows how exactly did you attempt to wrap the link, what version of doxygen are you using, and are you generating html output or something else? – Nick Sep 01 '20 at 18:15