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

Skip building bib_data if files are older than config time (for mkdocs serve) #240

Merged
merged 6 commits into from
Apr 4, 2024

Conversation

mdbenito
Copy link
Contributor

@mdbenito mdbenito commented Mar 30, 2024

This PR is a continuation to #238.

  • It uses on_startup() to avoid unloading the plugin when using mkdocs serve.
  • It avoids rendering the bibtex for all references during on_config() by storing the time() of the first run, then checking the timestamps of the bibtex files passed by the user. If any file is newer all refs are read again.

The speedup is only noticeable after merging #238, but with both PRs together, our re-build using mkdocs serve goes from ~41secs to ~25 secs, or a 40% total reduction in build time. This makes working on documentation much nicer :)

@mdbenito mdbenito marked this pull request as draft March 30, 2024 20:20
@mdbenito mdbenito marked this pull request as ready for review March 30, 2024 20:44
Copy link

codecov bot commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 96.20%. Comparing base (1496fab) to head (696189d).
Report is 4 commits behind head on main.

Files Patch % Lines
src/mkdocs_bibtex/plugin.py 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #240      +/-   ##
==========================================
- Coverage   97.97%   96.20%   -1.78%     
==========================================
  Files           3        3              
  Lines         198      211      +13     
==========================================
+ Hits          194      203       +9     
- Misses          4        8       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mdbenito
Copy link
Contributor Author

mdbenito commented Apr 4, 2024

@shyamd I see the errors. Sorry about that. I'll look into it and get back to you

@shyamd
Copy link
Owner

shyamd commented Apr 4, 2024

Thanks for all these performance improvements and no worries on the failing tests. Took me awhile to turn on tests for your PRs.

@shyamd
Copy link
Owner

shyamd commented Apr 4, 2024

I re-named the attribute that you used for holding the last config time. The fact that it wasn't throwing an AttributeError tells me that mkdocs was already using it. This new attribute throws an AttributeError if you don't use the hasattr guard, which is what we'd hope.

@shyamd shyamd merged commit 5119d08 into shyamd:main Apr 4, 2024
13 of 15 checks passed
@shyamd
Copy link
Owner

shyamd commented Apr 4, 2024

Thanks for all these performance improvements. Next minor version bump will include them.

@mdbenito
Copy link
Contributor Author

mdbenito commented Apr 4, 2024

My pleasure. Thank you for the plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants