diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 159214e27f..307761409c 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -540,10 +540,11 @@ proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var string; elif s != nil and s.kind in {skType, skVar, skLet, skConst} and sfExported in s.flags and s.owner != nil and belongsToProjectPackage(d.conf, s.owner) and d.target == outHtml: - let external = externalDep(d, s.owner) - result.addf "$3", - [changeFileExt(external, "html"), literal, - escLit] + let href = (if d.module == s.owner: "" + else: externalDep(d, s.owner).changeFileExt("html") + ) & "#" & literal + result.addf "$2", + [href, escLit] else: dispA(d.conf, result, "$1", "\\spanIdentifier{$1}", [escLit]) diff --git a/nimdoc/extlinks/project/expected/main.html b/nimdoc/extlinks/project/expected/main.html index 1e7c9c1269..2aaf19b3af 100644 --- a/nimdoc/extlinks/project/expected/main.html +++ b/nimdoc/extlinks/project/expected/main.html @@ -99,7 +99,7 @@
A = object
A = object
submoduleInt = distinct int
submoduleInt = distinct int
SomeType = enum +
SomeType = enum enumValueA, enumValueB, enumValueC
proc `$`[T](a: ref SomeType): string
proc `$`[T](a: ref SomeType): string
func `'big`(a: string): SomeType {....raises: [], tags: [], forbids: [].}
func `'big`(a: string): SomeType {....raises: [], tags: [], forbids: [].}
proc `[]`[T](x: G[T]): T
proc `[]`[T](x: G[T]): T
proc `[]=`[T](a: var G[T]; index: int; value: T)
proc `[]=`[T](a: var G[T]; index: int; value: T)
proc f(x: G[int]) {....raises: [], tags: [], forbids: [].}
proc f(x: G[int]) {....raises: [], tags: [], forbids: [].}
proc f(x: G[string]) {....raises: [], tags: [], forbids: [].}
proc f(x: G[string]) {....raises: [], tags: [], forbids: [].}
proc someType(): SomeType {....raises: [], tags: [], forbids: [].}
proc someType(): SomeType {....raises: [], tags: [], forbids: [].}
iterator fooBar(a: seq[SomeType]): int {....raises: [], tags: [], forbids: [].}
iterator fooBar(a: seq[SomeType]): int {....raises: [], tags: [], forbids: [].}
AnotherObject = object +
AnotherObject = object case x*: bool of true: y*: proc (x: string) @@ -402,7 +402,7 @@
FooBuzz {....deprecated: "FooBuzz msg".} = int
FooBuzz {....deprecated: "FooBuzz msg".} = int
MyObject = object +
MyObject = object someString*: string ## This is a string annotated* {.somePragma.}: string ## This is an annotated string
Shapes = enum +
Shapes = enum Circle, ## A circle Triangle, ## A three-sided shape Rectangle ## A four-sided shape
Xxx = object +
Xxx = object field*: int field3*: int ## Doc comment2