summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semtypes.nim3
-rw-r--r--nimdoc/testproject/expected/testproject.html15
-rw-r--r--nimdoc/testproject/expected/testproject.idx4
-rw-r--r--nimdoc/testproject/expected/theindex.html16
-rw-r--r--nimdoc/testproject/testproject.nim10
5 files changed, 46 insertions, 2 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 97cf7c5ec..21667895a 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -133,7 +133,8 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
     e.typ = result
     e.position = int(counter)
     let symNode = newSymNode(e)
-    if optNimV1Emulation notin c.config.globalOptions and identToReplace != nil:
+    if optNimV1Emulation notin c.config.globalOptions and identToReplace != nil and
+        c.config.cmd != cmdDoc: # A hack to produce documentation for enum fields.
       identToReplace[] = symNode
     if e.position == 0: hasNull = true
     if result.sym != nil and sfExported in result.sym.flags:
diff --git a/nimdoc/testproject/expected/testproject.html b/nimdoc/testproject/expected/testproject.html
index 103dea25f..d9132d087 100644
--- a/nimdoc/testproject/expected/testproject.html
+++ b/nimdoc/testproject/expected/testproject.html
@@ -109,6 +109,11 @@ function main() {
   <li><a class="reference" href="#Foo"
     title="Foo = enum
   enumValueA2">Foo</a></li>
+  <li><a class="reference" href="#Shapes"
+    title="Shapes = enum
+  Circle,                   ## A circle
+  Triangle,                 ## A three-sided shape
+  Rectangle                  ## A four-sided shape">Shapes</a></li>
 
   </ul>
 </li>
@@ -407,6 +412,16 @@ The enum B.
 
 
 </dd>
+<a id="Shapes"></a>
+<dt><pre><a href="testproject.html#Shapes"><span class="Identifier">Shapes</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
+  <span class="Identifier">Circle</span><span class="Other">,</span>                   <span class="Comment">## A circle</span>
+  <span class="Identifier">Triangle</span><span class="Other">,</span>                 <span class="Comment">## A three-sided shape</span>
+  <span class="Identifier">Rectangle</span>                  <span class="Comment">## A four-sided shape</span></pre></dt>
+<dd>
+
+Some shapes.
+
+</dd>
 
 </dl></div>
 <div class="section" id="8">
diff --git a/nimdoc/testproject/expected/testproject.idx b/nimdoc/testproject/expected/testproject.idx
index 0b75b29d2..8d132acc4 100644
--- a/nimdoc/testproject/expected/testproject.idx
+++ b/nimdoc/testproject/expected/testproject.idx
@@ -54,3 +54,7 @@ asyncFun1	testproject.html#asyncFun1	testproject: asyncFun1(): Future[int]
 asyncFun2	testproject.html#asyncFun2	testproject: asyncFun2(): owned(Future[void])	
 asyncFun3	testproject.html#asyncFun3	testproject: asyncFun3(): owned(Future[void])	
 testNimDocTrailingExample	testproject.html#testNimDocTrailingExample.t	testproject: testNimDocTrailingExample()	
+Circle	testproject.html#Circle	Shapes.Circle	
+Triangle	testproject.html#Triangle	Shapes.Triangle	
+Rectangle	testproject.html#Rectangle	Shapes.Rectangle	
+Shapes	testproject.html#Shapes	testproject: Shapes	
diff --git a/nimdoc/testproject/expected/theindex.html b/nimdoc/testproject/expected/theindex.html
index 66dea92fc..34d24e900 100644
--- a/nimdoc/testproject/expected/theindex.html
+++ b/nimdoc/testproject/expected/theindex.html
@@ -132,6 +132,10 @@ function main() {
 <li><a class="reference external"
           data-doc-search-tag="testproject: C_D" href="testproject.html#C_D">testproject: C_D</a></li>
           </ul></dd>
+<dt><a name="Circle" href="#Circle"><span>Circle:</span></a></dt><dd><ul class="simple">
+<li><a class="reference external"
+          data-doc-search-tag="Shapes.Circle" href="testproject.html#Circle">Shapes.Circle</a></li>
+          </ul></dd>
 <dt><a name="c_nonexistant" href="#c_nonexistant"><span>c_nonexistant:</span></a></dt><dd><ul class="simple">
 <li><a class="reference external"
           data-doc-search-tag="testproject: c_nonexistant(frmt: cstring): cint" href="testproject.html#c_nonexistant%2Ccstring">testproject: c_nonexistant(frmt: cstring): cint</a></li>
@@ -220,6 +224,14 @@ function main() {
 <li><a class="reference external"
           data-doc-search-tag="testproject: p1()" href="testproject.html#p1">testproject: p1()</a></li>
           </ul></dd>
+<dt><a name="Rectangle" href="#Rectangle"><span>Rectangle:</span></a></dt><dd><ul class="simple">
+<li><a class="reference external"
+          data-doc-search-tag="Shapes.Rectangle" href="testproject.html#Rectangle">Shapes.Rectangle</a></li>
+          </ul></dd>
+<dt><a name="Shapes" href="#Shapes"><span>Shapes:</span></a></dt><dd><ul class="simple">
+<li><a class="reference external"
+          data-doc-search-tag="testproject: Shapes" href="testproject.html#Shapes">testproject: Shapes</a></li>
+          </ul></dd>
 <dt><a name="someFunc" href="#someFunc"><span>someFunc:</span></a></dt><dd><ul class="simple">
 <li><a class="reference external"
           data-doc-search-tag="testproject: someFunc()" href="testproject.html#someFunc">testproject: someFunc()</a></li>
@@ -236,6 +248,10 @@ function main() {
 <li><a class="reference external"
           data-doc-search-tag="testproject: testNimDocTrailingExample()" href="testproject.html#testNimDocTrailingExample.t">testproject: testNimDocTrailingExample()</a></li>
           </ul></dd>
+<dt><a name="Triangle" href="#Triangle"><span>Triangle:</span></a></dt><dd><ul class="simple">
+<li><a class="reference external"
+          data-doc-search-tag="Shapes.Triangle" href="testproject.html#Triangle">Shapes.Triangle</a></li>
+          </ul></dd>
 <dt><a name="tripleStrLitTest" href="#tripleStrLitTest"><span>tripleStrLitTest:</span></a></dt><dd><ul class="simple">
 <li><a class="reference external"
           data-doc-search-tag="testproject: tripleStrLitTest()" href="testproject.html#tripleStrLitTest">testproject: tripleStrLitTest()</a></li>
diff --git a/nimdoc/testproject/testproject.nim b/nimdoc/testproject/testproject.nim
index 25cdf39a4..ffddc356f 100644
--- a/nimdoc/testproject/testproject.nim
+++ b/nimdoc/testproject/testproject.nim
@@ -363,4 +363,12 @@ when true:
     # where runnableExamples would not show if there was not at least 2 "\n" after
     # the last character of runnableExamples
     runnableExamples:
-      discard 2
\ No newline at end of file
+      discard 2
+
+when true: # issue #15702
+  type
+    Shapes* = enum
+      ## Some shapes.
+      Circle,     ## A circle
+      Triangle,   ## A three-sided shape
+      Rectangle   ## A four-sided shape