Skip to content

Commit 22b1e80

Browse files
committed
Update documentation, cleanup comments
1 parent ce3d9a3 commit 22b1e80

6 files changed

+47
-40
lines changed

jupyter-base.el

+11-5
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,17 @@ from the kernel.")
178178
(id (jupyter-new-uuid))
179179
(key nil))))
180180
"A `jupyter-session' holds the information needed to
181-
authenticate messages. Each `jupyter-session' should have a
182-
unique ID which is used as the `zmq-ROUTING-ID' for every
183-
`jupyter-channel' socket that utilizes the session object. The
184-
KEY of a `jupyter-session' is used for message signing. Message
185-
signing is not done if the KEY of a `jupyter-session' is empty."
181+
authenticate messages. A `jupyter-session' contains the following
182+
fields:
183+
184+
- CONN-INFO :: The connection info. property list of the kernel
185+
this session is used to sign messages for.
186+
187+
- ID :: A string of bytes used as the `zmq-ROUTING-ID' for every
188+
`jupyter-channel' that utilizes the sessiong object.
189+
190+
- KEY :: The key used when signing messages. If KEY is nil,
191+
message signing is not performed."
186192
(conn-info nil :read-only t)
187193
(id nil :read-only t)
188194
(key nil :read-only t))

jupyter-client.el

+1-4
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ initialization.")
111111
:documentation "If this client was initialized using a
112112
`jupyter-kernel-manager' this slot will hold the manager which
113113
initialized the client.")
114-
;; TODO: Periodically cleanup these buffers when the object they point to
115-
;; are no longer in use. How can we determine if an object has no more
116-
;; references? Maybe do something with `post-gc-hook'? Or require explicit
117-
;; cleanup?
118114
(-buffer
119115
:type buffer
120116
:documentation "An internal buffer used to store client local
@@ -762,6 +758,7 @@ received for it and it is not the most recently sent request."
762758
(remhash (jupyter-request-id req) requests)))
763759

764760
(defun jupyter--run-handler-maybe (client channel req msg)
761+
"Possibly run CLIENT's CHANNEL handler on REQ's received MSG."
765762
(let ((inhibited-handlers (and req (jupyter-request-inhibited-handlers req))))
766763
(unless (or (eq inhibited-handlers t)
767764
(memq (jupyter-message-type msg) inhibited-handlers))

jupyter-kernel-manager.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ class is CLIENT-CLASS. The client is connected to the kernel with
323323
all channels listening for messages and the heartbeat channel
324324
unpaused. Note that the client's `manager' slot will also be set
325325
to the kernel manager instance, see `jupyter-make-client'.
326-
Finally, INFO is the kernel info plist obtained from a
327-
`:kernel-info-request'."
326+
Finally, INFO is the kernel info plist obtained from an initial
327+
`:kernel-info-request' sent to the kernel using KC."
328328
(or client-class (setq client-class 'jupyter-kernel-client))
329329
(unless (child-of-class-p client-class 'jupyter-kernel-client)
330330
(signal 'wrong-type-argument

jupyter-repl.el

+32-21
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,32 @@ timeout, the built-in is-complete handler is used."
118118
;;; Implementation
119119

120120
(defclass jupyter-repl-client (jupyter-widget-client)
121-
((buffer :type buffer)
121+
((buffer
122+
:type (or null buffer)
123+
:initform nil
124+
:documentation "The REPL buffer whose
125+
`jupyter-repl-current-client' is this client.")
122126
(wait-to-clear
123127
:type boolean :initform nil
124128
:documentation "Whether or not we should wait to clear the
125129
current output of the cell. Set when the kernel sends a
126130
`:clear-output' message.")
127-
(kernel-info :type json-plist :initform nil)
128-
(execution-state :type string :initform "idle")
129-
(execution-count :type integer :initform 1)))
131+
(kernel-info
132+
:type json-plist
133+
:initform nil
134+
:documentation "The saved kernel info created when first
135+
initializing this client. This is the plist returned from the the
136+
call to `jupyter-start-new-kernel' when this client was
137+
created.")
138+
(execution-state
139+
:type string
140+
:initform "idle"
141+
:documentation "The current state of the kernel. Can be
142+
either \"idle\", \"busy\", or \"starting\".")
143+
(execution-count
144+
:type integer
145+
:initform 1
146+
:documentation "The current execution count of the kernel.")))
130147

131148
(defvar jupyter-repl-lang-buffer nil
132149
"A buffer with the `major-mode' set to the REPL language's `major-mode'.")
@@ -147,7 +164,7 @@ current output of the cell. Set when the kernel sends a
147164
See `jupyter-repl-fontify-according-to-mode'.")
148165

149166
(defvar jupyter-repl-use-builtin-is-complete nil
150-
"Whether or not to send is_complete_request's to a kernel.
167+
"Whether or not to send `:is-complete-request's to a kernel.
151168
If a Jupyter kernel does not respond to an is_complete_request,
152169
the buffer local value of this variable is set to t and code in a
153170
cell is considered complete if the last line in a code cell is a
@@ -159,8 +176,9 @@ Display IDs are implemented by setting the text property,
159176
`jupyter-display', to the display ID requested by a
160177
`:display-data' message. When a display is updated from an
161178
`:update-display-data' message, the display ID from the initial
162-
`:display-data' is retrieved from this table and used to find the
163-
display in the REPL buffer. See `jupyter-repl-update-display'.")
179+
`:display-data' message is retrieved from this table and used to
180+
find the display in the REPL buffer. See
181+
`jupyter-repl-update-display'.")
164182

165183
;;; Macros
166184

@@ -299,7 +317,7 @@ for the property."
299317

300318
;; Adapted from `org-src-font-lock-fontify-block'
301319
(defun jupyter-repl-fixup-font-lock-properties ()
302-
"Fixup the text properties in the `curren-buffer'.
320+
"Fixup the text properties in the `current-buffer'.
303321
Fixing the text properties of the current buffer involves
304322
substituting any `face' property with `font-lock-face' for
305323
insertion into the REPL buffer and adding
@@ -958,7 +976,6 @@ Finalizing a cell involves the following steps:
958976
(remove-text-properties beg (point) '(rear-nonsticky))
959977
;; font-lock-multiline to avoid improper syntactic elements from
960978
;; spilling over to the rest of the buffer.
961-
;; TODO: I don't think this is a proper use of this text property
962979
(add-text-properties beg (point) '(read-only t font-lock-multiline t))))
963980

964981
(defun jupyter-repl-replace-cell-code (new-code)
@@ -1177,7 +1194,7 @@ found."
11771194
(cl-defmethod jupyter-handle-clear-output ((client jupyter-repl-client)
11781195
req
11791196
wait)
1180-
;; TODO: Tale into account json-false elsewhere
1197+
;; TODO: Take into account json-false elsewhere
11811198
(unless (oset client wait-to-clear (eq wait t))
11821199
(cond
11831200
((eq (jupyter-message-parent-type
@@ -1215,8 +1232,6 @@ buffer to display TEXT."
12151232

12161233
(cl-defmethod jupyter-handle-stream ((client jupyter-repl-client) req name text)
12171234
(if (null req)
1218-
;; Otherwise the stream request is due to someone else, pop up a buffer.
1219-
;; TODO: Make this configurable so that we can just ignore output.
12201235
(jupyter-repl-display-other-output client name text)
12211236
(cond
12221237
((eq (jupyter-message-parent-type
@@ -1602,8 +1617,6 @@ is used for completion."
16021617

16031618
))
16041619
;; When a type is supplied add it as an annotation
1605-
;; TODO: Customize annotation types, when an annotation type "function"
1606-
;; appears, substitute "λ".
16071620
(when types
16081621
(let ((max-len (apply #'max (mapcar #'length matches))))
16091622
(cl-mapc
@@ -2258,14 +2271,14 @@ purposes and SYNTAX-TABLE is the syntax table of MODE."
22582271

22592272
(defun jupyter-repl--new-repl (client)
22602273
"Initialize a new REPL buffer based on CLIENT.
2261-
CLIENT is a `jupyter-repl-client' already connected to its
2262-
kernel and should have a non-nil kernel-info slot.
2274+
CLIENT is a `jupyter-repl-client' already connected to its kernel
2275+
and has a non-nil kernel-info slot.
22632276
22642277
A new REPL buffer communicating with CLIENT's kernel is created
2265-
and set as CLIENT'sthis case, if MANAGER will be the buffer slot.
2266-
If CLIENT already has a non-nil buffer slot, raise an error."
2278+
and set as CLIENT's buffer slot. If CLIENT already has a non-nil
2279+
buffer slot, raise an error."
22672280
(if (slot-boundp client 'buffer) (error "Client already has a REPL buffer")
2268-
(unless (ignore-errors (oref client kernel-info))
2281+
(unless (oref client kernel-info)
22692282
(error "Client needs to have valid kernel-info"))
22702283
(cl-destructuring-bind (&key language_info
22712284
banner
@@ -2306,8 +2319,6 @@ Otherwise, in a non-interactive call, return the
23062319
(setq kernel-name (caar (jupyter-find-kernelspecs kernel-name))))
23072320
(unless kernel-name
23082321
(error "No kernel found for prefix (%s)" kernel-name))
2309-
;; The manager is set as the client's manager slot in
2310-
;; `jupyter-start-new-kernel'
23112322
(cl-destructuring-bind (_manager client info)
23122323
(jupyter-start-new-kernel kernel-name 'jupyter-repl-client)
23132324
(oset client kernel-info info)

ob-jupyter.el

-7
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,8 @@ Return the cons cell (\"file\" . FILE), see
236236

237237
(defun org-babel-jupyter-prepare-result (data metadata params)
238238
"Return the rendered DATA.
239-
DATA is converted into a representation suitable for display in
240-
an `org-mode' buffer depending on
241-
242239
DATA is a plist, (:mimetype1 value1 ...), containing the
243240
different representations of a result returned by a kernel.
244-
Preparing a result
245-
246-
which is used to render
247-
a result which can be passed to `org-babel-insert-result'.
248241
249242
METADATA is the metadata plist used to render DATA with, as
250243
returned by the Jupyter kernel. This plist typically contains

widget.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</style>
1212
<script type="application/javascript">
1313
var kernel;
14-
// TODO: May not be available everywhere
1514
document.addEventListener("DOMContentLoaded", function(event) {
15+
// TODO: May not be available everywhere
1616
var p = new URLSearchParams(window.location.search);
1717
var kernel = new EmacsJupyter({username: p.get('username'),
1818
clientId: p.get('clientId')},

0 commit comments

Comments
 (0)