From 64d2cfeaf2e71abd695fb03437bcbd788ecb5580 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Thu, 23 Apr 2026 08:01:07 +0200 Subject: [PATCH] fix: line number anchor in source links The source link in the Synopsis section of each symbol page contained `#Lundefined` anchors. That's because the corresponding Handlebars template used the wrong field name (`dcl.line` instead of `dcl.lineNumber`). Note that the separate concern of these links pointing at a moving branch rather than at a permalink for the documented commit is tracked in #1034. --- .../common/partials/location/source.hbs | 2 +- .../config/base-url/base-url.adoc | 29 +++++++++++ .../golden-tests/config/base-url/base-url.cpp | 6 +++ .../config/base-url/base-url.html | 49 +++++++++++++++++++ .../golden-tests/config/base-url/base-url.xml | 36 ++++++++++++++ .../golden-tests/config/base-url/base-url.yml | 1 + 6 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 test-files/golden-tests/config/base-url/base-url.adoc create mode 100644 test-files/golden-tests/config/base-url/base-url.cpp create mode 100644 test-files/golden-tests/config/base-url/base-url.html create mode 100644 test-files/golden-tests/config/base-url/base-url.xml create mode 100644 test-files/golden-tests/config/base-url/base-url.yml diff --git a/share/mrdocs/addons/generator/common/partials/location/source.hbs b/share/mrdocs/addons/generator/common/partials/location/source.hbs index 094c4fbadf..617eaac5b8 100644 --- a/share/mrdocs/addons/generator/common/partials/location/source.hbs +++ b/share/mrdocs/addons/generator/common/partials/location/source.hbs @@ -12,7 +12,7 @@ --}} Declared in {{#>markup/code~}} {{ str "<" }}{{#if (and @root.config.base-url dcl.shortPath dcl.sourcePath)~}} - {{#>markup/a href=(concat @root.config.base-url dcl.sourcePath '#L' dcl.line)}}{{dcl.shortPath}}{{/markup/a}} + {{#>markup/a href=(concat @root.config.base-url dcl.sourcePath '#L' dcl.lineNumber)}}{{dcl.shortPath}}{{/markup/a}} {{~else~}} {{dcl.shortPath}} {{~/if~}}{{ str ">" }} diff --git a/test-files/golden-tests/config/base-url/base-url.adoc b/test-files/golden-tests/config/base-url/base-url.adoc new file mode 100644 index 0000000000..cf5329c2ae --- /dev/null +++ b/test-files/golden-tests/config/base-url/base-url.adoc @@ -0,0 +1,29 @@ += Reference +:mrdocs: + +[#index] +== Global namespace + +=== Functions + +[cols=1] +|=== +| Name +| link:#f[`f`] +|=== + +[#f] +== f + +=== Synopsis + +Declared in `<https://example.com/src/base-url.cpp#L6[base‐url.cpp]>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +void +f(); +---- + + +[.small]#Created with https://www.mrdocs.com[MrDocs]# diff --git a/test-files/golden-tests/config/base-url/base-url.cpp b/test-files/golden-tests/config/base-url/base-url.cpp new file mode 100644 index 0000000000..a4308e4781 --- /dev/null +++ b/test-files/golden-tests/config/base-url/base-url.cpp @@ -0,0 +1,6 @@ +// When the `base-url` config option is set, the generated +// documentation's Synopsis section carries a link to the source +// file, with an anchor pointing at the line where the symbol is +// declared. + +void f(); diff --git a/test-files/golden-tests/config/base-url/base-url.html b/test-files/golden-tests/config/base-url/base-url.html new file mode 100644 index 0000000000..905f871f0d --- /dev/null +++ b/test-files/golden-tests/config/base-url/base-url.html @@ -0,0 +1,49 @@ + + +Reference + + + +
+

Reference

+
+
+

+Global Namespace

+
+

+Functions

+ + + + + + + + + + +
Name
f
+ +
+
+
+

+f

+
+
+

+Synopsis

+
+Declared in <base-url.cpp>
+
void
+f();
+
+
+ +
+ + + \ No newline at end of file diff --git a/test-files/golden-tests/config/base-url/base-url.xml b/test-files/golden-tests/config/base-url/base-url.xml new file mode 100644 index 0000000000..2840f0f84d --- /dev/null +++ b/test-files/golden-tests/config/base-url/base-url.xml @@ -0,0 +1,36 @@ + + + + + + namespace + //////////////////////////8= + regular + + s6nsa+zVhpzzrN+yUVPP5rvdXqs= + + + + f + + + base-url.cpp + base-url.cpp + 6 + 1 + + + function + s6nsa+zVhpzzrN+yUVPP5rvdXqs= + regular + //////////////////////////8= + + + identifier + void + + + normal + + diff --git a/test-files/golden-tests/config/base-url/base-url.yml b/test-files/golden-tests/config/base-url/base-url.yml new file mode 100644 index 0000000000..cf370b0bde --- /dev/null +++ b/test-files/golden-tests/config/base-url/base-url.yml @@ -0,0 +1 @@ +base-url: https://example.com/src/