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

Clarify when to mark up numeric literals #1312

Open
erlend-aasland opened this issue Apr 24, 2024 · 4 comments
Open

Clarify when to mark up numeric literals #1312

erlend-aasland opened this issue Apr 24, 2024 · 4 comments
Labels
needs: decision Needs consensus decision from core devs question topic-documentation

Comments

@erlend-aasland
Copy link
Contributor

The current devguide recommendations reads:

backquotes: ``text`` for code samples, variables, and literals.

Earlier, I've been corrected to use double backticks when marking up literals. Example PR remark:

Recently, I've seen other styles enforced:

Perhaps we need a clarification, possibly with good/bad examples?

@Lincoln-developer
Copy link
Contributor

Hey I would love to work on this, I see there a couple of discussions that have been going on with associated PRs, may be I could first look at those and for any other details I must know on this, @erlend-aasland kindly guide.

@erlend-aasland
Copy link
Contributor Author

Hey I would love to work on this [...]

Thanks! I believe we need to discuss this a little bit more before we can propose actual changes to the devguide. We need to agree what to put in the "good" section and what to put in the "bad" section. This implies more discussion needs to take place first.

@erlend-aasland erlend-aasland added question needs: decision Needs consensus decision from core devs labels Apr 29, 2024
@Lincoln-developer
Copy link
Contributor

Thanks for this response, let me look at another issue.

@ezio-melotti
Copy link
Member

My rule of thumb is that numbers should be marked as literals if they refer to values in the code (either actually written as literals or assigned/calculated/returned), e.g.:

  • "The function will return 0 or 1."
  • "The default value is 42."
  • "math.pi is defined as equal to 3.14159."

When the number doesn't directly refer to a value in the code, the literal markup can be omitted, e.g.:

  • "A week is defined as 7 days."
  • "The mathematical constant π (with value 3.14159) is defined in the math module."
  • "The result has already been multiplied by 1000."

Sometimes the difference is subtle though. For example, if you are suggesting the reader to multiply the result by 1000 or talking about the operation done by a specific function, you might want to use a literal. However if the calculation already happened or if the focus is about the calculation itself and not the implementation that executes it, then you don't necessarily need to.

In some ambiguous cases and especially with lists/tables, marking them as literals might also help the values stand out more (which might be desirable or not) or be easier to scan/compare. As always, use your best judgment in order to make the docs as clear and readable as possible.

FWIW the same applies to strings or other literals. For example, you can talk about "version 1.2.3" in general but "version 1.2.3" if it's returned by a function, assigned to a variable, or even used in a file like requirements.txt, or you can say that "store is the default action of argparse.add_argument", and that "it will store the value passed from the CLI".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: decision Needs consensus decision from core devs question topic-documentation
Projects
None yet
Development

No branches or pull requests

3 participants