Skip to content

DOC: Redirect old whatsnew links #23695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TomAugspurger opened this issue Nov 14, 2018 · 7 comments
Open

DOC: Redirect old whatsnew links #23695

TomAugspurger opened this issue Nov 14, 2018 · 7 comments
Labels

Comments

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Nov 14, 2018

In #21599 we're chagning the structure of our whatsnew. Previously the whatsnew for each version was concatenated into a single large file.

Consider a link to the anchor #whatsnew-0190-enhancements-other. There are three cases:

  1. Version-specific URLs like http://pandas.pydata.org/pandas-docs/version/0.23.0/whatsnew.html#whatsnew-0190-enhancements-other will continue to work. We don't have to change anything.
  2. People linking via /stable (which is probably more common), or to version 0.24.0 or higher will break. http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#whatsnew-0190-enhancements-other won't be a valid reference. We would need to rewrite it to http://pandas.pydata.org/pandas-docs/stable/releases/#whatsnew-0190-enhancements-other

We use nginx for our webserver at pandas.pydata.org. But AFAICT, we can't use a rewrite rule to redirect this links, since nginx doesn't see the anchor.

We should be able to detect this in Javascript. When we're on the whatsnew for 0.24.0 or greater, we want to look for anchors pointing to /whatsnew.html#whatsnew-<version> for 0.23.4 or older. Then we'd rewrite /whatsnew.html#whatsnew-<version>-<title> to /whatsnew/<version>.html#<title>. So a test case is

before: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#whatsnew-0190-enhancements-other
after:  http://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.19.0.html#other-enhancements
@ismailuddin
Copy link

I can write a script for this, but where exactly are the HTML template files defined, from which the script can be called? Or do you just want the code?

@TomAugspurger
Copy link
Contributor Author

Thanks. I think in doc/source/themes/nature_with_gtoc/. Right now we hardcode JS in layout.html. You could maybe split that out to a _static/ directory and load it if you want.

@ismailuddin
Copy link

ismailuddin commented Nov 14, 2018

I've written a script to replace the URL links, which makes some assumptions:

  • The version needs to be converted from '0190' to 'v0.19.0' every time, and there are always written as 1 digit, 2 digits, 1 digit?
  • The version number is always separated from the text by a dash '-'

If these assumptions are correct, I can make the PR. Since this PR includes no changes to Python code, are running / passing the tests necessary?

Also, is there any page with many such links to test it on?

ismailuddin@1f3fabe

@TomAugspurger
Copy link
Contributor Author

Thanks.

The 0190 comes from the filename, which didn't change (aside from .txt to .rst). It should always be 1 digit, 1 or 2 digits, 1 digit (1 or 2 for the middle since we have 0.4.x through 0.9.x).

The "version number" for your second bullet is hand-written.

$ ag '_whatsnew_\d+:' | sort | uniq

doc/source/whatsnew/v0.10.0.txt:1:.. _whatsnew_0100:
doc/source/whatsnew/v0.10.1.txt:1:.. _whatsnew_0101:
doc/source/whatsnew/v0.11.0.txt:1:.. _whatsnew_0110:
doc/source/whatsnew/v0.12.0.txt:1:.. _whatsnew_0120:
doc/source/whatsnew/v0.13.0.txt:1:.. _whatsnew_0130:
doc/source/whatsnew/v0.13.1.txt:1:.. _whatsnew_0131:
doc/source/whatsnew/v0.14.0.txt:1:.. _whatsnew_0140:
doc/source/whatsnew/v0.14.1.txt:1:.. _whatsnew_0141:
doc/source/whatsnew/v0.15.0.txt:1:.. _whatsnew_0150:
doc/source/whatsnew/v0.15.1.txt:1:.. _whatsnew_0151:
doc/source/whatsnew/v0.15.2.txt:1:.. _whatsnew_0152:
doc/source/whatsnew/v0.16.0.txt:1:.. _whatsnew_0160:
doc/source/whatsnew/v0.16.1.txt:1:.. _whatsnew_0161:
doc/source/whatsnew/v0.16.2.txt:1:.. _whatsnew_0162:
doc/source/whatsnew/v0.17.0.txt:1:.. _whatsnew_0170:
doc/source/whatsnew/v0.17.1.txt:1:.. _whatsnew_0171:
doc/source/whatsnew/v0.18.0.txt:1:.. _whatsnew_0180:
doc/source/whatsnew/v0.18.1.txt:1:.. _whatsnew_0181:
doc/source/whatsnew/v0.19.0.txt:1:.. _whatsnew_0190:
doc/source/whatsnew/v0.19.1.txt:1:.. _whatsnew_0191:
doc/source/whatsnew/v0.19.2.txt:1:.. _whatsnew_0192:
doc/source/whatsnew/v0.20.0.txt:1:.. _whatsnew_0200:
doc/source/whatsnew/v0.20.2.txt:1:.. _whatsnew_0202:
doc/source/whatsnew/v0.20.3.txt:1:.. _whatsnew_0203:
doc/source/whatsnew/v0.21.0.txt:1:.. _whatsnew_0210:
doc/source/whatsnew/v0.21.1.txt:1:.. _whatsnew_0211:
doc/source/whatsnew/v0.22.0.txt:1:.. _whatsnew_0220:
doc/source/whatsnew/v0.23.0.txt:1:.. _whatsnew_0230:
doc/source/whatsnew/v0.23.1.txt:1:.. _whatsnew_0231:
doc/source/whatsnew/v0.23.2.txt:1:.. _whatsnew_0232:
doc/source/whatsnew/v0.23.3.txt:1:.. _whatsnew_0233:
doc/source/whatsnew/v0.23.4.txt:1:.. _whatsnew_0234:
doc/source/whatsnew/v0.23.5.txt:1:.. _whatsnew_0235:
doc/source/whatsnew/v0.24.0.txt:1:.. _whatsnew_0240:
doc/source/whatsnew/v0.5.0.txt:2:.. _whatsnew_050:
doc/source/whatsnew/v0.6.0.txt:1:.. _whatsnew_060:
doc/source/whatsnew/v0.6.1.txt:2:.. _whatsnew_061:
doc/source/whatsnew/v0.7.0.txt:1:.. _whatsnew_0700:
doc/source/whatsnew/v0.7.1.txt:1:.. _whatsnew_0701:
doc/source/whatsnew/v0.7.2.txt:1:.. _whatsnew_0702:
doc/source/whatsnew/v0.7.3.txt:1:.. _whatsnew_0703:
doc/source/whatsnew/v0.8.0.txt:1:.. _whatsnew_080:
doc/source/whatsnew/v0.8.1.txt:1:.. _whatsnew_0801:
doc/source/whatsnew/v0.9.0.txt:1:.. _whatsnew_0900:
doc/source/whatsnew/v0.9.1.txt:1:.. _whatsnew_0901:

Some inconsistencies. 060 vs. 0700.

#21599 will hopefully be merged soon. If not, you can apply your changes on top of it to check the actual URLs.

@ismailuddin
Copy link

Ok so this update should deal with the variable version numbers, so reformatting links to either v0.6.0 or v0.24.0.

About #21599 , how would you like me to proceed?

ismailuddin@8f35b4f

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Nov 14, 2018

Just merged it into master, so you you merge that then you're good to go.

FYI, the doc build will be live in ~1 hour, whenever https://travis-ci.org/pandas-dev/pandas/jobs/455198927 finishes. Those will be uploaded to http://pandas-docs.github.io/pandas-docs-travis/ (you don't have to worry about redirecting anything on that domain)

@westurner
Copy link
Contributor

Thanks for this! A redirect map with a hook for parsing uri fragments could be a useful addition to Sphinx, as well.

You can add custom JavaScript to Sphinx templates with add_js_file() (was: add_javascript()) in conf.py.

https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_js_file

https://docs.readthedocs.io/en/latest/guides/adding-custom-css.html#adding-custom-css-or-javascript-to-a-sphinx-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants