@@ -743,6 +743,7 @@ def jupyterlite_build(app: Sphinx, error):
743
743
if app .builder .format == "html" :
744
744
print ("[jupyterlite-sphinx] Running JupyterLite build" )
745
745
jupyterlite_config = app .env .config .jupyterlite_config
746
+ jupyterlite_overrides = app .env .config .jupyterlite_overrides
746
747
jupyterlite_contents = app .env .config .jupyterlite_contents
747
748
748
749
jupyterlite_dir = str (app .env .config .jupyterlite_dir )
@@ -752,9 +753,24 @@ def jupyterlite_build(app: Sphinx, error):
752
753
)
753
754
754
755
config = []
756
+ overrides = []
755
757
if jupyterlite_config :
756
758
config = ["--config" , jupyterlite_config ]
757
759
760
+ if jupyterlite_overrides :
761
+ # JupyterLite's build command does not validate the existence
762
+ # of the JSON file, so we do it ourselves.
763
+ # We will raise a FileNotFoundError if the file does not exist
764
+ # in the Sphinx project directory.
765
+ overrides_path = Path (app .srcdir ) / jupyterlite_overrides
766
+ if not Path (overrides_path ).exists ():
767
+ raise FileNotFoundError (
768
+ f"Overrides file { overrides_path } does not exist. "
769
+ "Please check your configuration."
770
+ )
771
+
772
+ overrides = ["--settings-overrides" , jupyterlite_overrides ]
773
+
758
774
if jupyterlite_contents is None :
759
775
jupyterlite_contents = []
760
776
elif isinstance (jupyterlite_contents , str ):
@@ -783,6 +799,7 @@ def jupyterlite_build(app: Sphinx, error):
783
799
"build" ,
784
800
"--debug" ,
785
801
* config ,
802
+ * overrides ,
786
803
* contents ,
787
804
"--contents" ,
788
805
os .path .join (app .srcdir , CONTENT_DIR ),
@@ -859,6 +876,7 @@ def setup(app):
859
876
860
877
# Config options
861
878
app .add_config_value ("jupyterlite_config" , None , rebuild = "html" )
879
+ app .add_config_value ("jupyterlite_overrides" , None , rebuild = "html" )
862
880
app .add_config_value ("jupyterlite_dir" , str (app .srcdir ), rebuild = "html" )
863
881
app .add_config_value ("jupyterlite_contents" , None , rebuild = "html" )
864
882
app .add_config_value ("jupyterlite_bind_ipynb_suffix" , True , rebuild = "html" )
0 commit comments