1
votes

Using doxygen 1.8.13, how can I get automatic links to be generated in markdown code? For example, I have the following two file:

test.h

/**
 * Function foo.
 * This is a code snippet in markdown format:
 *
 *          foo("Hello World!!!");
 *
 *  This is a regular code snippet:
 *  \code
 *  foo("Hello World!!!");
 *  \endcode
 **/
 void foo(const char *hello);

And the following companion file:

test.md

# Markdown Test

This is a code snippet in markdown format:

    foo("Hello World!!!");

This is a regular code snippet:
\code
foo("Hello World!!!");
\endcode

The output that I have when running doxygen on these files look like this:

test.h enter image description here

Notice how the second snippet has generated a link for the foo, but the first hasn't.

test.md

enter image description here

Notice how none of the snippets has generated a link for the foo function - also, the formatting is quite different.

So the question: is there a way to configure doxygen such that automatic links are generated in the code sections of markdown documents?

1

1 Answers

2
votes

Answering my own question.

  • From what I see, doxygen will not properly highlight indented code blocks. It will format them as code, but will not attempt to guess the language of the code; This can be resolved in by using a fenced code block - which will be assumed to be in the same language of the file it is found in. This works as expected:

foo.h

/**
 * Function foo.
 * This does not work properly:
 *
 *          foo("Hello World!!!");
 *
 *  But this does:
 *  ```
 *  foo("Hello World!!!");
 *  ```
 **/
 void foo(const char *hello);
  • When writing code samples in markdown files (.md), doxygen will not automatically guess the code language. The solution when hosting code examples in .md files was simply to specify the language. Thereafter, automatic links are properly generated:

foo.md

# Markdown Test

This does not work properly:

    foo("Hello World!!!");

But this does
```{cpp}
foo("Hello World!!!");
```