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

IOContext docstrings would benefit from more examples #22637

Closed
Sacha0 opened this issue Jun 30, 2017 · 0 comments
Closed

IOContext docstrings would benefit from more examples #22637

Sacha0 opened this issue Jun 30, 2017 · 0 comments
Assignees
Labels
domain:display and printing Aesthetics and correctness of printed representations of objects. domain:docs This change adds or pertains to documentation good first issue Indicates a good issue for first-time contributors to Julia Hacktoberfest Good for Hacktoberfest participants needs docs Documentation for this change is required

Comments

@Sacha0
Copy link
Member

Sacha0 commented Jun 30, 2017

The existing docstrings for IOContext (copied below) together contain only one example, and that example references a property not mentioned elsewhere in those docstrings. An example or two for each signature would make these methods much easier to grasp. Best!

IOContext

  IOContext provides a mechanism for passing output configuration settings among show
  methods.

  In short, it is an immutable dictionary that is a subclass of IO. It supports standard
  dictionary operations such as getindex, and can also be used as an I/O stream.

  IOContext(io::IO; properties...)

  The same as IOContext(io::IO, KV::Pair), but accepting properties as keyword arguments.

  IOContext(io::IO, context::IOContext)

  Create an IOContext that wraps an alternate IO but inherits the properties of context.

  IOContext(io::IO, KV::Pair)

  Create an IOContext that wraps a given stream, adding the specified key=>value pair to the
  properties of that stream (note that io can itself be an IOContext).

    •    use (key => value) in dict to see if this particular combination is in the
        properties set

    •    use get(dict, key, default) to retrieve the most recent value for a particular
        key


  The following properties are in common use::compact: Boolean specifying that small values should be printed more compactly,
        e.g. that numbers should be printed with fewer digits. This is set when printing
        array elements.

    •    :limit: Boolean specifying that containers should be truncated, e.g. showing 
        in place of most elements.

    •    :displaysize: A Tuple{Int,Int} giving the size in rows and columns to use for
        text output. This can be used to override the display size for called functions,
        but to get the size of the screen use the displaysize function.


  julia> function f(io::IO)
             if get(io, :short, false)
                 print(io, "short")
             else
                 print(io, "loooooong")
             end
         end
  f (generic function with 1 method)

  julia> f(STDOUT)
  loooooong
  julia> f(IOContext(STDOUT, :short => true))
  short
@Sacha0 Sacha0 added domain:display and printing Aesthetics and correctness of printed representations of objects. domain:docs This change adds or pertains to documentation Hacktoberfest Good for Hacktoberfest participants good first issue Indicates a good issue for first-time contributors to Julia needs docs Documentation for this change is required labels Jun 30, 2017
@rfourquet rfourquet self-assigned this Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:display and printing Aesthetics and correctness of printed representations of objects. domain:docs This change adds or pertains to documentation good first issue Indicates a good issue for first-time contributors to Julia Hacktoberfest Good for Hacktoberfest participants needs docs Documentation for this change is required
Projects
None yet
Development

No branches or pull requests

2 participants