-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
[docs] Improve docs for std.conv.to #4900
Conversation
7c9fc34
to
e7822ef
Compare
Have to say that I'm against these changes. Before I changed the |
The radix overload docs are currently buried in the middle of all the other |
We are currently in the process of removing overloads from Phobos - not adding new ones - as the overloads are an implementation details, that the user of a generic function shouldn't be bothered with.. @ntrel: is there a chance you could maybe improve the text documentation so that it's even clearer? |
The 2 radix overloads are not implementation details, they are important for the user - all the other overloads only take one argument. I have now simplified the constraints (and removed one) so they only show what source type the radix overloads apply to. I have undocumented the static array ref (non-radix) overload as I agree that could be seen as an implementation detail.
Possibly, but it would be fighting against ddoc's purpose of documenting declarations, we shouldn't be explaining what hidden arguments a function takes manually IMO. Documenting the 2 radix overloads normally we get the usual Parameters section etc. I have also added 3 signatures manually at the top of the docs, partly because the actual signatures from this PR are so far below the pages of docs & examples, but also so the user can quickly grok the function, and the docs now refer to |
@wilzbach Removed overloads from docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ntrel needs a rebase.
std/conv.d
Outdated
@@ -1732,7 +1735,7 @@ private T toImpl(T, S)(S value) | |||
/// ditto | |||
private T toImpl(T, S)(S value, uint radix) | |||
if (isInputRange!S && isSomeChar!(ElementEncodingType!S) && | |||
!isExactSomeString!T && is(typeof(parse!T(value, radix)))) | |||
isIntegral!T && is(typeof(parse!T(value, radix)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's with the template constraint change? We can't have that in a doc PR. Please remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to #5647.
@wilzbach I can't work out why |
Not really, looked pretty strange to me as well. However, rebasing to the latest master commit worked :) |
@wilzbach Thanks! |
Document overloads of `to` which take a radix.
Hide the static array ref overload from docs. Omit constraints involving T (unnecessary for the user).
Thanks for your pull request, @ntrel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
My impatience got the better of me, so I took it upon myself to rebase this. Let's see if it passes; if so, I'm going to pull the trigger. |
ping @JackStouffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My impatience got the better of me, so I took it upon myself to rebase this. Let's see if it passes; if so, I'm going to pull the trigger.
I really really like your enthusiasm and the way you most PRs in the Phobos queue ahead, but in this case I would be careful here as AFAICT we haven't had a precedent of specifying "pseudo-overloads" in the plain-text documentation.
@@ -176,8 +176,9 @@ class ConvOverflowException : ConvException | |||
} | |||
|
|||
/** | |||
The `to` template converts a value from one type _to another. | |||
The source type is deduced and the target type must be specified, for example the | |||
$(D_CODE T $(DDOC_PSYMBOL _to)$(DDOC_TEMPLATE_PARAM_LIST (S))(S value);) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* _To work around this, you can specify a radix for conversions involving numbers. | ||
* To work around this, you can specify a radix for conversions involving numbers: | ||
* $(D_CODE T $(DDOC_PSYMBOL _to)$(DDOC_TEMPLATE_PARAM_LIST (S))(S value, uint radix);) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* $(D_PARAM radix) must be a value from 2 _to 36. | ||
* $(D_PARAM value) is treated as a signed value only if $(D_PARAM radix) is 10. | ||
* The characters A through Z are used _to represent values 10 through 36. | ||
* $(D_PARAM letterCase) is the case _to use for non-decimal output characters.))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wilzbach There was a case (not sure if there still is now) where the ddoc header contained a "pseudo" declaration, I don't remember exactly now, it may have been But yeah, it's probably a bad idea to merge this without a good reason. Perhaps the solution here might be to document the 2-argument |
I'm still against splitting the An easy solution is to add a |
@JackStouffer Now that I look at at again, not only the current docs is missing a Worse yet, there's no indication whatever about what possible combination of arguments are possible. I see that since the last time I looked, the number of possible arguments has been generalized to 1 possible radix to now an additional |
P.S. I would say, from a doc reader's POV, the bare minimum for the docs would be:
|
Most of the changes in this PR have already been addressed. |
to
which take a radix - see last commit.Note: This continues the work done in #4208.