-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
DOC Use :doi: and :arxiv: directives for references #21099
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
dea00d1
DOC: use :doi: and :arxiv: directives for references
puhuk 5d92759
Update permutation_importance.rst
puhuk 4f50c25
Update semi_supervised.rst
puhuk 056a431
Update linear_model.rst
puhuk 627a6b2
Update linear_model.rst
puhuk 15cab74
Update kernel_approximation.rst
puhuk 61a3259
Update kernel_approximation.rst
puhuk fa7327b
Updates with issue #21088
puhuk 14794f2
Resolve issue #21088
puhuk 5e768d5
Update for PR #21099
puhuk a0094e7
Update with feedback
puhuk dabe843
Update doi_role.py
puhuk 8b66236
Update doi_role.py
puhuk 3182fac
Update doi_role.py
puhuk bcdc6d7
Update doi_role.py
puhuk 3e1a8d6
Merge remote-tracking branch 'origin' into issue_21088
puhuk 34ab3d6
Merge remote-tracking branch 'origin' into issue_21088
puhuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
doilinks | ||
~~~~~~~~ | ||
Extension to add links to DOIs. With this extension you can use e.g. | ||
:doi:`10.1016/S0022-2836(05)80360-2` in your documents. This will | ||
create a link to a DOI resolver | ||
(``https://doi.org/10.1016/S0022-2836(05)80360-2``). | ||
The link caption will be the raw DOI. | ||
You can also give an explicit caption, e.g. | ||
:doi:`Basic local alignment search tool <10.1016/S0022-2836(05)80360-2>`. | ||
|
||
:copyright: Copyright 2015 Jon Lund Steffensen. Based on extlinks by | ||
the Sphinx team. | ||
:license: BSD. | ||
""" | ||
|
||
from docutils import nodes, utils | ||
|
||
from sphinx.util.nodes import split_explicit_title | ||
|
||
|
||
def reference_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): | ||
text = utils.unescape(text) | ||
has_explicit_title, title, part = split_explicit_title(text) | ||
if typ in ["arXiv", "arxiv"]: | ||
full_url = "https://arxiv.org/abs/" + part | ||
if not has_explicit_title: | ||
title = "arXiv:" + part | ||
pnode = nodes.reference(title, title, internal=False, refuri=full_url) | ||
return [pnode], [] | ||
if typ in ["doi", "DOI"]: | ||
full_url = "https://doi.org/" + part | ||
if not has_explicit_title: | ||
title = "DOI:" + part | ||
pnode = nodes.reference(title, title, internal=False, refuri=full_url) | ||
return [pnode], [] | ||
|
||
|
||
def setup_link_role(app): | ||
app.add_role("arxiv", reference_role, override=True) | ||
app.add_role("arXiv", reference_role, override=True) | ||
app.add_role("doi", reference_role, override=True) | ||
app.add_role("DOI", reference_role, override=True) | ||
|
||
|
||
def setup(app): | ||
app.connect("builder-inited", setup_link_role) | ||
return {"version": "0.1", "parallel_read_safe": True} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The first link, https://www.researchgate.net/publication/233096619_A_Dendrite_Method_for_Cluster_Analysis gives free access to the paper while the doi does not have public access.
Since the version on
main
also has both links, I am okay with your change.