File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ ( function ( ) {
2+ /* Reformats last part of 'whatsnew' URLs */
3+ const generateWhatsNew = ( whatsNew ) => {
4+ let url = whatsNew [ 0 ] , anchor = whatsNew [ 1 ] ;
5+ url = ( ( url ) => url . split ( "." ) [ 0 ] + "/" ) ( url ) ;
6+ let anchorEls = anchor . slice ( 9 ) . split ( "-" ) ;
7+ anchorEls [ 0 ] = ( ( version ) => "v" + version . slice ( 0 , 1 ) + "." + version . slice ( 1 , - 1 ) + "." + version . slice ( - 1 ) + ".html#" ) ( anchorEls [ 0 ] ) ;
8+ return url + anchorEls [ 0 ] + anchorEls . slice ( 1 ) . join ( "-" ) ;
9+ }
10+
11+ const links = Array . from ( document . getElementsByTagName ( "a" ) ) ;
12+ links . forEach ( ( link ) => {
13+ const re = / ( w h a t s n e w .h t m l ) # ( w h a t s n e w ) - [ \d ] + ( - \w + ) + / g;
14+ let linkElements = link . href . split ( "/" ) ;
15+ if ( re . test ( linkElements . slice ( - 1 ) [ 0 ] ) ) {
16+ let whatsNew = linkElements . slice ( - 1 ) [ 0 ] . split ( "#" ) ;
17+ whatsNew = generateWhatsNew ( whatsNew ) ;
18+ linkElements [ linkElements . length - 1 ] = whatsNew ;
19+ link . href = linkElements . join ( "/" )
20+ }
21+ } ) ;
22+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -698,3 +698,4 @@ def setup(app):
698698 app .add_autodocumenter (AccessorMethodDocumenter )
699699 app .add_autodocumenter (AccessorCallableDocumenter )
700700 app .add_directive ('autosummary' , PandasAutosummary )
701+ app .add_js ('js/whatsnew_links.js' )
You can’t perform that action at this time.
0 commit comments