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

How to document my file-loader #97

Open
mauro3 opened this issue Jan 18, 2017 · 10 comments
Open

How to document my file-loader #97

mauro3 opened this issue Jan 18, 2017 · 10 comments

Comments

@mauro3
Copy link

mauro3 commented Jan 18, 2017

How/where would I document the keyword arguments of some specific loader, ideally using Julia's help system? Just adding a doc-string to each load method doesn't work, as that would make for a super long concatenated doc-string. Maybe add it to the format-string somehow?

@SimonDanisch
Copy link
Member

Interesting question, we should definitely have a nice solution for this! The format string seems to be a good place!

@mauro3
Copy link
Author

mauro3 commented Jan 18, 2017

Is there a central place where the format-strings are stored?

@SimonDanisch
Copy link
Member

Well, it's a type:

julia> format"PBMBinary"
FileIO.DataFormat{:PBMBinary}

Still looking at the docs, if a type with parameters can be explicitly documented.

@SimonDanisch
Copy link
Member

Maybe add it to the IO package module?

@mauro3
Copy link
Author

mauro3 commented Jan 18, 2017

I don't think one can document types with parameters separately for different parameters.

To actually be able to find the documentation of a loader, some call involving the file itself would be best as remembering anything else will be impossible. Maybe help("pic.png") or helpIO("pic.png")? These suggestions fall outside the julia-help system. But I don't think it can be used directly as a function call needs to be done to transform "pic.png" into something to which a doc-string can be attached.

Let's call @MichaelHatherly to the rescue! Do you have any idea on how to do this within the help system?

@MichaelHatherly
Copy link

The doc concatenation can be a bit annoying sometimes... though you should be able to search for docs for methods that only match a specific signature with:

julia> "docs for `load`"
       function load end
load

julia> type DataFormat{Sym} end

julia> "docs for png `load`"
       load(::DataFormat{:png}) = nothing
load

julia> macro format_str(text) DataFormat{Symbol(text)} end
@format_str (macro with 1 method)

help?> load(::format"png")
  docs for png load

help?> load
search: LoadError LOAD_PATH reload download unsafe_load logabsdet localindexes clipboard

  docs for load

  docs for png load

Doesn't look like the :: syntax for ? mode is documented currently, probably worth adding that somewhere in the manual.

@mauro3
Copy link
Author

mauro3 commented Jan 19, 2017

(+1 to documenting the :: syntax.)

But that then means that the doc-string returned by ?load is huge, as it is the concatenation of all of the method doc-strings (currently there are about 50 registered formats). I guess that might be a problem in other use cases too.

Perfect would be if:

  • ?load("foo.sif") could be made to work as remembering something like format"AndorSIF" would be hard.
  • ?load would just show the function doc and not the docs of all methods.

But I can't see how this could be made to work. So how about making a function docIO("foo.sif") and register a doc-string with the add_format?

@SimonDanisch
Copy link
Member

Yeah, that'd be the sane approach!

@mauro3
Copy link
Author

mauro3 commented Jan 20, 2017

Isn't this JuliaLang/julia#20142 what we need here?

@SimonDanisch
Copy link
Member

SimonDanisch commented Jan 20, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants