You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit fixes an advanced usage of doxygen, more especially latex
doxylink usage.
Standard doxylink is a simple hyperlink:
```latex
\newcommand{\doxylink}[2]{
\mbox{\hyperlink{#1}{#2}}
}
```
This simple reference is OK for digital pdf. But, in case of printed
document, it lacks location information.
We extended doxylink like this, to add section number and title:
```latex
\renewcommand{\doxylink}[2]{
\hyperlink{#1}{#2}, in \ref{#1} \nameref{#1}
}
```
The latex compiles well. But the generated latex is wrong. In the pdf,
we observe that the hyperlink is good, but the `ref` and `nameref` point
to the previous section.
Digging into generated .tex files, we found the following construct:
```latex
\Hypertarget{header_8h_ad8a2dfa8cbec508ec4cf97b2c5452797}\label{header_8h_ad8a2dfa8cbec508ec4cf97b2c5452797}
\index{header.h@{header.h}!bar@{bar}}
\index{bar@{bar}!header.h@{header.h}}
\doxysubsubsection{\texorpdfstring{bar()}{bar()}}
```
We can see that the `\label` is placed before `\doxysubsubsection`.
doxylink points to `label`. And in this case, `\label` is part of the
previous `doxy*section`.
This commit fixes this behavior, by splitting the function `startDoxyAnchor` into
`startDoxyAnchor` and `addLabel`. Then, the `Hypertarget` is placed before the `doxy*section`,
and the `label` is placed after.
We want the `Hypertarget` to be placed before the `doxy*section`. It allows, when the user click,
to land just before the section title, and then see the section title.
The resulted generated .tex is the following:
```latex
\Hypertarget{header_8h_a49a4b11e50430aa0a78de989ea99e082}\index{header.h@{header.h}!bar@{bar}}
\index{bar@{bar}!header.h@{header.h}}
\doxysubsubsection{\texorpdfstring{bar()}{bar()}}
{\footnotesize\ttfamily \label{header_8h_a49a4b11e50430aa0a78de989ea99e082}
```
This behavior can be tested with a simple header file like this:
```c
/** @file header.h */
/** foo function */
void
foo();
/** bar function, see @ref foo */
void
bar();
```
0 commit comments