8000 bpo-35044: Use the :exc: role for the exceptions in the doc by matrixise · Pull Request #10037 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-35044: Use the :exc: role for the exceptions in the doc #10037

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 7 commits into from
Oct 26, 2018

Conversation

matrixise
Copy link
Member
@matrixise matrixise commented Oct 22, 2018

Copy link
Member
@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Too much links is not good. If some thing is mentioned multiple times in one paragraph or in few consequent short paragraph, it is enough to create a link only from the first of them. In many cases links were omitted for purpose.

Inside a generator function, ``return value`` causes ``StopIteration(value)``
to be raised from the :meth:`~generator.__next__` method. Once this happens, or
the bottom of the function is reached, the procession of values ends and the
Inside a generator function, ``return value`` causes :exc:`StopIteration` to be
Copy link
Member

Choose a reason for hiding this comment

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

The current wording is more correct. StopIteration(value) will be raised.

@@ -560,15 +560,15 @@ PEP 479: Change StopIteration handling inside generators

The interaction of generators and :exc:`StopIteration` in Python 3.4 and
earlier was sometimes surprising, and could conceal obscure bugs. Previously,
``StopIteration`` raised accidentally inside a generator function was
:exc:`StopIteration` raised accidentally inside a generator function was
Copy link
Member

Choose a reason for hiding this comment

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

There is a link to StopIteration above. Too many links to the same target distract attention.

@gvanrossum gvanrossum removed their request for review October 22, 2018 15:19
@matrixise
Copy link
Member Author

@serhiy-storchaka do you want to continue the review? thank you

would raise a KeyError exception because the id of the ``[1, 2]`` used in the
second line differs from that in the first line. In other words, dictionary
keys should be compared using ``==``, not using :keyword:`is`.
would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` used
Copy link
Member

Choose a reason for hiding this comment

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

Please leave "in the" on the same line to reduce the number of modified lines in your change. It's fine if the line is "too long".

@@ -482,8 +482,8 @@ Here's a sample usage of the ``generate_ints()`` generator:
You could equally write ``for i in generate_ints(5)``, or ``a, b, c =
generate_ints(3)``.

Inside a generator function, ``return value`` causes ``StopIteration(value)``
to be raised from the :meth:`~generator.__next__` method. Once this happens, or
Inside a generator function, ``return value`` causes ``StopIteration(value)`` to
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@matrixise
Copy link
Member Author

@vstinner updated, thanks for your review.

@@ -1200,7 +1200,7 @@ importlib

Import now raises the new exception :exc:`ModuleNotFoundError`
(subclass of :exc:`ImportError`) when it cannot find a module. Code
that current checks for ``ImportError`` (in try-except) will still work.
that current checks for :exc:`ImportError` in try-except) will still work.
Copy link
Member

Choose a reason for hiding this comment

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

There is already a link to this exception in this paragraph.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that it's an issue. I prefer to always use :exc: role to always have the same formatting.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to get the same formatting, you can use :exc:`!ImportError`. But it is more verbose.

Since the formatting is not missed, but it just don't create a link, I'm sure this was done for purpose.

Copy link
Member

Choose a reason for hiding this comment

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

I don't why it's an issue to have two links to the same exception in the same paragraph. IMHO it's a good thing :)

Copy link
Member Author
@matrixise matrixise Oct 25, 2018

Choose a reason for hiding this comment

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

suggestions? remove/keep? tell me ;-)
thanks

Copy link
Member

Choose a reason for hiding this comment

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

Links have many disadvantages:

  • They distract attention.
  • Unintentional mouse click causes loading different page.
  • It is harder to copy linked text.
  • They increase the html file size and the time of its loading and rendering.

Links have great advantages which overwhelm disadvantages. But if repeat the same link multiple times, its advantages are left constant, while disadvantages are increased with every repetition.

Copy link
Member Author

Choose a reason for hiding this comment

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

@serhiy-storchaka done, thanks

@@ -1393,7 +1393,7 @@ The subprocess module is now more graceful when handling
:exc:`KeyboardInterrupt` during :func:`subprocess.call`,
:func:`subprocess.run`, or in a :class:`~subprocess.Popen`
context manager. It now waits a short amount of time for the child
to exit, before continuing the handling of the ``KeyboardInterrupt``
to exit, before continuing the handling of the :exc:`KeyboardInterrupt`
Copy link
Member

Choose a reason for hiding this comment

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

There is already a link to this exception in this paragraph.

@@ -0,0 +1 @@
Fix the documentation with the role exc for the appropriated exception.
Copy link
Member

Choose a reason for hiding this comment

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

"Patch by ..."

And perhaps highlight "exc"? ``exc``

Copy link
Member

Choose a reason for hiding this comment

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

+1 to format properly "exc" :) I hesitated to ask the same change.

Copy link
Member Author

Choose a reason for hiding this comment

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

@serhiy-storchaka I wanted to use :exc: but there was an exception during the build process of the doc. it's the reason why I simply used exc, but ok I am going to change that. Thanks

@miss-islington
Copy link
Contributor

Thanks @matrixise for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-10122 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 26, 2018
(cherry picked from commit e483f02)

Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
@miss-islington
Copy link
Contributor

Sorry, @matrixise and @vstinner, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker e483f02423917dc4dfd25f46e5b9e6fce304777d 3.6

@vstinner
Copy link
Member

Sorry, @matrixise and @vstinner, I could not cleanly backport this to 3.6 due to a conflict.

If the backport cannot be automated, I don't think that it's worth it.

Thanks @matrixise for your contribution and @serhiy-storchaka for the review ;-)

miss-islington added a commit that referenced this pull request Oct 26, 2018
(cherry picked from commit e483f02)

Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0