29
29
logger = logging .getLogger (__name__ )
30
30
31
31
32
- def update_config (app ):
32
+ def update_config_deprecations (app ):
33
+ """Update deprecated config values and raise warnings.
34
+
35
+ Each section should contain a comment describing which release
36
+ to remove the deprecated value entirely.
37
+ """
33
38
theme_options = app .config .html_theme_options
39
+ config = app .config
34
40
35
41
# DEPRECATE >= v0.10
36
42
if theme_options .get ("search_bar_position" ) == "navbar" :
@@ -43,27 +49,41 @@ def update_config(app):
43
49
if theme_options .get ("left_sidebar_end" ):
44
50
theme_options ["primary_sidebar_end" ] = theme_options .get ("left_sidebar_end" )
45
51
logger .warning (
46
- "The configuration `left_sidebar_end` is deprecated."
52
+ "The configuration `left_sidebar_end` is deprecated. "
47
53
"Use `primary_sidebar_end`"
48
54
)
49
55
56
+ # DEPRECATE >= 0.13
50
57
if theme_options .get ("logo_text" ):
51
58
logo = theme_options .get ("logo" , {})
52
59
logo ["text" ] = theme_options .get ("logo_text" )
53
60
theme_options ["logo" ] = logo
54
61
logger .warning (
55
- "The configuration `logo_text` is deprecated." "Use `'logo': {'text': }`."
62
+ "The configuration `logo_text` is deprecated. " "Use `'logo': {'text': }`."
56
63
)
57
64
65
+ # DEPRECATE >= 0.13
58
66
if theme_options .get ("page_sidebar_items" ):
59
67
theme_options ["secondary_sidebar_items" ] = theme_options .get (
60
68
"page_sidebar_items"
61
69
)
62
70
logger .warning (
63
- "The configuration `page_sidebar_items` is deprecated."
71
+ "The configuration `page_sidebar_items` is deprecated. "
64
72
"Use `secondary_sidebar_items`."
65
73
)
66
74
75
+ # DEPRECATE >= 0.14
76
+ if hasattr (config , "html_logo" ):
77
+ config .__dict__ ["html_logo_url" ] = config .html_logo
78
+ logger .warning (
79
+ "Config value `html_logo` is deprecated. " "Use `html_logo_url` instead."
80
+ )
81
+
82
+
83
+ def update_config (app ):
84
+ """Update configuration values with defaults and validation."""
85
+ theme_options = app .config .html_theme_options
86
+
67
87
# Validate icon links
68
88
if not isinstance (theme_options .get ("icon_links" , []), list ):
69
89
raise ExtensionError (
@@ -1048,6 +1068,7 @@ def setup(app):
1048
1068
app .set_translator ("readthedocs" , BootstrapHTML5Translator , override = True )
1049
1069
app .set_translator ("readthedocsdirhtml" , BootstrapHTML5Translator , override = True )
1050
1070
1071
+ app .connect ("builder-inited" , update_config_deprecations )
1051
1072
app .connect ("builder-inited" , update_config )
1052
1073
app .connect ("html-page-context" , setup_edit_url )
1053
1074
app .connect ("html-page-context" , add_toctree_functions )
0 commit comments