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

Add Github Pages using Sphinx documentation #19

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

Lodewic
Copy link

@Lodewic Lodewic commented Feb 19, 2024

Github Pages with Sphinx

This PR adds a Github Action to publish Github Pages, with documentation created with Sphinx and nbsphinx to allow writing pages with Jupyter notebooks.

The Preview hosted from my fork is here: https://lodewic.github.io/trelliscope-py/

Deploying using Github Actions

Added a new workflow that builds and publishes Sphinx documentation from a new ./docs directory.

Sphinx documentation

I am using Sphinx with the nbsphinx plugin. Sphinx is commonly used and can generate a classic 'read-the-docs` style for documentation. I also found bootstrap themes that are more similar to the TrelliscopeJS documentation - but they did not work for me out of the box.

For most of the codebase I intend to heavily autodoc and automodule. This will automatically document all the objects in a module, granted that they have a docstring in the first place. Docstrings are parsed and rendered automatically, but... this requires an agreed-upon style.

Docstring style

To make Sphinx documentation work with autodoc, we should choose one of 2 docstring-styles:

Personally I prefer the Google-style docstrings.

When being strict about type-hinting everything, types do not need to be included in the docstrings, which is nice. A good extension to handle type-hints with autodoc is this, https://pypi.org/project/sphinx-autodoc-typehints

About nbsphinx

Use Jupyter Notebooks to create documentation pages, largely for runnable examples. Documentation here: https://nbsphinx.readthedocs.io/en/0.9.3/

Using Jupyter notebooks to create documentation is quite powerful I think, and makes the example notebook you made instantly available in the documentation pages. I intend to create more example notebooks, both for users and for developers.

Additionally, when generating the documentation, the documentation notebooks are actually executed. Therefore I consider these a type of integration test, creating incentive to create documentation that executes most of the codebase. Also, by executing the notebooks in a workflow - and failing when any notebook fails - we ensure that all examples are in fact reproducible for users.

Lodewic added 21 commits February 19, 2024 18:17
The GitHub Actions workflow for building documentation has been significantly updated. A new job for configuring GitHub Pages has been added, run on ubuntu-latest. In addition, the original job for building HTML is split into separate jobs for building the pages and deploying the artifact, again run on ubuntu-latest. These additions should streamline and speed up
The GitHub Actions workflow for building documentation has been significantly updated. A new job for configuring GitHub Pages has been added, run on ubuntu-latest. In addition, the original job for building HTML is split into separate jobs for building the pages and deploying the artifact, again run on ubuntu-latest. These additions should streamline and speed up
The changes made refactor the method documentation from 'Params' to 'Args' in trelliscope.py, focusing on clearer syntax. Several documentation files (index.rst, usage.ipynb) have been removed while others (.github/workflows/build-docs.yml, pyproject.toml) have been updated within the project. Overall, these changes ensure coding standards and update documentation system.
The Sphinx command used in the GitHub Actions workflow for building documentation has been simplified. The "-W" and "--keep-going" flags that were previously used have been removed.
The Sphinx command used in the GitHub Actions workflow for building documentation has been simplified. The "-W" and "--keep-going" flags that were previously used have been removed.
The Sphinx command used in the GitHub Actions workflow for building documentation has been simplified. The "-W" and "--keep-going" flags that were previously used have been removed.
Changed the build output directory from '_build/html' to './_site' in the workflow file 'build-docs.yml'. Replaced the
The version of the 'deploy-pages' action used in the 'build-docs' GitHub workflow has been updated from v1 to v4. This will ensure the use of the latest version which might include improved features or bug fixes.
The build-docs GitHub actions workflow has been updated to adjust the pages deployment process. The 'build-pages' job now runs on ubuntu and installs pandoc via wget instead of brew. The deployment has been integrated into the 'build-pages' job for more streamlined operation.
The build-docs GitHub actions workflow has been updated to adjust the pages deployment process. The 'build-pages' job now runs on ubuntu and installs pandoc via wget instead of brew. The deployment has been integrated into the 'build-pages' job for more streamlined operation.
@hafen
Copy link

hafen commented Feb 21, 2024

@Lodewic thanks this looks awesome!

I think google style is good.

@sburton42 let me know if you have any additional comments otherwise I am good to merge.

@Lodewic
Copy link
Author

Lodewic commented Feb 21, 2024

Hi @hafen, thank you! I am happy to hear you like it and feel like it is ready to merge

There are some additional changes that need to be made to the pages before they are complete, which is why I flagged this PR as a [Draft]. However, I try to avoid creating a single Huge PR that changes too many things at once.

Before merging this, I think it would be nice to have a better first version of the docs in place. To achieve that, I would first like to make a series of PR's that would be merged into this one. These would be PR's such as:

  • Rewrite all docstrings to google-style format.
  • Include all python modules in the API Reference section of the docs.
  • Include a proper 'Quickstart' page with a small runnable example

Finally, before merging this, there are some Github repository settings that need to be configured for Github Pages to work. I don't have permissions to configure that but I am happy assist when the time comes.

@sburton42
Copy link
Collaborator

This all sounds great to me, including the use of the Google style. Thanks!

@hafen
Copy link

hafen commented Mar 1, 2024

@Lodewic I agree and think it's great to go ahead with each of those bullets. Are these things you would be interested in contributing? I am happy to assist but would need some direction since my development involvement is mostly on the R/JS side.

@Lodewic
Copy link
Author

Lodewic commented Mar 1, 2024

@hafen I am definitely aiming to contribute the bulletpoints I stated. Hope to find time this weekend.

I saw you made updates to the JS side of things and it makes me wonder if there are other channels where you collaborate that I might join the conversation.

@hafen
Copy link

hafen commented Mar 1, 2024

@Lodewic yes it would be great to add you to our slack channel. Send me a note at rhafen@gmail and I'll get you added. Thanks!

@Lodewic
Copy link
Author

Lodewic commented Mar 2, 2024

@hafen and @sburton42 , all the changes I wanted to implement for a first version of the docs are done!

Have a look and let me know what you think: https://lodewic.github.io/trelliscope-py/

  1. Added docstrings to every function.
  2. Added pydocstyle plugin for linting, which verifies that every public method and module has a google-style docstring.
  3. Added more notebook examples, for Mars Rover, Gapminder and Iris datsets.
  4. Removed the scripts from trelliscope.examples, since I created notebooks from them.
  5. Added a get_example_data() method to load the included example datasets easily, as shown in the docs notebooks.
  6. Ensured that all functions are shown in the 'API Reference' section of the docs

Now with:

@Lodewic
Copy link
Author

Lodewic commented Mar 2, 2024

To enable Github Pages for this repositoy, go to Settings -> Pages . Ensure Source = 'GitHub Actions.

Not every branch is set up to update the docs, this is configured under Settings -> Environments. I don't know yet how to host multiple versions of the docs, so I don't think you want feature branches to overwrite the Pages.

@Lodewic Lodewic changed the title [Draft] Add Github Pages using Sphinx documentation Add Github Pages using Sphinx documentation Mar 2, 2024
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