77import  sys 
88import  warnings 
99
10- import  pyvista 
1110import  numpy  as  np 
12- import  json 
1311from  sphinx_gallery .sorting  import  FileNameSortKey 
1412from  ansys_sphinx_theme  import  (ansys_favicon , 
1513                                get_version_match , pyansys_logo_black ,
@@ -230,26 +228,27 @@ def setup(app):
230228# The name of the Pygments (syntax highlighting) style to use. 
231229pygments_style  =  "sphinx" 
232230
233- # Manage errors 
234- pyvista .set_error_output_file ("errors.txt" )
235- 
236- # Ensure that offscreen rendering is used for docs generation 
237- pyvista .OFF_SCREEN  =  True 
238- 
239- # Preferred plotting style for documentation 
240- # pyvista.set_plot_theme('document') 
241- 
242- # must be less than or equal to the XVFB window size 
243- pyvista .global_theme ["window_size" ] =  np .array ([1024 , 768 ])
244- 
245- # Save figures in specified directory 
246- pyvista .FIGURE_PATH  =  os .path .join (os .path .abspath ("./images/" ), "auto-generated/" )
247- if  not  os .path .exists (pyvista .FIGURE_PATH ):
248-     os .makedirs (pyvista .FIGURE_PATH )
249231
250232# gallery build requires AEDT install 
251233# if is_windows and bool(os.getenv("PYAEDT_CI_RUN_EXAMPLES", "0")): 
252234if  run_examples :
235+     import  pyvista 
236+ 
237+     # # Pyvista settings 
238+ 
239+     # Ensure that offscreen rendering is used for docs generation 
240+     pyvista .OFF_SCREEN  =  True 
241+     # Save figures in specified directory 
242+     pyvista .FIGURE_PATH  =  os .path .join (os .path .abspath ("./images/" ), "auto-generated/" )
243+     if  not  os .path .exists (pyvista .FIGURE_PATH ):
244+         os .makedirs (pyvista .FIGURE_PATH )
245+     # Necessary for pyvista when building the sphinx gallery 
246+     pyvista .BUILDING_GALLERY  =  True 
247+ 
248+     # Manage errors 
249+     pyvista .set_error_output_file ("errors.txt" )
250+     # Must be less than or equal to the XVFB window size 
251+     pyvista .global_theme ["window_size" ] =  np .array ([1024 , 768 ])
253252
254253    # suppress annoying matplotlib bug 
255254    warnings .filterwarnings (
@@ -258,9 +257,6 @@ def setup(app):
258257        message = "Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." ,
259258    )
260259
261-     # necessary for pyvista when building the sphinx gallery 
262-     pyvista .BUILDING_GALLERY  =  True 
263- 
264260    extensions .append ("sphinx_gallery.gen_gallery" )
265261    sphinx_gallery_conf  =  {
266262        # convert rst to md for ipynb 
@@ -289,18 +285,6 @@ def setup(app):
289285        "run_examples" : run_examples ,
290286    },
291287}
292- # def prepare_jinja_env(jinja_env) -> None: 
293- #     """ 
294- #     Customize the jinja env. 
295- # 
296- #     Notes 
297- #     ----- 
298- #     See https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment 
299- #     """ 
300- #     jinja_env.globals["project_name"] = project 
301- # 
302- # 
303- # autoapi_prepare_jinja_env = prepare_jinja_env 
304288
305289# -- Options for HTML output ------------------------------------------------- 
306290html_short_title  =  html_title  =  "PyAEDT" 
0 commit comments