Skip to content

Replacing epydoc for API documentation #906

Closed

Description

@peterjc

(Had a keyboard glitch halfway through composing the issue, hence changing title and contents)

The current release of epydoc is v3.0 from 2008, see http://epydoc.sourceforge.net/ - the project is effectively dormant. The HTML output it produces is functional but ugly, currently available at http://biopython.org/DIST/docs/api/ via https://github.com/biopython/DIST/tree/gh-pages/docs/api

This replaces old issue https://redmine.open-bio.org/issues/3221 Port the Biopython Tutorial to Sphinx/reStructuredText (filed by @etal), and overlapping issue https://redmine.open-bio.org/issues/3219 Port Biopython documentation to Sphinx (also filed by @etal).

Mailing list discussion:
http://lists.open-bio.org/pipermail/biopython-dev/2010-July/007977.html

Numpy's approach to building API docs with Sphinx:
http://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt

See also #907

Activity

  1. changed the title [-]Modernising API and Tutorial Documentation[/-] [+]Replacing epydoc for API documentation[/+] on Aug 3, 2016
  2. peterjc commented on Aug 3, 2016

    @peterjc
    MemberAuthor

    One possible replacement for epydoc is pdoc, https://github.com/BurntSushi/pdoc - see its self-generated documentation at http://pdoc.burntsushi.net/pdoc

    However, unlike epydoc which supported multiple markup languages including epytext and reStructuredText (but not MarkDown), pdoc currently only supports MarkDown: mitmproxy/pdoc#111

    Switching all the docstrings from reStructuredText (and epydoc) to MarkDown (and pdoc) might not be as much work as it sounds, since most of the docstrings use minimal markup anyway.

    Switching to MarkDown would also have the benefit of matching the Biopython website source files https://github.com/biopython/biopython.github.io/tree/master/wiki (rendered using Jekyll using GitHub Pages).

  3. peterjc commented on Aug 15, 2016

    @peterjc
    MemberAuthor
  4. etal commented on Aug 15, 2016

    @etal
    Contributor

    Sphinx can do markdown, too. It doesn't look like pdoc is at the same level of project maturity as Sphinx or even epydoc.

    Many years ago Ruan ported the LaTeX docs to rST in both English and Chinese, intended to be used with Sphinx. I remember another Biopython user in China set up and hosted Sphinx API docs in English and Chinese. These are out of date now, but the point is that we should really use Sphinx and rST to unify our documentation efforts and the community of potential contributors.

  5. peterjc commented on Aug 15, 2016

    @peterjc
    MemberAuthor

    I agree pdoc isn't yet ready to replace epydoc although if mitmproxy/pdoc#111 was addressed to allow RST input it would be worth exploring.

    As I noted on #907 (which overlaps with #906), it would be nice to use the same markup language on the docstrings (currently RST with epydoc), tutorial (currently LaTeX with hevea) and webpages (currently Markdown with GitHub Pages) - but it doesn't look possible right now.

  6. peterjc commented on Apr 25, 2017

    @peterjc
    MemberAuthor

    Related to this, we should check our docstrings are valid RST, see e.g. feature request at PyCQA/pydocstyle#245

  7. peterjc commented on Sep 8, 2017

    @peterjc
    MemberAuthor

    As a proof of principle, I hacked pdoc to support reStructuredText using docutils, mitmproxy/pdoc#137

    Run as follows, not sure if I can get it to do Bio and BioSQL at the same time:

    $ rm -rf api && pdoc --html --html-dir /tmp/api --docformat restructuredtext Bio
    <string>:7: (WARNING/2) malformed hyperlink target.
    <string>:3: (ERROR/3) Unknown target name: "konieczny and ausubel (1993)".
    <string>:11: (WARNING/2) Block quote ends without a blank line; unexpected unindent.
    <string>:3: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.
    ...
    $ open /tmp/api/Bio/SeqRecord.m.html
    

    Sample output showing the SeqRecord class. Note the doctest snippets of Python code are not currently syntax coloured:

    screenshot 2017-09-08 11 59 43

    Equivalent page from epydoc:

    screenshot 2017-09-08 11 59 53

    Unfortunately the author of pdoc has not been merging any contributions recently, and the project seems dormant.

    TODO: Example rendering of the docstrings using Sphinx.

  8. peterjc commented on Sep 11, 2017

    @peterjc
    MemberAuthor

    Using Sphinx,

    sphinx-apidoc -e -F -o Doc/api/Bio Bio
    # I was running Sphinx under Python 3, thus needed:
    sed -i.bak "s/ python / python3 /g" Doc/api/Bio/Makefile
    # Note Bio.Restriction breaks Sphinx, so skip it entirely!
    #
    # Exception occurred:
    #   File ".../site-packages/Bio/Restriction/Restriction.py", line 341, in __len__
    #     return cls.size
    # AttributeError: type object 'RestrictionType' has no attribute 'size'
    #
    rm -rf Doc/api/Bio/Bio.Restriction.*
    make -C Doc/api/Bio/ html
    open doc/api/Bio/_build/html/Bio.SeqRecord.html

    screenshot 2017-09-11 11 34 15

    Note there are quite a few warnings from Sphinx about section names etc.

    There are some things I don't like in the default API template, for example I find the division of the left hand column listing into sub-packages vs sub-modules unhelpful - the user should not care. Others have looked at this, https://stackoverflow.com/questions/29385564/customize-templates-for-sphinx-apidoc suggests https://github.com/goerz/better-apidoc

  9. peterjc commented on Sep 12, 2017

    @peterjc
    MemberAuthor

    Work in progress for automating building the API documentation using Sphinx, using our TravisCI/Tox setup (tested under Python 2.7):

    [testenv:api]
    # Note Sphinx likes to have the code installed so can import it
    skip_install = False
    whitelist_externals =
        bash
        sphinx-apidoc
        make
    deps =
        mmtf-python
        mysql-python
        numpy
        rdflib
        reportlab
        scipy
        sphinx
    commands =
        bash -c \'python setup.py install > /dev/null\'
        # Can't see a better way than running apidoc twice,
        sphinx-apidoc -e -F -o /tmp/api/Bio Bio
        sphinx-apidoc -e -F -o /tmp/api/BioSQL BioSQL
        # Now merge RST files where we have a custom index.rst and conf.py
        bash -c \'cp /tmp/api/BioSQL/BioSQL*.rst Doc/api/\'
        bash -c \'cp /tmp/api/Bio/Bio*.rst Doc/api/\'
        bash -c \'cp /tmp/api/Bio/Makefile Doc/api/\'
        bash -c \'mkdir -p Doc/api/_templates Doc/api/_static Doc/api/_build\'
        make -C Doc/api/ html
    

    This branch also includes a conf.py file with Biopython meta-data filled in, plus a custom index.rst file in order to cover both the Bio and BioSQL top level namespaces:

    .. Biopython API documentation master file, based on sphinx-quickstart
       This depends on having sphinx-apidoc run on both Bio and BioSQL to
       generate the per-module/package RST file referenced here.
    
    Welcome to Biopython's API documentation!
    =========================================
    
    .. toctree::
       :maxdepth: 4
       :caption: Contents:
    
       Bio
       BioSQL
    
    
    Indices and tables
    ==================
    
    * :ref:`genindex`
    * :ref:`modindex`
    * :ref:`search`

    There is still a lot to tinker with here, including things like private modules, special methods (especially __init__), but shows promise.

  10. peterjc commented on Oct 10, 2017

    @peterjc
    MemberAuthor

    I think I've got the special methods working nicely now on #1388 (subject to a feature request being merged in Sphinx itself).

  11. peterjc commented on Jun 14, 2019

    @peterjc
    MemberAuthor

    Some of you will have noticed a new (currently almost empty) repository appeared, https://github.com/biopython/docs

    The goal here is to extend the existing TravisCI job which turns our API documentation into RST and HTML using Sphinx autodoc, by deploying the files to https://github.com/biopython/docs using https://github.com/drdoctr/doctr

  12. peterjc commented on Jun 28, 2019

    @peterjc
    MemberAuthor

    There is a proof of principle live right now, http://biopython.org/docs/dev/api/

    Not so pretty initially, untill you drill down to a specific page, e.g. https://biopython.org/docs/dev/api/Bio.SeqRecord.html

    Final URLs subject to change (I am thinking .../dev/ for the latest code, otherwise the version).

  13. peterjc commented on Aug 14, 2019

    @peterjc
    MemberAuthor

    As of 3c6a2c2 the Sphinx API documentation pages all have working "Edit on GitHub" links (which point at the associated Python files):

    https://biopython.org/docs/dev/api/

    Again final URLs subject to change, we discussed including a language code like /en/ in the URL - probably before the version or /dev/ for latest version?

  14. peterjc commented on Aug 14, 2019

    @peterjc
    MemberAuthor

    Cross reference #2174 for the current deliberate exclusion of Bio.Restriction.Restriction from the Sphinx API documentation.

  15. peterjc commented on Aug 14, 2019

    @peterjc
    MemberAuthor

    Other points raised by @MarkusPiotrowski on #2172,

    While the Sphinx version looks quite stylish, the Epydoc version is much easier to read and understand. One reason for this is related to style (size of main frame, font-size),

    Style and font sizes are down to the Sphinx theme, currently the popular read-the-docs theme. We can look at changing that.

    the other to the organization of the document, e.g. the summary tables for functions and variables, which are available in Epydoc.

    tables of functions - I'm unsure if sphinx apidoc offers anything like this?

    tables of variables - I'm not sure how to get Sphinx to include public variables in a module. That would be useful.

    It might be worth looking at https://github.com/astropy/sphinx-automodapi in place of the apidoc extension, as used for astropy: https://astropy.readthedocs.io/en/stable/utils/index.html

    Also, I'm missing (or haven't found yet) the possibility to directly open the source code, which, for me, is a very useful function.

    Solved that today by adding links to GitHub (see comment above).

    ...

    The "Home" button on top of the menu frame does link to the API home, not to Biopython.org

    Theme limitation, logged as readthedocs/sphinx_rtd_theme#777 - can probably be done now with theme template customisation.

    Another problem, also present in Epydoc, is that variables in function definitions are "filled" with the content, instead of just displaying the name. Epydoc does a little bit better job by abbreviating long list. E.g. compare:

    https://biopython.org/DIST/docs/api/Bio.SeqUtils.MeltingTemp-module.html#Tm_NN
    https://biopython.org/docs/dev/api/Bio.SeqUtils.MeltingTemp.html#Bio.SeqUtils.MeltingTemp.Tm_NN

    That specific case would be fixed by #2213, and others like it could and perhaps should be tackled the same way. There is an open sphinx issue for this related problem:

    sphinx-doc/sphinx#759

    Bio.Restriction.Restriction and Bio.Restriction.Restriction_dictionary are empty. I guess this is deliberate due to the long list of enzyme classes

    Logged as #2174

  16. peterjc commented on Jul 28, 2020

    @peterjc
    MemberAuthor

    I think we can close this now.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions