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

docs: Various improvements to the contributor guide #14151

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
50 changes: 44 additions & 6 deletions docs/development/contributing/ide.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,38 @@ This page contains some recommendations for configuring popular IDEs.

## Visual Studio Code

### Python environment

Make sure to configure VSCode to use the virtual environment created by the Makefile.
VSCode will prompt you to do this automatically once the Makefile creates the `.venv` folder.
You can also run the `Python: Select Interpreter` command to manually configure the workspace to use the local `.venv` interpreter.

You can use the `Python: Create Terminal` command to easily launch a terminal instance that has the virtual environment loaded.

### Line lengths

We use 88 characters for Python code and 100 characters for Rust code. If you want VSCode to show you rulers at those points, add the following settings to your `.vscode/settings.json`:

```json
{
"[python]": {
"editor.rulers": [
88
],
},
"[rust]": {
"editor.rulers": [
100
],
},
}
```

In addition, the extensions below are recommended.
### Extensions

### rust-analyzer
We recommend using the following VSCode extensions to aid your development experience.

#### rust-analyzer

If you work on the Rust code at all, you will need the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) extension. This extension provides code completion for the Rust code.

Expand All @@ -21,11 +48,22 @@ For it to work well for the Polars code base, add the following settings to your
}
```

### Ruff
#### Ruff

We use the Ruff linter and formatter on our Python code. The [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extension will help you conform to the formatting requirements of the Python code.

If you want to configure Ruff to format automatically on save, add the following settings to your `.vscode/settings.json`:

```json
{
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
}
}
```

The Ruff extension will help you conform to the formatting requirements of the Python code.
We use both the Ruff linter and formatter.
It is recommended to configure the extension to use the Ruff installed in your environment.
You should also configure the extension to use the Ruff installed in your virtual environment.
This will make it use the correct Ruff version and configuration.

```json
Expand Down
3 changes: 2 additions & 1 deletion docs/development/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ The user guide is maintained in the `docs/user-guide` folder. Before creating a

The user guide is built using [MkDocs](https://www.mkdocs.org/). You install the dependencies for building the user guide by running `make requirements` in the root of the repo.

Run `mkdocs serve` to build and serve the user guide, so you can view it locally and see updates as you make changes.
Run `mkdocs serve` from inside the virtual environment to build and serve the user guide, so you can view it locally and see updates as you make changes.
stinodego marked this conversation as resolved.
Show resolved Hide resolved

#### Creating a new user guide page

Expand Down Expand Up @@ -228,6 +228,7 @@ From the `py-polars` directory, run `make fmt` to make sure your additions pass
Polars uses Sphinx to build the API reference.
This means docstrings in general should follow the [reST](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) format.
If you want to build the API reference locally, go to the `py-polars/docs` directory and run `make html SPHINXOPTS=-W`.
By default, this uses only one thread. To speed it up, run `make html SPHINXOPTS="-W -j auto"` to use all available cpus.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is enabled by default - see the Makefile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ran without the -j auto and it went extremely slowly for me and only seemed to be using one core. I added -j auto and it went much faster. Is that just because it had been built once before? Is the first time always really slow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the Makefile sets the following by default, as you said:

SPHINXOPTS ?= -j auto -W

However, if you do as the contrib guide suggests and run make html SPHINXOPTS=-W, then you will override that default and get rid of the -j auto. So we should change the guide to say make html.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right!

The resulting HTML files will be in `py-polars/docs/build/html`.

New additions to the API should be added manually to the API reference by adding an entry to the correct `.rst` file in the `py-polars/docs/source/reference` directory.
Expand Down
Loading