Skip to content

Commit

Permalink
[doc] Add notebook and copy button in code
Browse files Browse the repository at this point in the history
  • Loading branch information
parcollet committed Feb 13, 2024
1 parent 7b36300 commit d8b2a36
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
python3-pip
python3-sphinx
python3-sphinx-rtd-theme
python3-sphinx-copybutton
python3-myst-parser &&
pip3 install linkify-it-py
Expand Down
66 changes: 66 additions & 0 deletions doc/C2pyMagicDemo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "eb187f68-7c62-4561-89a4-d8f0d10c2f32",
"metadata": {},
"outputs": [],
"source": [
"%load_ext clair.c2py_magic"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7f1865b8-2ff3-459b-806b-58a21dbb124b",
"metadata": {},
"outputs": [],
"source": [
"%%c2py \n",
"int add(int i, int j) { \n",
" return i+j;\n",
"}\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a36f64c-0a85-4d83-880e-1bcd2fe6d75d",
"metadata": {},
"outputs": [],
"source": [
"print(add(2))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4367c72b-ab5c-42b3-8df5-54d9872d7213",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
4 changes: 4 additions & 0 deletions doc/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ extensions = ['sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.autosummary',
'sphinx.ext.githubpages',
'sphinx_copybutton',
# 'nbsphinx',
'myst_parser',
]

# Copy button options
copybutton_exclude = '.linenos, .gp'

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

Expand Down
1 change: 0 additions & 1 deletion doc/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Let us begin with a simple example in file `my_module.cpp`.

.. literalinclude:: examples/gs1.cpp
:language: cpp
:linenos:

We just compile the C++ file with `clang` using the ``clair`` plugin as

Expand Down
10 changes: 9 additions & 1 deletion doc/install_packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Experimental packages of ``c2py`` and ``clair`` are::

They are built from source from the GitHub parcollet/ccq repository.


.. note::

To use the plugin as in the example below,
Expand All @@ -24,5 +25,12 @@ They are built from source from the GitHub parcollet/ccq repository.
for clang to find its plugins in brew directory as in the documentation examples.
Alternatively, you can provide the full path to the plugin.
This setup is not necessary to use the CMake targets.


Uninstalling
............

In order to uninstall all formulas from the `parcollet/ccq` tap, you can use::

brew uninstall `brew list --full-name -1|grep ccq`


0 comments on commit d8b2a36

Please sign in to comment.