-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Moving Docstrings #12703
Moving Docstrings #12703
Conversation
💯 🎉 🍰 |
dir(path...) = Dir.path(path...) | ||
|
||
""" | ||
init(meta = DEFAULT_META, branch = META_BRANCH) |
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.
worth keeping the type info here, isn't it?
🍰! My first question (out of probably many). Why does some strings start with |
Docstrings which need LaTeX |
Is there any harm/cost to putting |
No, it shouldn't make a difference. |
Very nice! I noticed that almost all docstrings contain the method signature. Would it be possible to include the method signature using a command (like %signature%, or something like this)? For types, this would include all inner constructors on the docstring. |
For the moment that's going to need to be done manually. Would be good to eventually do it automatically, but probably not before 0.4 unless @one-more-minute has something planned already. |
Why can't the method signature be picked up with |
They're not actually in the docs for the |
I explicitly used the new syntax for defining a generic function, i.e. |
Yes, this PR should definitely not be merged until that item is taken care of! 😜 |
Yeah, all I had left was "The Docshank Redemption" and I was too ashamed. RE discussion of methods: We're yet to settle on a lot of documentation conventions, but one thing I'm very strongly in favour of is always treating docs for a function as a single unit, not as a collection of independent methods.
There are a couple of really good reasons to split a docstring across methods. Occasionally you have different APIs depending on arity (unlike dependency on types this is generally OK) and want to make the source clearer, as in the current package docs. The other is to add important notes for particular types (without changing the fundamental behaviour of the function), e.g.: """"
x*y
Multiply `x` and `y` together.
"""
*(x, y) = ...
"When applied multidimensional arrays, matrix (as opposed to element-wise) multiplication
is used."
*(::AbstractArray, ::AbstractArray) = ... The key point to notice in both cases is that this is still written as a single docstring for a single function, it just happens to be spread out a little. On top of being good code style, I think it makes a lot of sense from a user perspective as well. If I'm using @MichaelHatherly I know you've been approaching things slightly differently to this in Docile, so I'm interested in your take – let me know if I'm missing a crucial concern here. |
No, that was all really well-reasoned I think.
lol |
My important and necessary input:
|
|
Keeping docstrings general seems very worthwhile, I like that, especially for methods which are frequently extended. We could definitely do a better job in Base. For packages it's questions like "should I document what multiplication, *, means in this context"? Pretty much every time I use help follow it up with methods(..), so I want to see that prepended to help. :) |
can we also get an item added to NEWS.md explaining where we should be putting docs now (and how to transition them) |
Given that this PR seems to be about figuring out where docstrings have moved to, I second @quinnj's suggestion of renaming this "Dude, where's my Docstring?" (it's called truth in advertising) 😀 |
+1 for "Dude, where's my Docstring?" |
Is anything blocking this from merging? |
I would strongly suggest not moving docstrings until #12573 is sorted out. Adding indirection to the current process complicates things. |
Is there a policy or guidance on ordering of docstrings vs. ordering of methods? Users probably prefer to have the docstrings be ordered from general application to more specific. For example, in 0.4,
This is because I believe the user should be prioritized in help. One solution is to have docstrings appear in the order most helpful to user, prior to a group of related method definitions, which can be in their coder-preferred order. Another would be to actually order them like the help. Is there a policy for docstring order, and should there be one? |
@artkuo, docs for methods are sorted by signature using I agree that in some cases the ordering isn't that great and there probably are better ways to sort them. This PR isn't really the right place to discuss that though. Could you open a new issue? Thanks! |
Thanks for the explanation @MichaelHatherly. I'll try to see what's causing that particular docstring to come out in apparently wrong order, and file an issue if it is one. |
@MikeInnes, @tkelman, was this done in another PR? It would be nice to have them linked :) a brief look at this list indicates #17959 and #18041 as potential candidates, but there way be more. |
look at the commit history of the helpdb folder, or blame on the files with the now inline docstrings. I'd be amazed if these hadn't been moved by now. |
Or, the final step in Julia's doc transition.
This PR begins the process of moving our shiny new markdown docstrings into Base, and should hopefully clarify the process of adding and modifying documentation as well. If you want to help out, read on!
In the first commit I've simply moved the Pkg docstrings from
base/docs/helpdb.jl
to their appropriate locations in thepkg.jl
file. You'll notice that I've split functions with multiple signatures, such asdir()
, and put each method next to its definition. (Isn't it beautiful?) These will be combined in the same order when viewed in the REPL. I also reflowed the paragraphs to 92 chars, which is helpful but not essential.As with code changes, getting Julia to recognise doc changes requires a
make
. It's worth building and checking that things look right in the repl help at this stage.I made a couple of tweaks to the Pkg docstrings, which means that the RST manual is now out of date. Easy enough to fix; in commit two I ran
julia doc/genstdlib.jl
(aftermake
) andpkg.rst
was updated appropriately.In commit three I added a new docstring to a currently-undocumented function,
Pkg.dependents
. After a quickmake
this is available from the REPL with?Pkg.dependents
. Simples!However, I also want to add this docstring to the manual. This is easy to do as well; I just added the line
.. function:: dependents
to the end ofpkg.rst
, and after another run ofgenstdlib.jl
it appeared, as if by magic.That's basically as much as you can want from documentation, I think. (Or at least, it's as much as I can think of right now. It's late.) If you're interested in helping out, please go ahead and pick some docstrings from
helpdb.jl
, and move them to appropriate places. The only caveat is that it's probably best to avoid docstrings emblazoned with `rst```` for now.One of the main reasons we pushed for this transition was to really put the doc system through its paces and shake out any remaining issues before releasing it into the wild. If you have any issues or need any kind of assistance with it, please let us know!