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

Express sizes in more human-readable form? #2272

Closed
cormullion opened this issue Sep 19, 2023 · 8 comments
Closed

Express sizes in more human-readable form? #2272

cormullion opened this issue Sep 19, 2023 · 8 comments
Labels
Format: HTML Related to the default HTML output good first issue Indicates a good issue for first-time contributors help wanted Type: Enhancement

Comments

@cormullion
Copy link
Contributor

Congratulations on Documenter 1.0 - I've been using it without issues for various packages. It's awesome!

I think that this output:

Screenshot 2023-09-19 at 09 18 01

could be made better if the "bytes" were converted to something more familiar. These days I'd be happy with MB, but KB could be OK. And perhaps it could be rounded to the nearest sensible amount, the precision here seems unnecessary (and we'd avoid the Kibibytes versus Kilobytes issue too).

@mortenpi mortenpi added Type: Enhancement Format: HTML Related to the default HTML output labels Sep 19, 2023
@mortenpi
Copy link
Member

Yeah, absolutely. I was just too lazy to implement it 🙂

@mortenpi
Copy link
Member

The only thing is that there is a bit of range to the values, so I think it should pick the appropriate unit based on the order of magnitude (don't need to worry about anything other than B, KiB and MiB though).

@Hetarth02
Copy link
Contributor

I would be happy to contribute.

@mortenpi Can you guide me, what we want to achieve(display in kb, mb, etc.) and where should I start looking?

@mortenpi
Copy link
Member

mortenpi commented Oct 29, 2023

@Hetarth02 The relevant line of code should be here:

size_threshold_msg(var::Symbol) = """
Generated HTML over $(var) limit: $(navnode.page)
Generated file size: $(file_size) (bytes)
size_threshold_warn: $(ctx.settings.size_threshold_warn) (bytes)
size_threshold: $(ctx.settings.size_threshold) (bytes)
HTML file: $(page_path)"""

And as far as what we want to achieve: make sure that it prints the file sizes in B, KiB and MiB as appropriate. No need to support GiB and bigger, since if the user has pages that big, they have bigger problems.

@mortenpi mortenpi added help wanted good first issue Indicates a good issue for first-time contributors labels Oct 29, 2023
@cormullion
Copy link
Contributor Author

9223372036854775807 was the worst one 😂

@mortenpi
Copy link
Member

9223372036854775807 was the worst one 😂

That probably needs to be special cased though. I'm using typemax(Int) to indicate "no limit".

size_threshold = typemax(Int)

@mortenpi
Copy link
Member

#2344

@cormullion
Copy link
Contributor Author

Thanks!

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 good first issue Indicates a good issue for first-time contributors help wanted Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants