Skip to content
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

switched sphinx theme with MDAnalysis styling #1126

Merged
merged 5 commits into from
May 24, 2017
Merged

Conversation

orbeckst
Copy link
Member

@orbeckst orbeckst commented Dec 15, 2016

Fixes #378

Changes made in this Pull Request:

  • switch sphinx theme to alabaster
  • small style changes to adapt to MDAnalysis home page look and feel

See screenshot for what it looks like:

mda_new_style

PR Checklist

  • works locally?
  • n/a Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Problems

I can't build the docs locally at the moment: sphinx.autodoc appears to fail.

@orbeckst
Copy link
Member Author

Figured out why autodoc wasn't working... I overwrote extensions due to mindless copy & paste.

@orbeckst orbeckst force-pushed the new-sphinx-style branch 2 times, most recently from e4ec6c1 to d241db5 Compare December 15, 2016 00:19
@orbeckst
Copy link
Member Author

In order to review you need to build locally. I used a virtual env. If you do this, make sure to install sphinx into the venv or otherwise it will fail to pick up packages. If all goes well:

cd package/doc/sphinx
make html
open ../html/index.html

@orbeckst
Copy link
Member Author

orbeckst commented Dec 15, 2016

Some things aren't great yet

  • the author footer can overlap with the sidebar on pages with little content
  • not sure if I like orange underbar for links to objects/functions (which remain black although we can probably make them orange if we want to)
  • not using MDA gray anywhere
  • code block boxes extend to far in docs
  • code font size seems to big
  • Narrow sidebar (for narrow window) does not look good (black links on dark-gray bg, maybe use MDA gray)
  • sidebar TOC is static (does not give you any indication where you are, unlike RTD)

Notes on customization:

  • configuration in package/doc/sphinx/source/conf.py
  • set theme options, try to avoid explicit CSS (although that's also possible)
  • note: CSS lists must be written as Python strings (not as Python lists)
  • True and False seem to work

@kain88-de
Copy link
Member

@orbeckst sorry for not looking over this earlier. I should have some time this week to look over the changes.

@kain88-de kain88-de self-assigned this Dec 18, 2016
@kain88-de
Copy link
Member

Which version of sphinx are you using? I'm getting build errors with 1.5 also on the master branch

@orbeckst
Copy link
Member Author

orbeckst commented Dec 20, 2016 via email

@kain88-de
Copy link
Member

Yes I have sphinx installed in the conda environment. Here is the error I'm getting

(mda-py2) thinki doc/sphinx ‹develop*› » make html
sphinx-build -b html   source ../html
Running Sphinx v1.5
loading pickled environment... not yet created
loading intersphinx inventory from http://docs.python.org/objects.inv...
intersphinx inventory has moved: http://docs.python.org/objects.inv -> https://docs.python.org/2/objects.inv
loading intersphinx inventory from http://docs.scipy.org/doc/scipy/reference/objects.inv...
intersphinx inventory has moved: http://docs.scipy.org/doc/scipy/reference/objects.inv -> https://docs.scipy.org/doc/scipy/reference/objects.inv
loading intersphinx inventory from http://matplotlib.org/objects.inv...
loading intersphinx inventory from https://networkx.readthedocs.io/en/stable/objects.inv...
loading intersphinx inventory from http://docs.scipy.org/doc/numpy/objects.inv...
intersphinx inventory has moved: http://docs.scipy.org/doc/numpy/objects.inv -> https://docs.scipy.org/doc/numpy/objects.inv
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 126 source files that are out of date
updating environment: 126 added, 0 changed, 0 removed
reading sources... [ 10%] documentation_pages/analysis/encore/similarity                                 
Exception occurred:
  File "/home/max/anaconda2/lib/python2.7/site-packages/sphinx/domains/std.py", line 543, in note_citations
    path = env.doc2path(self.data['citations'][0])
KeyError: 0
The full traceback has been saved in /tmp/sphinx-err-ChKK5K.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Makefile:42: recipe for target 'html' failed

@kain88-de
Copy link
Member

OK with sphinx=1.4.8 I can compile the docs. It doesn't work with 1.5 and later.

@kain88-de
Copy link
Member

the author footer can overlap with the sidebar on pages with little content

also when scrolling towards the bottom.

I have some more errors. On my laptop screen I can't see the fill side bar. Neither can I scroll the sidebar.

screenshot from 2016-12-20 22-57-10

It is very hard for me to see where an old function stops and a new function starts. Even worse the note and other boxes are much much more prominent then the actual function and arguments.

screenshot from 2016-12-20 22-58-13

@kain88-de
Copy link
Member

I found an awesome-list for sphinx. They have a theme for autodoc generated docs https://sphinx-readable-theme.readthedocs.io/en/latest/. What I like in that theme is that the line with the function name is highlighted from the background which makes it easy to see when I have a new function.

@orbeckst
Copy link
Member Author

orbeckst commented Dec 21, 2016 via email

@orbeckst
Copy link
Member Author

orbeckst commented Dec 21, 2016 via email

@dotsdl
Copy link
Member

dotsdl commented Feb 4, 2017

@orbeckst is this still WIP? Or do you want review followed by merge?

@kain88-de
Copy link
Member

This is still WIP. The sidebar is an issue and the theme makes the config harder to read IMHO. I didn't have time to try out any of the other themes I linked to above.

@orbeckst
Copy link
Member Author

orbeckst commented Feb 4, 2017

This is currently just a test bed and not to be merged.

@orbeckst
Copy link
Member Author

I played around with the alabaster scheme and I am actually pretty happy with the result; at least I like it better than the old theme. You can see it at http://www.mdanalysis.org/docs/

With a little bit of hacking in custom.css we can probably also get the highlighting of methods as in https://sphinx-readable-theme.readthedocs.io/en/latest/#example.Storage working. Alternatively, feel free to do a PR with the sphinx-readable theme (you can use this one because it should not be too hard to move between them... or do a PR onto this one).

The deploy_master_docs.sh script is not yet ready for travis (see #1315 (comment)) but everything else should work.

Anyway, comments, please.

@orbeckst orbeckst changed the title switched sphinx theme to alabaster with MDAnalysis styling switched sphinx theme with MDAnalysis styling May 18, 2017
@orbeckst
Copy link
Member Author

I also tried a customized version of sphinx-readable-theme as suggested by @kain88-de and it looks rather nice. You can compare the two styles:

alabaster has better configuration options via the conf.py file, it can do fancy things with the navigation in the sidebar (unfold the current section that one is in), and it has nice little additions such as travis build status and GitHub links.

readable has really nice autodoc sections and overall slightly cleaner layout.

@MDAnalysis/coredevs , which theme would you like? I'll then rewrite the PR into a few clean commits, ask for approval by review, and we'll have pretty docs.

@jbarnoud
Copy link
Contributor

jbarnoud commented May 18, 2017 via email

@kain88-de
Copy link
Member

I also prefer the readable version.

@mnmelo
Copy link
Member

mnmelo commented May 18, 2017

Graphically I prefer 'readable' (but I don't agree with @jbarnoud's call for a more emphasized sidebar).
However, it's a deal breaker for me that the sidebar doesn't unfold the section. If I'm looking for selection commands, for instance, I have to either click 'Contents' on the sidebar or scroll down till the Contents section. And only then I get to click on the 'Selection commands' link. It doesn't feel half as intuitive and fast as alabaster.

Is there a way to have the best of both worlds?

@orbeckst
Copy link
Member Author

orbeckst commented May 18, 2017 via email

@utkbansal
Copy link
Member

utkbansal commented May 18, 2017

Small question - why don't we use readthedocs to host our docs? That seems to be default choice to host docs by most of the python packages out there.

I'm thinking that readthedocs would have already figured out all the design and readability issues, why reinvent the wheel? Devs are already used to it.

Also its free and supports webhooks, so that can update docs on each commit. I think, right now @orbeckst does this manually every now and then - this might reduce some work too.

@orbeckst
Copy link
Member Author

orbeckst commented May 18, 2017 via email

@orbeckst
Copy link
Member Author

Also its free and supports webhooks, so that can update docs on each commit. I think, right now @orbeckst does this manually every now and then - this might reduce some work too.

That's not a problem, we update our docs from travis builds.

Developer doc publication is fully automated and integrated in the CI and we will be doing this for the release docs as well (see #1315 ). Just for the playing around with themes I am pushing manually.

RTD has one advantage and that is they make it easy to switch between different versions.

Ultimately, I don't mind if someone else figures out to make it all work on RTD but time is a pretty precious resource...

@orbeckst
Copy link
Member Author

orbeckst commented May 18, 2017

I combined the readable styling with alabaster and you can see the latest version at http://mdanalysis.org/docs.

I am happy with it.

Either this or pure readable https://orbeckst.github.io/mdanalysis_docs/

@orbeckst
Copy link
Member Author

orbeckst commented May 18, 2017

Once I know what we want to do I will clean up the history in a few sensible commits. Please don't just squash.

@kain88-de
Copy link
Member

Last iteration looks great and also works well on a tablet.

- https://alabaster.readthedocs.io/en/latest/ for notes on styling;
  note that CSS has to be entered as strings, not as Python lists.
- use normal non-floating sidebar in alabaster
  Using the standard sidebar avoids funny rendering artifacts when the pages are short
- collapsible sidebar navigation
  - only show the TOC in sidebar
  - enable depth 4 in sidebar, but 2nd level is collapsed until one
    navigates to the page; we want 4 levels because this is where most
    of our analysis docs has the per-page headings
  - use MDA gray for the background in the mobile menu (or when page is
    very narrow)
- enabled Related Topics in sidebar and adjusted font sizes
- custom.css: smaller Notes/See Also (admonition) title
- new deploy_master_docs.sh script for pushing to https://github.com/MDAnalysis/docs
  - EXPERIMENTAL --- only use manually at the moment.
  - nuke the html/.git --- only needed for manual testing
  - commit message with fullgy GitHub-linked commit SHA1
- fixed syntax error in die() in maintainer/deploy_docs.sh
- doc front page update: added key information
  - use sections (now that the TOC has been removed, we
    have a bit more space to include stuff that people
    want to know right away)
  - Getting Involved: includes link to Code of Conduct
  - Installation: abbreviated quick install (with link)
    and correct conda channel (MDAnalysis/MDAnalysis.github.io#54)
  - Source Code: git clone
  - added link to Topology formats table
- must cite each reference somewhere
  Newer sphinx versions (1.6.x or so) throw a warning for any reference that is not
  cited anywhere.
  - Now we cite every reference in the Reference page itself instead
    of linking these references to the individual module reference sections.
  - Touched up encore docs references.
- small reST fix in coordinates/__init__ and analysis.pca
We use a stripped-down version of the readable.css_t from https://github.com/ignacysokolowski/sphinx-readable-theme
as a custom CSS (included in custom.css). Minor touch-ups are performed in custom.css.

The overall effect is Alabaster fancyness with readable style.
@orbeckst
Copy link
Member Author

I rewrote the history of this PR into sensible units. Please merge as is (do not squash).

Compared to the last revision I also increased the level depth of headings in the navigation sidebar to 4; it's sometimes a bit more cluttered but I think it's important that even deep in analysis docs you can still navigate around, eg http://www.mdanalysis.org/docs/documentation_pages/analysis/hbond_analysis.html

@MDAnalysis/coredevs please have a look at http://www.mdanalysis.org/docs and if you are in general happy with this then I would like to merge this. (We can do more CSS adjustments and fine-tuning as we go along.)

The maintainer/deploy_master_docs.sh script was used in order to create the docs at http://www.mdanalysis.org/docs but will be properly integrated into Travis when we address #1315 .

@orbeckst
Copy link
Member Author

PS: I am not 100% sure why the build status badge on the docs shows "error". It refers to the master branch (this is hard-coded in the alabaster theme as far as I can tell)

https://api.travis-ci.org/MDAnalysis/mdanalysis.svg?branch=master

I am not sure why it should show an error because looking at https://travis-ci.org/MDAnalysis/mdanalysis/branches our master branch is shown as green (although https://travis-ci.org/MDAnalysis/mdanalysis/builds/232796240 errored...) – any insights welcome.

@orbeckst orbeckst modified the milestone: 0.16.x May 19, 2017
@orbeckst
Copy link
Member Author

Has any one of the current reviewers @kain88-de @dotsdl @tylerjereddy any further comments?

This needs at least one approval so that it can get merged.

@kain88-de : Please merge (and don't squash) because the commits are independent. Thanks.

@orbeckst orbeckst merged commit ad5ff75 into develop May 24, 2017
@orbeckst orbeckst deleted the new-sphinx-style branch May 24, 2017 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants