-
Notifications
You must be signed in to change notification settings - Fork 22.1k
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
DOC: dynamically create a version pull-down using javascript #46652
Conversation
docs/source/_static/docversions.js
Outdated
open_list = '<li id="current">' | ||
} | ||
} | ||
const pathPattern = /docs\/(build\/html|stable|master|[0-9.rc]+)(.*)/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whether you build locally or deploy to pytorch/pytorch.github.io, the document URL will look like
file:///home/user/pytorch/docs/build/html/generated/torch.nn.parameter.Parameter.html
or
https://pytorch.org/docs/1.6.0/generated/torch.nn.parameter.Parameter.html
So the docs
part is a consistent anchor, then either build/html
or one of the versions (stable',
master,
1.6.0` etc), then the actual document name we are interested in.
document.write(open_list); | ||
document.write('<a id=ID href="URL">VERSION</a> </li>\n' | ||
.replace('VERSION', label) | ||
.replace('URL', url)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't get this to work with async: true
and then rewriting the item.href
.
<script type="text/javascript" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/docversions.js', 1) }}"></script> | ||
{{ super() }} | ||
{% endblock %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This si the bit that should be upstreamed to the theme (without the _static/docversions.js
). Is there a reason they have it so late in the template there? Connected to {% if not embedded %}
?
{% endif %} | ||
{% endif %} | ||
{% endblock %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block overrides the original sidebartitle block
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 766bafb (more details on the Dr. CI page): Commit 766bafb was recently pushed. Waiting for builds... This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
Hi @mattip! Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours needs attention. You currently have a record in our system, but we do not have a signature on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the preview for this and I think it's good. Would love to see this added to release going forward, and master. (We don't need to rebuild previous versions.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks mostly good, just one minor nit
Co-authored-by: Eli Uriegas <1700823+seemethere@users.noreply.github.com>
Converted to Draft, @ranman is going to work on some changes. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
This was mostly a proof-of-concept. Closing. At some point, the pytorch doc team may want to look at how the pydata theme implemented a version pulldown. |
Enhancement to create a version pulldown rather than a link to a static list of
versions.html
ul
list of versions on document loading (provides consistency across documentation versions)I could not get the page existence check to work asynchronously, so page loading time takes a hit. Is the UX improvement worth it? I was basing this off the warning in the NumPy docs when you view older documentation, this is a page with no parallel in the latest version, so the message will pre-populate a search qeury (source code here). maybe I missed something? In any case, the NumPy script only needs to check for the latest page, my adaptaion scans all the versions.
Help here would be welcome from people fluent in web front-end programming.