Skip to content

Commit

Permalink
docs: tighten the "previewing docs" section
Browse files Browse the repository at this point in the history
  • Loading branch information
neongreen committed Nov 10, 2024
1 parent a7a3a0f commit 1e515e3
Showing 1 changed file with 51 additions and 28 deletions.
79 changes: 51 additions & 28 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,46 +219,67 @@ multi-threaded. It should use all the CPU cores without any configuration.

## Previewing the HTML documentation

The documentation for `jj` is automatically published to the website at
The documentation for `jj` is automatically published online at
<https://martinvonz.github.io/jj/>.

When editing documentation, we'd appreciate it if you checked that the
result will look as expected when published to the website.
When editing documentation, you should check your changes locally — especially
if you are adding a new page, or doing a major rewrite.

### Setting up the prerequisites
The only thing you need is [`uv`][uv], a Python project manager written in Rust.
It will fetch the right Python version and the dependencies. Install it like so:

To build the website, you must have `uv` installed. Please see: [Installing uv].
[uv]: https://docs.astral.sh/uv/

[Installing uv]: https://docs.astral.sh/uv/getting-started/installation/
=== "macOS/Linux"

Once you have `uv` installed, you should ask it to install the rest
of the required tools into a virtual environment as follows:
``` { .shell .copy }
curl -LsSf https://astral.sh/uv/install.sh | sh
```

```shell
uv sync
```
=== "Windows"

### Building the HTML docs locally (with live reload)
``` { .shell .copy }
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```

The HTML docs are built with [MkDocs](https://github.com/mkdocs/mkdocs). After
following the above steps, you should be able to view the docs by running
=== "Homebrew"

```shell
# Note: this and all the commands below should be run from the root of
# the `jj` source tree.
``` { .shell .copy }
brew install uv
```

=== "Cargo"

``` { .shell .copy }
# This might take a while
cargo install --git https://github.com/astral-sh/uv uv
```

=== "Other options"

See [Installing uv](https://docs.astral.sh/uv/getting-started/installation/).

To build the docs, run from the root of the `jj` repository:

``` { .shell .copy }
uv run mkdocs serve
```

and opening <http://127.0.0.1:8000> in your browser.
Open <http://127.0.0.1:8000> in your browser to see the docs.

As you edit the `.md` files in `docs/`, the website should be rebuilt and
reloaded in your browser automatically.

As you edit the `md` files, the website should be rebuilt and reloaded in your
browser automatically, unless build errors occur.
!!! note "If the docs are not updating"
Check the terminal from which you ran `uv run mkdocs serve` for any build
errors or warnings. Warnings about `"GET /versions.json HTTP/1.1" code 404`
are expected and harmless.

You should occasionally check the terminal from which you ran `uv run mkdocs serve` for
any build errors or warnings. Warnings about `"GET /versions.json HTTP/1.1" code
404` are expected and harmless.
## Building the entire website

### How to build the entire website (not usually necessary)
!!! tip
Building the entire website is not usually necessary. If you are editing
documentation, the previous section is enough.

The full `jj` website includes the documentation for several `jj` versions
(`prerelease`, latest release, and the older releases). The top-level
Expand All @@ -274,16 +295,18 @@ On a POSIX system or WSL, one way to build the entire website is as follows (on
Windows, you'll need to understand and adapt the shell script):

1. Check out `jj` as a co-located `jj + git` repository (`jj clone --colocate`),
cloned from your fork of `jj` (e.g. `jjfan.github.com/jj`). You can also use a
cloned from your fork of `jj` (e.g. `github.com/jjfan/jj`). You can also use a
pure Git repo if you prefer.

2. Make sure `jjfan.github.com/jj` includes the `gh-pages` bookmark of the jj repo
2. Make sure `github.com/jjfan/jj` includes the `gh-pages` bookmark of the jj repo
and run `git fetch origin gh-pages`.

3. Go to the GitHub repository settings, enable GitHub Pages, and configure them
to use the `gh-pages` bookmark (this is usually the default).

4. Run the same `sh` script that is used in GitHub CI (details below):
4. Install `uv` as explained in [Previewing the HTML
documentation](#previewing-the-html-documentation), and run the same `sh` script
that is used in GitHub CI (details below):

```shell
.github/scripts/docs-build-deploy 'https://jjfan.github.io/jj/'\
Expand Down Expand Up @@ -322,7 +345,7 @@ this can be done with:
If you want to preserve some of the changes you made, you can do `jj bookmark
set my-changes -r gh-pages` BEFORE running the above commands.

#### Explanation of the `docs-build-deploy` script
### Explanation of the `docs-build-deploy` script

The script sets up the `site_url` mkdocs config to
`'https://jjfan.github.io/jj/'`. If this config does not match the URL
Expand Down

0 comments on commit 1e515e3

Please sign in to comment.