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

Add support for Rust/Evxcr #351

Merged
merged 5 commits into from
Oct 18, 2019
Merged

Add support for Rust/Evxcr #351

merged 5 commits into from
Oct 18, 2019

Conversation

jonasbb
Copy link
Contributor

@jonasbb jonasbb commented Oct 16, 2019

I tried to follow the listed for "Add support for another language". I do have some questions about the last point though.

Evcxr has special commands, which are not valid Rust in any way. In contrast to Python magic cells they start with : instead of %, so they are not covered by the current logic for line magic.
From the code it looked like changing the variables _MAGIC_RE/_MAGIC_FORCE_ESC_RE might be the way to go here, but since I do not see any special casing there yet, I first wanted to know if that would be correct.

Here is a list of the supported magics in Evcxr.

:vars             List bound variables and their types
:opt [level]      Toggle/set optimization level
:explain          Print explanation of last error
:clear            Clear all state, keeping compilation cache
:dep              Add dependency. e.g. :dep regex = "1.0"
:version          Print Evcxr version
:preserve_vars_on_panic [0|1]  Try to keep vars on panic

Mostly for development / debugging purposes:
:last_compile_dir Print the directory in which we last compiled
:timing           Toggle printing of how long evaluations take
:last_error_json  Print the last compilation error as JSON (for debugging)
:time_passes      Toggle printing of rustc pass times (requires nightly)
:internal_debug   Toggle various internal debugging code

Rust identifiers can also contain : at the start, for example ::std::mem::drop.
The difference is that Evcxr commands have exactly one and in identifiers it is always as ::.

The sample notebook stems from the Evcxr project, which provides a Rust kernel.
https://github.com/google/evcxr/blob/942e166965e47073a592864440acd59cb8f4dfe1/evcxr_jupyter/samples/evcxr_jupyter_tour.ipynb

@codecov
Copy link

codecov bot commented Oct 16, 2019

Codecov Report

Merging #351 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #351      +/-   ##
=========================================
+ Coverage    99.2%   99.2%   +<.01%     
=========================================
  Files          72      73       +1     
  Lines        7031    7052      +21     
=========================================
+ Hits         6975    6996      +21     
  Misses         56      56
Impacted Files Coverage Δ
jupytext/languages.py 100% <ø> (ø) ⬆️
tests/test_read_simple_rust.py 100% <100%> (ø)
tests/test_mirror.py 100% <100%> (ø) ⬆️
jupytext/magics.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81ebd6b...df59adb. Read the comment docs.

@mwouts
Copy link
Owner

mwouts commented Oct 16, 2019

Awesome! Thank you @jonasbb.

Let me see what I can propose regarding the : magics - maybe we can simply have a rust case in the magics.is_magic function. I'll give it a try, add a few tests, and you will tell me if that does the job.

@mwouts mwouts added this to the 1.3.0 milestone Oct 16, 2019
@mwouts
Copy link
Owner

mwouts commented Oct 16, 2019

Hi @jonasbb , I think we're good: 297cf56. If that sounds right for you I'll merge this into master. And thanks for contributing!

@jonasbb
Copy link
Contributor Author

jonasbb commented Oct 17, 2019

@mwouts Thanks for finishing the PR. Looks good.

@mwouts mwouts merged commit df59adb into mwouts:master Oct 18, 2019
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.

2 participants