@@ -444,6 +444,8 @@ def get_projects(basedir: str) -> list[ProjectEntry]:
444444# Used to render version list in the sidebar
445445VersionEntry = namedtuple ('VersionEntry' , 'version, url, diff_url' )
446446
447+ VersionPath = namedtuple ('VersionPath' , 'major, minor, path' )
448+
447449# Takes result of Query.get_versions() and prepares it for the sidebar template.
448450# Returns an OrderedDict with version information and optionally a triple with
449451# (major, minor, version) of current_version. The triple is useful, because sometimes
@@ -456,10 +458,10 @@ def get_projects(basedir: str) -> list[ProjectEntry]:
456458def get_versions (versions : OrderedDict [str , OrderedDict [str , str ]],
457459 get_url : Callable [[str ], str ],
458460 get_diff_url : Optional [Callable [[str ], str ]],
459- current_version : str ) -> Tuple [dict [str , dict [str , list [VersionEntry ]]], Tuple [ str | None , str | None , str | None ] ]:
461+ current_version : str ) -> Tuple [dict [str , dict [str , list [VersionEntry ]]], VersionPath ]:
460462
461463 result = OrderedDict ()
462- current_version_path = (None , None , None )
464+ current_version_path = VersionPath (None , None , None )
463465 for major , minor_verions in versions .items ():
464466 for minor , patch_versions in minor_verions .items ():
465467 for v in patch_versions :
@@ -471,10 +473,20 @@ def get_versions(versions: OrderedDict[str, OrderedDict[str, str]],
471473 VersionEntry (v , get_url (v ), get_diff_url (v ) if get_diff_url is not None else None )
472474 )
473475 if v == current_version :
474- current_version_path = (major , minor , v )
476+ current_version_path = VersionPath (major , minor , v )
475477
476478 return result , current_version_path
477479
480+ def find_version_path (versions : OrderedDict [str , OrderedDict [str , str ]],
481+ version : str ) -> VersionPath :
482+ for major , minor_verions in versions .items ():
483+ for minor , patch_versions in minor_verions .items ():
484+ for v in patch_versions :
485+ if v == version :
486+ return VersionPath (major , minor , v )
487+
488+ return VersionPath (None , None , None )
489+
478490def get_versions_cached (q , ctx , project ):
479491 with ctx .versions_cache_lock :
480492 if project not in ctx .versions_cache :
@@ -501,6 +513,7 @@ def get_layout_template_context(q: Query, ctx: RequestContext, get_url_with_new_
501513 'projects' : get_projects (ctx .config .project_dir ),
502514 'versions' : versions ,
503515 'current_version_path' : current_version_path ,
516+ 'other_version_path' : (None , None , None ),
504517 'topbar_families' : TOPBAR_FAMILIES ,
505518 'elixir_version_string' : ctx .config .version_string ,
506519 'elixir_repo_url' : ctx .config .repo_url ,
@@ -920,7 +933,8 @@ def generate_warning(type, version):
920933 warning = f'Files are the same in { version } and { version_other } .'
921934 else :
922935 missing_version = version_other if type == 'blob' else version
923- warning = f'File does not exist, or is not a file in { missing_version } . ({ version } displayed)'
936+ shown_version = version if type == 'blob' else version_other
937+ warning = f'File does not exist, or is not a file in { missing_version } . ({ shown_version } displayed)'
924938
925939 template_ctx = {
926940 'code' : generate_source (q , project , version if type == 'blob' else version_other , path ),
@@ -952,6 +966,7 @@ def generate_warning(type, version):
952966 ** get_layout_template_context (q , ctx , get_url_with_new_version , get_diff_url , project , version ),
953967 ** template_ctx ,
954968
969+ 'other_version_path' : find_version_path (get_versions_cached (q , ctx , project ), version_other ),
955970 'diff_mode_available' : True ,
956971 'diff_checked' : True ,
957972 'diff_exit_url' : stringify_source_path (project , version , path ),
0 commit comments