Skip to content

Commit 56b72e0

Browse files
authored
Enabled file magic support for xeus-cpp-lite (#261)
* added file magic in xeus-lite
1 parent 74902e7 commit 56b72e0

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ set(XEUS_CPP_SRC
213213
src/xoptions.cpp
214214
src/xparser.cpp
215215
src/xutils.cpp
216+
src/xmagics/os.cpp
216217
)
217218

218219
if(NOT EMSCRIPTEN)
219220
list(APPEND XEUS_CPP_SRC
220221
src/xmagics/xassist.cpp
221-
src/xmagics/os.cpp
222222
)
223223
endif()
224224

docs/source/file_magic.png

24.6 KB
Loading

docs/source/magics.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Here are the magics available in xeus-cpp.
1212
%%xassist
1313
========================
1414

15-
Leverage the large language models to assist in your development process. Currently supported models are Gemini, OpenAI, Ollama.
15+
Leverage the large language models to assist in your development process. Currently supported models are Gemini, OpenAI, Ollama. This magic command is supported in only xeus-cpp.
1616

1717
- Save the api key (for OpenAI and Gemini)
1818

@@ -54,3 +54,23 @@ Leverage the large language models to assist in your development process. Curren
5454
.. image:: gemini.png
5555

5656
.. image:: ollama.png
57+
58+
59+
%%file
60+
========================
61+
62+
This magic command copies the content of the cell in a file named `filename`. This magic command is supported in both xeus-cpp and xeus-cpp-lite.
63+
64+
.. code::
65+
66+
%%file [-a] filename
67+
68+
- Example
69+
70+
.. image:: file_magic.png
71+
72+
- Optional argument:
73+
74+
+------------+---------------------------------+
75+
| -a | append the content to the file. |
76+
+------------+---------------------------------+

src/xinterpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include "xinput.hpp"
1919
#include "xinspect.hpp"
20-
#ifndef EMSCRIPTEN
2120
#include "xmagics/os.hpp"
21+
#ifndef EMSCRIPTEN
2222
#include "xmagics/xassist.hpp"
2323
#endif
2424
#include "xparser.hpp"
@@ -372,9 +372,9 @@ __get_cxx_version ()
372372
// preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("timeit",
373373
// timeit(&m_interpreter));
374374
// preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("python", pythonexec());
375+
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("file", writefile());
375376
#ifndef EMSCRIPTEN
376377
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("xassist", xassist());
377-
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("file", writefile());
378378
#endif
379379
}
380380
}

0 commit comments

Comments
 (0)