@@ -30,7 +30,7 @@ layout: home
3030hero:
3131 name: SymbolicRegression.jl
3232 text: Discover Mathematical Laws from Data
33- tagline: A flexible, user-friendly framework that automatically finds interpretable equations from your data
33+ tagline: Fast, flexible evolutionary algorithms for interpretable machine learning
3434 actions:
3535 - theme: brand
3636 text: Get Started
@@ -190,6 +190,14 @@ function fix_vitepress_base_path()
190190 " /SymbolicRegression.jl/dev/"
191191 end
192192
193+ # The version picker should link to sibling versions that live one
194+ # directory above the active version, e.g. `/symbolicregression/v1.12.0/`.
195+ # Compute that shared prefix (always the first path segment) so that we can
196+ # rewrite `__DEPLOY_ABSPATH__` accordingly.
197+ stripped = isempty (base_path) ? base_path : rstrip (base_path, ' /' )
198+ segments = split (stripped, ' /' ; keepempty= false )
199+ deploy_abspath = isempty (segments) ? " /" : " /" * first (segments) * " /"
200+
193201 # Find and fix VitePress SOURCE config file (before build)
194202 config_paths = [joinpath (@__DIR__ , " src" , " .vitepress" , " config.mts" )]
195203
@@ -201,18 +209,57 @@ function fix_vitepress_base_path()
201209 # Replace the base path with the correct one for this deployment
202210 # Look for existing base: '...' patterns and replace them
203211 content = replace (content, r" base:\s *'[^']*'" => " base: '$base_path '" )
212+ content = replace (
213+ content,
214+ r" __DEPLOY_ABSPATH__\s *:\s *JSON\. stringify\( '[^']*'\) " =>
215+ " __DEPLOY_ABSPATH__: JSON.stringify('$deploy_abspath ')" ,
216+ )
204217
205218 write (config_path, content)
206- @info " Updated VitePress base path to: $base_path "
219+ @info " Updated VitePress base path to: $base_path (deploy abspath: $deploy_abspath ) "
207220 else
208221 @warn " VitePress config not found at: $config_path "
209222 end
210223 end
211224end
212225
226+ # Generate favicon files from logo.png
227+ function generate_favicons ()
228+ logo_path = joinpath (@__DIR__ , " src" , " assets" , " logo.png" )
229+ public_dir = joinpath (@__DIR__ , " src" , " public" )
230+
231+ if ! isfile (logo_path)
232+ @warn " Logo file not found at: $logo_path - skipping favicon generation"
233+ return false
234+ end
235+
236+ mkpath (public_dir)
237+
238+ @info " Generating favicon files from logo.png..."
239+
240+ # Generate different sizes
241+ favicon_configs = [
242+ (" favicon.ico" , " 32x32" ),
243+ (" favicon-16x16.png" , " 16x16" ),
244+ (" favicon-32x32.png" , " 32x32" ),
245+ (" apple-touch-icon.png" , " 180x180" ),
246+ ]
247+
248+ for (filename, size) in favicon_configs
249+ output_path = joinpath (public_dir, filename)
250+ run (` magick $(logo_path) -resize $(size) -background none -gravity center -extent $(size) $(output_path) ` )
251+ @info " Generated: $filename "
252+ end
253+
254+ return true
255+ end
256+
213257# Run preprocessing on source files before makedocs()
214258preprocess_source_index ()
215259
260+ # Generate favicons before building docs
261+ generate_favicons ()
262+
216263# Fix VitePress base path BEFORE makedocs() - this is crucial for timing!
217264fix_vitepress_base_path ()
218265
@@ -240,6 +287,20 @@ else
240287 )
241288end
242289
290+ current_version = let
291+ version = get (ENV , " DOCUMENTER_VERSION" , nothing )
292+ if version != = nothing && ! isempty (version)
293+ version
294+ else
295+ fallback = get (ENV , " DOCUMENTER_CURRENT_VERSION" , nothing )
296+ if fallback != = nothing && ! isempty (fallback)
297+ fallback
298+ else
299+ " dev"
300+ end
301+ end
302+ end
303+
243304DocMeta. setdocmeta! (
244305 SymbolicRegression,
245306 :DocTestSetup ,
@@ -250,6 +311,7 @@ DocMeta.setdocmeta!(
250311makedocs (;
251312 sitename= " SymbolicRegression.jl" ,
252313 authors= " Miles Cranmer" ,
314+ current_version= current_version,
253315 doctest= true ,
254316 clean= get (ENV , " DOCUMENTER_PRODUCTION" , " false" ) == " true" ,
255317 warnonly= [:docs_block , :cross_references , :missing_docs ],
@@ -291,9 +353,19 @@ post_process_vitepress_index()
291353function fix_empty_bases ()
292354 bases_file = joinpath (@__DIR__ , " build" , " bases.txt" )
293355 mkpath (dirname (bases_file))
294- if ! isfile (bases_file) || isempty (filter (! isempty, readlines (bases_file)))
295- @info " Creating/fixing bases.txt for deployment"
356+
357+ if ! isfile (bases_file)
358+ @info " Creating bases.txt for dev deployment"
296359 write (bases_file, " dev\n " )
360+ else
361+ bases = filter (! isempty, readlines (bases_file))
362+ if isempty (bases)
363+ @info " Fixing empty bases.txt for dev deployment"
364+ write (bases_file, " dev\n " )
365+ else
366+ @info " bases.txt already exists with $(length (bases)) bases: $bases "
367+ # Don't overwrite it - DocumenterVitepress may have generated multiple bases
368+ end
297369 end
298370end
299371
0 commit comments