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

Fix printing guidelines #2769

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/src/DeveloperDocumentation/printing_details.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ found in the [Developer Style Guide](@ref).

## Implementing show functions

Here is the translation between `:detail`, `one line` and `:supercompact`.
Here is the translation between `:detail`, `one line` and `:supercompact`,
where `io` is an `IO` object (such as `stdout` or an `IOBuffer`):

```
print(io, "text/plain", x) # detailed printing
print(io, x) # one line printing
print(IOContext(:supercompact => true), x) # supercompact printing
show(io, MIME"text/plain"(), x) # detailed printing
print(io, x) # one line printing
print(IOContext(io, :supercompact => true), x) # supercompact printing
```

For reference, string interpolation `"$(x)"` will also use `print(io, x)`.
For reference, string interpolation `"$(x)"` uses one line printing via `print(io, x)`,
while on the REPL detailed printing is used to show top level objects.

### Mockup

Expand Down Expand Up @@ -173,7 +175,7 @@ end

function Base.show(io::IO, b::B)
io = AbstractAlgebra.pretty(io)
print(io, LowercaseOff(), "Hilbert thing")
print(io, AbstractAlgebra.LowercaseOff(), "Hilbert thing")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is exported? Then AbstractAlgebra. is not necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, LowercaseOff, Indent, Dedent, pretty are imported from AbstractAlgebra into Oscar, thus one need not write AbstractAlgebra. in code inside Oscar; but they are not exported from Oscar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example code uses an explicit AbstractAlgebra. everywhere else, and it should be consistent. With it there, a user can copy&paste the example code and start working with it, whether or not they have done using AbstractAlgebra (which is dangerous inside a package) or import AbstractAlgebra.

Anyway, my primary concern was to make it consistent. If someone prefers to drop the AbstractAlgebra. everywhere, that should be a seperate PR, IMHO

end
```

Expand Down
Loading