gh-138772: Improve documentation for turtle color functions#139325
gh-138772: Improve documentation for turtle color functions#139325serhiy-storchaka merged 3 commits intopython:mainfrom
Conversation
Use multiple signatures for clarity. Explain different forms of bgcolor() in details.
26df454 to
78c3b27
Compare
| Four input formats are allowed: | ||
|
|
||
| ``bgcolor()`` | ||
| Return the current background color as color specification string or | ||
| as a tuple (see example). May be used as input to another | ||
| color/pencolor/fillcolor/bgcolor call. | ||
|
|
||
| ``bgcolor(colorstring)`` | ||
| Set the background color to *colorstring*, which is a Tk color | ||
| specification string, such as ``"red"``, ``"yellow"``, or ``"#33cc8c"``. | ||
|
|
||
| Set or return background color of the TurtleScreen. | ||
| ``bgcolor((r, g, b))`` | ||
| Set the background color to the RGB color represented by the tuple of | ||
| *r*, *g*, and *b*. | ||
| Each of *r*, *g*, and *b* must be in the range 0..colormode, where | ||
| colormode is either 1.0 or 255 (see :func:`colormode`). | ||
|
|
||
| ``bgcolor(r, g, b)`` | ||
| Set the background color to the RGB color represented by *r*, *g*, and *b*. Each of | ||
| *r*, *g*, and *b* must be in the range 0..colormode. |
There was a problem hiding this comment.
Do you think it could it be better to link to a more commonly used function, rather than repeat all the info?
| Four input formats are allowed: | |
| ``bgcolor()`` | |
| Return the current background color as color specification string or | |
| as a tuple (see example). May be used as input to another | |
| color/pencolor/fillcolor/bgcolor call. | |
| ``bgcolor(colorstring)`` | |
| Set the background color to *colorstring*, which is a Tk color | |
| specification string, such as ``"red"``, ``"yellow"``, or ``"#33cc8c"``. | |
| Set or return background color of the TurtleScreen. | |
| ``bgcolor((r, g, b))`` | |
| Set the background color to the RGB color represented by the tuple of | |
| *r*, *g*, and *b*. | |
| Each of *r*, *g*, and *b* must be in the range 0..colormode, where | |
| colormode is either 1.0 or 255 (see :func:`colormode`). | |
| ``bgcolor(r, g, b)`` | |
| Set the background color to the RGB color represented by *r*, *g*, and *b*. Each of | |
| *r*, *g*, and *b* must be in the range 0..colormode. | |
| The arguments use the same format as :func:`fillcolor`. |
There was a problem hiding this comment.
Should not both refer to pencolor()? Although bgcolor() is a method of different class than pencolor() and fillcolor().
And we need to repeat this in the docstrings.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Docstrings also require an update.
Docstrings were outdated and incorrect -- all these functions now return a tuple instead of "#"-string.
| Four input formats are allowed: | ||
|
|
||
| ``bgcolor()`` | ||
| Return the current background color as color specification string or | ||
| as a tuple (see example). May be used as input to another | ||
| color/pencolor/fillcolor/bgcolor call. | ||
|
|
||
| ``bgcolor(colorstring)`` | ||
| Set the background color to *colorstring*, which is a Tk color | ||
| specification string, such as ``"red"``, ``"yellow"``, or ``"#33cc8c"``. | ||
|
|
||
| Set or return background color of the TurtleScreen. | ||
| ``bgcolor((r, g, b))`` | ||
| Set the background color to the RGB color represented by the tuple of | ||
| *r*, *g*, and *b*. | ||
| Each of *r*, *g*, and *b* must be in the range 0..colormode, where | ||
| colormode is either 1.0 or 255 (see :func:`colormode`). | ||
|
|
||
| ``bgcolor(r, g, b)`` | ||
| Set the background color to the RGB color represented by *r*, *g*, and *b*. Each of | ||
| *r*, *g*, and *b* must be in the range 0..colormode. |
There was a problem hiding this comment.
Should not both refer to pencolor()? Although bgcolor() is a method of different class than pencolor() and fillcolor().
And we need to repeat this in the docstrings.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ions (pythonGH-139325) Use multiple signatures for clarity. Explain different forms of bgcolor() in details. Fix outdated docstrings. (cherry picked from commit 525dcfe) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…ions (pythonGH-139325) Use multiple signatures for clarity. Explain different forms of bgcolor() in details. Fix outdated docstrings. (cherry picked from commit 525dcfe) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-140047 is a backport of this pull request to the 3.14 branch. |
|
GH-140048 is a backport of this pull request to the 3.13 branch. |
Use multiple signatures for clarity.
Explain different forms of bgcolor() in details.
📚 Documentation preview 📚: https://cpython-previews--139325.org.readthedocs.build/