-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
runnableExamples that are only compiled #10731
Comments
❔ |
runnableExamples:
proc main() =
echo "I'm not running" ^ that's also a way. |
Any "if false", "when false", "def main" line is confusing to people reading the examples (as they are unaware of the hack). Also |
Non-running runnable examples are confusing, you might as well use |
@Araq the code-block renders differently and (as you said before) leads to code rot. I guess runnableExamples:
proc example() =
echo "I'm not running" |
fixing this more generally in #14384, which allows passing an arbitrary cmd |
This sounds like a good use-case for the Effect system - if there was a way to ensure that examples are not doing I/O and other unwanted activities. |
nim-lang#14384) * runnableExamples "-b:cpp -r:off": code
runnableExamples are run by
nim doc
. Some code examples should not be run due to side effects or other reasons, but parsing and compiling the code is still beneficial to prevent code rot.For example: httpclient fetching a remote URL; deleting files; and so on.
This can become quite dangerous when running
nim doc
on 3rd party libraries where the authors might have written examples without realizing they would be execute automatically!The text was updated successfully, but these errors were encountered: