From 19898e1225862560b216b765187fc0b98dca7608 Mon Sep 17 00:00:00 2001
From: Andrey Makarov
Date: Mon, 20 Dec 2021 23:10:15 +0300
Subject: [PATCH] Fix group reference (with capital letters (#19196)
in group name)
---
compiler/docgen.nim | 3 +-
lib/packages/docutils/rst.nim | 2 +-
.../expected/subdir/subdir_b/utils.html | 28 +++++++++++++++++++
.../expected/subdir/subdir_b/utils.idx | 2 ++
nimdoc/testproject/expected/theindex.html | 6 ++++
nimdoc/testproject/subdir/subdir_b/utils.nim | 6 ++++
6 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 7ba9520834..90e0f54b3d 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -1301,7 +1301,8 @@ proc finishGenerateDoc*(d: var PDoc) =
let tooltip = "$1 ($2 overloads)" % [
k.toHumanStr & " " & plainName, $overloadChoices.len]
addAnchorNim(d.sharedState, refn, tooltip,
- LangSymbol(symKind: k.toHumanStr, name: plainName,
+ LangSymbol(symKind: k.toHumanStr,
+ name: nimIdentBackticksNormalize(plainName),
isGroup: true),
priority = symbolPriority(k),
# select index `0` just to have any meaningful warning:
diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim
index 4c28894fb7..a04eb696fb 100644
--- a/lib/packages/docutils/rst.nim
+++ b/lib/packages/docutils/rst.nim
@@ -993,7 +993,7 @@ proc findMainAnchorNim(s: PRstSharedState, signature: PRstNode,
result.add s
else: # when there are many overloads a link like foo_ points to all
# of them, so selecting the group
- var foundGroup = true
+ var foundGroup = false
for s in sList:
if s.langSym.isGroup:
result.add s
diff --git a/nimdoc/testproject/expected/subdir/subdir_b/utils.html b/nimdoc/testproject/expected/subdir/subdir_b/utils.html
index c640399417..574ac5b9ba 100644
--- a/nimdoc/testproject/expected/subdir/subdir_b/utils.html
+++ b/nimdoc/testproject/expected/subdir/subdir_b/utils.html
@@ -207,6 +207,13 @@ window.addEventListener('DOMContentLoaded', main);
fn10(a: int): int
+
+
Ref. type like G and type G and G[T] and type G*[T].
+Group ref. with capital letters works: fN11 or fn11
Ref. [] is the same as proc `[]`(G[T]) because there are no overloads. The full form: proc `[]`*[T](x: G[T]): TRef. []= aka `[]=`(G[T], int, T).Ref. $ aka proc $ or proc `$`.Ref. $(a: ref SomeType).Ref. foo_bar aka iterator foo_bar_.Ref. fn[T; U,V: SomeFloat]().Ref. 'big or func `'big` or `'big`(string).
@@ -539,6 +547,26 @@ comment
comment
+
+
+
+
+
+
+
+
func fN11() {....raises: [], tags: [].}
+
+
+
+
+
+
+
+
func fN11(x: int) {....raises: [], tags: [].}
+
+
+
+
diff --git a/nimdoc/testproject/expected/subdir/subdir_b/utils.idx b/nimdoc/testproject/expected/subdir/subdir_b/utils.idx
index 441bd86757..5c8fee5277 100644
--- a/nimdoc/testproject/expected/subdir/subdir_b/utils.idx
+++ b/nimdoc/testproject/expected/subdir/subdir_b/utils.idx
@@ -17,6 +17,8 @@ fn7 subdir/subdir_b/utils.html#fn7 utils: fn7()
fn8 subdir/subdir_b/utils.html#fn8 utils: fn8(): auto
fn9 subdir/subdir_b/utils.html#fn9,int utils: fn9(a: int): int
fn10 subdir/subdir_b/utils.html#fn10,int utils: fn10(a: int): int
+fN11 subdir/subdir_b/utils.html#fN11 utils: fN11()
+fN11 subdir/subdir_b/utils.html#fN11,int utils: fN11(x: int)
aEnum subdir/subdir_b/utils.html#aEnum.t utils: aEnum(): untyped
bEnum subdir/subdir_b/utils.html#bEnum.t utils: bEnum(): untyped
fromUtilsGen subdir/subdir_b/utils.html#fromUtilsGen.t utils: fromUtilsGen(): untyped
diff --git a/nimdoc/testproject/expected/theindex.html b/nimdoc/testproject/expected/theindex.html
index da76334d45..88d4b86aa7 100644
--- a/nimdoc/testproject/expected/theindex.html
+++ b/nimdoc/testproject/expected/theindex.html
@@ -209,6 +209,12 @@ window.addEventListener('DOMContentLoaded', main);
utils: fn10(a: int): int
+
fN11:
fn2:
- utils: fn2()
diff --git a/nimdoc/testproject/subdir/subdir_b/utils.nim b/nimdoc/testproject/subdir/subdir_b/utils.nim
index 5d881e6203..e201a3d388 100644
--- a/nimdoc/testproject/subdir/subdir_b/utils.nim
+++ b/nimdoc/testproject/subdir/subdir_b/utils.nim
@@ -36,6 +36,7 @@ Note that `proc` can be used in postfix form: `binarySearch proc`_.
Ref. type like G_ and `type G`_ and `G[T]`_ and `type G*[T]`_.
+Group ref. with capital letters works: fN11_ or fn11_
]##
include ./utils_helpers
@@ -77,6 +78,11 @@ proc fn8*(): auto =
func fn9*(a: int): int = 42 ## comment
func fn10*(a: int): int = a ## comment
+# Note capital letter N will be handled correctly in
+# group references like fN11_ or fn11_:
+func fN11*() = discard
+func fN11*(x: int) = discard
+
# bug #9235
template aEnum*(): untyped =