-
Notifications
You must be signed in to change notification settings - Fork 0
Claude add bib entry support r6c2 i #49
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
base: main
Are you sure you want to change the base?
Conversation
Implements automatic BibTeX entry generation from figure metadata: - Add configuration options for BibTeX generation: - generate_bib: Enable/disable BibTeX generation (default: false) - output_file: Output .bib file path (default: references.bib) - overwrite_existing: Overwrite existing entries (default: false) - Implement _generate_bib_entry() function: - Converts figure metadata to @misc BibTeX format - Supports author, title, date/year, url/howpublished, license (in note), copyright - Handles URLs, markdown links, and plain text sources - Implement _write_bib_entry() function: - Writes BibTeX entries to configured output file - Checks for existing entries to avoid duplicates - Supports overwriting existing entries when configured - Integrate generation into MetadataFigure.run(): - Generates BibTeX when :bib: option is specified with metadata - Extracts caption from figure node for title field - Only generates if metadata is present - Update documentation: - README: Add BibTeX generation configuration and usage examples - Includes complete example showing metadata-to-BibTeX conversion This completes Option 1 from Issue #16, complementing the existing Option 3 (BibTeX extraction) from PR #34.
Updated the citation text format from ':cite:empty:`{bib_key}`' to '{cite:empty}`{bib_key}`' to ensure correct parsing when adding to the bibliography.
Implements the hybrid approach for BibTeX synchronization: 1. Cache injection: Injects generated entries directly into sphinxcontrib-bibtex's internal cache using pybtex, enabling same-build citation support without requiring a rebuild. 2. File persistence: Also writes entries to .bib file for future builds and version control. 3. Graceful fallback: If cache injection fails (API changes, pybtex unavailable), warns user and file is still written. New configuration options: - generate_bib: Enable BibTeX generation (default: false) - output_file: Output .bib file path (default: references.bib) - overwrite_existing: Overwrite existing entries (default: false) This solves the "bibtex-sync challenge" from PR #38 review where generated entries weren't recognized until a second build.
Resolves merge conflicts by incorporating: - All features from main (page-level defaults, license translations, etc.) - BibTeX generation with cache injection for single-build support The cache injection solution addresses the reviewer feedback about requiring a second build. Generated entries are now injected directly into sphinxcontrib-bibtex's cache, enabling same-build citations.
…project-bibtext-ie7Gv
Changed the priority order for resolving figure metadata fields so that BibTeX metadata is now checked before page-level defaults. Updated both the code logic and documentation to reflect this new precedence for license, date, author, copyright, and source fields.
Refines the logic for handling unrecognized BibTeX keys by checking the 'generate_bib' setting before displaying a message. Also includes minor whitespace and formatting adjustments for clarity.
…ie7Gv Review project and investigate bibtext-sync issue
The cache injection was failing because it was looking for the wrong attribute name. Changed from env.bibtex_bibfiles to env.bibtex_cache.bibfiles to match the actual sphinxcontrib-bibtex cache structure. Changes: - Fix cache attribute: env.bibtex_cache instead of env.bibtex_bibfiles - Access bibfiles through cache.bibfiles - Add detailed debug logging to track cache access - Improve error messages with actionable guidance - Change successful injection logging from debug to info level - Add traceback logging for exceptions This enables single-build citation of auto-generated BibTeX entries. Fixes the issue reported in PR #45 review where cache was never found.
|
@lkdmc , I've tested it in the manual, but it still gives a warning that it requires a rebuild: https://github.com/TeachBooks/manual/actions/runs/21023441945/job/60442569461#step:10:282 and the built book doesn't contain the bib entry: https://teachbooks.io/manual/bib/references.html (it only contains the entry used by another figure: https://teachbooks.io/manual/bib/_git/github.com_TeachBooks_Sphinx-Metadata-Figure/claude-add-bib-entry-support-R6c2I/MANUAL.html#example-11-metadata-with-bibtex-extraction Do you see an option how this could work? If so, could you test it first in this manual page? Please let me know if you need help with that! Furthermore, @douden , shouldn't the priority order be bib at 2? Now because of the bib entry we get the local page defaults although that's not desired: https://teachbooks.io/manual/bib/_git/github.com_TeachBooks_Sphinx-Metadata-Figure/claude-add-bib-entry-support-R6c2I/MANUAL.html#tb-logo-metadata13 |
|
If we really cannot fix this in a single build. would it be an idea to do this in the |
|
Tested here too: https://oit.tudelft.nl/CTB1310/test_bib/shear/instructie.html |
Yes, priority should be 2, which it is in the latest release. Already fixed that. |
Could be am option, but that means we have to write our own complete myst-parser, which can be very buggy. And this is not really a thing of TeachBooks, but of this extension. If possible, it could be triggered on the source-read event, if that is before the bibtex load. But that should be researched. |
Apparantely it isn't because we get the metadata of the local page instead of the bib entry. I think there should be the option for the default-metadata-page to do bib creation and extraction too, although that should be overruled when a bib entry is used for creation or extraction on a single figure. |
For a new bib entry that makes sense, as the key did not exist, so no information was extracted from the cache. For existing entries it works as it should.
That is possible, but still the same restriction applies with the bibtex cache. So that should be fixed first. |
|
@lkdmc : let me know using a mention when you have found a fix for the caching problem. I will review then. |
Renamed branch name, replaces #48