diff --git a/CMakeLists.txt b/CMakeLists.txt index 63f4bf6b..d2a3ad37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,12 +213,12 @@ set(XEUS_CPP_SRC src/xoptions.cpp src/xparser.cpp src/xutils.cpp + src/xmagics/os.cpp ) if(NOT EMSCRIPTEN) list(APPEND XEUS_CPP_SRC src/xmagics/xassist.cpp - src/xmagics/os.cpp ) endif() diff --git a/docs/source/file_magic.png b/docs/source/file_magic.png new file mode 100644 index 00000000..72e6b68b Binary files /dev/null and b/docs/source/file_magic.png differ diff --git a/docs/source/magics.rst b/docs/source/magics.rst index d596a71b..a50ee75c 100644 --- a/docs/source/magics.rst +++ b/docs/source/magics.rst @@ -12,7 +12,7 @@ Here are the magics available in xeus-cpp. %%xassist ======================== -Leverage the large language models to assist in your development process. Currently supported models are Gemini, OpenAI, Ollama. +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. - Save the api key (for OpenAI and Gemini) @@ -54,3 +54,23 @@ Leverage the large language models to assist in your development process. Curren .. image:: gemini.png .. image:: ollama.png + + +%%file +======================== + +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. + +.. code:: + + %%file [-a] filename + +- Example + +.. image:: file_magic.png + +- Optional argument: + ++------------+---------------------------------+ +| -a | append the content to the file. | ++------------+---------------------------------+ \ No newline at end of file diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 5ed527e3..85aa07b1 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -17,8 +17,8 @@ #include "xinput.hpp" #include "xinspect.hpp" -#ifndef EMSCRIPTEN #include "xmagics/os.hpp" +#ifndef EMSCRIPTEN #include "xmagics/xassist.hpp" #endif #include "xparser.hpp" @@ -372,9 +372,9 @@ __get_cxx_version () // preamble_manager["magics"].get_cast().register_magic("timeit", // timeit(&m_interpreter)); // preamble_manager["magics"].get_cast().register_magic("python", pythonexec()); + preamble_manager["magics"].get_cast().register_magic("file", writefile()); #ifndef EMSCRIPTEN preamble_manager["magics"].get_cast().register_magic("xassist", xassist()); - preamble_manager["magics"].get_cast().register_magic("file", writefile()); #endif } }