-
Notifications
You must be signed in to change notification settings - Fork 37
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
Docstring pollution #137
Comments
In my opinion, having these docstrings is great to provide examples with
Because the original docstring refers to help?> real
search: real Real realpath isreal readlink readline readlines ReadOnlyMemoryError reenable_sigint isreadonly isreadable @threadcall readuntil readavailable ReentrantLock ProcessFailedException replacefield! read read! readdir readeach readchomp readbytes! break isready foreach Threads IOStream extrema!
real(z)
Return the real part of the complex number z.
See also: imag, reim, complex, isreal, Real.
That seems acceptable. PRs are welcomed! |
Several of these are added because the version of the docstring in Base julia explicitly mentions function behavior for complex numbers, which does not describe behavior for quaternions. So not including the docstring is incomplete. e.g.
In these cases Base julia seems to be assuming the number is something like hypercomplex, so more general than what is documented. For
I agree raising a "not implemented" error is not great. This is indeed a perfect case for error hints with |
A docstring does not help discoverability. Once one is reading I understand that these docstrings are not literally 100% redundant if one draws a strong distinction between "complex" and "hyper-complex", but note that the existing docstrings refer to "complex number" instead of " The I honestly cannot remember if it was always this way, but If every package added docstrings to every function that experienced a trivial epsilon extension, any medium or large project would risk having functions with unreadably-long docstrings. Docstrings are useful because they are short. That's why I object to many of these. I would not object to these same descriptions exclusively within the package docs. |
It appears that some
Base
functions extended to::Quaternion
arguments contribute their own docstrings that are near-verbatim repeats of the existing versions fromBase
. They don't provide any new information but they are printed via>help?
anyway, cluttering the output. It doesn't seem sustainable for every package that adds a new type to document semantically-unchanged functions just for the sake of saying that they do exactly what the docstrings already said they do. If anything, this makes them more confusing (in addition to the clutter) because the user may try to spot the difference.Other packages don't seem to take this approach.
Base
doesn't feel the need to document thatsign
works onRational
specifically, nor doesDualNumbers
feel the need to do the same forDual
. For that matter,Quaternions
doesn't (yet) feel the need to do this for the majority of its extended functions (arithmetic,==
,exp
,sin
, etc.).Offending functions at the present time appear to be:
real
-- only adds a "See also: imag_part, quat
" to thereal(::Quaternion)
methodconj
sign
-- we don't even provide a custom implementationinv
-- proposed by Update aroundinv
#133At least the
real
docstring adds literally something, if only references. I can't see whyquat
is relevant there, and it's already linked fromQuaternion
which seems a more reasonable place. Discoverability ofimag_part
is important (arguably, field access is fine) but I would argueimag
is a much better place to find it thanreal
. That said, I wouldn't be excited to clutter that docstring either. I despise "not implemented" errors, but this is more of a "the operation is ill-defined for this type" error so I could be convinced to do something liketo help discoverability. I vaguely recall there were "error hints" being considered for
Base
at some point (which seems like an even better solution), but I don't know if those ever became a thing.It's unfortunate that
round
does appear to need::Quaternion
-specific documentation for the imaginary-part rounding modes, but I don't see a way around that. The only thing I would have considered (breaking change now, technically, although perhaps not in any actual use) would be that the imaginary parts all share a rounding mode (in which case we would have followed theround(::Complex,...)
semantics). It's not easy to imagine that many people have needs to round imaginary parts differently from each other, so I wouldn't have hated making users roll-their-own for that level of control. It doesn't benefit from being part ofBase.round
anyway, because no other version accepts 4RoundingMode
s. But this is a matter for a separate issue and not one that I feel strongly about since it'd be breaking to remove that functionality.The text was updated successfully, but these errors were encountered: