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

feat: write at-example outputs over threshold to a file #2247

Merged
merged 19 commits into from
Sep 14, 2023

Conversation

mortenpi
Copy link
Member

@mortenpi mortenpi commented Sep 8, 2023

Building on top of @jvaverka's contribution. Close #2143.

  • Currently only implemented for PNG. Expand for other binary images.
  • Expand for SVG -- it's a bit more complicated, so needs testing.
  • Tests-tests-tests.

@mortenpi mortenpi added Type: Enhancement Format: HTML Related to the default HTML output labels Sep 8, 2023
@mortenpi mortenpi added this to the 1.0.0 milestone Sep 8, 2023
@mortenpi mortenpi force-pushed the mp/at-example-to-file branch from 06f4667 to 04f39a8 Compare September 8, 2023 09:24
@mortenpi mortenpi marked this pull request as ready for review September 11, 2023 10:23
@mortenpi
Copy link
Member Author

mortenpi commented Sep 11, 2023

This should essentially be good to go, except for the complication described in #2143 (comment).

src/html/HTMLWriter.jl Outdated Show resolved Hide resolved
@mortenpi
Copy link
Member Author

@odow Would you by any chance have time to test this branch with JuMP, see if it helps with the page sizes? I actually suspect it might not be as useful as I had hoped due to #2143 (comment).

@odow
Copy link
Collaborator

odow commented Sep 11, 2023

Let me have a go

@mortenpi
Copy link
Member Author

One possibility to work around the text/html issue:

Check the size of text/html. If it is over the size limit, check if shows for any of the file-based image ones are available. If yes, use one of those (with a warning saying that text/html MIME was ignored due to size). If not, write text/html, but issue a warning that it's above the size threshold.

src/html/HTMLWriter.jl Outdated Show resolved Hide resolved
src/html/HTMLWriter.jl Outdated Show resolved Hide resolved
mortenpi and others added 2 commits September 12, 2023 14:00
Co-authored-by: Oscar Dowson <odow@users.noreply.github.com>
Co-authored-by: Oscar Dowson <odow@users.noreply.github.com>
@odow
Copy link
Collaborator

odow commented Sep 12, 2023

@mortenpi
Copy link
Member Author

Aren't the images just svg blocks?

Yes, but they are generated using the text/html show method, so we can't really reliably determine whether they are pure SVG or not.

@mortenpi
Copy link
Member Author

One user-level hack here is to define

Base.showable(::MIME"text/html", ::Plots.Plot) = false

in your make.jl, which will make Documenter ignore the text/html representation.

@mortenpi
Copy link
Member Author

Documenter should now print just a single warning that looks something like this:

┌ Warning: For 3 @example blocks, the 'text/html' representation of the resulting
│ object is above the the threshold (example_size_threshold: 8192 bytes).
│ - 1 blocks had no image MIME show() method representation as an alternative.
│   Sticking to the 'text/html' representation (largest block is 121034 bytes).
│   On pages: index.md
│ - 2 blocks had 'image/svg+xml' fallback image representation available, using that.
│   On pages: index.md, plots.md
└ @ Documenter.HTMLWriter ~/juliadocs/Documenter/src/html/HTMLWriter.jl:779

@mortenpi mortenpi enabled auto-merge (squash) September 14, 2023 08:15
@mortenpi mortenpi merged commit 1aaf685 into master Sep 14, 2023
20 of 21 checks passed
@mortenpi mortenpi deleted the mp/at-example-to-file branch September 14, 2023 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Format: HTML Related to the default HTML output Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An option to write at-example outputs to file
3 participants