File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -820,13 +820,12 @@ def run(self):
820820
821821 if notebook_unique_name is None :
822822 nb = examples_to_notebook (self .content , warning_text = warning_text )
823- preamble_path = Path ("try_examples_preamble.py" )
824- if preamble_path .is_file ():
825- preamble = preamble_path .read_text ()
826- # or raise an error if `preamble` is empty
827- if preamble :
828- # insert after the "experimental" warning
829- nb .cells .insert (1 , new_code_cell (preamble ))
823+
824+ preamble = self .env .config .try_examples_preamble
825+ if preamble :
826+ # insert after the "experimental" warning
827+ nb .cells .insert (1 , new_code_cell (preamble ))
828+
830829 self .content = None
831830 notebooks_dir = Path (self .env .app .srcdir ) / CONTENT_DIR
832831 notebook_unique_name = f"{ uuid4 ()} .ipynb" .replace ("-" , "_" )
@@ -1134,6 +1133,7 @@ def setup(app):
11341133 default = None ,
11351134 rebuild = "html" ,
11361135 )
1136+ app .add_config_value ("try_examples_preamble" , default = None , rebuild = "html" )
11371137
11381138 # Allow customising the button text for each directive (this is useful
11391139 # only when "new_tab" is set to True)
You can’t perform that action at this time.
0 commit comments