From 45ad485858bcbaa07c1e3a246f2bbcd072d291cb Mon Sep 17 00:00:00 2001 From: Asko Soukka Date: Fri, 8 Nov 2019 20:29:48 +0200 Subject: [PATCH] Add Robot Framework (.robot) -language support --- jupytext/languages.py | 5 +- .../ipynb_robot/simple_robot_notebook.ipynb | 70 +++++++++++++++++++ tests/test_mirror.py | 10 +++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 tests/notebooks/ipynb_robot/simple_robot_notebook.ipynb diff --git a/jupytext/languages.py b/jupytext/languages.py index eb6114619..fc5c45990 100644 --- a/jupytext/languages.py +++ b/jupytext/languages.py @@ -3,7 +3,7 @@ # 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', - 'matlab', 'octave', 'idl', 'spark', 'sql'] + 'matlab', 'octave', 'idl', 'robotframework', 'spark', 'sql'] # Supported file extensions (and languages) # Please add more languages here (and add a few tests) - see CONTRIBUTING.md @@ -23,7 +23,8 @@ '.js': {'language': 'javascript', 'comment': '//'}, '.ts': {'language': 'typescript', 'comment': '//'}, '.scala': {'language': 'scala', 'comment': '//'}, - '.rs': {'language': 'rust', 'comment': '//'}} + '.rs': {'language': 'rust', 'comment': '//'}, + '.robot': {'language': 'robotframework', 'comment': '#'}} _COMMENT_CHARS = [_SCRIPT_EXTENSIONS[ext]['comment'] for ext in _SCRIPT_EXTENSIONS if _SCRIPT_EXTENSIONS[ext]['comment'] != '#'] diff --git a/tests/notebooks/ipynb_robot/simple_robot_notebook.ipynb b/tests/notebooks/ipynb_robot/simple_robot_notebook.ipynb new file mode 100644 index 000000000..7e9277628 --- /dev/null +++ b/tests/notebooks/ipynb_robot/simple_robot_notebook.ipynb @@ -0,0 +1,70 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "*** Settings ***\n", + "\n", + "Library Collections" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "*** Keywords ***\n", + "\n", + "Head\n", + " [Arguments] ${list}\n", + " ${value}= Get from list ${list} 0\n", + " [Return] ${value}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "lines_to_next_cell": 0 + }, + "outputs": [], + "source": [ + "*** Tasks ***\n", + "\n", + "Get head\n", + " ${array}= Create list 1 2 3 4 5\n", + " ${head}= Head ${array}\n", + " Should be equal ${head} 1" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Robot Framework", + "language": "robotframework", + "name": "robotkernel" + }, + "language_info": { + "codemirror_mode": "robotframework", + "file_extension": ".robot", + "mimetype": "text/plain", + "name": "robotframework", + "pygments_lexer": "robotframework" + }, + "pycharm": { + "stem_cell": { + "cell_type": "raw", + "source": [], + "metadata": { + "collapsed": false + } + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/tests/test_mirror.py b/tests/test_mirror.py index d9e34d345..fa9a84e3f 100644 --- a/tests/test_mirror.py +++ b/tests/test_mirror.py @@ -248,3 +248,13 @@ def test_ipynb_to_scheme_percent(nb_file, extension, no_jupytext_version_number) assert_conversion_same_as_mirror(nb_file, '{}:percent'.format(extension), 'ipynb_to_percent') + + +@pytest.mark.parametrize('nb_file', list_notebooks('ipynb_robot')) +def test_ipynb_to_robot_light(nb_file, no_jupytext_version_number): + assert_conversion_same_as_mirror(nb_file, 'auto', 'ipynb_to_script') + + +@pytest.mark.parametrize('nb_file', list_notebooks('ipynb_robot')) +def test_ipynb_to_robot_percent(nb_file, no_jupytext_version_number): + assert_conversion_same_as_mirror(nb_file, 'auto:percent', 'ipynb_to_percent')