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

Docs: simple docstring for write(filename::AbstractString, x) #49835

Merged
merged 4 commits into from
Jun 5, 2023

Conversation

fonsp
Copy link
Member

@fonsp fonsp commented May 16, 2023

Point 2 of #43428.

I also changed "the canonical binary representation of a value" to just say "x".
It felt like a very complex way of saying that it does what you think it does. 🙂 I think it's good to document it like this for the write(io::IO, x) method, but as I expressed in #43428, I think we should document the write(filename::String, content) method in a more beginner-friendly way.

@Seelengrab
Copy link
Contributor

Seelengrab commented May 16, 2023

I also changed "the canonical binary representation of a value" to just say "x".

The distinction is important though - writing the binary representation of 1.0 to a file is very different from taking 1.0 and writing that to a file (i.e., what print would do). You can't open the resulting file with a text editor and see 1.0 there. That write doesn't print is quite literally the defining distinction of the two.

@fonsp
Copy link
Member Author

fonsp commented May 16, 2023

I see! Is it possible to link to the other method's documentation? I feel like it is important to keep this method's documentation accessible to people without a CS/math background.

@Seelengrab
Copy link
Contributor

Seelengrab commented May 16, 2023

For linking other functions, it's usually done like this:

See also: [`print`](@ref).

which will link to the documentation of print.

I feel like it is important to keep this method's documentation accessible to people without a CS/math background.

I'm not sure this is possible - we have to stop explaining at some point, otherwise docstrings get too long and miss their actual purpose, documenting what a given method does. For write, I think mentioning that this writes the binary representation is the most accurate it can be, without being overly off-topic. It'd be weird to start explaining in a docstring that there's a difference between displaying a value and how its represented internally. That's more the job of a manual or tutorial than that of a docstring.

base/io.jl Outdated Show resolved Hide resolved
Co-authored-by: Jameson Nash <[email protected]>
@fonsp fonsp requested a review from vtjnash May 31, 2023 19:45
base/io.jl Outdated Show resolved Hide resolved
@vtjnash vtjnash added docs This change adds or pertains to documentation merge me PR is reviewed. Merge when all tests are passing labels Jun 1, 2023
@giordano giordano merged commit 270a1d8 into JuliaLang:master Jun 5, 2023
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Jun 5, 2023
giordano pushed a commit that referenced this pull request Oct 31, 2023
Point 5 of #43428

Motivation: I feel like the most fundamental *file* operations in Julia
are `read(filename::String)` and `write(filename::String, content)`, so
it makes sense to repeat their documentation in the **Filesystem**
documentation. I also see
these methods as fundamental to teach beginners.


Like #49837, the goal is to only
show short docstrings for these methods, not the whole `IOStream`
functionality. So it depends on
#49835 and
#49836 to be useful :)
giordano pushed a commit that referenced this pull request Nov 1, 2023
…efore `open` (#49837)

Point 3 of #43428

Depends on #49835 and
#49836 to be useful :)

---------

Co-authored-by: Jameson Nash <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants