GSoC 2023 @ PyBaMM, NumFOCUS: Weeks 1 and 2
Tags: gsoc, python, opensource
Published: 2023-07-13 22:08:03

Hi there! This is the second blog in a series of seven blogs that document my journey of my Google Summer of Code project under the NumFOCUS umbrella organisation where I aim to improve the documentation infrastructure for PyBaMM, a Python package for working with physics-based battery models.

---

## A summary of the tasks I completed

1. Use `Lychee` to check for broken links ([#3](https://github.com/pybamm-team/pybamm.org/pull/3))
2. Add `pre-commit` support ([#4](https://github.com/pybamm-team/pybamm.org/pull/4))
3. Improvements to `pre-commit` ([#5](https://github.com/pybamm-team/pybamm.org/pull/5))
4. Netlify deployment infrastructure ([#8](https://github.com/pybamm-team/pybamm.org/pull/8))
5. Add news pages from PyBaMM blogspot ([#10](https://github.com/pybamm-team/pybamm.org/pull/10))
6. Custom PyBaMM 404 page ([#12](https://github.com/pybamm-team/pybamm.org/pull/12))
7. Favicon for PyBaMM ([#14](https://github.com/pybamm-team/pybamm.org/pull/14))
8. Donations and sponsors ([#16](https://github.com/pybamm-team/pybamm.org/pull/16))
9. Twitter feed, institutional partners, and about PyBaMM ([#19](https://github.com/pybamm-team/pybamm.org/pull/19))

I have started a summary issue to keep track of my progress, which I will be editing on a regular basis. Please feel free to suggest an improvement in the [summary issue thread](https://github.com/pybamm-team/pybamm.org/issues/6) and I will be glad to look into it!

## Building blocks: the initial infrastructure for the new [pybamm.org](pybamm.org) website

We started the project by creating a [repository](https://github.com/pybamm-team/pybamm.org) for the website in the [pybamm-team](https://github.com/pybamm-team) organisation. To set up the website itself, we planned to use the [Scientific Python Hugo theme](https://theme.scientific-python.org); also used by [NumPy](https://numpy.org) and [SciPy](https://scipy.org), and by some other Python projects in the [Scientific Python community](https://scientific-python.org/).

To host the website, we preferred Netlify to GitHub Pages owing to the fact that it would be easier to see collaborative previews on changes made via pull requests. The development version of the website can be accessed at https://pybamm-developer-preview.netlify.app/. Please feel free to [open an issue](https://github.com/pybamm-team/pybamm.org/issues) if you see something broken!

![A screengrab of the PyBaMM website](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/agoyc825yabb72xceqg5.png)

## The war against broken links: validating and checking them with a workflow

I also added my favourite link checker ([Lychee](https://github.com/lycheeverse/lychee) in a GitHub Action to check for broken links and. It is incredibly fast and written in Rust — which is also the reason it is one of my favourites! It also serves as a personal reminder to learn Rust some day. The [workflow](https://github.com/pybamm-team/pybamm.org/actions/workflows/links.yml) currently runs as a CRON job at 0300 hours UTC scheduled daily. The link checker also has features such as excluding selected links or status codes, adding user agents, and an option to enable caching.

## `pre-commit` hooks are cool!

I added pre-commit hooks for developers to use, such as [`ruff`](https://astral.sh/ruff)—an extremely fast Python linter written in Rust, `black` as an autoformatter, `codespell` to fix common spelling errors and some other pre-commit hooks to remove trailing whitespaces and lint Markdown files. This way, developers working on the website locally can run

```bash
pre-commit install
pre-commit run --all-files
```

to fix all the files with the pre-commit hooks before committing, or let `git` do it for them.

In addition, we enabled support for the [pre-commit.ci](https://pre-commit.ci) bot to automatically perform these operations wherever possible on pull requests and commits.

## For every piece of art, there is another that does it better

I ported over many pages and items from the previous PyBaMM website, redesigning and editing them as neccessary:

1. The Donations page for enlisting sponsorships and ways to contribute PyBaMM fiscally
2. Blogs by the PyBaMM team, in a newsroom page (https://pybamm.org/news/)
3. A custom 404 page
4. A favicon for the website, which is essentially the PyBaMM logo
5. A Twitter feed for PyBaMM, and
6. The home page and other pages, which contain training material and institutional partners

## Tasks to focus on in the coming weeks

1. Improving the structure for the newly-set-up PyBaMM website and reordering certain pages
2. Adding over the remaining pages, and 
3. Making sure the website adheres to the W3C Web Content Accessibility Guidelines specification

## Stay tuned

I will be posting these blogs fortnightly as a part of my GSoC project. Thoughts, comments, constructive criticism, and insights will be greatly appreciated. See you soon on the next one! For updates, please follow me on my social media handles:

- [Twitter](https://twitter.com/agriyakhetarpal)
- [GitHub](https://github.com/agriyakhetarpal)
- [LinkedIn](https://linkedin.com/in/agriyakhetarpal)