-
Notifications
You must be signed in to change notification settings - Fork 619
Link to the correct PEP source file. #1195
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
Conversation
Some PEPs are using the .rst extension, and many are in .txt. The source link currently assumes that all the PEPs are using the .txt extension. Fixes python/peps#431
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 good to me, I just left some comments on cosmetic issues. Thanks!
peps/converters.py
Outdated
@@ -181,7 +181,14 @@ def convert_pep_page(pep_number, content): | |||
|
|||
data['content'] = str(pep_content) | |||
|
|||
source_link = "https://github.com/python/peps/blob/master/pep-{0}.txt".format(pep_number) | |||
pep_ext = ".txt" | |||
pep_rst_source = os.path.join(settings.PEP_REPO_PATH, |
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.
That's pretty clever! I never thought about using settings.PEP_REPO_PATH
.
peps/converters.py
Outdated
@@ -181,7 +181,14 @@ def convert_pep_page(pep_number, content): | |||
|
|||
data['content'] = str(pep_content) | |||
|
|||
source_link = "https://github.com/python/peps/blob/master/pep-{0}.txt".format(pep_number) | |||
pep_ext = ".txt" |
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.
Style nit: I'm trying to use single quotes in new code. Can we change these to single quotes?
peps/converters.py
Outdated
if os.path.exists(pep_rst_source): | ||
pep_ext = ".rst" | ||
|
||
source_link = "https://github.com/python/peps/blob/master/pep-{0}{1}".format( |
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.
Style nit: {0}{1} -> {}{}
@@ -25,6 +25,16 @@ def test_source_link(self): | |||
) | |||
|
|||
@override_settings(PEP_REPO_PATH=FAKE_PEP_REPO) | |||
def test_source_link_rst(self): | |||
pep = get_pep_page('0012') |
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.
Is it possible to make the content of the PEP shorter?
Thanks @berkerpeksag! I made the requested changes. Please re-check. |
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.
LGTM, but I suggest a more generic implementation (and not specific to the pair .txt/.rst
), if possible and if someone else agrees.
pep_rst_source = os.path.join(settings.PEP_REPO_PATH, | ||
'pep-{}.rst'.format(pep_number)) | ||
if os.path.exists(pep_rst_source): | ||
pep_ext = '.rst' |
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.
That's an OK solution for just .txt
or .rst
.
Wouldn't it be possible to write a generic test, by looking for a glob pattern pep-{}.*
and selecting the extension from that?
Because if the documentation system goes to .md
or whatever new extension, the website code would again have to be changed here!
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'm pretty sure we aren't going to support another documentation format (especially Markdown) within the Python organization. Plus, we are going to move all PEP infrastructure to RtD so YAGNI :)
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.
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.
And if we ever did, we'd probably move generation of the source link inside pep2html.py
in the PEP's repo (we were even considering that as an option this time).
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.
OK @ncoghlan, I see.
@Mariatta LGTM, please merge when you're ready. Note that current master is ahead of the release branch (for example, master is Django 1.11, release is Django 1.7) so I made the release branch protected in order to prevent accidental outages. I can do the cherry-picking if you need this PR immediately deployed to production. |
Thanks @Naereen and @berkerpeksag. Does this get deployed automatically to staging.python.org? I don't have access to a computer where I can do the cherry-pick, I can do it later this evening. If you can get to it before me, it's fine too :) |
Can't do it either. Sorry. |
Some PEPs are using the .rst extension, and many are in .txt. The source link assumed that all the PEPs are using the .txt extension. With this change, it will use the correct file extension. Fixes python/peps#431
Yes, it does.
Done in 9235355. |
Thanks @berkerpeksag! Hmm the link to PEP 12 in staging.p.o is still incorrect though In staging.p.o, it still links to the .txt file. |
For some reason the peps repo on staging.p.o didn't get updated since the beginning of September. I will check it out. Production version works as expected: https://www.python.org/dev/peps/pep-0547/ |
Some PEPs are using the .rst extension, and many are in .txt.
The source link currently assumes that all the PEPs are using
the .txt extension.
Fixes python/peps#431