1010import sys
1111import urllib3
1212import shutil
13+ import numpy as np
1314sys .path .insert (0 , os .path .abspath ('..' ))
1415
1516import imkar # noqa
5556
5657# General information about the project.
5758project = 'imkar'
58- copyright = "2024 , The pyfar developers"
59+ copyright = "2025 , The pyfar developers"
5960author = "The pyfar developers"
6061
6162# The version info for the project you're documenting, acts as replacement
117118 "navbar_start" : ["navbar-logo" ],
118119 "navbar_end" : ["navbar-icon-links" , "theme-switcher" ],
119120 "navbar_align" : "content" ,
120- "header_links_before_dropdown" : 10 ,
121+ "header_links_before_dropdown" : None , # will be automatically set later based on headers.rst
122+ "header_dropdown_text" : "Packages" , # Change dropdown name from "More" to "Packages"
121123 "icon_links" : [
122124 {
123125 "name" : "GitHub" ,
144146}
145147
146148# -- download navbar and style files from gallery -----------------------------
149+ branch = 'main'
150+ link = f'https://github.com/pyfar/gallery/raw/{ branch } /docs/'
151+ folders_in = [
152+ '_static/css/custom.css' ,
153+ '_static/favicon.ico' ,
154+ '_static/header.rst' ,
155+ 'resources/logos/pyfar_logos_fixed_size_imkar.png' ,
156+ ]
157+
147158def download_files_from_gallery (link , folders_in ):
148159 c = urllib3 .PoolManager ()
149160 for file in folders_in :
@@ -155,14 +166,6 @@ def download_files_from_gallery(link, folders_in):
155166 with open (filename , 'wb' ) as out_file :
156167 shutil .copyfileobj (res , out_file )
157168
158- branch = 'main'
159- link = f'https://github.com/pyfar/gallery/raw/{ branch } /docs/'
160- folders_in = [
161- '_static/css/custom.css' ,
162- '_static/favicon.ico' ,
163- '_static/header.rst' ,
164- 'resources/logos/pyfar_logos_fixed_size_imkar.png' ,
165- ]
166169download_files_from_gallery (link , folders_in )
167170# if logo does not exist, use pyfar logo
168171if not os .path .exists (html_logo ):
@@ -179,5 +182,16 @@ def download_files_from_gallery(link, folders_in):
179182
180183 fout .writelines (lines )
181184
185+ # add project to the list of projects if not in header
182186 if not contains_project :
183187 fout .write (f' { project } <{ project } >\n ' )
188+
189+ # count the number of gallery headings
190+ count_gallery_headings = np .sum (
191+ ['https://pyfar-gallery.readthedocs.io' in line for line in lines ])
192+
193+
194+ # set dropdown header after gallery headings
195+ html_theme_options ['header_links_before_dropdown' ] = count_gallery_headings + 1
196+
197+
0 commit comments