Skip to content

Commit

Permalink
Polish of example Jupyter notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Jul 6, 2018
1 parent e7e7a64 commit 815d148
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
15 changes: 8 additions & 7 deletions docs/source/magics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
Magic commands
==============

Magic commands are widely used in the IPython kernel to perform some actions on a notebook cell. There are defined by the symbol `%` for a line magic and `%%` for a cell magic.
Magics are special commands for the kernel that are not part of the C++
programming language.

We have started to implement these commands in `xeus-cling` and, in a future release, it will be possible to add your own. In general, the magic command is defined by its name and several options. We use cxxopts_ to manage the options.
There are defined with the symbol ``%`` for a line magic and ``%%`` for a cell
magic.

For now, we have implemented 2 magic commands
A few magics are available in xeus-cling. In the future, user-defined magics
will also be enabled.

%%file
------
Expand All @@ -43,7 +46,8 @@ This magic command copies the content of the cell in a file named `filename`.
%timeit
-------

Time execution of a line statement (`%timeit`) or of a block of statements (`%%timeit`)
Measure the execution time execution for a line statement (`%timeit`) or for a
block of statements (`%%timeit`)

- Usage in line mode

Expand Down Expand Up @@ -71,6 +75,3 @@ Time execution of a line statement (`%timeit`) or of a block of statements (`%%t
+------------+---------------------------------------------------------------------------------------------------------+
| -p | use a precision of <P> digits to display the timing result. Default: 3 |
+------------+---------------------------------------------------------------------------------------------------------+


.. _cxxopts: https://en.cppreference.com
26 changes: 20 additions & 6 deletions notebooks/xcpp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"![xeus-cling](images/xeus-cling.png)\n",
"[![xeus-cling](images/xeus-cling.png)](https://github.com/QuantStack/xeus-cling/)\n",
"\n",
"A Jupyter kernel for C++ based on the C++ interpreter cling and the native implementation of the Jupyter protocol, xeus."
"A Jupyter kernel for C++ based on the `cling` C++ interpreter and the `xeus` native implementation of the Jupyter protocol, xeus.\n",
"\n",
"- GitHub repository: https://github.com/QuantStack/xeus-cling/\n",
"- Online documentation: https://xeus-cling.readthedocs.io/"
]
},
{
Expand Down Expand Up @@ -353,7 +356,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Documentation and completion"
"## Documentation and completion\n",
"\n",
" - Documentation for types of the standard library is retrieved on cppreference.com.\n",
" - The quick-help feature can also be enabled for user-defined types and third-party libraries. More documentation on this feature is available at https://xeus-cling.readthedocs.io/en/latest/inline_help.html.\n"
]
},
{
Expand All @@ -376,7 +382,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For a user-defined type `T`, implementing the function `xeus::xjson mime_bundle_repr(const T* im)` returning the json mime bundle representation for that type enables the rich rendering in the notebook."
"For a user-defined type `T`, the rich rendering in the notebook and JupyterLab can be enabled by by implementing the function `xeus::xjson mime_bundle_repr(const T& im)`, which returns the JSON mime bundle for that type.\n",
"\n",
"More documentation on the rich display system of Jupyter and Xeus-cling is available at https://xeus-cling.readthedocs.io/en/latest/rich_display.html"
]
},
{
Expand Down Expand Up @@ -591,7 +599,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Magics"
"## Magics\n",
"\n",
"Magics are special commands for the kernel that are not part of the C++ language.\n",
"\n",
"They are defined with the symbol `%` for a line magic and `%%` for a cell magic.\n",
"\n",
"More documentation for magics is available at https://xeus-cling.readthedocs.io/en/latest/magics.html."
]
},
{
Expand Down Expand Up @@ -634,7 +648,7 @@
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "14"
"version": "-std=c++14"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 815d148

Please sign in to comment.