@@ -445,6 +445,8 @@ def get_projects(basedir: str) -> list[ProjectEntry]:
445445# Used to render version list in the sidebar
446446VersionEntry = namedtuple ('VersionEntry' , 'version, url, diff_url' )
447447
448+ VersionPath = namedtuple ('VersionPath' , 'major, minor, path' )
449+
448450# Takes result of Query.get_versions() and prepares it for the sidebar template.
449451# Returns an OrderedDict with version information and optionally a triple with
450452# (major, minor, version) of current_version. The triple is useful, because sometimes
@@ -457,10 +459,10 @@ def get_projects(basedir: str) -> list[ProjectEntry]:
457459def get_versions (versions : OrderedDict [str , OrderedDict [str , str ]],
458460 get_url : Callable [[str ], str ],
459461 get_diff_url : Optional [Callable [[str ], str ]],
460- current_version : str ) -> Tuple [dict [str , dict [str , list [VersionEntry ]]], Tuple [ str | None , str | None , str | None ] ]:
462+ current_version : str ) -> Tuple [dict [str , dict [str , list [VersionEntry ]]], VersionPath ]:
461463
462464 result = OrderedDict ()
463- current_version_path = (None , None , None )
465+ current_version_path = VersionPath (None , None , None )
464466 for major , minor_verions in versions .items ():
465467 for minor , patch_versions in minor_verions .items ():
466468 for v in patch_versions :
@@ -472,10 +474,20 @@ def get_versions(versions: OrderedDict[str, OrderedDict[str, str]],
472474 VersionEntry (v , get_url (v ), get_diff_url (v ) if get_diff_url is not None else None )
473475 )
474476 if v == current_version :
475- current_version_path = (major , minor , v )
477+ current_version_path = VersionPath (major , minor , v )
476478
477479 return result , current_version_path
478480
481+ def find_version_path (versions : OrderedDict [str , OrderedDict [str , str ]],
482+ version : str ) -> VersionPath :
483+ for major , minor_verions in versions .items ():
484+ for minor , patch_versions in minor_verions .items ():
485+ for v in patch_versions :
486+ if v == version :
487+ return VersionPath (major , minor , v )
488+
489+ return VersionPath (None , None , None )
490+
479491def get_versions_cached (q , ctx , project ):
480492 with ctx .versions_cache_lock :
481493 if project not in ctx .versions_cache :
@@ -502,6 +514,7 @@ def get_layout_template_context(q: Query, ctx: RequestContext, get_url_with_new_
502514 'projects' : get_projects (ctx .config .project_dir ),
503515 'versions' : versions ,
504516 'current_version_path' : current_version_path ,
517+ 'other_version_path' : (None , None , None ),
505518 'topbar_families' : TOPBAR_FAMILIES ,
506519 'elixir_version_string' : ctx .config .version_string ,
507520 'elixir_repo_url' : ctx .config .repo_url ,
@@ -809,7 +822,8 @@ def generate_warning(type, version):
809822 warning = f'Files are the same in { version } and { version_other } .'
810823 else :
811824 missing_version = version_other if type == 'blob' else version
812- warning = f'File does not exist, or is not a file in { missing_version } . ({ version } displayed)'
825+ shown_version = version if type == 'blob' else version_other
826+ warning = f'File does not exist, or is not a file in { missing_version } . ({ shown_version } displayed)'
813827
814828 template_ctx = {
815829 'code' : generate_source (q , project , version if type == 'blob' else version_other , path ),
@@ -841,6 +855,7 @@ def generate_warning(type, version):
841855 ** get_layout_template_context (q , ctx , get_url_with_new_version , get_diff_url , project , version ),
842856 ** template_ctx ,
843857
858+ 'other_version_path' : find_version_path (get_versions_cached (q , ctx , project ), version_other ),
844859 'diff_mode_available' : True ,
845860 'diff_checked' : True ,
846861 'diff_exit_url' : stringify_source_path (project , version , path ),
0 commit comments