@@ -982,11 +982,10 @@ def has_wildcard(pattern: str) -> bool:
982982 matched = pattern
983983 sidebars = pat_sidebars
984984
985- if len (sidebars ) == 0 :
986- # keep defaults
987- pass
988-
989- ctx ['sidebars' ] = list (sidebars )
985+ # See error_on_html_sidebars_string_values.
986+ # Replace with simple list coercion in Sphinx 8.0
987+ # xref: RemovedInSphinx80Warning
988+ ctx ['sidebars' ] = sidebars
990989
991990 # --------- these are overwritten by the serialization builder
992991
@@ -1287,6 +1286,25 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:
12871286 config .html_favicon = None
12881287
12891288
1289+ def error_on_html_sidebars_string_values (app : Sphinx , config : Config ) -> None :
1290+ """Support removed in Sphinx 2."""
1291+ errors = {}
1292+ for pattern , pat_sidebars in config .html_sidebars .items ():
1293+ if isinstance (pat_sidebars , str ):
1294+ errors [pattern ] = [pat_sidebars ]
1295+ if not errors :
1296+ return
1297+ msg = __ ("Values in 'html_sidebars' must be a list of strings. "
1298+ "At least one pattern has a string value: %s. "
1299+ "Change to `html_sidebars = %r`." )
1300+ bad_patterns = ', ' .join (map (repr , errors ))
1301+ fixed = config .html_sidebars | errors
1302+ logger .error (msg , bad_patterns , fixed )
1303+ # Enable hard error in next major version.
1304+ # xref: RemovedInSphinx80Warning
1305+ # raise ConfigError(msg % (bad_patterns, fixed))
1306+
1307+
12901308def error_on_html_4 (_app : Sphinx , config : Config ) -> None :
12911309 """Error on HTML 4."""
12921310 if config .html4_writer :
@@ -1357,6 +1375,7 @@ def setup(app: Sphinx) -> ExtensionMetadata:
13571375 app .connect ('config-inited' , validate_html_static_path , priority = 800 )
13581376 app .connect ('config-inited' , validate_html_logo , priority = 800 )
13591377 app .connect ('config-inited' , validate_html_favicon , priority = 800 )
1378+ app .connect ('config-inited' , error_on_html_sidebars_string_values , priority = 800 )
13601379 app .connect ('config-inited' , error_on_html_4 , priority = 800 )
13611380 app .connect ('builder-inited' , validate_math_renderer )
13621381 app .connect ('html-page-context' , setup_resource_paths )
0 commit comments