Skip to content

Deploy API docs from Sphinx autodoc HTML using GitHub pages - #2172

Merged
peterjc merged 15 commits into
biopython:masterfrom
peterjc:deploy
Jul 16, 2019
Merged

peterjc merged 15 commits into
biopython:masterfrom
peterjc:deploy

Conversation

@peterjc

@peterjc peterjc commented Jul 11, 2019

Copy link
Copy Markdown
Member

This pull request addresses issue #906, replacing epydoc with Sphinx and autodoc.

Since #1803 we already build the API documentation with Sphinx and autodoc on TravisCI via the tox api target.

This adds automated deployment of the HTML output (via a bash script using a deployment key) to the new repository https://github.com/biopython/docs using github pages, to appear online under https://biopython.org/docs/dev/api/ etc (with .../dev/ for the master branch development code, or a version like .../1.74/... instead for releases).

This URL patterns should leave open the possibility of hosting all the Tutorial here as well, probably easiest to do if if we convert that from LaTeX to RST and stay within Sphinx, see #907.

This requires an SSH deployment key. We add the public key to https://github.com/biopython/docs (multiple keys can be added, see below), and the private key is added to https://travis-ci.org/biopython/biopython/settings (suitably escaped).

The proposed setup uses the TravisCI deploy: stage https://docs.travis-ci.com/user/job-lifecycle/ (although after_success: works nicely too), currently restricted to the master branch only.

Testing on a fork is possible, for example from https://github.com/peterjc/biopython/ to https://github.com/biopython/docs as long as you have the private key (have permission to add a new key to the docs repository). Alternatively we could make it try to push to the owner's fork of the docs repository?

e.g. https://travis-ci.org/peterjc/biopython/jobs/557346277 didn't deploy as deploy was not the master branch (nor should the testing of this pull request trigger a deploy), while identical code in https://travis-ci.org/peterjc/biopython/jobs/557346457 on my fork's master branch did run the deploy script.

The implementation right now is in a bash script .github/deploy_docs.sh and tiny helper .github/ssh_via_deploy_key.sh but in principle this private key approach could be added to the tool doctr instead (see drdoctr/doctr#348 and drdoctr/doctr#349 where I am working on this).

  • 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.rst file, have run flake8 locally, and
    understand that AppVeyor and TravisCI 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.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

peterjc added 4 commits July 10, 2019 10:19
Including this will massively inflate the size of any deployment
repository (especially if we track the biopython source code master
branch), and is of little value over a (tagged version specific)
link to GitHub.
Created a pass-phrase less SSH key, uploaded the public key to
biopython/docs settings as a deployment key (write permissions).

For TravisCI must escape the spaces and newlines as '\ ' and '\\n'
respectively when setting DOC_KEY as a secure environment variable.

Can test this locally by setting the DOC_KEY environment variable.

Idea here is to call this from TravisCI/Tox after running Sphinx
to build our API documentation.
@peterjc

peterjc commented Jul 11, 2019

Copy link
Copy Markdown
Member Author

Note: Looking at the recent history on https://github.com/biopython/docs/commits/gh-pages from testing, even with no code changes there are documentation changes, apparently due to cases of objects as default arguments, e.g.

get_dn_ds_matrix(self, method='NG86', codon_table=<Bio.Data.CodonTable.NCBICodonTable object at 0x7fb0e534c0f0>)

This is from https://biopython.org/docs/dev/api/Bio.codonalign.codonalignment.html#Bio.codonalign.codonalignment.CodonAlignment.get_dn_ds_matrix

We can probably address this with an explicit __repr__ on the underlying objects, but this could be a sign of some subtle bugs (instances of mutable objects as defaults), but are also a side effect of sphinx-doc/sphinx#759

@peterjc
peterjc requested a review from bow as a code owner July 11, 2019 14:37
@codecov

codecov Bot commented Jul 11, 2019

Copy link
Copy Markdown

Codecov Report

Merging #2172 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2172      +/-   ##
==========================================
- Coverage   84.57%   84.56%   -0.01%     
==========================================
  Files         317      317              
  Lines       51243    51243              
==========================================
- Hits        43338    43336       -2     
- Misses       7905     7907       +2
Impacted Files Coverage Δ
Bio/Graphics/BasicChromosome.py 93.71% <0%> (-0.32%) ⬇️
Bio/File.py 87.01% <0%> (-0.26%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 568b429...4b63f08. Read the comment docs.

@codecov

codecov Bot commented Jul 11, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #2172 into master will increase coverage by <.01%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2172      +/-   ##
==========================================
+ Coverage   84.57%   84.57%   +<.01%     
==========================================
  Files         317      317              
  Lines       51243    51253      +10     
==========================================
+ Hits        43338    43347       +9     
- Misses       7905     7906       +1
Impacted Files Coverage Δ
Bio/AlignIO/FastaIO.py 94.39% <ø> (ø) ⬆️
BioSQL/BioSeqDatabase.py 77.72% <ø> (ø) ⬆️
Bio/GenBank/Scanner.py 82.76% <ø> (ø) ⬆️
Bio/kNN.py 94% <100%> (+0.52%) ⬆️
Bio/SearchIO/__init__.py 90.24% <100%> (+0.5%) ⬆️
Bio/SearchIO/HHsuiteIO/hhsuite2_text.py 97.01% <100%> (ø) ⬆️
Bio/Data/CodonTable.py 97.56% <50%> (-0.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 568b429...77ceb12. Read the comment docs.

@peterjc

peterjc commented Jul 11, 2019 •

Copy link
Copy Markdown
Member Author

The documentation changes on Bio.Restriction are more interesting - it looks like the class order is essentially random?

e.g. Search https://biopython.org/docs/dev/api/Bio.Restriction.Restriction.html for class Bio.Restriction.Restriction.

P.S. We are using 'member-order': 'bysource', though, see https://www.sphinx-doc.org/en/stable/usage/extensions/autodoc.html#confval-autodoc_member_order

peterjc added 6 commits July 11, 2019 15:52
This module would take a disproportionate amount of time, and
since it defines hundreds of classes, takes a lot of space too.

Finally, the class order seemed to be non-deterministic.
.../numpydoc/docscrape.py:424: UserWarning: Unknown section Examples: in the docstring
Default blue looked wrong with our logo, this grey is to
match that used on biopython.org currently (a Hyde theme)
@peterjc

peterjc commented Jul 11, 2019

Copy link
Copy Markdown
Member Author

Updated to use the Read-The-Docs theme with our logo and the same dark grey side bar as on https://biopython.org - this to me looks pretty good now: https://biopython.org/docs/dev/api/

@peterjc

peterjc commented Jul 16, 2019

Copy link
Copy Markdown
Member Author

Merging ready to try to do the Biopython 1.74 release later today.

@peterjc
peterjc deleted the deploy branch July 16, 2019 07:05

@MarkusPiotrowski MarkusPiotrowski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterjc I'm missing the correct words to tell you that I think what you tried is great but the result, at the moment, is not optimal.

I would suggest, for the moment, to make both versions of the API available, the 'old' Epydoc as standard and the new Sphinx as an alternative.

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), the other to the organization of the document, e.g. the summary tables for functions and variables, which are available in Epydoc. 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.

So, at the moment, when I want to look up some module/function, I would use the Eypdoc version.

Further comments:

@peterjc

peterjc commented Jul 16, 2019

Copy link
Copy Markdown
Member Author

Thanks Markus,

As to links, I agree - for Biopython 1.74 we have both, linked to from the main documentation page although that could be prettier:

https://biopython.org/wiki/Documentation

The Biopython 1.74 tutorial ought to have included a link to the new documentation but I only remembered afterwards.

My hope is for Biopython 1.75 we can stop using epydoc, and just use Sphinx for the API docs.

Regarding the source code, I turned that off explicitly. Reason one, it will ballon the docs/ repository if every time we commit a change to the main repository master branch, the dev documentation is updated with the pretty rendering of the source code. Reason two, I'd rather have it link directly to the GitHub page (which ought to be possible via templates).

Styling. There are a number of Sphinx themes, this is currently using the read-the-docs theme. That can be tweaked, or replaced. Also the docstring content itself can be polished (e.g. adopt numpydoc style).

Home link (top of side bar). That can probably be changed, although I am in two minds if it should go to the Sphinx documentation home (as now), or biopython.org - and we don't really need the little house icon and text, given the logo is shown below it with the same link.

Default arguments in signatures. There are some settings in Sphinx, but this has been a long standing issue for several projects. Typically they want something like out_function(x, y, colors=our_module.DEFAULT_COLOR_MAP) but Sphinx will replace the named constant with the actual value. Using mutable objects as default values is generally a bad idea anyway. Often using None is a good work around, see e.g. 1afe6a6 from this pull request.

Yes, Bio.Restriction.Restriction was explicitly disabled in 7c23899 from this pull request - not sure about Bio.Restriction.Restriction_dictionary right away. If we can fix the stochastic class sort order, I'm open to restoring it - otherwise that balloons the docs/ repository with noise.

@peterjc

peterjc commented Jul 16, 2019

Copy link
Copy Markdown
Member Author

Fixed the redundancy of the home icon and text Biopython plus the logo in 958bb57

@peterjc

peterjc commented Jul 16, 2019

Copy link
Copy Markdown
Member Author

Logged readthedocs/sphinx_rtd_theme#777 for changing the Sphinx RTD theme's logo URL.

@fkgl

This comment has been minimized.

@peterjc

peterjc commented Jun 15, 2020

Copy link
Copy Markdown
Member Author

@fkgl I think you probable need to look at the snakes project documentation - nothing in your comment seems relevant to Biopython, sorry.

@fkgl

fkgl commented Jun 16, 2020

Copy link
Copy Markdown

@peterjc Thank you.

@peterjc peterjc mentioned this pull request Jun 4, 2021
8 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants