Skip to content

Commit 39cd76e

Browse files
committed
normalize client behavior
1 parent 48f4e3d commit 39cd76e

File tree

16 files changed

+107
-85
lines changed

16 files changed

+107
-85
lines changed

docs/KEYWORDS.ipynb

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,44 @@
2525
},
2626
{
2727
"cell_type": "code",
28-
"execution_count": 2,
28+
"execution_count": 6,
2929
"metadata": {
3030
"jupyter": {
3131
"source_hidden": true
3232
}
3333
},
3434
"outputs": [],
3535
"source": [
36-
"iframe = lambda url: __import__(\"IPython\").display.HTML(f\"\"\"<iframe src=\"_static/{url}.html\" id=\"{url}\" width=\"100%\"></iframe>\"\"\")"
36+
"iframe = lambda url: __import__(\"IPython\").display.IFrame(f\"_static/{url}.html\", width=\"100%\", height=\"\")"
3737
]
3838
},
3939
{
4040
"cell_type": "code",
41-
"execution_count": 3,
41+
"execution_count": 7,
4242
"metadata": {
4343
"jupyter": {
4444
"source_hidden": true
4545
}
4646
},
4747
"outputs": [
48-
{
49-
"name": "stderr",
50-
"output_type": "stream",
51-
"text": [
52-
"/home/weg/Documents/projects/robotframework-jupyterlibrary/envs/rfjl37/lib/python3.7/site-packages/IPython/core/display.py:689: UserWarning: Consider using IPython.display.IFrame instead\n",
53-
" warnings.warn(\"Consider using IPython.display.IFrame instead\")\n"
54-
]
55-
},
5648
{
5749
"data": {
5850
"text/html": [
59-
"<iframe src=\"_static/JupyterLibrary.html\" id=\"JupyterLibrary\" width=\"100%\"></iframe>"
51+
"\n",
52+
" <iframe\n",
53+
" width=\"100%\"\n",
54+
" height=\"\"\n",
55+
" src=\"_static/JupyterLibrary.html\"\n",
56+
" frameborder=\"0\"\n",
57+
" allowfullscreen\n",
58+
" ></iframe>\n",
59+
" "
6060
],
6161
"text/plain": [
62-
"<IPython.core.display.HTML object>"
62+
"<IPython.lib.display.IFrame at 0x7fda84204be0>"
6363
]
6464
},
65-
"execution_count": 3,
65+
"execution_count": 7,
6666
"metadata": {},
6767
"output_type": "execute_result"
6868
}
@@ -81,7 +81,7 @@
8181
},
8282
{
8383
"cell_type": "code",
84-
"execution_count": 4,
84+
"execution_count": 8,
8585
"metadata": {
8686
"jupyter": {
8787
"source_hidden": true
@@ -91,19 +91,27 @@
9191
{
9292
"data": {
9393
"text/html": [
94-
"<iframe src=\"_static/NotebookClassic.html\" id=\"NotebookClassic\" width=\"100%\"></iframe>"
94+
"\n",
95+
" <iframe\n",
96+
" width=\"100%\"\n",
97+
" height=\"\"\n",
98+
" src=\"_static/notebook.html\"\n",
99+
" frameborder=\"0\"\n",
100+
" allowfullscreen\n",
101+
" ></iframe>\n",
102+
" "
95103
],
96104
"text/plain": [
97-
"<IPython.core.display.HTML object>"
105+
"<IPython.lib.display.IFrame at 0x7fda84204a58>"
98106
]
99107
},
100-
"execution_count": 4,
108+
"execution_count": 8,
101109
"metadata": {},
102110
"output_type": "execute_result"
103111
}
104112
],
105113
"source": [
106-
"iframe(\"NotebookClassic\")"
114+
"iframe(\"notebook\")"
107115
]
108116
},
109117
{
@@ -116,7 +124,7 @@
116124
},
117125
{
118126
"cell_type": "code",
119-
"execution_count": 4,
127+
"execution_count": 9,
120128
"metadata": {
121129
"jupyter": {
122130
"source_hidden": true
@@ -130,23 +138,23 @@
130138
" <iframe\n",
131139
" width=\"100%\"\n",
132140
" height=\"\"\n",
133-
" src=\"_static/JupyterLab.html\"\n",
141+
" src=\"_static/jupyterlab.html\"\n",
134142
" frameborder=\"0\"\n",
135143
" allowfullscreen\n",
136144
" ></iframe>\n",
137145
" "
138146
],
139147
"text/plain": [
140-
"<IPython.lib.display.IFrame at 0x7ff15c5cca20>"
148+
"<IPython.lib.display.IFrame at 0x7fda842042b0>"
141149
]
142150
},
143-
"execution_count": 4,
151+
"execution_count": 9,
144152
"metadata": {},
145153
"output_type": "execute_result"
146154
}
147155
],
148156
"source": [
149-
"iframe(\"JupyterLab\")"
157+
"iframe(\"jupyterlab\")"
150158
]
151159
}
152160
],

docs/conf.py

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,54 @@
1-
# -*- coding: utf-8 -*-
2-
#
3-
# Configuration file for the Sphinx documentation builder.
4-
#
5-
# This file does only contain a selection of the most common options. For a
6-
# full list see the documentation:
7-
# http://www.sphinx-doc.org/en/master/config
1+
""" Documentation configuration and workflow for JupyterLibrary
82
3+
Unlike the JupyterLibrary core, this may use Python3 syntax.
4+
"""
95
import subprocess
106
import sys
117
from pathlib import Path
128
from tempfile import TemporaryDirectory
139

1410
import nbsphinx
1511

12+
# you have to have run `python -m pip install -e`
13+
from JupyterLibrary.core import CLIENTS
14+
15+
16+
def setup(app):
17+
""" Runs before the "normal business" of sphinx. Don't go too crazy here.
18+
"""
19+
here = Path(__file__).parent
20+
21+
subprocess.check_call(
22+
[
23+
sys.executable,
24+
"-m",
25+
"robot.libdoc",
26+
"JupyterLibrary",
27+
str(here / "_static" / "JupyterLibrary.html"),
28+
]
29+
)
30+
31+
for client_dir in CLIENTS:
32+
client = Path(client_dir)
33+
with TemporaryDirectory() as td:
34+
tdp = Path(td)
35+
agg = ""
36+
for sub in client.rglob("*.robot"):
37+
agg += sub.read_text()
38+
out_file = Path(tdp / f"{client.name}.robot")
39+
out_file.write_text(agg)
40+
subprocess.run(
41+
[
42+
sys.executable,
43+
"-m",
44+
"robot.libdoc",
45+
str(out_file),
46+
str(here / "_static" / f"{client.name}.html"),
47+
]
48+
)
49+
50+
app.add_css_file("css/custom.css")
51+
1652

1753
nbsphinx.RST_TEMPLATE = nbsphinx.RST_TEMPLATE.replace(
1854
"""{% block input -%}""",
@@ -215,41 +251,3 @@
215251

216252
# If true, `todo` and `todoList` produce output, else they produce nothing.
217253
todo_include_todos = True
218-
219-
220-
def setup(app):
221-
here = Path(__file__).parent
222-
root = here.parent.resolve()
223-
224-
subprocess.check_call(
225-
[
226-
sys.executable,
227-
"-m",
228-
"robot.libdoc",
229-
"JupyterLibrary",
230-
str(here / "_static" / "JupyterLibrary.html"),
231-
]
232-
)
233-
234-
client_resources = root / "src" / "JupyterLibrary" / "resources"
235-
236-
print("looking for resources in", client_resources)
237-
for client in client_resources.glob("*"):
238-
with TemporaryDirectory() as td:
239-
tdp = Path(td)
240-
agg = ""
241-
for sub in client.rglob("*.robot"):
242-
agg += sub.read_text()
243-
out_file = Path(tdp / f"{client.name}.robot")
244-
out_file.write_text(agg)
245-
subprocess.run(
246-
[
247-
sys.executable,
248-
"-m",
249-
"robot.libdoc",
250-
str(out_file),
251-
str(here / "_static" / f"{client.name}.html"),
252-
]
253-
)
254-
255-
app.add_css_file("css/custom.css")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# JupyterLibrary Clients
2+
3+
To make it as easy as possible for a tester to become a contributor, individual
4+
client libraries are implemented as Robot Keywords. Look through the examples
5+
when building your new client library, and when possible provide similar
6+
capabilities and phrasings as the other libraries.
7+
8+
While not a hard requirement, if your users can install your frontend, it would
9+
be great if the directory here was named as the importable/installable name
10+
that they would use

src/JupyterLibrary/resources/JupyterLab/Commands.robot renamed to src/JupyterLibrary/clients/jupyterlab/Commands.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Resource JupyterLibrary/resources/JupyterLab/Selectors.robot
2+
Resource JupyterLibrary/clients/jupyterlab/Selectors.robot
33

44

55
*** Keywords ***

src/JupyterLibrary/resources/JupyterLab/Launcher.robot renamed to src/JupyterLibrary/clients/jupyterlab/Launcher.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Resource JupyterLibrary/resources/JupyterLab/Selectors.robot
2+
Resource JupyterLibrary/clients/jupyterlab/Selectors.robot
33

44
*** Keywords ***
55
Launch a new JupyterLab Document

src/JupyterLibrary/resources/JupyterLab/Notebook.robot renamed to src/JupyterLibrary/clients/jupyterlab/Notebook.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Resource JupyterLibrary/resources/JupyterLab/Selectors.robot
2+
Resource JupyterLibrary/clients/jupyterlab/Selectors.robot
33

44
*** Keywords ***
55
Add and Run JupyterLab Code Cell

src/JupyterLibrary/resources/JupyterLab/Output.robot renamed to src/JupyterLibrary/clients/jupyterlab/Output.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Resource JupyterLibrary/resources/JupyterLab/Selectors.robot
2+
Resource JupyterLibrary/clients/jupyterlab/Selectors.robot
33

44
*** Keywords ***
55
Screenshot Each Output of Active JupyterLab Cell

src/JupyterLibrary/resources/JupyterLab/Selectors.robot renamed to src/JupyterLibrary/clients/jupyterlab/Selectors.robot

File renamed without changes.

src/JupyterLibrary/resources/JupyterLab/Shell.robot renamed to src/JupyterLibrary/clients/jupyterlab/Shell.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Resource JupyterLibrary/resources/JupyterLab/Selectors.robot
2+
Resource JupyterLibrary/clients/jupyterlab/Selectors.robot
33
Documentation Keywords for working with the JupyterLab web application
44
... You should have already started a Jupyter Server, such as with
55
... *Wait For New Jupyter Server To Be Ready*.

src/JupyterLibrary/resources/JupyterLab/Sidebar.robot renamed to src/JupyterLibrary/clients/jupyterlab/Sidebar.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*** Settings ***
2-
Resource JupyterLibrary/resources/JupyterLab/Selectors.robot
2+
Resource JupyterLibrary/clients/jupyterlab/Selectors.robot
33

44

55
*** Keywords ***

0 commit comments

Comments
 (0)