Skip to content

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

Merged
merged 2 commits into from
Nov 15, 2017
Merged

Conversation

Mariatta
Copy link
Member

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

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
Copy link
Member

@berkerpeksag berkerpeksag left a 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!

@@ -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,
Copy link
Member

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.

@@ -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"
Copy link
Member

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?

if os.path.exists(pep_rst_source):
pep_ext = ".rst"

source_link = "https://github.com/python/peps/blob/master/pep-{0}{1}".format(
Copy link
Member

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')
Copy link
Member

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?

@Mariatta
Copy link
Member Author

Thanks @berkerpeksag! I made the requested changes. Please re-check.

Copy link

@Naereen Naereen left a 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'
Copy link

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!

Copy link
Member

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 :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK @ncoghlan, I see.

@berkerpeksag
Copy link
Member

berkerpeksag commented Nov 15, 2017

@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.

@Mariatta Mariatta merged commit b89f75f into python:master Nov 15, 2017
@Mariatta Mariatta deleted the fix-source-url branch November 15, 2017 17:33
@Mariatta
Copy link
Member Author

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.
Is it a matter of git cherry-pick b89f75f7c9bdf9b42ea0c61e413b204bbd59e6a1 to the release branch and then create a pull request?

If you can get to it before me, it's fine too :)

@Naereen
Copy link

Naereen commented Nov 15, 2017

Can't do it either. Sorry.

berkerpeksag pushed a commit that referenced this pull request Nov 15, 2017
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
@berkerpeksag
Copy link
Member

Does this get deployed automatically to staging.python.org?

Yes, it does.

If you can get to it before me, it's fine too :)

Done in 9235355.

@Mariatta
Copy link
Member Author

Thanks @berkerpeksag! Hmm the link to PEP 12 in staging.p.o is still incorrect though
PEP 12 was changed from .txt to .rst in python/peps@f026481.

In staging.p.o, it still links to the .txt file.

@berkerpeksag
Copy link
Member

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/

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

Successfully merging this pull request may close these issues.

4 participants