1515__all__ = ["ON_RTD" , "PNG_ICON" , "SVG_ICON" , "get_html_theme_path" ]
1616
1717
18+ def get_theme_options (app ):
19+ """
20+ This gets the user configured options and the defaults and merges them.
21+ """
22+ return {** app .builder .theme .get_options (), ** utils .get_theme_options_dict (app )}
23+
24+
1825def get_html_theme_path ():
1926 """
2027 Return list of HTML theme paths.
@@ -23,66 +30,6 @@ def get_html_theme_path():
2330 return parent / "theme" / "sunpy"
2431
2532
26- def default_navbar ():
27- return [
28- (
29- "About" ,
30- [
31- ("Our Mission" , "about/" , 2 ),
32- ("SunPy Project" , "about/project/" , 2 ),
33- ("Presentations" , "about/presentations/" , 2 ),
34- ("Meetings" , "about/meetings/" , 2 ),
35- ("Code of Conduct" , "coc/" , 2 ),
36- ],
37- ),
38- (
39- "Documentation" ,
40- [
41- # Core goes first always
42- ("sunpy" , "https://docs.sunpy.org/" , 3 ),
43- # Other affiliated packages are in alphabetical order
44- ("aiapy" , "https://aiapy.readthedocs.io/" , 3 ),
45- ("dkist" , "https://docs.dkist.nso.edu/projects/python-tools" , 3 ),
46- ("drms" , "https://docs.sunpy.org/projects/drms/" , 3 ),
47- ("irispy" , "https://irispy.readthedocs.io/" , 3 ),
48- ("ndcube" , "https://docs.sunpy.org/projects/ndcube/" , 3 ),
49- ("roentgen" , "https://roentgen.readthedocs.io/" , 3 ),
50- ("scope" , "https://statistical-confidence-of-oscillatory-processes-with-emd.readthedocs.io" , 3 ),
51- ("solarmach" , "https://solarmach.readthedocs.io/en/stable/" , 3 ),
52- ("sunkit-image" , "https://docs.sunpy.org/projects/sunkit-image/" , 3 ),
53- ("sunkit-instruments " , "https://docs.sunpy.org/projects/sunkit-instruments/" , 3 ),
54- ("sunkit-magex" , "https://docs.sunpy.org/projects/sunkit-magex/" , 3 ),
55- ("sunkit-pyvista" , "https://docs.sunpy.org/projects/sunkit-pyvista/" , 3 ),
56- ("sunpy-soar" , "https://docs.sunpy.org/projects/soar/" , 3 ),
57- ("sunraster" , "https://docs.sunpy.org/projects/sunraster/" , 3 ),
58- ("xrtpy" , "https://xrtpy.readthedocs.io/" , 3 ),
59- # Provisional packages submenu
60- (
61- "Provisional" ,
62- [
63- ("pyflct" , "https://pyflct.readthedocs.io/" , 3 ),
64- ("radiospectra" , "https://docs.sunpy.org/projects/radiospectra/" , 3 ),
65- ],
66- ),
67- # Tools submenu
68- (
69- "Tools" ,
70- [
71- ("ablog" , "https://ablog.readthedocs.io/en/stable/" , 3 ),
72- ("mpl-animators" , "https://docs.sunpy.org/projects/mpl-animators/" , 3 ),
73- ("streamtracer" , "https://docs.sunpy.org/projects/streamtracer/" , 3 ),
74- ],
75- ),
76- ],
77- ),
78- ("Packages" , "affiliated/" , 2 ),
79- ("Get Help" , "help/" , 2 ),
80- ("Contribute" , "contribute/" , 2 ),
81- ("Blog" , "blog/" , 2 ),
82- ("Cite SunPy" , "https://docs.sunpy.org/en/stable/citation.html" , 3 ),
83- ]
84-
85-
8633def update_config (app ) -> None :
8734 """
8835 Update config with new default values and handle deprecated keys.
@@ -91,31 +38,20 @@ def update_config(app) -> None:
9138 # At this point, modifying app.config.html_theme_options will NOT update the
9239 # page's HTML context (e.g. in jinja, `theme_keyword`).
9340 # To do this, you must manually modify `app.builder.theme_options`.
94- theme_options = utils . get_theme_options_dict (app )
41+ theme_options = get_theme_options (app )
9542
9643 if theme_options .get ("sst_logo" ) and not isinstance (theme_options ["sst_logo" ], dict ):
9744 sst_logo = str (theme_options ["sst_logo" ])
9845 theme_options ["sst_logo" ] = {"light" : sst_logo , "dark" : sst_logo }
9946
10047 theme_options ["sst_is_root" ] = bool (theme_options .get ("sst_is_root" , False ))
10148
102- if not theme_options .get ("navbar_links" ):
103- theme_options ["navbar_links" ] = default_navbar ()
104-
105- if not theme_options .get ("footer_links" , False ):
106- theme_options ["footer_links" ] = [
107- ("Code" , "https://github.com/sunpy" , 3 ),
108- ("Forum" , "https://community.openastronomy.org/c/sunpy" , 3 ),
109- ("Chat" , "https://openastronomy.element.io/#/room/#sunpy:openastronomy.org" , 3 ),
110- ]
111-
112- # TODO: This is nasty
11349 # Set the default value of show_source to False unless it's specified in the user config
114- if "html_show_sourcelink" not in app . config . _raw_config : # NOQA: SLF001
50+ if not utils . config_provided_by_user ( app , "html_show_sourcelink" ):
11551 app .config .html_show_sourcelink = False
11652
11753 # Set the logo to the sunpy logo unless it's overridden in the user config
118- if "html_logo" not in app . config . _raw_config : # NOQA: SLF001
54+ if not utils . config_provided_by_user ( app , "html_logo" ):
11955 app .config .html_logo = str (get_html_theme_path () / "static" / "img" / "sunpy_icon.svg" )
12056
12157
@@ -160,7 +96,7 @@ def generate_search_config(app):
16096 """
16197 This function parses the config for the "Documentation" section of the theme config.
16298 """
163- theme_config = utils . get_theme_options_dict (app )
99+ theme_config = get_theme_options (app )
164100 search_projects = theme_config .get ("rtd_search_projects" , None )
165101 if search_projects is None :
166102 navbar_links = theme_config ["navbar_links" ]
0 commit comments