From 26816d59bac49c769e9f11570f357e855c526811 Mon Sep 17 00:00:00 2001 From: narimiran Date: Fri, 30 Oct 2020 12:35:11 +0100 Subject: [PATCH] fix #15702, show enum fields documentation --- compiler/semtypes.nim | 3 ++- nimdoc/testproject/expected/testproject.html | 15 +++++++++++++++ nimdoc/testproject/expected/testproject.idx | 4 ++++ nimdoc/testproject/expected/theindex.html | 16 ++++++++++++++++ nimdoc/testproject/testproject.nim | 10 +++++++++- 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 97cf7c5ece2e9..21667895a253f 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 103dea25fdc44..d9132d087baec 100644 --- a/nimdoc/testproject/expected/testproject.html +++ b/nimdoc/testproject/expected/testproject.html @@ -109,6 +109,11 @@

testproject

  • Foo
  • +
  • Shapes
  • @@ -406,6 +411,16 @@

    Types

    + + +
    Shapes = enum
    +  Circle,                   ## A circle
    +  Triangle,                 ## A three-sided shape
    +  Rectangle                  ## A four-sided shape
    +
    + +Some shapes. +
    diff --git a/nimdoc/testproject/expected/testproject.idx b/nimdoc/testproject/expected/testproject.idx index 0b75b29d2e0e4..8d132acc4f06c 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 66dea92fcc58c..34d24e90051ab 100644 --- a/nimdoc/testproject/expected/theindex.html +++ b/nimdoc/testproject/expected/theindex.html @@ -132,6 +132,10 @@

    Index

  • testproject: C_D
  • +
    Circle:
    c_nonexistant:
    +
    Rectangle:
    +
    Shapes:
    someFunc:
    +
    Triangle:
    tripleStrLitTest: