Skip to content

Commit 54b7a39

Browse files
committed
Fix all Documenter warnings
Namely by adding docstrings for all the internal methods that were missing them. Also used updated the docs CI to use the latest stable release (so we can use `[sources]`) and the cache action.
1 parent 72215f4 commit 54b7a39

File tree

14 files changed

+181
-23
lines changed

14 files changed

+181
-23
lines changed

.github/workflows/Docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17+
- uses: julia-actions/setup-julia@v2
18+
with:
19+
version: '1'
20+
- uses: julia-actions/cache@v2
1721
- uses: julia-actions/julia-buildpkg@v1
1822
- uses: julia-actions/julia-docdeploy@v1
1923
env:

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
44

55
[compat]
66
Documenter = "1"
7+
8+
[sources]
9+
IJulia = {path = ".."}

docs/make.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ makedocs(
2222
"library/internals.md",
2323
],
2424
],
25-
warnonly=true,
2625
)
2726

2827
# Deploy docs

docs/src/library/internals.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ IJulia.send_status
3535
## Request handlers
3636

3737
```@docs
38-
IJulia.handlers
3938
IJulia.connect_request
4039
IJulia.execute_request
4140
IJulia.shutdown_request

src/IJulia.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,19 @@ whether you are in an IJulia notebook, therefore, you can check
7575
"""
7676
inited = false
7777

78-
# set this to false for debugging, to disable stderr redirection
79-
"""
78+
const _capture_docstring = """
8079
The IJulia kernel captures all [stdout and stderr](https://en.wikipedia.org/wiki/Standard_streams)
8180
output and redirects it to the notebook. When debugging IJulia problems,
8281
however, it can be more convenient to *not* capture stdout and stderr output
8382
(since the notebook may not be functioning). This can be done by editing
8483
`IJulia.jl` to set `capture_stderr` and/or `capture_stdout` to `false`.
8584
"""
85+
86+
@doc _capture_docstring
8687
const capture_stdout = true
88+
89+
# set this to false for debugging, to disable stderr redirection
90+
@doc _capture_docstring
8791
const capture_stderr = !IJULIA_DEBUG
8892

8993
set_current_module(m::Module) = current_module[] = m

src/display.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,21 @@ const ijulia_jsonmime_types = Vector{Union{MIME, Vector{MIME}}}([
4040
MIME("application/vnd.dataresource+json"), MIME("application/vnd.plotly.v1+json")
4141
])
4242

43-
register_mime(x::Union{MIME, Vector{MIME}})= push!(ijulia_mime_types, x)
43+
"""
44+
register_mime(x::Union{MIME, Vector{MIME}})
45+
register_mime(x::AbstractVector{<:MIME})
46+
47+
Register a new MIME type.
48+
"""
49+
register_mime(x::Union{MIME, Vector{MIME}}) = push!(ijulia_mime_types, x)
4450
register_mime(x::AbstractVector{<:MIME}) = push!(ijulia_mime_types, Vector{Mime}(x))
51+
52+
"""
53+
register_jsonmime(x::Union{MIME, Vector{MIME}})
54+
register_jsonmime(x::AbstractVector{<:MIME})
55+
56+
Register a new JSON MIME type.
57+
"""
4558
register_jsonmime(x::Union{MIME, Vector{MIME}}) = push!(ijulia_jsonmime_types, x)
4659
register_jsonmime(x::AbstractVector{<:MIME}) = push!(ijulia_jsonmime_types, Vector{Mime}(x))
4760

@@ -92,8 +105,8 @@ display_mimejson(m::MIME, x) = (m, JSON.JSONText(limitstringmime(m, x, true)))
92105

93106
"""
94107
Generate a dictionary of `mime_type => data` pairs for all registered MIME
95-
types. This is the format that Jupyter expects in display_data and
96-
execute_result messages.
108+
types. This is the format that Jupyter expects in `display_data` and
109+
`execute_result` messages.
97110
"""
98111
function display_dict(x)
99112
data = Dict{String, Union{String, JSONText}}()

src/eventloop.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
eventloop(socket)
3+
4+
Generic event loop for one of the [kernel
5+
sockets](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introduction).
6+
"""
17
function eventloop(socket)
28
task_local_storage(:IJulia_task, "write task")
39
try
@@ -33,6 +39,13 @@ function eventloop(socket)
3339
end
3440

3541
const requests_task = Ref{Task}()
42+
43+
"""
44+
waitloop()
45+
46+
Main loop of a kernel. Runs the event loops for the control and shell sockets
47+
(note: in IJulia the shell socket is called `requests`).
48+
"""
3649
function waitloop()
3750
@async eventloop(control[])
3851
requests_task[] = @async eventloop(requests[])

src/execute_request.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ import REPL: helpmode
2424
# use a global array to accumulate "payloads" for the execute_reply message
2525
const execute_payloads = Dict[]
2626

27+
"""
28+
execute_request(socket, msg)
29+
30+
Handle a [execute
31+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute).
32+
This will execute Julia code, along with Pkg and shell commands.
33+
"""
2734
function execute_request(socket, msg)
2835
code = msg.content["code"]
2936
@vprintln("EXECUTING ", code)

src/handlers.jl

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ function complete_types(comps)
108108
return typeMap
109109
end
110110

111+
"""
112+
complete_request(socket, msg)
113+
114+
Handle a [completion
115+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
116+
"""
111117
function complete_request(socket, msg)
112118
code = msg.content["code"]
113119
cursor_chr = msg.content["cursor_pos"]
@@ -153,6 +159,12 @@ function complete_request(socket, msg)
153159
"cursor_end" => cursor_end)))
154160
end
155161

162+
"""
163+
kernel_info_request(socket, msg)
164+
165+
Handle a [kernel info
166+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
167+
"""
156168
function kernel_info_request(socket, msg)
157169
send_ipython(socket,
158170
msg_reply(msg, "kernel_info_reply",
@@ -179,21 +191,34 @@ function kernel_info_request(socket, msg)
179191
"status" => "ok")))
180192
end
181193

194+
"""
195+
connect_request(socket, msg)
196+
197+
Handle a [connect
198+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#connect).
199+
"""
182200
function connect_request(socket, msg)
183201
send_ipython(requests[],
184202
msg_reply(msg, "connect_reply",
185203
Dict("shell_port" => profile["shell_port"],
186-
"iopub_port" => profile["iopub_port"],
187-
"stdin_port" => profile["stdin_port"],
188-
"hb_port" => profile["hb_port"])))
204+
"iopub_port" => profile["iopub_port"],
205+
"stdin_port" => profile["stdin_port"],
206+
"hb_port" => profile["hb_port"])))
189207
end
190208

209+
"""
210+
shutdown_request(socket, msg)
211+
212+
Handle a [shutdown
213+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-shutdown). After
214+
sending the reply this will exit the process.
215+
"""
191216
function shutdown_request(socket, msg)
192217
# stop heartbeat thread by closing the context
193218
close(heartbeat_context[])
194219

195220
send_ipython(requests[], msg_reply(msg, "shutdown_reply",
196-
msg.content))
221+
msg.content))
197222
sleep(0.1) # short delay (like in ipykernel), to hopefully ensure shutdown_reply is sent
198223
exit()
199224
end
@@ -235,6 +260,12 @@ function get_token(code, pos)
235260
return code[startpos:endpos]
236261
end
237262

263+
"""
264+
inspect_request(socket, msg)
265+
266+
Handle a [introspection
267+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
268+
"""
238269
function inspect_request(socket, msg)
239270
try
240271
code = msg.content["code"]
@@ -256,6 +287,13 @@ function inspect_request(socket, msg)
256287
end
257288
end
258289

290+
"""
291+
history_request(socket, msg)
292+
293+
Handle a [history
294+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history). This
295+
is currently only a dummy implementation that doesn't actually do anything.
296+
"""
259297
function history_request(socket, msg)
260298
# we will just send back empty history for now, pending clarification
261299
# as requested in ipython/ipython#3806
@@ -264,6 +302,12 @@ function history_request(socket, msg)
264302
Dict("history" => [])))
265303
end
266304

305+
"""
306+
is_complete_request(socket, msg)
307+
308+
Handle a [completeness
309+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
310+
"""
267311
function is_complete_request(socket, msg)
268312
ex = Meta.parse(msg.content["code"], raise=false)
269313
status = Meta.isexpr(ex, :incomplete) ? "incomplete" : Meta.isexpr(ex, :error) ? "invalid" : "complete"
@@ -272,6 +316,13 @@ function is_complete_request(socket, msg)
272316
Dict("status"=>status, "indent"=>"")))
273317
end
274318

319+
"""
320+
interrupt_request(socket, msg)
321+
322+
Handle a [interrupt
323+
request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-interrupt). This
324+
will throw an `InterruptException` to the currently executing request handler.
325+
"""
275326
function interrupt_request(socket, msg)
276327
@async Base.throwto(requests_task[], InterruptException())
277328
send_ipython(socket, msg_reply(msg, "interrupt_reply", Dict()))

src/init.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ const socket_locks = Dict{Socket,ReentrantLock}()
4545
const minirepl = Ref{MiniREPL}()
4646
end
4747

48+
"""
49+
init(args)
50+
51+
Initialize a kernel. `args` may either be empty or have one element containing
52+
the path to an existing connection file. If `args` is empty a connection file
53+
will be generated.
54+
"""
4855
function init(args)
4956
inited && error("IJulia is already running")
5057
if length(args) > 0

0 commit comments

Comments
 (0)