@@ -1040,31 +1040,30 @@ def get_output_path(self, page_name: str, /) -> Path:
10401040 def get_outfilename (self , pagename : str ) -> _StrPath :
10411041 return _StrPath (self .get_output_path (pagename ))
10421042
1043- def add_sidebars (self , pagename : str , ctx : dict [str , Any ]) -> None :
1044- def has_wildcard (pattern : str ) -> bool :
1045- return any (char in pattern for char in '*?[' )
1046-
1043+ def _get_sidebars (self , pagename : str , / ) -> tuple [str , ...]:
10471044 matched = None
10481045
10491046 # default sidebars settings for selected theme
1050- sidebars = list ( self .theme .sidebar_templates )
1047+ sidebars = self .theme .sidebar_templates
10511048
10521049 # user sidebar settings
10531050 html_sidebars = self .get_builder_config ('sidebars' , 'html' )
10541051 msg = __ ('page %s matches two patterns in html_sidebars: %r and %r' )
10551052 for pattern , pat_sidebars in html_sidebars .items ():
10561053 if patmatch (pagename , pattern ):
1057- if matched and has_wildcard (pattern ):
1054+ if matched and _has_wildcard (pattern ):
10581055 # warn if both patterns contain wildcards
1059- if has_wildcard (matched ):
1056+ if _has_wildcard (matched ):
10601057 logger .warning (msg , pagename , matched , pattern )
10611058 # else the already matched pattern is more specific
10621059 # than the present one, because it contains no wildcard
10631060 continue
10641061 matched = pattern
1065- sidebars = pat_sidebars
1062+ sidebars = tuple (pat_sidebars )
1063+ return sidebars
10661064
1067- ctx ['sidebars' ] = list (sidebars )
1065+ def add_sidebars (self , pagename : str , ctx : dict [str , Any ]) -> None :
1066+ ctx ['sidebars' ] = list (self ._get_sidebars (pagename ))
10681067
10691068 # --------- these are overwritten by the serialization builder
10701069
@@ -1123,7 +1122,7 @@ def hasdoc(name: str) -> bool:
11231122 ctx ['hasdoc' ] = hasdoc
11241123
11251124 ctx ['toctree' ] = lambda ** kwargs : self ._get_local_toctree (pagename , ** kwargs )
1126- self .add_sidebars (pagename , ctx )
1125+ ctx [ 'sidebars' ] = list ( self ._get_sidebars (pagename ) )
11271126 ctx .update (addctx )
11281127
11291128 # 'blah.html' should have content_root = './' not ''.
@@ -1292,6 +1291,10 @@ def dump_search_index(self) -> None:
12921291 Path (search_index_tmp ).replace (search_index_path )
12931292
12941293
1294+ def _has_wildcard (pattern : str , / ) -> bool :
1295+ return any (char in pattern for char in '*?[' )
1296+
1297+
12951298def convert_html_css_files (app : Sphinx , config : Config ) -> None :
12961299 """Convert string styled html_css_files to tuple styled one."""
12971300 html_css_files : list [tuple [str , dict [str , str ]]] = []
0 commit comments