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

Updating doc building to Sphinx 4.3.2 (python 3) #2662

Merged
merged 33 commits into from Jan 17, 2022
Merged

Updating doc building to Sphinx 4.3.2 (python 3) #2662

merged 33 commits into from Jan 17, 2022

Conversation

barsch
Copy link
Member

@barsch barsch commented Jun 29, 2020

This PR updates the docs build process to Sphinx 3.1.1. After unsucessfully trying to fix the old doc builder I decided to restart the whole process from scratch and reimplement existing features afterwards.

  • Bootstrap theme got replaced by more lightweight "Read the Docs" theme - however I didn't spend to much time on styling yet as this is something which should be tackled after the build process is running smooth
  • stylesheet/javascript/image optimization is done via gulp
  • played a bit with sphinx-gallery but didn't like it, so its again a modified version of matplotlib.sphinxext.plot_directive, which work good enough for me
  • all plots using basemap or mlpy are failing -> segmentation fault on ubuntu as well on win10 for basemap 1.2.1 on py38
  • docs were in pretty bad shape - a lot of warnings have been fixed - there are still many left
  • currently only the html builder has been tested - latex/docset etc need work
  • the structure of the start page probably needs some tweak - I suggest to remove all help/mailing list options from there and link to a github page instead - we should focus on documentation only IMHO

A preview of the current results can be seen here: https://docs.obspy.org/sphinx3/

Feel free to participate - running the doc building takes unfortunatly ages ... If someone could rewrite all examples using basemap to cartopy would be a big help.

@megies
Copy link
Member

megies commented Jun 30, 2020

Awesome stuff @barsch. I like the overall looks, and I'm real happy that we'll have a proper navigation again (with the left side bar).

Can you put the exact version numbers of the build environment somewhere, I can help set up the cron jobs later.. or.. we could have @d-chambers and @heavelock give a shot at building docs in gh-actions? Might be the right time to give it a try, since we would have to set up docs building on new server from scratch more or less anyway?

Also, can you put the build log as a gist maybe.. interesting to see if it got any more readable at all compared to the 80-page warning/error logs we used to have

@megies megies added the docs issues that only affect the content of documentation pages, docstrings etc label Jun 30, 2020
@megies megies mentioned this pull request Jun 30, 2020
@barsch
Copy link
Member Author

barsch commented Jun 30, 2020

@megies its already build on the new server (manually atm) - log can be found here https://docs.obspy.org/sphinx3/log.txt

@megies
Copy link
Member

megies commented Jun 30, 2020

OK, oof, still such a bookshelf of warnings.

@barsch
Copy link
Member Author

barsch commented Jun 30, 2020

jupp - and still takes ages to run - its not fun working on it ...

@megies
Copy link
Member

megies commented Jun 30, 2020

No kidding, it might easily be the most painful thing to work on in the whole project.

@adigitoleo
Copy link

Hey I was browsing the docs and saw that there are some bits where sphinx links to the builtin time module, just because time is used as a parameter name:

2020-11-08_152125_985291775

It's a very small thing and it seems like you've got enough work cut out already, but I thought I'd point it out since you're updating the docs. It might be solved using the :samp: sphinx role, but I've never used it:

https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-samp

@heavelock
Copy link
Contributor

heavelock commented Feb 10, 2021

Hey! I had some spare time today and I thought about finally working on building docs on GithubActions. Coming from GitlabCI this action systems seems to be weird but I think I managed to make the builder run.

Check it out on PR against my fork:
heavelock#9

It's based on obspy/sphinx3 branch that was rebased on top of current master

From some of the important changes in the code of docs itself I changed m2r dependency to m2r2 that is a fork of the former one which is not maintained anymore.

@heavelock
Copy link
Contributor

heavelock commented Feb 15, 2021

Oh dammit. I accidentally pushed to wrong remote and my changes got in here. Sorry for that as I meant to first ask before doing that ...

Anyway, should I remove my changes or can they stay here?

My changes include:

  1. Rebasing on top of current master
  2. Add GH action for building in CI
  3. GH action for exporting the artifact with built docs (Working!)
  4. Added cartopy to dependencies of docs so we can start fixing plotting routines.
  5. Pinned sphinx==3.4.3 as 3.5.0 that was released yesterday has a bug that prevents from building.

@barsch
Copy link
Member Author

barsch commented Feb 15, 2021

All fine - knock yourself out ;)

@heavelock
Copy link
Contributor

Since we are at the docs, do you think it would beneficial for us to start using some linter for docs?
In my projects I'm using doc8 which is equivalent to flake8 for rst docs.

What do you think?

@heavelock
Copy link
Contributor

heavelock commented Feb 15, 2021

Basemap -> Cartopy conversion progress:

  • basemap_with_beachball_read_events.py
  • basemap_plot_with_beachballs2.py
  • basemap_plot_with_beachballs.py
  • basemap_plot_custom.py ----- This plot will be crippled until Inventory.plot and Catalog.plot will not be converted to Cartopy

@barsch
Copy link
Member Author

barsch commented Feb 15, 2021

@heavelock first of all big thanks for looking into this! Two rants from my side while you are on it:

@heavelock
Copy link
Contributor

  1. Yeah, sure. Not today though, I have to come back to my normal tasks for now. I will take a look on that tomorrow.

And the second point:
Definitely. How about having a dedicated docker image for building it?

@barsch
Copy link
Member Author

barsch commented Feb 15, 2021

docker would be perfect imho

@heavelock
Copy link
Contributor

perf. I had it already done but then I ditched it because the sphinx-action I am using here does not support using a custom image as argument. I could fork it and have our own action for that or just create a custom workflow. Positive side of the action is that it is parsing the warnings from sphinx and dropping them in diff.

@heavelock
Copy link
Contributor

heavelock commented Feb 17, 2021

I testes the :samp: directive but it breaks the rendering. I noticed that this problem occurs only for class variables, it is not cross-referenced for standard :param:. I guesss it might be a bug upstream. I will post it to the sphinx's bugtracker.
obraz

Edit: Bugfix for that will be included in 4.0.0:
sphinx-doc/sphinx#8902

@heavelock
Copy link
Contributor

@barsch Would you mind forking this repo as organization? https://github.com/ammaraskar/sphinx-action
It is the action that I used for building docs. Unfortunately, I don't see a possibility of hanging a docker image used by it without modifying the code.

@barsch
Copy link
Member Author

barsch commented Feb 17, 2021

@barsch Would you mind forking this repo as organization? https://github.com/ammaraskar/sphinx-action

done: https://github.com/obspy/sphinx-action

@ThomasLecocq
Copy link
Contributor

my turn to give it a go :-)

@ThomasLecocq ThomasLecocq changed the title [WIP] Updating doc building to Sphinx 3.1.1 [WIP] Updating doc building to Sphinx 4.3.2 (python 3) Jan 11, 2022
@ThomasLecocq
Copy link
Contributor

ThomasLecocq commented Jan 11, 2022

2022 changes

  • Rebased on current master

  • Changed the template for class so that the Private and Special methods don't create a new page, but are listed/inline on the Class's page. This results in a gigantic reduction of output html (there was one for each of __eq__, __del__ etc, for each class). It makes longer pages, but all the info (and cross-refs) are preserved: see example [after/before]:
    image

  • Disabled rendering hires & pdf for plots, it takes a lot of time for no real usefulness

  • removed the ":numbered:" param to the tutorial

  • The build on github actions + @heavelock 's docker takes ~20 min, and the artifact works smooth

Example output: http://msnoise.org/obspy-doc/

on my local machine, the first build took also ~20 minutes, successive builds (adding one comma to one RST file): less than 2 minutes. This means, running a doc builder that doesn't redo everything from scratch could produce docs in a flash. That'd require having some workflow which would include some "persistence":

first run ever (ever)

  • create conda env (+cache it)
  • pull master branch
  • build the doc
  • upload the whole package content as artifact

successive builds:

  • activate doc environment
  • download the artifact
  • pull/checkout the branch (!pulling changes the "version" and makes a full new build, need to "patch" !)
  • build doc
  • export .build/html folder somewhere

TODO still:

  • revert or adapt the changelog.rst vs changelog.md
  • try to shrink the 3554 (!) warnings
  • fix gallery plots
  • find a way to reduce slow processes:
====================== slowest reading durations =======================
452.730 packages/autogen/obspy.imaging.cm
42.885 packages/autogen/obspy.core.inventory.network.Network.plot
34.954 tutorial/code_snippets/beamforming_fk_analysis
29.142 packages/autogen/obspy.core.event.Catalog.plot
9.388 tutorial/code_snippets/waveform_plotting_tutorial

@trichter
Copy link
Member

I reverted my changes here and created a new branch at PR #2947.

@ThomasLecocq
Copy link
Contributor

ThomasLecocq commented Jan 17, 2022

work in progress to make the event & inventory cartopy-proof (might put that in a separate PR, not sure yet):
image

@trichter
Copy link
Member

might put that in a separate PR, not sure yet

What fits best for you. I skimmed through changes introduced by this PR and I didn't find any obvious glitches. Maybe we can try to get rid of the image replacements of _images/*.png to not grow the size of the repository unnecessarily. Some stuff I don't understand (e.g. gulpfile.js), so maybe @barsch can also have look after you finished.

@barsch
Copy link
Member Author

barsch commented Jan 17, 2022

gulp (https://gulpjs.com/docs/en/getting-started/quick-start) is just a build tool to automate CSS, JavaScript and static image management, e.g. minifying code, optimizing images, preprocessing CSS, etc.

I wouldn't try to automate this via GH actions if not needed as this has failed in the past after updating dependencies etc. Instead I suggest we just leave the the gulpfile.js in the root and once some theme changes are needed one just runs the script locally and creates new static minimized and compressed .css and .js files

@trichter
Copy link
Member

I checked ObsPy's sectret tab and:

Secrets are not passed to workflows that are triggered by a pull request from a fork.

Because we want to see doc builds also from forks, it will not work to deploy the doc via SSH in a run triggered in the doc building workflow. We either need a separate github action checking in a time interval for artifacts to upload. Or straightforward, the server can check for runs and relevant artifacts on its own. So the doc building would still be on github actions and can be maintained in this repository, but the server fetches and deploys the docs.

@barsch
Copy link
Member Author

barsch commented Jan 17, 2022

Or straightforward, the server can check for runs and relevant artifacts on its own. So the doc building would still be on github actions and can be maintained in this repository, but the server fetches and deploys the docs.

I very much prefer that.

@trichter
Copy link
Member

trichter commented Jan 17, 2022

Great. @barsch Do you want to write the necessary server-side code? I could also do it. This PR can serve as test load.

@ThomasLecocq
Copy link
Contributor

Great. @barsch Do you want to write the necessary server-side code? I could also do it. This PR can serve as test load.

@trichter I propose we do it you & me when the PR is ready. I'm almost done with the final plots.

@barsch
Copy link
Member Author

barsch commented Jan 17, 2022

there should be code which could be recycled here: https://github.com/obspy/obspy/tree/master/misc/scripts/docs_buildbot

Great. @barsch Do you want to write the necessary server-side code? I could also do it. This PR can serve as test load.

I'm happy to maintain/admin the server and obspy-reporter, but as stated before coding for obspy is not really on my agenda any more - didn't use obspy since 10 years or so and its about time other take over ;)

(but I'm actually very impressed and quite happy to see huge progress here)

@ThomasLecocq
Copy link
Contributor

all look OK now (didn't yet port all the "resolution" stuff, but as a PoC it works)

image
image
image
image

@ThomasLecocq
Copy link
Contributor

YESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS http://msnoise.org/obspy-doc/packages/autogen/obspy.core.event.Event.plot.html#obspy.core.event.Event.plot

@barsch
Copy link
Member Author

barsch commented Jan 17, 2022

hmm

https://docs.obspy.org/sphinx3/gallery.html

vs.

http://msnoise.org/obspy-doc/gallery.html

for whatever reason custom.min.css is not used

@ThomasLecocq
Copy link
Contributor

ThomasLecocq commented Jan 17, 2022

hmm

https://docs.obspy.org/sphinx3/gallery.html

vs.

http://msnoise.org/obspy-doc/gallery.html

for whatever reason custom.min.css is not used

ah, indeed, that... checking now- difference is that on your site div has class "gallery" and not on mine

@ThomasLecocq
Copy link
Contributor

ThomasLecocq commented Jan 17, 2022

CI was 🟢 , which is very satisfactory :-)
now rebuilding the doc locally to update http://msnoise.org/obspy-doc/gallery.html & then I think it'll be good to merge.

And move on with, on the DOC side: the doc builder and on the code side: remove all basemap stuff

🎉 tadaaaaaaaaaaaaaaaaaaa
image

@ThomasLecocq
Copy link
Contributor

ThomasLecocq commented Jan 17, 2022

249 commits +2,927 −3,259 ... wow

I will squash to "1 commit" to merge in master :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build_docs Docs will be automatically built and deployed in github actions on pushes to the PR docs issues that only affect the content of documentation pages, docstrings etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants