Skip to content
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

Sphinx changes number system from hexadecimal to decimal for function default arguments #8255

Closed
dybber opened this issue Sep 30, 2020 · 0 comments

Comments

@dybber
Copy link

dybber commented Sep 30, 2020

Describe the bug

When documenting a function, which requires a default argument specified in hexadecimal:

.. function:: lcd.print(msg, x, y, color=0xffffff, transparent=False)

Sphinx 3.2.1 will render HTML documentation where the hexadecimal value is in a different number system, than what was specified by the user (decimal), as seen in the following output from the above input:

Screenshot 2020-09-30 at 14 32 21

Expected behavior
The expected behaviour would be to present the default argument in the same radix/number system as the user typed in, thus in this case the documentation would also display the value in hexadecimal.

In the above example of with colors, it is unintuitive what the color 16777215 might refer to, but it's easy read RGB colors in hexadecimal format - e.g. 0xffffff is white, thus which number system is used can make a huge difference. The same for example goes for e.g. specifying access rights for files (chmod)

Screenshots
Screenshot 2020-09-30 at 14 32 21

Environment info

  • OS: Mac OS X 10.14.6
  • Python version: 3.8.5
  • Sphinx version: 3.2.1
  • Sphinx extensions: None
  • Extra tools: None
tk0miya added a commit to tk0miya/sphinx that referenced this issue Oct 4, 2020
Number literals in default argument value is converted to decimal form
unexpectedly by AST module.  This fixes the signature parsing code to
recosntruct it correctly.

Note: This is only available in Python 3.8+.
@tk0miya tk0miya added this to the 3.3.0 milestone Oct 4, 2020
@tk0miya tk0miya closed this as completed in cc941db Oct 5, 2020
tk0miya added a commit that referenced this issue Oct 5, 2020
Fix #8255: py domain: number in defarg is changed to decimal
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants