@@ -41,8 +41,8 @@ def __init__(
4141 self ,
4242 rawsource = "" ,
4343 * children ,
44- width = None ,
45- height = None ,
44+ width = "100%" ,
45+ height = "100%" ,
4646 replite_options = None ,
4747 ** attributes ,
4848 ):
@@ -54,12 +54,9 @@ def html(self):
5454 replite_options = self ["replite_options" ]
5555 options = "&" .join ([f"{ key } ={ value } " for key , value in replite_options .items ()])
5656
57- width = self ["width" ] if self ["width" ] is not None else "100%"
58- height = self ["height" ] if self ["height" ] is not None else "100%"
59-
6057 return (
6158 f'<iframe src="{ JUPYTERLITE_DIR } /repl/index.html?{ options } "'
62- f'width="{ width } " height="{ height } " style="{ IFRAME_STYLE } "></iframe>'
59+ f'width="{ self [ " width" ] } " height="{ self [ " height" ] } " style="{ IFRAME_STYLE } "></iframe>'
6360 )
6461
6562
@@ -80,8 +77,8 @@ class RepliteDirective(SphinxDirective):
8077 }
8178
8279 def run (self ):
83- width = self .options .pop ("width" , None )
84- height = self .options .pop ("height" , None )
80+ width = self .options .pop ("width" , "100%" )
81+ height = self .options .pop ("height" , "100%" )
8582
8683 if self .content :
8784 self .options ["code" ] = "" .join (self .content )
@@ -95,15 +92,23 @@ class RetroliteIframe(Element):
9592 Renders an iframe that shows a Notebook with RetroLite.
9693 """
9794
98- def __init__ (self , rawsource = "" , * children , notebook = None , ** attributes ):
99- super ().__init__ ("" , notebook = notebook )
95+ def __init__ (
96+ self ,
97+ rawsource = "" ,
98+ * children ,
99+ width = "100%" ,
100+ height = "1000px" ,
101+ notebook = None ,
102+ ** attributes ,
103+ ):
104+ super ().__init__ ("" , notebook = notebook , width = width , height = height )
100105
101106 def html (self ):
102107 notebook = self ["notebook" ]
103108
104109 return (
105110 f'<iframe src="{ JUPYTERLITE_DIR } /retro/notebooks/?path={ notebook } "'
106- f'width="100%" height="1000px " style="{ IFRAME_STYLE } "></iframe>'
111+ f'width="{ self [ "width" ] } " height="{ self [ "height" ] } " style="{ IFRAME_STYLE } "></iframe>'
107112 )
108113
109114
@@ -121,17 +126,16 @@ def run(self):
121126 notebook = self .arguments [0 ]
122127 notebook_name = os .path .basename (notebook )
123128
124- notebooks_dir = (
125- Path (self .env .app .srcdir )
126- / CONTENT_DIR
127- / notebook_name
128- )
129+ width = self .options .get ("width" , "100%" )
130+ height = self .options .get ("height" , "1000px" )
131+
132+ notebooks_dir = Path (self .env .app .srcdir ) / CONTENT_DIR / notebook_name
129133
130134 # Copy the Notebook for RetroLite to find
131135 os .makedirs (os .path .dirname (notebooks_dir ), exist_ok = True )
132136 shutil .copyfile (notebook , str (notebooks_dir ))
133137
134- return [RetroliteIframe (notebook = notebook_name )]
138+ return [RetroliteIframe (notebook = notebook_name , width = width , height = height )]
135139
136140
137141class RetroLiteParser (rst .Parser ):
@@ -155,7 +159,7 @@ def inited(app: Sphinx, error):
155159
156160
157161def jupyterlite_build (app : Sphinx , error ):
158- if app .builder .format == ' html' :
162+ if app .builder .format == " html" :
159163 print ("[jupyterlite-sphinx] Running JupyterLite build" )
160164
161165 config = []
0 commit comments