@@ -47,7 +47,7 @@ def write_file(reponame, targetdir, filename, data, tagname, date):
4747    # New file content and filename 
4848    filecontent  =  header  +  "\n "  +  data 
4949    filepath  =  os .path .join (targetdir ,dest_filepath (reponame , tagname )+ ".md" )
50-      
50+ 
5151    with  open (filepath , "w" ) as  text_file :
5252        text_file .write (filecontent )
5353    print ("Wrote file: " + filepath )
@@ -87,10 +87,14 @@ def checkout_repo(targetdir, reponame, repourl, checkoutdir, update_repos):
8787    if  not  os .path .exists (targetdir ):
8888        os .makedirs (targetdir )
8989
90+     # Sort tags in reverse order of commit date rather than git's default 
91+     # lexicographical order. 
92+     sorted_tags  =  sorted (repo .tags , key = lambda  t : t .commit .committed_datetime , reverse = True )
93+ 
9094    # Add "develop" and all tags 
9195    refs  =  []
9296    refs .append (repo .heads .develop )
93-     refs .extend (repo . tags )
97+     refs .extend (sorted_tags )
9498
9599    # Get all preface sections from the latest develop version 
96100    repo .head .reference  =  repo .heads .develop 
@@ -114,8 +118,11 @@ def checkout_repo(targetdir, reponame, repourl, checkoutdir, update_repos):
114118        date  =  ref .commit .committed_datetime 
115119        absurl  =  repourl .replace (".git" ,"" )+ "/tree/" + ref .name 
116120        write_file (reponame , targetdir , mainfile , data , tagname , date )
117-     
118-     shutil .copyfile (os .path .join (targetdir ,dest_filepath (reponame , "develop" )+ ".md" ), os .path .join (targetdir ,"_index.md" ))
121+ 
122+     # Use the most-recently-created tag as the "default" version of the 
123+     # specification to render when a user clicks on the "specification" tab 
124+     # and does not use a version-specific URL. 
125+     shutil .copyfile (os .path .join (targetdir ,dest_filepath (reponame , sorted_tags [0 ].name )+ ".md" ), os .path .join (targetdir ,"_index.md" ))
119126
120127    refs  =  []
121128    refs .extend (repo .tags )
0 commit comments