Skip to content

Commit ff27c17

Browse files
authored
Merge pull request #391 from JohanMabille/update_doc
Updated documentation after parent header PR
2 parents e6d62ff + 8174fc6 commit ff27c17

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

docs/source/example/src/custom_interpreter.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ namespace nl = nlohmann;
1919
namespace custom
2020
{
2121

22-
nl::json custom_interpreter::execute_request_impl(int execution_counter, // Typically the cell number
22+
nl::json custom_interpreter::execute_request_impl(xrequest_context request_context, // data required by other functions
23+
int execution_counter, // Typically the cell number
2324
const std::string& /*code*/, // Code to execute
2425
bool /*silent*/,
2526
bool /*store_history*/,
@@ -37,12 +38,12 @@ namespace custom
3738
// Replace "Hello World !!" by what you want to be displayed under the execution cell
3839
nl::json pub_data;
3940
pub_data["text/plain"] = "Hello World !!";
40-
publish_execution_result(execution_counter, std::move(pub_data), nl::json::object());
41+
publish_execution_result(request_context, execution_counter, std::move(pub_data), nl::json::object());
4142

4243
// You can also use this method for publishing errors to the client, if the code
4344
// failed to execute
4445
// publish_execution_error(error_name, error_value, error_traceback);
45-
publish_execution_error("TypeError", "123", {"!@#$", "*(*"});
46+
publish_execution_error(request_context, "TypeError", "123", {"!@#$", "*(*"});
4647

4748
return xeus::create_successful_reply();
4849
}

docs/source/example/src/custom_interpreter.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ namespace custom
3131

3232
void configure_impl() override;
3333

34-
nl::json execute_request_impl(int execution_counter,
34+
nl::json execute_request_impl(xrequest_context request_context,
35+
int execution_counter,
3536
const std::string& code,
3637
bool silent,
3738
bool store_history,

docs/source/kernel_implementation.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ Input request
6464
~~~~~~~~~~~~~
6565

6666
For input request support, you would need to monkey-patch the language functions that prompt for a user input (``input``
67-
and ``raw_input`` in Python, ``io.read`` in Lua etc) and call ``xeus::blocking_input_request`` instead. The second parameter
68-
should be set to False if what the user is typing should not be visible on the screen.
67+
and ``raw_input`` in Python, ``io.read`` in Lua etc) and call ``xeus::blocking_input_request`` instead. The first parameter
68+
should be forwarded from the execution_request implementation. The third parameter should be set to False if what the user
69+
is typing should not be visible on the screen.
6970

7071
.. code::
7172
7273
#include "xeus/xinput.hpp"
7374
74-
xeus::blocking_input_request("User name:", true);
75-
xeus::blocking_input_request("Password:", false);
75+
xeus::blocking_input_request(request_context, "User name:", true);
76+
xeus::blocking_input_request(request_context, "Password:", false);
7677
7778
Configuration
7879
~~~~~~~~~~~~~

include/xeus/xinput.hpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212

1313
#include <string>
1414

15-
#include "xeus.hpp"
15+
#include "xeus/xeus.hpp"
16+
#include "xeus/xrequest_context.hpp"
1617

1718
namespace xeus
1819
{
19-
XEUS_API std::string blocking_input_request(const std::string& prompt, bool password);
20+
XEUS_API
21+
std::string blocking_input_request(
22+
xrequest_context context,
23+
const std::string& prompt,
24+
bool password
25+
);
2026
}
2127

2228
#endif

include/xeus/xrequest_context.hpp

+15-13
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,23 @@ namespace nl = nlohmann;
2020

2121
namespace xeus
2222
{
23-
24-
class XEUS_API xrequest_context{
25-
public:
26-
using guid_list = xmessage::guid_list;
27-
xrequest_context(nl::json header, channel origin, guid_list id);
28-
const nl::json& header() const;
29-
channel origin() const;
30-
const guid_list& id() const;
31-
32-
private:
23+
class XEUS_API xrequest_context
24+
{
25+
public:
26+
27+
using guid_list = xmessage::guid_list;
3328

34-
nl::json m_header;
35-
channel m_origin;
36-
guid_list m_id;
29+
xrequest_context(nl::json header, channel origin, guid_list id);
3730

31+
const nl::json& header() const;
32+
channel origin() const;
33+
const guid_list& id() const;
34+
35+
private:
36+
37+
nl::json m_header;
38+
channel m_origin;
39+
guid_list m_id;
3840
};
3941
}
4042

0 commit comments

Comments
 (0)