Repository navigation
Conversion of Tutorial from LaTeX to RST for Sphinx - #4371
Conversation
|
Local testing is using: and (The old version of pandoc is to avoid a regression in LaTeX to RST conversion of figure metadata, that should be fixed in their next release) Currently output: The The table cross-references have not been addressed yet: This looks like a false positive as the two class references are explicitly using |
|
This would resolve #4228 by dropping the arguments to the minted blocks before converting them to RST. |
|
I'm thinking of using the basic RST citation function for our references: This would mean transforming the embedded reference list from here https://github.com/biopython/biopython/blob/biopython-181/Doc/Tutorial.tex \begin{thebibliography}{99}
\bibitem{cock2009}
Peter J. A. Cock, Tiago Antao, Jeffrey T. Chang, Brad A. Chapman, Cymon J. Cox, Andrew Dalke, Iddo Friedberg, Thomas Hamelryck, Frank Kauff, Bartek Wilczynski, Michiel J. L. de Hoon: ``Biopython: freely available Python tools for computational molecular biology and bioinformatics''. {\it Bioinformatics} {\bf 25} (11), 1422--1423 (2009).
\url{https://doi.org/10.1093/bioinformatics/btp163}
...
\end{thebibliography}into something like this: .. [cock2009] Peter J. A. Cock, Tiago Antao, Jeffrey T. Chang, Brad A. Chapman, Cymon J. Cox, Andrew Dalke, Iddo Friedberg, Thomas Hamelryck, Frank Kauff, Bartek Wilczynski, Michiel J. L. de Hoon: ``Biopython: freely available Python tools for computational molecular biology and bioinformatics''. *Bioinformatics* **25** (11), 1422--1423 (2009).
https://doi.org/10.1093/bioinformatics/btp163Happily for this plan, we're not using the bibtex format. |
|
Confirming that using Sphinx 4.3.2 (as currently used by GitHub Actions for the API docs) avoids this error which does look then like a regression somewhere in Sphinx: Instead we get a different error "duplicated entry found in toctree" in the autogenerated API docs... The "more than one target" also appears in Sphinx 4.4.0, 4.5.0, 5.0.2, 5.1.1, 5.2.3, 5.3.0 and 6.2.1 (I should have started testing the older releases in hindsight). It would probably be prudent to pin versions once I have this all working! |
|
As to references, using this in RST Renders like this:
where the square brackets shows the citation key as-s, and as a clickable link to the bibliography. For that the raw RST can be: And that rendered fine - but again shows the raw citation key as-is. My inclination is to change the keys to title case first author and year. So not as much control as LaTeX offers, but good enough (and we can change this later if we really want to). |
|
Rebase without re-running pandoc (simpler), note will want to remove recent additions of |
48b53ef to
904bfde
Compare
|
Will have to decide if want to use Likewise for However, that's not something I want to worry about right now. See https://docutils.sourceforge.io/docs/ref/rst/roles.html#math |
|
The HTML build looks to be working without errors on CircleCI using Sphinx v4.3.2 Locally on macOS using Sphinx 7.2.6 however, there are two warnings (which are treated as an error in strict mode): See notes above about this. It looks like a false positive as two fragments do not reference the class as just "Chain" but deliberately use the fully qualified name. |
|
Question: Should the git history remove |
|
@mdehoon I'll have to refresh this again since the LaTeX files are in flux, but can you comment on the general approach here for conversion to RST and building the Tutorial in Sphinx alongside the API docs? Thanks! |
|
@peterjc I don't have a strong opinion about it. |
|
Do you have a lot more Tutorial changes pending? If not, perhaps I should refresh the conversion and apply the changes this week. |
|
@peterjc I can hold off on tutorial changes until this PR is done. |
|
I've pulled out some of the base changes as #4565 which I plan to merge shortly. This now also includes the updates for |
Note doc8 is not happy yet!
Sphinx/RST needs relative image paths - while for LaTeX we
used include-file, so was relative to parent dir.
Replacing Figure<nbsp>:ref: with :numref:
Note sed-trickery to preserve our doctest comment lines.
NOTE - Using pandoc v2.19.2 to ensure sensible figure output
$ for f in *.tex; do echo "Converting $f to rst"; sed "s/^%doctest/\n\\\\pandocignoreme .. doctest/g" $f | sed "s/^%cont-doctest/\n\\\\pandocignoreme .. cont-doctest/g" | pandoc --strip-comments -f latex -t rst | ../../.github/ref_fix.py - | sed "s#.. figure:: images/#.. figure:: ../images/#g" | sed "s# image:: images/# image:: ../images/#g" | sed "s/Figure :ref:/:numref:/g" > ${f%.*}.rst; done
Also avoid using math mode in the label
Also solves 'WARNING: document isn't included in any toctree' from Sphinx
Avoiding hard breaks in longer attribute names and empty entries from some rows
Setup header, then: $ python ../.github/rst_bibitem.py Tutorial.tex >> Tutorial/chapter_bibliography.rst
D000 Unknown target name: seems to give false positives on citations, probably as they are in a separate file. D001 Line too long: we ought to review this later, we might be able to improve on the pandoc layout. D002 Trailing whitespace: probably from doctests, which is hard to avoid.
Original commit from Anil Tuncel, 27 July 2019, on pull request biopython#2188. Cherry-picked, conflicts fixed, path assumptions updated, documentation and error messages updated, by Peter Cock.
|
The Sphinx generated HTML Tutorial is now live on https://biopython.org/docs/dev/ alongside https://biopython.org/docs/dev/api/ following the big automated update which worked as expected via the CI, biopython/docs@dc91097 |
Should have been included in #4371.
Should have been included in #4371.


I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rstfile, have runpre-commitlocally, and understand that continuous integration checks will be used to
confirm the Biopython unit tests and style checks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)
Would close #907
but this PR is not ready yet.My plan is to work on this PR with occasional rebasing on the master to get the latest changes to the LaTeX files (which will require rerunning the pandoc conversion with a suitable version of pandoc, and fixing any conflicts which follow - especially in figure captions).
Automatic deployment ought to work as a simple extension of the current API doc deployment to https://github.com/biopython/docs
Final commits would remove the helper scripts and the LaTeX files.