GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-115986 Improve pprint docs formatting by Privat33r-dev · Pull Request #117401 · python/cpython Conversation
|
|
If we're putting the params list in the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@erlend-aasland, I do completely agree that Moreover, I want to address the whole "pp vs pprint" thing. If we are writing docs from the developer's perspective, it would seem more logical to write the full description in one function's docs and just mention in another that it's an alias to keep everything DRY and readable (please, ignore formatting and minor details): pprint.pp(object, stream=None, indent=1, width=80, depth=None, *, compact=False, sort_dicts=False, underscore_numbers=False) Prints the formatted representation of object on stream, followed by a newline. If stream is None, [sys.stdout] is used. This may be used in the interactive interpreter instead of the [print()] function for inspecting values (you can even reassign print = pprint.pp for use within a scope). The configuration parameters stream, indent, width, depth, compact, sort_dicts and underscore_numbers are passed to the [PrettyPrinter] constructor and their meanings are as described in its documentation below. ** PrettyPrinter PARAMS HERE ** pprint.pprint(object, stream=None, indent=1, width=80, depth=None, *, compact=False, sort_dicts=True, underscore_numbers=False) Alias to pprint.pp. Note that sort_dicts is True by default and you might want to use [pp()] instead where it is False by default. It feels like it would make the most sense, because here we would give all the usage info on pprint.pp and only then mention "pprint.pprint" and other stuff. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Privat33r-dev, do you have a draft PR of your suggestion? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
not yet, but I can make (or rather edit existing) one if my proposed change sounds good |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think a draft PR would be interesting, but only if you have time available for it; I find it easier to decide on doc layouts when they are rendered :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
done, you can check it out :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks! I like this very much. We could use Sphinx placeholders to minimise the duplication. I'm not sure if it is worth it, though, because you'd have to create one placeholder for each parameter description. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Indentation of code blocks made them nested "Version changed" is better placed after the code block
|
There are 2 differences between the params table:
Even if we technically can make a placeholder for table (by "table" I mean params list), the first difference is resolved by putting We can keep it DAMP for now since there is low change of significant changes in the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
My recent change |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Moving the example code out of the parameter list sounds good. IMO we should never embed code examples in parameter lists, since it is (IMO) visually cluttering. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
You need to adjust the indentation so it matches the expected output; AFAIK, there is no other way. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
putting additional newline between "usage example" and code fixed the indentation. I tried to use comment ( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I figured out that the problem wasn't in the indentation of the code block but because my IDE decided to align code inside of the code blocks on <shift>+<tab>. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Failure has been successfully managed. Ready for review :) P.S. Why does |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| *width*, *depth*, *compact*, *sort_dicts* and *underscore_numbers* are | ||
| passed to the :class:`PrettyPrinter` constructor as formatting parameters | ||
| and their meanings are as described in its documentation below. | ||
| and their meanings are as described in the documentation above. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The documentation for PrettyPrinter is still below. Maybe this should be:
The arguments have the same meaning as for :func:`~pprint.pprint`.
Note that *sort_dicts* defaults to ``True``.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That's why "its" was changed to "the", as arguments description is above (in the pp.pprint description).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I've merged |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thanks. It worked :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* Move pprinter parameters description to the table The change improves readability. Suggested in the GHGH-116085 PR discussion. * Make pprint doc with params markup * Fix formatting Indentation of code blocks made them nested "Version changed" is better placed after the code block * Fix formatting for tests * fix code indentation for autotests * Fix identation for autotests * Remove duplication of the parameters' description * Rearrange parameters description in a correct order --------- (cherry picked from commit 0890ad7) Co-authored-by: Kerim Kabirov <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
|
GH-121098 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* Move pprinter parameters description to the table The change improves readability. Suggested in the GHGH-116085 PR discussion. * Make pprint doc with params markup * Fix formatting Indentation of code blocks made them nested "Version changed" is better placed after the code block * Fix formatting for tests * fix code indentation for autotests * Fix identation for autotests * Remove duplication of the parameters' description * Rearrange parameters description in a correct order --------- (cherry picked from commit 0890ad7) Co-authored-by: Kerim Kabirov <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
|
GH-121099 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* Move pprinter parameter descriptions to a table * Make pprint doc with params markup * Remove duplication of the parameters' description --------- (cherry picked from commit 0890ad7) Co-authored-by: Kerim Kabirov <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
gh-115986 Improve pprint docs formatting (GH-117401) * Move pprinter parameters description to the table The change improves readability. Suggested in the GHGH-116085 PR discussion. * Make pprint doc with params markup * Fix formatting Indentation of code blocks made them nested "Version changed" is better placed after the code block * Fix formatting for tests * fix code indentation for autotests * Fix identation for autotests * Remove duplication of the parameters' description * Rearrange parameters description in a correct order --------- (cherry picked from commit 0890ad7) Co-authored-by: Kerim Kabirov <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
* Move pprinter parameters description to the table The change improves readability. Suggested in the GH#116085 PR discussion. * Make pprint doc with params markup * Fix formatting Indentation of code blocks made them nested "Version changed" is better placed after the code block * Fix formatting for tests * fix code indentation for autotests * Fix identation for autotests * Remove duplication of the parameters' description * Rearrange parameters description in a correct order --------- Co-authored-by: Hugo van Kemenade <[email protected]>
|
Next time, remember to edit the commit message upon merging, @encukou :) Thanks for the contribution, Kerim! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* Move pprinter parameters description to the table The change improves readability. Suggested in the GH#116085 PR discussion. * Make pprint doc with params markup * Fix formatting Indentation of code blocks made them nested "Version changed" is better placed after the code block * Fix formatting for tests * fix code indentation for autotests * Fix identation for autotests * Remove duplication of the parameters' description * Rearrange parameters description in a correct order --------- Co-authored-by: Hugo van Kemenade <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.