New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type which followed by a function and generated by a template will not shown in docs generated by `nim doc` #9235

Closed
7sDream opened this Issue Oct 7, 2018 · 2 comments

Comments

Projects
None yet
5 participants
@7sDream
Copy link
Contributor

7sDream commented Oct 7, 2018

MWE

def.nim

import macros

template aEnum*(): untyped = 
  type
    A* {.inject.} = enum
      aA

template bEnum*(): untyped = 
  type
    B* {.inject.} = enum
      bB
  
  func someFunc*() = discard

doc.nim

import ./def

aEnum()
bEnum()

Then run nim doc doc.nim as usual, you can notice there is no enum B in generated html.

Screenshot:

image

@LemonBoy

This comment has been minimized.

Copy link
Collaborator

LemonBoy commented Oct 7, 2018

The problem is that the second template is translated into a nkStmtList containing the type-section and the proc declaration and the compiler marks only the last statement as belonging to the place where the template is expanded (check wrapInComesFrom for more info). This means that generateDoc will happily skip all but the last expressions.

@7sDream

This comment has been minimized.

Copy link
Contributor

7sDream commented Oct 7, 2018

@LemonBoy

The strange thing is, if I merge the two files into one, it works as expected:

image

@Araq Araq added the Showstopper label Oct 30, 2018

@Araq Araq closed this in c9e8b89 Oct 30, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

narimiran added a commit that referenced this issue Nov 1, 2018

docgen: fixes #9235 [backport]
(cherry picked from commit c9e8b89)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment