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

Run an example in a separated byexample execution #108

Open
eldipa opened this issue Jan 25, 2020 · 1 comment
Open

Run an example in a separated byexample execution #108

eldipa opened this issue Jan 25, 2020 · 1 comment
Labels
enhancement something nice to have but it is not neither critical nor urgent request for comments a draft idea that needs more brainstorming, comments are welcome!

Comments

@eldipa
Copy link
Collaborator

eldipa commented Jan 25, 2020

Describe the feature you'd like
Sounds weird but there are cases where we want to show how
a bad written example breaks byexample and writing the
example in the documentation itself breaks it of course.

Currently the trick is to write the offensive example
in a separated file and run it with byexample from
a shell example.

Typically we also do a cat to show the content of the
file.

Also, because the file probably has other examples
that we don't want to run, when we do the cat we prepend
the ~ marker that we remove later with +rm=~.

All of this is quite disruptive.

It would be cool to write the offensive example directly in
the documentation like any other example but marking it
in somehow (with an option perhaps? -x-fork?)

byexample should then spawn a fork of itself and run that example
only and all the output will be seen as the output of the example
hiding the fact that we ran another byexample instance; no need
to do a cat.

@eldipa eldipa added enhancement something nice to have but it is not neither critical nor urgent request for comments a draft idea that needs more brainstorming, comments are welcome! labels Jan 25, 2020
@eldipa
Copy link
Collaborator Author

eldipa commented Jan 31, 2020

The "fork" point could be before starting the parsing. A specialized Concern could perform a pre-parsing to try to see if the example has the, let's say, the +self option.

If not, do nothing more.

Otherwise, rewrite the example before parsing it:

  • change its language to shell (hey, this must be activated before!)
  • change the source to a call to byexample with, in some how, the original example's source code as a parameter and an extra flag to avoid a recursive call.
  • all the options should be preserved including the ones passed to the original byexample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement something nice to have but it is not neither critical nor urgent request for comments a draft idea that needs more brainstorming, comments are welcome!
Projects
None yet
Development

No branches or pull requests

1 participant