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

UnusedImport warning is displayed for every runnable example #11819

Closed
Jjp137 opened this issue Jul 24, 2019 · 1 comment
Closed

UnusedImport warning is displayed for every runnable example #11819

Jjp137 opened this issue Jul 24, 2019 · 1 comment
Labels
Documentation Generation Related to documentation generation (but not content). Error Messages

Comments

@Jjp137
Copy link
Contributor

Jjp137 commented Jul 24, 2019

For every usage of runnableExamples within a module, an UnusedImport warning appears
when documentation is generated for that module, and the warnings occur in a file that nim doc itself generates.

For large modules with many documented procs and runnable examples, this can result in dozens of false warnings from the user's perspective.

Example

## An example module.

proc addOne*(x: int): int =
  ## Adds one to an integer and returns the result.
  runnableExamples:
    doAssert addOne(1) == 2
  result = x + 1

Generate the documentation with nim doc.

Current Output

Within the usual compiler output:

/home/jjp/.cache/nim/example_d/runnableExamples/example_examples.nim(1, 8) Warning: imported and not used: 'example_examples1' [UnusedImport]

Expected Output

The UnusedImport warning should not appear.

Possible Solution

Would disabling that warning via a pragma at the top of the generated file (in this case, example_examples.nim) work? Or are there better solutions?

Additional Information

Version info:

$ nim -v
Nim Compiler Version 0.20.99 [Linux: amd64]
Compiled at 2019-07-24
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 8c93c692b95da7b19a88cc0d56a8cdd20e3ae576
active boot switches: -d:release
@mratsim mratsim added Documentation Generation Related to documentation generation (but not content). Error Messages labels Jul 24, 2019
@Araq
Copy link
Member

Araq commented Aug 5, 2019

Would disabling that warning via a pragma at the top of the generated file (in this case, example_examples.nim) work?

Yeah and it's the right way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Generation Related to documentation generation (but not content). Error Messages
Projects
None yet
3 participants