Skip to content

Commit 19898e1

Browse files
authored
Fix group reference (with capital letters (#19196)
in group name)
1 parent 4da7dbf commit 19898e1

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

compiler/docgen.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,8 @@ proc finishGenerateDoc*(d: var PDoc) =
13011301
let tooltip = "$1 ($2 overloads)" % [
13021302
k.toHumanStr & " " & plainName, $overloadChoices.len]
13031303
addAnchorNim(d.sharedState, refn, tooltip,
1304-
LangSymbol(symKind: k.toHumanStr, name: plainName,
1304+
LangSymbol(symKind: k.toHumanStr,
1305+
name: nimIdentBackticksNormalize(plainName),
13051306
isGroup: true),
13061307
priority = symbolPriority(k),
13071308
# select index `0` just to have any meaningful warning:

lib/packages/docutils/rst.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ proc findMainAnchorNim(s: PRstSharedState, signature: PRstNode,
993993
result.add s
994994
else: # when there are many overloads a link like foo_ points to all
995995
# of them, so selecting the group
996-
var foundGroup = true
996+
var foundGroup = false
997997
for s in sList:
998998
if s.langSym.isGroup:
999999
result.add s

nimdoc/testproject/expected/subdir/subdir_b/utils.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ <h1 class="title">subdir/subdir_b/utils</h1>
207207
<li><a class="reference" href="#fn10%2Cint"
208208
title="fn10(a: int): int">fn10(a: int): int</a></li>
209209

210+
</ul>
211+
<ul class="simple nested-toc-section">fN11
212+
<li><a class="reference" href="#fN11"
213+
title="fN11()">fN11()</a></li>
214+
<li><a class="reference" href="#fN11%2Cint"
215+
title="fN11(x: int)">fN11(x: int)</a></li>
216+
210217
</ul>
211218
<ul class="simple nested-toc-section">funWithGenerics
212219
<li><a class="reference" href="#funWithGenerics%2CT%2CU"
@@ -290,6 +297,7 @@ <h6><a class="toc-backref" id="more-headers-up-to-level-6" href="#more-headers-u
290297
<p>Note that <tt class="docutils literal"><span class="pre"><span class="Keyword">proc</span></span></tt> can be used in postfix form: <a class="reference internal nimdoc" title="proc binarySearch[T, K](a: openArray[T]; key: K;
291298
cmp: proc (x: T; y: K): int {.closure.}): int" href="#binarySearch,openArray[T],K,proc(T,K)">binarySearch proc</a>.</p>
292299
<p>Ref. type like <a class="reference internal nimdoc" title="type G" href="#G">G</a> and <a class="reference internal nimdoc" title="type G" href="#G">type G</a> and <a class="reference internal nimdoc" title="type G" href="#G">G[T]</a> and <a class="reference internal nimdoc" title="type G" href="#G">type G*[T]</a>.</p>
300+
<p>Group ref. with capital letters works: <a class="reference internal nimdoc" title="proc fN11 (2 overloads)" href="#fN11-procs-all">fN11</a> or <a class="reference internal nimdoc" title="proc fN11 (2 overloads)" href="#fN11-procs-all">fn11</a> </p>
293301
Ref. <a class="reference internal nimdoc" title="proc `[]`[T](x: G[T]): T" href="#[],G[T]">[]</a> is the same as <a class="reference internal nimdoc" title="proc `[]`[T](x: G[T]): T" href="#[],G[T]">proc `[]`(G[T])</a> because there are no overloads. The full form: <a class="reference internal nimdoc" title="proc `[]`[T](x: G[T]): T" href="#[],G[T]">proc `[]`*[T](x: G[T]): T</a>Ref. <a class="reference internal nimdoc" title="proc `[]=`[T](a: var G[T]; index: int; value: T)" href="#[]=,G[T],int,T">[]=</a> aka <a class="reference internal nimdoc" title="proc `[]=`[T](a: var G[T]; index: int; value: T)" href="#[]=,G[T],int,T">`[]=`(G[T], int, T)</a>.Ref. <a class="reference internal nimdoc" title="proc $ (2 overloads)" href="#$-procs-all">$</a> aka <a class="reference internal nimdoc" title="proc $ (2 overloads)" href="#$-procs-all">proc $</a> or <a class="reference internal nimdoc" title="proc $ (2 overloads)" href="#$-procs-all">proc `$`</a>.Ref. <a class="reference internal nimdoc" title="proc `$`[T](a: ref SomeType): string" href="#$,ref.SomeType">$(a: ref SomeType)</a>.Ref. <a class="reference internal nimdoc" title="iterator fooBar(a: seq[SomeType]): int" href="#fooBar.i,seq[SomeType]">foo_bar</a> aka <a class="reference internal nimdoc" title="iterator fooBar(a: seq[SomeType]): int" href="#fooBar.i,seq[SomeType]">iterator foo_bar_</a>.Ref. <a class="reference internal nimdoc" title="proc fn[T; U, V: SomeFloat]()" href="#fn">fn[T; U,V: SomeFloat]()</a>.Ref. <a class="reference internal nimdoc" title="proc `'big`(a: string): SomeType" href="#'big,string">'big</a> or <a class="reference internal nimdoc" title="proc `'big`(a: string): SomeType" href="#'big,string">func `'big`</a> or <a class="reference internal nimdoc" title="proc `'big`(a: string): SomeType" href="#'big,string">`'big`(string)</a>.</p>
294302
<div class="section" id="7">
295303
<h1><a class="toc-backref" href="#7">Types</a></h1>
@@ -539,6 +547,26 @@ <h1><a class="toc-backref" href="#12">Procs</a></h1>
539547

540548
comment
541549

550+
</dd>
551+
</div>
552+
553+
</div>
554+
555+
<div id="fN11-procs-all">
556+
<div id="fN11">
557+
<dt><pre><span class="Keyword">func</span> <a href="#fN11"><span class="Identifier">fN11</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
558+
<dd>
559+
560+
561+
562+
</dd>
563+
</div>
564+
<div id="fN11,int">
565+
<dt><pre><span class="Keyword">func</span> <a href="#fN11%2Cint"><span class="Identifier">fN11</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
566+
<dd>
567+
568+
569+
542570
</dd>
543571
</div>
544572

nimdoc/testproject/expected/subdir/subdir_b/utils.idx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ fn7 subdir/subdir_b/utils.html#fn7 utils: fn7()
1717
fn8 subdir/subdir_b/utils.html#fn8 utils: fn8(): auto
1818
fn9 subdir/subdir_b/utils.html#fn9,int utils: fn9(a: int): int
1919
fn10 subdir/subdir_b/utils.html#fn10,int utils: fn10(a: int): int
20+
fN11 subdir/subdir_b/utils.html#fN11 utils: fN11()
21+
fN11 subdir/subdir_b/utils.html#fN11,int utils: fN11(x: int)
2022
aEnum subdir/subdir_b/utils.html#aEnum.t utils: aEnum(): untyped
2123
bEnum subdir/subdir_b/utils.html#bEnum.t utils: bEnum(): untyped
2224
fromUtilsGen subdir/subdir_b/utils.html#fromUtilsGen.t utils: fromUtilsGen(): untyped

nimdoc/testproject/expected/theindex.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ <h1 class="title">Index</h1>
209209
<li><a class="reference external"
210210
data-doc-search-tag="utils: fn10(a: int): int" href="subdir/subdir_b/utils.html#fn10%2Cint">utils: fn10(a: int): int</a></li>
211211
</ul></dd>
212+
<dt><a name="fN11" href="#fN11"><span>fN11:</span></a></dt><dd><ul class="simple">
213+
<li><a class="reference external"
214+
data-doc-search-tag="utils: fN11()" href="subdir/subdir_b/utils.html#fN11">utils: fN11()</a></li>
215+
<li><a class="reference external"
216+
data-doc-search-tag="utils: fN11(x: int)" href="subdir/subdir_b/utils.html#fN11%2Cint">utils: fN11(x: int)</a></li>
217+
</ul></dd>
212218
<dt><a name="fn2" href="#fn2"><span>fn2:</span></a></dt><dd><ul class="simple">
213219
<li><a class="reference external"
214220
data-doc-search-tag="utils: fn2()" href="subdir/subdir_b/utils.html#fn2">utils: fn2()</a></li>

nimdoc/testproject/subdir/subdir_b/utils.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Note that `proc` can be used in postfix form: `binarySearch proc`_.
3636
3737
Ref. type like G_ and `type G`_ and `G[T]`_ and `type G*[T]`_.
3838
39+
Group ref. with capital letters works: fN11_ or fn11_
3940
]##
4041

4142
include ./utils_helpers
@@ -77,6 +78,11 @@ proc fn8*(): auto =
7778
func fn9*(a: int): int = 42 ## comment
7879
func fn10*(a: int): int = a ## comment
7980

81+
# Note capital letter N will be handled correctly in
82+
# group references like fN11_ or fn11_:
83+
func fN11*() = discard
84+
func fN11*(x: int) = discard
85+
8086
# bug #9235
8187

8288
template aEnum*(): untyped =

0 commit comments

Comments
 (0)