-
-
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
RFC: towards scalable documentation #1619
Conversation
+1 |
|
@nolta, many thanks for the correction! You taught me something new. However, even supposing one doesn't care about dispatching on the arguments as a mechanism to provide more specific help, am I right in guessing that this doesn't entirely obviate the need for some improvements in this area? For example, do we have a mechanism for packages to get their documentation loaded into helpdb? The approach here would also automatically handle that. |
Cool idea, Tim. An
The idea is you could stick @help in front of any normal call that you want help on, so it could find out the type signature for you. |
If I'm interpreting your
|
Another idea is to point to a file instead of using a string with one of these options:
You might want to be able to list multiple help resources:
|
See here for examples of the ideas above that relate to metadata associated with method definitions.: https://github.com/tshort/Sims.jl/blob/master/doc/Possible-future-developments.md#one-option |
The |
Very cool, Tim! |
Actually, this is one case that I don't think should add to the ambiguity messages because it's adding a specific type to the method signature rather than an abstract type. It will clog up the display of methods, and for that reason, it may not be the best idea. Anyway, the idea of making |
@tshort, thanks for the input! Glad to see some interest here, I was beginning to think this suggestion was sinking like a rock. The only reason I generate those
Finally, I too have wondered about "links" to other documentation. Matlab has a nice "see also" facility that makes exploration much, much easier. To your suggestions, we could add The key thing is, is there enough buy-in on this general framework for me to go forward with it? It's not a tiny project:
I am also a little bit worried about whether documenting |
OK, so since I started writing that, lots more comments got posted. I'll take it as a "yes" that there's interest. Definitely hoping to hear about method signatures (and I'll keep looking myself). |
You have buy-in from me. I like your general idea of
http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Documenting-functions
Multiline strings that can handle quotes would help, like:
|
Another feature I'd like to see is easy viewing of package documentation on github. That could be done by a |
I'm skeptical about this project, just because i think you're going to end up rewriting sphinx, and that seems like a low priority. Also, i'd be curious to hear why people prefer markdown over reStructuredText. They're basically the same, except rst is more powerful, w/ tables, blocks, block parameters, etc. |
Markdown is much cleaner than reStructuredText in my mind. If you're using rST, I feel like you might as well be using LaTeX. |
I'm curious to hear more. Can sphinx use package documentation based on reStructuredText files I put in .julia/MyPackage/docs? Can sphinx understand multiple dispatch signatures? As a package writer, do I have to do anything other than write rst files? I guess I like markdown because it's most familiar to me. Also, julia/doc/stdlib/base.rst looks bad when viewed on github. |
I definitely want to hear skeptics. And Tom's most recent wish list is quite cautionary, frankly enough to make me doubt that I want to head down this path. If we can do something like this within sphinx, I'm all ears. Here are real things I'm worried about in the current state of affairs, maybe you (@nolta) or others can suggest some solutions:
I think these are pretty big issues. Being able to do help-multiple-dispatch on arguments is really just a nice touch I threw in because I could. The real point was to begin addressing these two problems. |
@johnmyleswhite: De gustibus non est disputandum, i guess. @tshort: Extending the sphinx tooling to packages should be straightforward. And agreed that rst looks terrible on github, but that's a github bug, not an rst flaw. @timholy: (1) I agree that we need an API for adding new entries to the helpdb. But calling the web docs "nice [to have]" seems a bit weird (to me at least). I think of the web docs as primary, and the online help as subordinate. (2) I guess i'm the Bizarro Tim Holy: everything you think is bad, i think is good ;) |
(1) Oh, don't get me wrong, I like the web docs too. I would be even happier with them if, for example, I could type (2) You're certainly not alone in not wanting code to be free of long documentation sections: I think you, Jeff, and Stefan agree on that, and I'd call that a quorum. But with many different people writing packages, some package authors would probably like to have more expansive documentation in the code (or at least, clearly linked to the code), but currently nothing in Julia supports that. |
What about this: @doc myfun(x::Type1, y::Type2) docfile("filename.html#section") Then sphinx does all the markup; Julia, which knows about types, can easily find the right place. |
As far as opinions go, I generally agree with @nolta. More in detail, I'm concerned about the model for web docs, as it seems to me that there are two possible general models, a distributed and a centralized one. But since both have major drawbacks IMO, I'll propose a mixed model instead (which I have already sketched at some point on the dev list). My idea is that, at least for official packages (i.e. the ones in METADATA) it should be possible to navigate to all of them, and get help from the repl for anything in any package, regardless if it's installed locally or not. Mostly, this requirement is for the sake of easily exploring functionality: for example, if I do Mike, you say it should be straightforward to extend sphinx tooling to packages. Maybe I'm don't know enough about it, but it seems to me that in a distributed approach one would need to have a On the other hand, having all docs in the Julia website would clearly be a pain to manage and basically just wrong. So, one admittedly ugly bit simple and maybe viable idea I had is that each package should hold its own rst files in a more or less standard format, and those could be automatically fetched and kept in the julia repo by some Am I wrong about the distributed approach? Can anyone think of a better solution? |
I agree with @carlobaldassi that we ultimately want a mixed approach so that I can search through the documentation for uninstalled packages. I am quite ignorant about the details of Sphinx, but one point I don't recall seeing raised in our documentation discussions is how we are going to insure that the documentation for each package uses a consistent format. The examples I've seen are one-liners, but we're ultimately going to want to require that every package document every exported function in a format that clearly separates things like:
|
@carlobaldassi , your suggestion is basically what I meant by
Just to illustrate the importance of this point further, for the specific @nolta case where we want to make the pretty html documentation primary: suppose I'm coding away in Matlab. I need to use the Coding in Julia: I'm programming away, I need to use the Especially if we want to make the web documentation primary, it has to be a lot easier than it is now. |
@johnmyleswhite, +1 for all the items on your list. As someone who has a lab full of scientist/programmers who don't have the sophistication of your typical Julia developer, I have evolved to become a believer in the value of code examples as a component of good documentation. |
@carlobaldassi , I started at the end of your comment. The beginning part, about not-yet-installed packages, is compelling too. A bit scary, though; I wonder if it could become a needle-in-a-haystack problem, especially if we get to 10,000 packages some day. |
+1 for promulgation of clarifying examples |
For what it's worth, I also think @timholy's idea of putting documentation in standalone files, but annotating Julia code with the location of the corresponding documentation in those standalone files is a good one. This strikes a balance between the "documentation should live where the code lives" and the "documentation should be gathered in one place so it doesn't clog up the code" camps, and even gives us some nice computational tools to process this data. (Interactive code will know where to go to get documentation for a function object, doc tools don't have to speak Julia to parse documentation and turn it into something else, like HTML) As far as what the documentation is actually written in, I think that's less of an issue. ReST, Markdown, LaTeX, .docx files using the Equation editor, it doesn't matter too much. All I would say is we should achieve an ease of use similar to ipython's Markdown and MathJax (a javascript LaTeX renderer) mashup; it makes mixing prose and math a breeze. |
@johnmyleswhite: Maybe I'm an optimist, but I think a reasonable approach towards insuring some standard documentation format would be through a mix of clear guidelines, opening issues/pull requests in the packages repos, having a package skeleton to start from for new packages. Maybe in the future a "validation" script to spot the most obvious problems might be conceivable. So I don't think of it as an urgent problem at the moment. I agree on your points about annotating all parts of a function and I think Sphinx supports that, but it probably needs some Julia-specific code and definitions in the parser, since at the moment it is tailored on Python. Plus, it's not completely obvious how to organize the presentation of all the required information in the presence of multiple dispatch (and the ability of packages to leverage that) without making it extremely heavy. This is not a lightweight project. Examples would probably be less of a problem though. @timholy: I'm confused. To be honest, I don't quite understand your example about how to look for info about the arguments of a function in Julia: what you describe (delving into the file system hierarchy etc.) is only true for undocumented functions (which shouldn't exist at all for anything in Base and any package version beyond v0), otherwise So, about your points: 1) I agree that each package should have its own doc/ directory; 2) I'm concerned about the fully distributed approach of having each package build its own helpdb and html, as I wrote; 3) I like the idea of storing an explicit link between any exported functions and its html documentation for the sake of being able to fire up the relevant portion of the html help from the command line (but see below for more on that). About the comparison with Matlab: I know how good it can be when you hit F1 and an html-like help window pops-up, complete with links etc. It's even better in Mathematica. But in both those cases, this is possible because 1) you're working within a graphical IDE (try So: having something like F1-keypress work is probably only feasible when working in some kind of graphical environment (e.g. the web repl?); opening a browser when you issue As per the needle-in-a-haystack potential problem, I think it's basically unavoidable (think of the tons of stuff which come up in any search in Matlab's help or in the Python documentation website); the only way out is probably having a good search mechanism, and maybe (?) annotating the docs by using some tags to help filtering results. |
Unless I'm mistaken, currently there is no mechanism for parsing documentation that lives in a package into helpdb. I don't think it will scale to have every package's documentation in I also am in favor of making plain-text documentation "primary" via |
@carlobaldassi: Thanks, that was the kind of thing I was thinking about. Is it documented somewhere, so that others can find it too? |
@carlobaldassi and @StefanKarpinski, what about having an optional "keywords" file in JuliaLang/METADATA.jl? That could be the basis for searching for not-yet-installed documentation, without "polluting" the detailed database of function names and descriptions. For example, when one types We'd also need to start tagging help by module, so that people know what Bottom line: having packages is divine, but I think we need to put some effort into their documentation. |
@toivoh: I don't think it's documented anywhere. But it seems this is not the best time for documenting the documentation ;) @timholy: my point was that missing documentation should simply not happen. It is so right now for packages because nobody's sure on how to proceed (at least that's true for me), but in my view, once there's an agreement, no package should be undocumented except while in "wild development" mode (v0). I'd go as far as refusing to acknowledge inclusion in the official METADATA if a package claims to be at version 1 and lacks a complete API documentation (but then maybe it's just me). So I assume that The concern about scalability is a relevant one. I take you're concerned about issuing About keywords in METADATA: I think associating keywords with packages would be helpful, and having summaries of what each package has to offer would be even better, but if that's an alternative "mixed" model, in which summary info is centralized and detailed info is distributed, I'm not convinced: regardless what you see as "primary", I think it's at least reasonable to say that the documentation of any package should be available in html format, and should be reachable from the Julia website. This means that either all pages are built and uploaded online independently, and the links between them are managed manually (I don't think this is doable) or the pages are fetched in the central repo, built all together and uploaded on a single site (I'd love to have better alternatives, but this is the only viable way I can think of). But if we go for the second option, then we might as well fetch all there is to fetch, so there's no need to have METADATA as another "information hub". One thing which would still be very necessary, even in the approach I'm advocating, is the possibility for installed packages to integrate and supersede the centralized documentation (in particular if the centralized helpdb is installed system-wide and it's not writeable, while the packages are installed in the user's directory and can get updated). |
Today, I tinkered around with a decentralized approach for package help. See here for a package I set up as a testbed: https://github.com/tshort/HelpTestbed.jl The main idea is that everything is decentralized. Nothing needs to be generated when you add a package. Help commands and browser-based help both go looking for help. From the REPL, you could ask for help in several ways: @help mydataframe["col1"] # figures out the function name and package based on the function call
@help DataFrames.ref # lookup by module and keyword name (must be loaded)
@help DataFrames ref # lookup by package and keyword name
help(DataFrames.ref) # same but from a function definition
help("DataFrames", "ref") # string-based lookups All of the above end up calling the same function: For browser-based help, we could feed web pages to the browser from the Julia webserver. Using |
Tom, I won't have time to look at this today, but I'm glad to see your efforts here! It looks promising. |
Thanks Tim. I made a bit more progress. I have a working julia> load("HelpTestbed"); using Help
julia> @help sin
Loading help data...
Base.sin(x)
Compute sine of "x"
julia> @help sin(1)
sin(Real,) at math.jl:86
Base.sin(x)
Compute sine of "x"
julia> m = Modelica.MyType(1)
MyType(1)
julia> @help sin(m)
sin(MyType,) at /home/tshort/.julia/HelpTestbed/src/HelpTestbed.jl:166
Package `HelpTestbed`, sin
Miscellaneous trig functions
# Basic trig operations
sin(x::MyType)
cos(x::MyType)
That's it...
|
The RDatasets package now has documentation along with a |
@carlobaldassi : I am chiming in a little late, but one comment regarding enforcing documentation coming from experience with R. I'd favour making it easy to write documentation over enforcement, and unobtrusive warnings in case of missing documentation would seem to me a better stand to take. |
bump. it appears this would address several other open issues. what are the remaining concerns with this right now? |
This seems to be a big topic, not the incremental step I was hoping for when I first ventured the topic. There seem to be several unresolved design issues. Here's my attempt to summarize them; I think there are really two main issues. First: how much documentation should be available, and when? There seem to be at least three choices:
My original pull request essentially does the third. IIUC, @carlobaldassi is suggesting we do the first. I now agree that the third is probably not adequate, but I wonder whether the second has some advantages. It seems that this issue needs to be resolved before any further steps can be taken. Second: how should the help should be represented? @nolta correctly points out that abandoning sphinx has disadvantages. However, integrating dispatch into the help system (the original "gimmick" in this pull request) also seems to have struck a chord. I have a suspicion that it might be possible to do this via sphinx (sphinx can clearly be used to generate a julia-parseable file, as witnessed by helpdb.jl), but currently I'm too ignorant about (& insufficiently educated about the merits of) sphinx to dream of tackling that in the time before the ubuntu deadline. @tshort and @johnmyleswhite have both pointed out that there are several types of help (brief, detailed, examples, etc.) you might want to get; |
For 0.1, there's really only time to ship with what we have. It covers Base pretty well. Longer term, we need to have a way to integrate documentation from packages into online help. Sphinx could be adapted to this, or we could support multiple systems. In some experiments that I did, a system doesn't need to be "pre-compiled"--it can search through each package directory fast enough. I think we also need HTML help. That's the best looking and most interactive way for users to dig into documentation. Right now, we could have |
@timholy I think it would be great if we could at this time achieve the third point you refer to - all installed packages have their documentation available through help. We do need more comprehensive documentation within Base, and support all kinds of stuff in the help for any given function: calling, brief description, detailed help, examples, illustrations, citations, etc. This is perhaps a longer term effort. For now, as a baby step, if packages can adopt the documentation infrastructure that is used in Base, and |
Given the relative lack of consensus, baby steps seem good, and I agree that the need to document and search packages is growing. (Jeff's brilliant and incredibly useful "add the parameter names to method dumps" patch notwithstanding.) But sadly I'm short on time right now and need to use what Julia-time I have for other coding priorities, so if we're going to do something on this issue I'm afraid someone else will have to lead this charge. |
Can anyone speculate on the odds that a 'Joxygen'-like module will be developed in the not too distant future to convert Doxygen style in-line documentation to whatever format becomes the Julia standard? I would like to start writing code, but want to document as I go. |
I second Tim's statement. Baby steps seem good. On Fri, Apr 5, 2013 at 1:26 PM, Steven Pav [email protected] wrote:
|
If I recall correctly, credit is actually due to @vtjnash. |
Nope, it was me, but vtjnash probably fixed and improved it. And now that
|
Kudos to @vtjnash too!
Useless is probably too strong, but yes, I see what you mean! But in that sense much of the existing documentation could become obsolete. |
I don't think I can take any credit for it. All I recall doing was opening a bug report for Jeff shortly afterwards for some failure case of it. |
Is this pull request still relevant? |
See also #762 |
In the spirit of wrapping up Chaos Month, let me throw in some documentation chaos.
This bare-bones prototype addresses two issues:
This aims to fix point1, and at least allow authors to make their own choices for point2.
Here's a demo file:
And here's a sample session:
Some notes:
help(func, args...)
andargs
is of lengthn
, then only worry about type intersection with the firstn
function arguments. This allows one to handle functions with optional arguments without additional@doc
declarations.