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

1.1.7 #261

Merged
merged 18 commits into from
Jun 23, 2019
Merged

1.1.7 #261

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing to Jupytext

Thanks for reading this! Contributions to this project are welcome.
There are many ways you can contribute...
Thanks for reading this. Contributions to this project are welcome.
And there are many ways you can contribute...

## Spread the word

@@ -12,7 +12,7 @@ By the way, we're also interested to know how you use Jupytext! There may well b

## Improve the documentation

You think the documentation could be improved? You've spotted a typo, or you think you can rephrase a paragraph to make is easier to follow? Please follow the _Edit on Github_ link, edit the document, and submit a pull request!
You think the documentation could be improved? You've spotted a typo, or you think you can rephrase a paragraph to make is easier to follow? Please follow the _Edit on Github_ link, edit the document, and submit a pull request.

## Report an issue

@@ -53,7 +53,7 @@ pip install dist/jupytext-XXX.tar.gz
## Jupytext's extension for Jupyter Notebook
Our extension for Jupyter Notebook adds a Jupytext entry to Jupyter Notebook. The code is found at `jupytext/nbextension/index.js`. Instructions to develop that extension are found [here](https://github.com/mwouts/jupytext_nbextension).
Our extension for Jupyter Notebook adds a Jupytext entry to Jupyter Notebook Menu. The code is found at `jupytext/nbextension/index.js`. Instructions to develop that extension are at `jupytext/nbextension/README.md`.
## Jupytext's extension for JupyterLab
@@ -70,4 +70,4 @@ pip install -r doc-requirements.txt
and build the HTML documentation locally with
```
make html
```
```
18 changes: 18 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -3,6 +3,24 @@
Release History
---------------

1.1.7 (2019-06-23)
++++++++++++++++++++++

**Improvements**

- Added support for Scala notebook, by Tobias Frischholz (#253)
- Added a getting started notebook for jupytext (and Binder), by Chris Holdgraf (#257)
- The Markdown and R Markdown representations are now tested for all the languages
- The Jupytext notebook extension also works when the notebook is a text file (#213)


**BugFixes**

- The Jupytext Menu in Jupyter Notebook is now compatible with ``jupyter_nbextensions_configurator`` (#178)
- Entries in the Jupytext menu are updated when the menu is hovered on (#248)
- Fixed link to ``.md`` files in the documentation (#255)


1.1.6 (2019-06-11)
++++++++++++++++++++++

5 changes: 0 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -2,8 +2,3 @@ include LICENSE
include *.md
include *.txt
include *.rst

recursive-include jupyter-config *.json
recursive-include jupytext/nbextension *.js

graft packages
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ It can also convert these documents **into** Jupyter
Notebooks, allowing you to synchronize content in both
directions.

The languages that are currently supported by Jupytext are: Julia, Python, R, Bash, Scheme, Clojure, Matlab, Octave, C++, q/kdb+, IDL, TypeScript and Javascript. Extending Jupytext to more languages should be easy - read more at [CONTRIBUTING.md](https://github.com/mwouts/jupytext/blob/master/CONTRIBUTING.md). In addition, jupytext users can choose between two formats for notebooks as scripts:
The languages that are currently supported by Jupytext are: Julia, Python, R, Bash, Scheme, Clojure, Matlab, Octave, C++, q/kdb+, IDL, TypeScript, Javascript and Scala. Extending Jupytext to more languages should be easy - read more at [CONTRIBUTING.md](https://github.com/mwouts/jupytext/blob/master/CONTRIBUTING.md). In addition, jupytext users can choose between two formats for notebooks as scripts:
- The `percent` format, compatible with several IDEs, including Spyder, Hydrogen, VScode and PyCharm. In that format, cells are delimited with a commented `%%`.
- The `light` format, designed for this project. Use that format to open standard scripts as notebooks, or to save notebooks as scripts with few cell markers - none when possible.

2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ Jupytext can save Jupyter notebooks as
- Markdown and R Markdown documents,
- Scripts in many languages.

The languages that are currently supported by Jupytext are: Julia, Python, R, Bash, Scheme, Clojure, Matlab, Octave, C++, q/kdb+, IDL, TypeScript and Javascript. Extending Jupytext to more languages should be easy - read more at [CONTRIBUTING.md](https://github.com/mwouts/jupytext/blob/master/CONTRIBUTING.md#). In addition, jupytext users can choose between two formats for notebooks as scripts:
The languages that are currently supported by Jupytext are: Julia, Python, R, Bash, Scheme, Clojure, Matlab, Octave, C++, q/kdb+, IDL, TypeScript, Javascript and Scala. Extending Jupytext to more languages should be easy - read more at [CONTRIBUTING.md](https://github.com/mwouts/jupytext/blob/master/CONTRIBUTING.md#). In addition, jupytext users can choose between two formats for notebooks as scripts:
- The `percent` format, compatible with several IDEs, including Spyder, Hydrogen, VScode and PyCharm. In that format, cells are delimited with a commented `%%`.
- The `light` format, designed for this project. Use that format to open standard scripts as notebooks, or to save notebooks as scripts with few cell markers - none when possible.

2 changes: 1 addition & 1 deletion jupytext/cell_metadata.py
Original file line number Diff line number Diff line change
@@ -304,7 +304,7 @@ def md_options_to_metadata(options):

if metadata:
language = metadata[0][0]
for lang in _JUPYTER_LANGUAGES + ['julia', 'scheme', 'c++']:
for lang in _JUPYTER_LANGUAGES:
if language.lower() == lang.lower():
return lang, dict(metadata[1:])

21 changes: 13 additions & 8 deletions jupytext/languages.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Determine notebook or cell language"""

# Languages that may appear as magic instructions in Python notebooks
# Jupyter magic commands that are also languages
_JUPYTER_LANGUAGES = ['R', 'bash', 'sh', 'python', 'python2', 'python3', 'javascript', 'js', 'perl',
'html', 'latex', 'markdown', 'pypy', 'ruby', 'script', 'svg', 'writefile',
'matlab', 'octave', 'idl', 'scala']
'html', 'latex', 'markdown', 'pypy', 'ruby', 'script', 'svg',
'matlab', 'octave', 'idl', 'spark', 'sql']

# Supported file extensions (and languages)
# Please add more languages here (and add a few tests) - see CONTRIBUTING.md
@@ -26,6 +26,10 @@
_COMMENT_CHARS = [_SCRIPT_EXTENSIONS[ext]['comment'] for ext in _SCRIPT_EXTENSIONS if
_SCRIPT_EXTENSIONS[ext]['comment'] != '#']

_JUPYTER_LANGUAGES = _JUPYTER_LANGUAGES + [
_SCRIPT_EXTENSIONS[ext]['language'] for ext in _SCRIPT_EXTENSIONS if
_SCRIPT_EXTENSIONS[ext]['language'] not in _JUPYTER_LANGUAGES]


def default_language_from_metadata_and_ext(metadata, ext):
"""Return the default language given the notebook metadata, and a file extension"""
@@ -35,18 +39,19 @@ def default_language_from_metadata_and_ext(metadata, ext):
or metadata.get('kernelspec', {}).get('language')
or default_from_ext)

if language is None or language == 'R':
return language

if language.startswith('C++'):
language = 'c++'
return 'c++'

return language
return language.lower()


def set_main_and_cell_language(metadata, cells, ext):
"""Set main language for the given collection of cells, and
use magics for cells that use other languages"""
main_language = (metadata.get('kernelspec', {}).get('language') or
metadata.get('jupytext', {}).get('main_language') or
_SCRIPT_EXTENSIONS.get(ext, {}).get('language'))
main_language = default_language_from_metadata_and_ext(metadata, ext)

if main_language is None:
languages = {'python': 0.5}
30 changes: 30 additions & 0 deletions jupytext/nbextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# A Jupyter notebook extension for Jupytext

This extension adds a [Jupytext](https://github.com/mwouts/jupytext/blob/master/README.md) menu to Jupyter notebook. Use the menu to select the desired ipynb/text pairing for your notebook.

![Jupytext menu screenshot](jupytext_menu.png)

## Installation

The extension requires [Jupytext](https://github.com/mwouts/jupytext/blob/master/README.md). Please make sure that Jupytext is installed on you system, and that its contents manager is active, i.e. that Markdown files and scripts are displayed with a notebook icon.

Installing Jupytext activates the Jupytext Menu by default. If you want to install and activate it manually, use the following commands:

```bash
jupyter nbextension install --py jupytext
jupyter nbextension enable --py jupytext
```

Add `--user` to these commands if you want to activate the extension only for the current user.

## How to develop this extension

If you wish to develop this extension, install the javascript file locally with:

```bash
cd jupytext/nbextension
jupyter nbextension install index.js --symlink --user
jupyter nbextension enable jupytext --user
```

Then, make the desired changes to `index.js` and reload the extension by simply refreshing the notebook (Ctrl+R). In case your OS does not allow symlinks, edit the copy of `index.js` that is actually used by Jupyter (refer to the output of `jupyter nbextension install --user index.js`).
Loading