Skip to content
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

fix #14846; add macros.extractDocCommentsAndRunnables #14849

Merged
merged 4 commits into from
Jul 1, 2020

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Jun 29, 2020

proc main*() =
  template gun()=discard
  ## in main
  discard

before #14439, the doc comment would be docgen'd even though the doc comment is at wrong place (after some initial non-doc comment/non-runnableExamples statement)
after #14439, in main correctly doesn't get docgen'd

this PR fixes async template by introducing extractDocCommentsAndRunnables which extracts all top-level runnableExamples and doc comments

after this PR

after this I have another PR that removes the awaitDefinition block which redefines await templates in each each async proc, and instead bindSym's a await template defined once, which simplifies the generated code

@timotheecour timotheecour requested a review from Araq June 29, 2020 23:32
@juancarlospaco
Copy link
Collaborator

Why not 2 extractComments() and extractRunnables(), shorter name and differentiates both instead of mixing them.

@timotheecour
Copy link
Member Author

timotheecour commented Jun 30, 2020

because of interleaving; having to procs would not preserve interleaving eg:

proc fn*=
  ## c1
  runnableExamples:
    discard
  runnableExamples:
    discard
  ## c2
  runnableExamples:
    discard
  ## c3
  echo "start of actual code"

(interleaving is supported since #14441; before that it was buggy as it dropped the doc comments after the 1st one)

@Clyybber
Copy link
Contributor

IMO docgen should simply support this pattern instead (the doc comment appearing after template definitions/other code).

@timotheecour
Copy link
Member Author

timotheecour commented Jun 30, 2020

we can debate that in nim-lang/RFCs#231 but until then this PR fixes docgen for async procs; one potential problem is doc comments appearing inside proc body but not intended to be docgen'd; another one is doc comments in templates called from a proc.

lib/core/macros.nim Outdated Show resolved Hide resolved
@timotheecour
Copy link
Member Author

the failure is potentially caused by this PR, not sure yet

2020-06-30T18:09:23.7296506Z FAIL: tests/async/testmanyasyncevents.nim C
2020-06-30T18:09:23.7297206Z Test "tests\async\testmanyasyncevents.nim" in category "async"
2020-06-30T18:09:23.7298204Z Failure: reOutputsDiffer
2020-06-30T18:09:23.7298736Z Expected:
2020-06-30T18:09:23.7299265Z hasPendingOperations: false
2020-06-30T18:09:23.7299819Z triggerCount: 100
2020-06-30T18:09:23.7300206Z 
2020-06-30T18:09:23.7300642Z Gotten:
2020-06-30T18:09:23.7301187Z hasPendingOperations: true
2020-06-30T18:09:23.7301763Z triggerCount: 68
2020-06-30T18:09:23.7302159Z 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation missing on devel asyncftpclient
4 participants