-
Notifications
You must be signed in to change notification settings - Fork 46
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
Example for using v2.X with Read the Docs #214
Comments
Maybe a more general approach would be document if / how it is possible to generate the cache and use it in a single Sphinx pass. Requiring to manually run Sphinx twice is also going to be a problem for Jupyter Book as well :-/ e.g., could you somehow init the cache manually as a part of your |
That's exactly what the extension already does. Quoting from the documentation:
Does this help? |
If you need examples, there's plenty in the regression tests. Most tests store the json in version control, so they only need to run sphinx once. There's a few tests where that's not the case if they explicitly need to test the json generation. You can find them here: https://github.com/mcmtroffaes/sphinxcontrib-bibtex/tree/develop/test/roots/ |
Sorry I should have added "without committing the auto-generated file" - as a general strategy we are trying not to require users to package build assets with their repositories and only include user-edited files. I don't think it is a deal breaker, but I'm just wondering if there's a way to do it |
No, not at the moment unfortunately. I understand it's not ideal to have a generated file in version control. That's the price for wanting to run sphinx just once: the extension needs this information to resolve references. I take from this issue that the documentation may not be 100% clear. If anyone sees a better way of phrasing it, I'm open to suggestions. |
Yeah, same. Having to maintain the This was my motivation for asking about examples of telling RTD to run Sphinx twice. I'm not sure if this is possible, but if it isn't then I think it would be very helpful to make a large notice in the docs that if you want to use RTD then you must version (Thanks for the very fast responses btw!) |
Eurgh, I honestly think this is going to be a big deal breaker for a lot of people looking to use this package. |
Thanks for all the feedback, everyone. I deeply appreciate that! I realize 2.0.0 is a bit of a double edged sword: one the one hand it fixes some very long standing issues (unresolved citations, parallel builds), but on the other hand it now needs to either run sphinx twice or keep a generated file in version control. The reason the extra file is required is to ensure that the bibliography directives can generate the correct citation nodes even if the citing document has not yet been processed, as sphinx processes documents out of order. There might be other ways to achieve this for instance by postponing citation nodes to be generated to a much later stage when all documents have already been read and processed. However to do that, the extension must do all the heavy lifting to resolve all references appropriately, basically duplicating what sphinx already does for regular citations. I currently don't understand enough of sphinx to code this with confidence, and so far, I've preferred not to duplicate anything that sphinx can already can do for me. So I've leveraged the existing sphinx citation system rather than built my own one from scratch and basically reinvent the wheel. You can find a bit more discussion about this from the sphinx devs at this thread sphinx-doc/sphinx#6393 (comment) although I'm not sure how that specific suggestion would work with multiple bibliography directives, besides being potentially quite inefficient in case of large bib files with only few citations. Maybe something else with pending_xref or SphinxPostTransform could work too. For now, an alternative is to use the new footcite and footbibliography system if you're ok with references being part of the footnotes, and if you're ok to have your reference details duplicated across documents. The json is only used for regular citations. If you don't use regular citations a single build will work fine. |
thanks @mcmtroffaes, yeh I'll try to have a think about it a some point. We've pinned jupyter-book to v1 for now, and I feel we will be motivated to help come up with a simpler approach, otherwise we will have more people complaining than already are lol (jupyter-book/jupyter-book#1137) |
Sure, and this is a major update for a reason. Pinning to sphinxcontrib-bibtex<2.0.0 makes sense. I hope I can eventually make some updates to make the new system work without needing to use a generated file, but it may take some time. |
Oh absolutely, thanks for putting in the time for the improvements 🙏 |
…xcontrib.bibtex`. Note that we need to run Sphinx twice on Travis. See issue mcmtroffaes/sphinxcontrib-bibtex#214.
…xcontrib.bibtex`. Note that we need to run Sphinx twice on Travis. See issue mcmtroffaes/sphinxcontrib-bibtex#214.
With version 2.0.0, Sphinx needs to run twice on Travis. See issue mcmtroffaes/sphinxcontrib-bibtex#214. This is what I tried to get it running (the first command is allowed to fail, the second not): - if [ $TRAVIS_PYTHON_VERSION == "3.7" ] ; then travis-sphinx build --source=hydpy/docs/auto || true; fi - if [ $TRAVIS_PYTHON_VERSION == "3.7" ] ; then travis-sphinx build --source=hydpy/docs/auto; fi However, the second command also fails, as Sphinx cannot find the `bibtex.json` file generated in the first run. I suspect, this is due to how the `travis-sphinx` script works.
* Use check_consistency to identify all citation cross-references, use resolve_xref for citation references, and SphinxPostTransform for bibliography citations, so that bibtex.json no longer needed and thus Sphinx no longer needs to run twice as in the past if the file did not exist (closes issues #214 #215). * Citations with multiple keys will now reside in the same bracket (closes issue #94). * Consistent use of doctutils note_explicit_target to set ids, to ensure no clashing ids. * Improved and robustified test suit, using regular expressions to verify generated html. * Various API updates to accommodate the new design.
I thought putting bibtex.json in the source directory was a decent workaround, but it is not in my case. I use the same sources to build multiple configurations and each new build results in an unwanted update of the bibtex.json (which was build using the maximal configuration, i.e., the one with all citations included). So I am glad an alternative is materializing. |
Glad to hear it's appreciated! It's just in develop, will be releasing later today as soon as I have the documentation and release notes finished. |
@mcmtroffaes I have been enjoying watching your code marathon these past few days :-) |
The post-transform branch is now included with the 2.1.0 release, so closing as sphinx no longer needs to run twice. |
Hi. Thanks for making
sphinxcontrib-bibtex
! My team and I are working on updating to thev2.0.0
release but as withv2.0
Sphinx must be run twice to generate the bibliography:It isn't exactly clear how one would accomplish this for a testing system like Read The Docs, which we use to test the rendering of our docs for each PR. It would be great if possible if an example could be added to the documentation that highlighted possible solutions to this.
The text was updated successfully, but these errors were encountered: