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

Update docs #837

Merged
merged 6 commits into from
Oct 23, 2022
Merged
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
13 changes: 8 additions & 5 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@ jobs:
docs:
name: Generate Website
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.9'

- name: Install dependencies
run: pip install -r docs/requirements.txt

- name: Install PettingZoo
run: pip install .

- name: Generate environment docs
run: python docs/_scripts/gen_envs_mds.py


- name: Generate environments display
run: python docs/_scripts/gen_envs_display.py

- name: Build
run: sphinx-build -b dirhtml -v docs _build

Expand Down
3 changes: 2 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
environments/**/*.md
environments/**/*.md
environments/**/list.html
38 changes: 38 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# PettingZoo docs

This folder contains the documentation for [PettingZoo](https://github.com/Farama-Foundation/PettingZoo).

## Instructions for editing content

Our documentation is written in Markdown (more precisely, MyST - Markedly Structured Text) and built using [Sphinx](https://www.sphinx-doc.org/en/master/).
All content present in the documentation website can be found in this directory except for the environments.

### Editing an environment page

Environemnts' documentation can be found at the top of the file python file where the environment is declared, for example, the documentation for the chess environment can be at [/pettingzoo/classic/chess/chess.py](https://github.com/Farama-Foundation/PettingZoo/blob/master/pettingzoo/classic/chess/chess.py)

To generate the environments pages you need to execute the `_scripts/gen_envs_mds.py` script.

## Build the Documentation

Install the required packages and PettingZoo:

```
pip install -e .
cd docs/
pip install -r requirements.txt
```

To build the documentation once:

```
cd docs
make dirhtml _build
```

To rebuild the documentation automatically every time a change is made:

```
cd docs
sphinx-autobuild -b dirhtml . _build
```
5 changes: 3 additions & 2 deletions docs/_scripts/gen_envs_display.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys

all_envs = {
Expand Down Expand Up @@ -111,8 +112,8 @@ def generate_page(env_type_id, env_list, limit=-1, base_path=""):

for key in all_envs.keys():
env_list = all_envs[key]
envs_path = f"../environments/{key}"
envs_path = os.path.join(os.path.dirname(__file__), "..", "environments", key)
page = generate_page(key, env_list)
fp = open(f"{envs_path}/list.html", "w+", encoding="utf-8")
fp = open(os.path.join(envs_path, "list.html"), "w+", encoding="utf-8")
fp.write(page)
fp.close()
2 changes: 1 addition & 1 deletion docs/_scripts/gen_envs_mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def add_frontmatter(text, frontmatter_options):
frontmatter_text = "---"
frontmatter_text = "---\nautogenerated:"
for key, value in frontmatter_options.items():
frontmatter_text += f"\n{key}: {value}"
frontmatter_text += "\n---\n\n"
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pettingzoo

project = "PettingZoo"
copyright = "2022"
copyright = "2022 Farama Foundation"
author = "Farama Foundation"

# The full version, including alpha/beta/rc tags
Expand Down
Loading