@@ -256,12 +256,16 @@ Voilà currently supports the following hooks:
256256 for authentication cookies, access request header details or modify the
257257 notebook before rendering for example:
258258
259+ .. blacken-docs:off
260+
259261 .. code-block :: python
260262
261263 def prelaunch_hook (req : tornado.web.RequestHandler,
262264 notebook : nbformat.NotebookNode,
263265 cwd : str ) -> Optional[nbformat.NotebookNode]:
264266
267+ .. blacken-docs:on
268+
265269 ``req ``
266270 refers to the Tornado RequestHandler, which you can use to check
267271 parameters, headers and so on.
@@ -305,10 +309,12 @@ There are two ways to add the hook function to Voilà:
305309 """ Add your prelaunch hook heere"""
306310 return notebook
307311
312+
308313 def page_config_hook_function (current_page_config , ** kwargs ):
309314 """ Modify the current_page_config"""
310315 return new_page_config
311316
317+
312318 c.VoilaConfiguration.prelaunch_hook = hook_function
313319 c.VoilaConfiguration.page_config_hook = page_config_hook
314320
@@ -337,7 +343,7 @@ There are two ways to add the hook function to Voilà:
337343 # these two blocks are done to avoid triggering errors i
338344 # papermill’s notebook loading logic
339345 for cell in notebook.cells:
340- if ' tags' not in cell.metadata:
346+ if " tags" not in cell.metadata:
341347 cell.metadata.tags = []
342348 if " papermill" not in notebook.metadata:
343349 notebook.metadata.papermill = {}
@@ -347,15 +353,15 @@ There are two ways to add the hook function to Voilà:
347353
348354
349355 def page_config_hook (
350- current_page_config : Dict[str , Any],
351- base_url : str ,
352- settings : Dict[str , Any],
353- log : Logger,
354- voila_configuration : VoilaConfiguration,
355- notebook_path : str
356- ):
357- page_config[' fullLabextensionsUrl' ] = ' /custom/labextensions_url'
358- return page_config
356+ current_page_config : Dict[str , Any],
357+ base_url : str ,
358+ settings : Dict[str , Any],
359+ log : Logger,
360+ voila_configuration : VoilaConfiguration,
361+ notebook_path : str ,
362+ ):
363+ page_config[" fullLabextensionsUrl" ] = " /custom/labextensions_url"
364+ return page_config
359365
360366 You can use both hooks at the same time by adding the following to your Voilà
361367app:
0 commit comments