X Tutup
The Wayback Machine - https://web.archive.org/web/20251228202529/https://github.com/python/cpython/pull/928
Skip to content

Conversation

@csabella
Copy link
Contributor

@csabella csabella commented Mar 31, 2017

  1. Separated functions and constants descriptions in sections.
  2. Added a note about the limitations of timezone constants.
  3. Removed redundant lists from the module docstring.

https://bugs.python.org/issue28157

@mention-bot
Copy link

@csabella, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @abalkin and @akheron to be potential reviewers.

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 like that the same note is repeated four times. Maybe we can split the functions and constants in two separate sections and place this note in the constants section once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I thought that it wasn't DRY when I was changing it but didn't know about moving things around. I step back and look at the overall layout.

@Mariatta Mariatta added docs Documentation in the Doc dir needs backport to 3.6 labels Mar 31, 2017
Copy link
Member

Choose a reason for hiding this comment

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

Please remove "and data items" from the introductory sentence above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I had originally removed it, but then put it back in because I left some of the new data constants (starting with time.CLOCK_HIGHRES.) in that section. I didn't know if I should move the newer data items to the bottom with the deprecated ones or not. Maybe I should change the one on the bottom to be 'Deprecated data items:'?

Copy link
Member

Choose a reason for hiding this comment

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

Please note that the time module also defines a few constants starting with CLOCK_. Their descriptions should also go to the "Constants" section.

    CLOCK_MONOTONIC = 6
    CLOCK_MONOTONIC_RAW = 4
    CLOCK_PROCESS_CPUTIME_ID = 12
    CLOCK_REALTIME = 0
    CLOCK_THREAD_CPUTIME_ID = 16

@csabella
Copy link
Contributor Author

Thank you for pointing out the math.rst to look at.

One question - I'm new to this, so can you send a link instructions on changing pydoc and docstrings? Thanks!

@abalkin
Copy link
Member

abalkin commented Mar 31, 2017

C modules' docstrings are hardcoded in the C files. For the time module, see Modules/timemodule.c.

@csabella
Copy link
Contributor Author

I've been looking at pydoc math and pydoc time (and the the module.c source).

Before I go down the wrong path, I'm not sure I fully understand your comment - "(Also, markup can be improved in the time module docstring. Compare pydoc time and pydoc math.)" The time one is more vebose in the description and it lists the Variables and Functions in the text and then defines them with markup further down. Are you saying the variables and functions should be removed from being written in text within the description?

Thanks.

@abalkin
Copy link
Member

abalkin commented Mar 31, 2017

Are you saying the variables and functions should be removed from being written in text within the description?

Yes, I think so. Note that this discussion should probably be held at the b.p.o. issue.

@csabella
Copy link
Contributor Author

OK, sorry about that. I'll copy my question to there.

Copy link
Member

Choose a reason for hiding this comment

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

You may also mention here that these constants are reset when time.tzset() is called. Maybe add "or the last time tzset() is called" after "at module load time".

@abalkin abalkin changed the title bpo-28157: DOC: Warning on time module constants (timezone, tzname, etc) bpo-28157: Improvements for the time module documentation Apr 1, 2017
@abalkin abalkin self-assigned this Apr 1, 2017
@abalkin abalkin requested a review from vstinner April 1, 2017 18:34
Copy link
Member

Choose a reason for hiding this comment

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

Indentation should be the same level as others since the note is talking about altzone, daylight, timezone and tzname constants, not just tzname.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Member

Choose a reason for hiding this comment

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

We also need to document which functions of the time modules accept these constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added one comment right under the constants heading. It seemed that all the constants would apply to clock_getres and clock_getttime, so hopefully this is appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

Good point. How about removing clock_settime() from the paragraph below and add a note to CLOCK_REALTIME documentation that says this constant can only be passed to time.clock_settime()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a note to CLOCK_REALTIME.

Copy link
Member

Choose a reason for hiding this comment

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

I would suggest adding a link of this section to appropriate members of the time module. For example, see https://docs.python.org/3/library/time.html#time.clock_gettime -- I would add something like

See :ref:`time-clock-id-constants` for a list of accepted values for *clk_id*.

to the time.clock_gettime() documentation.

My wording is probably terrible (it's 3 a.m. here and my brain doesn't work well now), but I think you get the idea :)

And don't forget to create a link for the section:

.. _time-clock-id-constants:

Clock ID Constants
------------------

Copy link
Contributor Author

@csabella csabella Apr 17, 2017

Choose a reason for hiding this comment

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

@berkerpeksag Thank you for all your suggestions. I added this reference to time.clock_gettime(), time.clock_getres(), and time.clock_settime(). It seems that settime only works for CLOCK_REALTIME though, so maybe it shouldn't link to the whole section? Also, I did not add any references in time.monotonic(), time.perf_counter(), or time.process_time(), but those seem to be shortcuts to time.clock_gettime()?

Copy link
Member

Choose a reason for hiding this comment

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

It seems that settime only works for CLOCK_REALTIME though, so maybe it shouldn't link to the whole section?

Good catch. I'd keep it in the same section, but add something like ":data:`CLOCK_REALTIME` is the only acceptable constant for *clk_id*." to time.clock_settime() documentation. My wording is probably a bit bad, feel free to tweak it :)

Also, I did not add any references in time.monotonic(), time.perf_counter(), or time.process_time(), but those seem to be shortcuts to time.clock_gettime()?

Agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a line to the clock_settime() section.

Copy link
Member

Choose a reason for hiding this comment

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

We don't need to create a link for this case, but I believe we can still use some markup to make it more readable: ``CLOCK_HIGHRES``

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, but I didn't understand this comment.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, my comment wasn't clear. I meant to say replace CLOCK_HIGHRES with ``CLOCK_HIGHRES``.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@berkerpeksag Thank you for clarifying. I had tried to do that, but, when I did, the tick marks show up in the HTML (after running make html). It doesn't show up here when I cut and paste from the HTML because of Markdown, so I don't know how to show you what it looks like.

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 weird. I don't know why it didn't work. Could you try copy and paste the backticks in line 27 in Doc/library/time.rst? Perhaps something was wrong with my earlier comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to change it next to data::. :-( After looking at it again, I realized what you meant. Sorry about that.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe "See note below." would be more descriptive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@abalkin
Copy link
Member

abalkin commented Jul 31, 2017

This LGTM. @berkerpeksag - it looks like your comments have been addressed. Can this be merged?

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.

This looks pretty great, thank you! I just left two minor comments.

Copy link
Member

Choose a reason for hiding this comment

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

I'd listCLOCK_REALTIME after CLOCK_THREAD_CPUTIME_ID and make it look like in the following format:

Clock ID Constants
------------------

These constants are used as parameters for :func:`clock_getres` and
:func:`clock_gettime`.

.. All CLOCK_* constants except CLOCK_REALTIME documented here.

The following constant is the only parameter that can be sent to
:func:`clock_settime`.

.. data:: CLOCK_REALTIME

   System-wide real-time clock.  Setting this clock requires
   appropriate privileges.

   Availability: Unix.

   .. versionadded:: 3.3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for the suggestion.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: We use "time zone" and "timezone" a bit inconsistently in this note. I don't know which one is correct, but I don't see a reason to use the both forms here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I hadn't even realized I had done that and googling it seems that both ways is correct, so, as you said, it's best to be consistent. I left the 'T' capitalized, but I wasn't sure if I should 1. make it a link, 2. uppercase the 'C' in constant, or 3. lowercase the 'T'.

@csabella
Copy link
Contributor Author

@berkerpeksag @abalkin Thanks for the review. I've made the additional changes.

@berkerpeksag
Copy link
Member

Looks great to me, thank you again. I'll let @abalkin do the merging since he's our datetime/time expert (I can do it this weekend in case he's busy with other issues)

@berkerpeksag berkerpeksag merged commit 703ff38 into python:master Oct 11, 2017
@miss-islington
Copy link
Contributor

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

@bedevere-bot
Copy link

GH-3953 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 11, 2017
…onGH-928)

* Separated functions and constants descriptions in sections.
* Added a note about the limitations of timezone constants.
* Removed redundant lists from the module docstring.
(cherry picked from commit 703ff38)
@berkerpeksag
Copy link
Member

I went ahead and merged this PR (I hope that's OK, @abalkin) Thanks again, @csabella.

berkerpeksag pushed a commit that referenced this pull request Oct 11, 2017
* Separated functions and constants descriptions in sections.
* Added a note about the limitations of timezone constants.
* Removed redundant lists from the module docstring.

(cherry picked from commit 703ff38)
@csabella csabella deleted the upstream branch October 11, 2017 20:25
@csabella csabella restored the upstream branch April 7, 2018 13:22
@csabella csabella deleted the upstream branch April 26, 2018 21:59
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.

8 participants

X Tutup