You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replacing LaTeX based Tutorial (pdflatex and hevea)? #907
We can likely use pandoc as a first pass of converting the current LaTeX source for the tutorial into a more modern markdown language like reStructuredText (*.rst, currently used in our docstrings) or MarkDown (*.md, currently used for our website).
Any conversion will also need to rewrite test_Tutorial.py which pulls doctest formatted examples out of the tutorial source (together with a simple dependency mechanism).
Is switching to markdown viable for a document at complex as the current Tutorial? If we switched the docstrings as well (see pdoc suggestion on #906) this would be much more attractive as a single option.
While we're at it, we may want to slim down the Tutorial and move some of the more detailed material to a separate Reference based on the automated API docs.
Having both the docstrings and the Tutorial written in the same markup language would make this sort of restructuring much easier in future (regardless of if we use reStructuredText or MarkDown, which seem to be the only sensible choices).
In order to preserve the test_Tutorial.py functionality (which I feel has been well worth the time investment so far in both keeping the examples working, but also sometimes catching bugs not covered by the main test suite), we will likely need to define a special comment or markup block.
(empty line)
[comment]: # (This actually is the most platform independent comment)
Alternatively we might use Markdown's fenced code blocks feature (triple back-ticks) with a bespoke info-string (rather than just python for the colour syntax markup)?
With respect to 'slimming down the tutorial' I disagree. I would prefer to have even more examples and details in the tutorial, so that I don't have to switch back and forth between the tutorial, the cookbook sections of the homepage, the wiki entries of the homepage and the api documentation (and the source code for the undocumented functions). So why don't we call the tutorial 'manual' and build it as the main comprehensive Biopython documentation source?
Text which is simultaneously both Markdown and reStructuredText is an intriguing idea, but practically we'd loose out on Python syntax formatted examples etc.
But let's keep this issue on the technical side about what (if anything) we should use instead of LaTeX?
I think that reST would be preferable given its compatibility with Sphinx and Python documentation generally, but on the other hand it looks like there's still no syntax highlighting of Python code blocks in reST files in GitHub. That argues for Markdown. Any new thoughts on this? Happy to help, if an approach is chosen.
Following the work in #2172 etc to close #906, we now have the API documentation (docstring comments written in RST) converted to HTML documentation using Sphinx.
I have now managed a proof of principle conversion of the Tutorial from LaTeX into RST, and combined this with the API documentation using Sphinx (which could be deployed on our website via GitHub pages, and/or on Read The Docs).
I deliberately kept one page per chapter (i.e. one *.rst file per chapter, like we have now one *.tex file per chapter). That has a side effect of complicating links between pages from the LaTeX \label{XXX} and \ref{XXX}, but I can fix that by converting them to RST style :ref: entries (and we give up on having chapter and section numbering in the link captions).
I'm unsure at this point if any automated conversion is realistic as part of the continuous integration system. It would be more realistic to aim for a one-off conversion from LaTeX to RST. Thereafter contributors would only need to learn RST for writing or editing the main Biopython documentation.
During the BOSC CoFest 2019, @anilbey was able to convert test_Tutorial.py to work with RST files - pull request #2188.
Another idea is to use sphinx's built in doctest support - but as far as I know that lacks any fine grained control (e.g. dependencies). We would also have to update all the examples to use a particular working directory for relative paths.
I think if we do the LaTeX to RST conversion now, we'd put the Sphinx build on our GitHub pages site instead - alongside the Sphinx RST API documentation.
Update: I deleted the RTD pages. We might also consider dual hosting in future?
Yesterday going through the process of building the release it was a bit frustrating to handle all these doc-building quirks. Is this move to rst still desirable? I'd be willing to spend some time doing the one-off conversion and cleaning, hopefully making everything a little simpler to build in the future?
Yes, that was the goal with moving off LaTeX to RST - which seemed last time I looked at this to be the only viable alternative (and we're using it for our docstrings and API docs via Sphinx). It ought to be possible to automatically deploy this just like we autodeploy the API docs.
There are some glitches with figures, RST/Sphinx seems to want one-line caption titles before any extended caption text. That's OK to resolve manually.
Currently the citations and bibliography are a stubling block. We have about 45 entries, about half with a DOI. If they all had a DOI or URL, I'd be happy with replacing them with links (e.g. link text like Cock et al. (2009) with the DOI as the URL). However, that does not cover everything.
Looks like table references will also need checking, proably similar to figures.
Equation references look more tricky (not numbered by default), but we only have two labelled equations - both in the machine learning chapter. Perhaps with minor editing we can avoid explicit references to them?
@peterjc Maybe it's time to deprecate the machine learning code in Biopython? Things like logistic regression are better served in a machine learning library like scikit-learn than in Biopython.
That may be wise (deprecating the logistic regression code), likewise the generic plotting stuff in Bio.Graphics. I'll keep that in mind as deleting the chapter might be easier than converting it ;)
My figure caption issue seems in part to be an issue in recent versions of pandoc, jgm/pandoc#8930 - with that avoided, :numref: works nicely with the Figures (after editing the handful with multi-line captions).
And also there are some table references which I need to look at...
Doc/Tutorial/chapter_align.rst:1974: WARNING: Failed to create a cross reference. A title or caption not found: 'table:align-meta-attributes'
Doc/Tutorial/chapter_motifs.rst:946: WARNING: Failed to create a cross reference. A title or caption not found: 'table:transfaccodes'
Doc/Tutorial/chapter_pdb.rst:1594: WARNING: Failed to create a cross reference. A title or caption not found: 'table:ic-attribs'
Doc/Tutorial/chapter_pdb.rst:1727: WARNING: Failed to create a cross reference. A title or caption not found: 'table:dssp-codes'
Adding a note here from the test_Tutorial.py work on #2188, we need to convert our special LaTeX comment lines used to flag and customize doctests within the LaTeX source. For example:
%doctest ../Tests/GenBank
\begin{minted}{pycon}
>>> from Bio import SeqIO
>>> original_rec = SeqIO.read("NC_005816.gb", "genbank")
\end{minted}
Text here
%cont-doctest
\begin{minted}{pycon}
>>> import random
>>> nuc_list = list(original_rec.seq)
>>> random.shuffle(nuc_list) # acts in situ!
\end{minted}
Using RST comments:
.. doctest ../Tests/GenBank
.. code:: pycon
>>> from Bio import SeqIO
>>> original_rec = SeqIO.read("NC_005816.gb", "genbank")
Text here
.. cont-doctest
.. code:: pycon
>>> import random
>>> nuc_list = list(original_rec.seq)
>>> random.shuffle(nuc_list) # acts in situ!
The workaround was a search-and-replace before calling pandoc, using \pandocignoreme .. doctest ../Tests/GenBank and \pandocignoreme .. cont-doctest for this example. Pandoc seems to ignore the undefined latex term, and just leaves the following text as a line in the output. We can do this with sed, e.g. sed "s/^%doctest/\n\\\\pandocignoreme .. doctest/g" (adding an extra blank line in case there wasn't one to ensure this is not tacked onto the previous paragraph).
Activity
peterjc commentedon Aug 3, 2016
See also #906 about replacing epydoc for generating our API documentation from the docstrings, which are currently written using reStructuredText
peterjc commentedon Aug 3, 2016
Currently we have three markup languages in use:
Is switching to markdown viable for a document at complex as the current Tutorial? If we switched the docstrings as well (see pdoc suggestion on #906) this would be much more attractive as a single option.
peterjc commentedon Aug 3, 2016
A relevant comment from @etal on https://redmine.open-bio.org/issues/3221
Having both the docstrings and the Tutorial written in the same markup language would make this sort of restructuring much easier in future (regardless of if we use reStructuredText or MarkDown, which seem to be the only sensible choices).
peterjc commentedon Aug 3, 2016
In order to preserve the
test_Tutorial.pyfunctionality (which I feel has been well worth the time investment so far in both keeping the examples working, but also sometimes catching bugs not covered by the main test suite), we will likely need to define a special comment or markup block.For markdown https://stackoverflow.com/questions/4823468/comments-in-markdown suggests something like this for a comment:
Alternatively we might use Markdown's fenced code blocks feature (triple back-ticks) with a bespoke info-string (rather than just python for the colour syntax markup)?
MarkusPiotrowski commentedon Aug 3, 2016
I find this https://gist.github.com/dupuy/1855764 document interesting, which shows how to write text that can usually be understood by both reStructuredText and Markdown interpreters. When we try to follow these guidelines for the homepage and the docstrings, a later swith to one of the two markup languages may be easier.
MarkusPiotrowski commentedon Aug 3, 2016
With respect to 'slimming down the tutorial' I disagree. I would prefer to have even more examples and details in the tutorial, so that I don't have to switch back and forth between the tutorial, the cookbook sections of the homepage, the wiki entries of the homepage and the api documentation (and the source code for the undocumented functions). So why don't we call the tutorial 'manual' and build it as the main comprehensive Biopython documentation source?
peterjc commentedon Aug 3, 2016
Text which is simultaneously both Markdown and reStructuredText is an intriguing idea, but practically we'd loose out on Python syntax formatted examples etc.
But let's keep this issue on the technical side about what (if anything) we should use instead of LaTeX?
bosborne commentedon Mar 12, 2017
I think that reST would be preferable given its compatibility with Sphinx and Python documentation generally, but on the other hand it looks like there's still no syntax highlighting of Python code blocks in reST files in GitHub. That argues for Markdown. Any new thoughts on this? Happy to help, if an approach is chosen.
peterjc commentedon Mar 12, 2017
I'm leaning very much towards RST - we're already using it for the Python docstrings in the code itself, and the misc text files.
peterjc commentedon Jul 18, 2019
Following the work in #2172 etc to close #906, we now have the API documentation (docstring comments written in RST) converted to HTML documentation using Sphinx.
I have now managed a proof of principle conversion of the Tutorial from LaTeX into RST, and combined this with the API documentation using Sphinx (which could be deployed on our website via GitHub pages, and/or on Read The Docs).
I deliberately kept one page per chapter (i.e. one
*.rstfile per chapter, like we have now one*.texfile per chapter). That has a side effect of complicating links between pages from the LaTeX\label{XXX}and\ref{XXX}, but I can fix that by converting them to RST style:ref:entries (and we give up on having chapter and section numbering in the link captions).I'm unsure at this point if any automated conversion is realistic as part of the continuous integration system. It would be more realistic to aim for a one-off conversion from LaTeX to RST. Thereafter contributors would only need to learn RST for writing or editing the main Biopython documentation.
peterjc commentedon Aug 12, 2019
During the BOSC CoFest 2019, @anilbey was able to convert
test_Tutorial.pyto work with RST files - pull request #2188.Another idea is to use sphinx's built in doctest support - but as far as I know that lacks any fine grained control (e.g. dependencies). We would also have to update all the examples to use a particular working directory for relative paths.
peterjc commentedon Jul 7, 2021
As noted on #3658, it looks like my earlier experiments had left https://biopython.readthedocs.io/ live with a version from July 2019.
I think if we do the LaTeX to RST conversion now, we'd put the Sphinx build on our GitHub pages site instead - alongside the Sphinx RST API documentation.
Update: I deleted the RTD pages. We might also consider dual hosting in future?
JoaoRodrigues commentedon Feb 13, 2023
Hey Peter,
Yesterday going through the process of building the release it was a bit frustrating to handle all these doc-building quirks. Is this move to rst still desirable? I'd be willing to spend some time doing the one-off conversion and cleaning, hopefully making everything a little simpler to build in the future?
peterjc commentedon Feb 17, 2023
Yes, that was the goal with moving off LaTeX to RST - which seemed last time I looked at this to be the only viable alternative (and we're using it for our docstrings and API docs via Sphinx). It ought to be possible to automatically deploy this just like we autodeploy the API docs.
See https://github.com/biopython/biopython/tree/sphinx (would need to try rebasing this, where the pandoc steps would be re-run rather than manual conflict resolution), which as I recall was on the main repository in order to render on ReadTheDocs. I had a copy at https://github.com/peterjc/biopython/tree/sphinx too.
peterjc commentedon Jun 21, 2023
I've been working on this again at https://github.com/peterjc/biopython/tree/sphinx_2023 based on my previous efforts. I have the hevea-specific LaTeX cleaned up (scripted), and sensible looking output from Sphinx. As discussed above this uses one RST file per chapter, and converts the section references into
:ref:commands so that they work between chapters.There are some glitches with figures, RST/Sphinx seems to want one-line caption titles before any extended caption text. That's OK to resolve manually.
Currently the citations and bibliography are a stubling block. We have about 45 entries, about half with a DOI. If they all had a DOI or URL, I'd be happy with replacing them with links (e.g. link text like Cock et al. (2009) with the DOI as the URL). However, that does not cover everything.
The built-in citation support in RST/Sphinx is basic, e.g. https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#citations - but should probably work. I need to convert a couple by hand to confirm that.
We might instead consider https://pypi.org/project/sphinxcontrib-bibtex/ which would mean turning the bibliography from a list of
\bibtexentries of pre-formatted text into a traditional bibtex file of fields. This is not the nicest file format to work with, but most bibliography packages can export this.peterjc commentedon Jun 22, 2023
Looks like table references will also need checking, proably similar to figures.
Equation references look more tricky (not numbered by default), but we only have two labelled equations - both in the machine learning chapter. Perhaps with minor editing we can avoid explicit references to them?
mdehoon commentedon Jun 22, 2023
@peterjc Maybe it's time to deprecate the machine learning code in Biopython? Things like logistic regression are better served in a machine learning library like scikit-learn than in Biopython.
peterjc commentedon Jun 22, 2023
That may be wise (deprecating the logistic regression code), likewise the generic plotting stuff in Bio.Graphics. I'll keep that in mind as deleting the chapter might be easier than converting it ;)
peterjc commentedon Jul 12, 2023
My figure caption issue seems in part to be an issue in recent versions of pandoc, jgm/pandoc#8930 - with that avoided,
:numref:works nicely with the Figures (after editing the handful with multi-line captions).And also there are some table references which I need to look at...
peterjc commentedon Jan 3, 2024
Adding a note here from the
test_Tutorial.pywork on #2188, we need to convert our special LaTeX comment lines used to flag and customize doctests within the LaTeX source. For example:Using RST comments:
Sadly pandoc does not handle comments jgm/pandoc#1926
The workaround was a search-and-replace before calling pandoc, using
\pandocignoreme .. doctest ../Tests/GenBankand\pandocignoreme .. cont-doctestfor this example. Pandoc seems to ignore the undefined latex term, and just leaves the following text as a line in the output. We can do this with sed, e.g.sed "s/^%doctest/\n\\\\pandocignoreme .. doctest/g"(adding an extra blank line in case there wasn't one to ensure this is not tacked onto the previous paragraph).peterjc commentedon Sep 19, 2024
Note if we were to adopt pytest, then https://github.com/scientific-python/pytest-doctestplus might cover most of our doctests in RST files needs (currently handled via
test_Tutorial.py). See scientific-python/pytest-doctestplus#264