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

Documentation site build rework #204

Merged
merged 15 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ The homepage source code is in `./docs/source/index.rst`.
To build the documentation locally (not required but good check)

```bash
cd docs
make html
python3 docs/build_docs.py
```
Copy link
Member

Choose a reason for hiding this comment

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

the make html/pdf/etc and make clean are common interfaces. It is a shame to have to replace them. But that's OK, it is not like we use this often. It is mostly just the CI.


The built documentation will be in `./docs/_build` and the homepage is `./docs/_build/index.html`.
To delete do `make clean`.
To delete, do `python3 docs/clean_docs.py`.

The documentation uses the Jupyter notebook tutorials in the `examples` directory.
When building the documentation locally you will need to have installed [pandoc](https://pandoc.org/installing.html) and [gifsicle](https://github.com/kohler/gifsicle).
We recommend installing pandoc using its Anaconda distribution: `conda install -c conda-forge pandoc`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added this while investigating #203. Pandoc is a pain to get playing nice with Python on Windows using the methods suggested on the website, but there is an undocumented precompiled version supported on conda-forge that works like a charm.

Copy link
Member

Choose a reason for hiding this comment

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

seems to be the case with a lot of codes that require compiling.


### Editing the tutorials
The tutorials are used as part of the Documentation.
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ jobs:
- name: Build documentation
shell: bash -l {0}
run: |
cd docs
make linkcheck
make html
cd ../
python3 docs/build_docs.py

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
24 changes: 0 additions & 24 deletions docs/Makefile

This file was deleted.

39 changes: 39 additions & 0 deletions docs/build_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
from shutil import rmtree
import source.make_theory_animations
from sphinx.application import Sphinx

docs_dir = os.path.dirname(os.path.abspath(__file__))
source_dir = os.path.join(docs_dir, 'source')
conf_dir = source_dir
build_dir = os.path.join(docs_dir, '_build')
doctree_dir = os.path.join(build_dir, '.doctrees')
example_dir = os.path.join(source_dir, '_examples')
api_dir = os.path.join(source_dir, 'api_docs')


def linkcheck():
app = Sphinx(source_dir,
conf_dir,
build_dir,
doctree_dir,
'linkcheck',
warningiserror=True)
app.build()


def html():
app = Sphinx(source_dir,
conf_dir,
build_dir,
doctree_dir,
'html',
warningiserror=True)
Comment on lines +15 to +31
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think writing it like this is redundant, but Sphinx doesn't have a good way of handling multiple builders outside of the Makefile interface at the moment. However, this should be addressed in sphinx-doc/sphinx#5618 whenever it gets merged.


app.build()


if __name__ == '__main__':
source.make_theory_animations
linkcheck()
html()
14 changes: 14 additions & 0 deletions docs/clean_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
from shutil import rmtree

docs_dir = os.path.dirname(os.path.abspath(__file__))
source_dir = os.path.join(docs_dir, 'source')
example_dir = os.path.join(source_dir, '_examples')
api_dir = os.path.join(source_dir, 'api_docs')

def clean():
rmtree(example_dir)
rmtree(api_dir)

if __name__ == '__main__':
clean()
6 changes: 5 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@
def setup(app):
app.add_css_file('css/custom.css')

suppress_warnings = ["autosectionlabel.*"] # nbsphinx and austosectionlabel do not play well together
suppress_warnings = ['autosectionlabel.*', # nbsphinx and austosectionlabel do not play well together
'app.add_node', # using multiple builders in custom Sphinx objects throws a bunch of these
'app.add_directive',
'app.add_role',]

linkcheck_ignore = [
'https://github.com/HIPS/autograd/blob/master/docs/tutorial.md#supported-and-unsupported-parts-of-numpyscipy',
'https://www.osti.gov/biblio/1330189/',
]

# -- References (BibTex) -----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion wecopttool/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WaveBot:
See, e.g.,

- https://doi.org/10.3390/en10040472
- https://doi.org/10.2172/1330189
- https://www.osti.gov/biblio/1330189/

"""

Expand Down