Skip to content

Commit

Permalink
feature(pu): add lightzero sphinx docs (#237)
Browse files Browse the repository at this point in the history
* feature(pu): add lightzero sphinx docs

* feature(pu): add .readthedocs.yaml

* polish(pu): move .readthedocs.yaml to the root directory

* polish(pu): polish sphinx requirements

* polish(pu): polish recommonmark requirements

* fix(pu): fix api_doc and use sphinx_rtd_theme

* fix(pu): fix .readthedocs.yaml

* fix(pu): fix .readthedocs.yaml

* fix(pu): fix .readthedocs.yaml

* fix(pu): fix conf.py

* fix(pu): fix requirements-doc.txt

* fix(pu): fix requirements-doc.txt

* fix(pu): fix requirements-doc.txt

* fix(pu): fix requirements-doc.txt

* polish(pu): delete doc/zh_CN

* polish(pu): polish conf.py

* polish(pu): polish conf.py

* polish(pu): polish deploy.yml for docs

* fix(pu): Update GitHub Actions workflow and add .nojekyll file

* polish(pu): polish deploy.yml for docs

* polish(pu): polish deploy.yml for docs

* polish(pu): polish deploy.yml for docs

* polish(pu): polish deploy.yml for docs

* polish(pu): polish deploy.yml for docs

* polish(pu): polish deploy.yml for docs

* polish(pu): polish documentation
  • Loading branch information
puyuan1996 authored Jul 15, 2024
1 parent d2f5ba8 commit 230a4a5
Show file tree
Hide file tree
Showing 68 changed files with 947 additions and 619 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy Sphinx Docs to GitHub Pages

on:
push:
branches:
- dev-doc

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade -r requirements-doc.txt
pip install -e .
pip install sphinx sphinx-rtd-theme recommonmark
- name: Build the Sphinx documentation
run: |
cd docs/en
make html
cp ../../.nojekyll ./build/html/.nojekyll
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/en/build/html
File renamed without changes.
36 changes: 36 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/en/source/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- epub
- htmlzip

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: requirements-doc.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

Updated on 2024.07.12 LightZero-v0.1.0

English | [简体中文(Simplified Chinese)](https://github.com/opendilab/LightZero/blob/main/README.zh.md) | [LightZero Paper](https://arxiv.org/abs/2310.08348) | [🔥UniZero Paper](https://arxiv.org/abs/2406.10667) | [🔥ReZero Paper](https://arxiv.org/abs/2404.16364)
English | [简体中文(Simplified Chinese)](https://github.com/opendilab/LightZero/blob/main/README.zh.md) | [Documentation](https://opendilab.github.io/LightZero) | [LightZero Paper](https://arxiv.org/abs/2310.08348) | [🔥UniZero Paper](https://arxiv.org/abs/2406.10667) | [🔥ReZero Paper](https://arxiv.org/abs/2404.16364)

> LightZero is a lightweight, efficient, and easy-to-understand open-source algorithm toolkit that combines Monte Carlo Tree Search (MCTS) and Deep Reinforcement Learning (RL).
> For any questions about LightZero, you can consult the RAG-based Q&A assistant: [ZeroPal](https://huggingface.co/spaces/OpenDILabCommunity/ZeroPal).
Expand Down
3 changes: 1 addition & 2 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@

最近更新于 2024.07.12 LightZero-v0.1.0

[English](https://github.com/opendilab/LightZero/blob/main/README.md) | 简体中文 | [LightZero 论文](https://arxiv.org/abs/2310.08348) | [🔥UniZero 论文](https://arxiv.org/abs/2406.10667) | [🔥ReZero 论文](https://arxiv.org/abs/2404.16364)
[English](https://github.com/opendilab/LightZero/blob/main/README.md) | 简体中文 | [文档](https://opendilab.github.io/LightZero) | [LightZero 论文](https://arxiv.org/abs/2310.08348) | [🔥UniZero 论文](https://arxiv.org/abs/2406.10667) | [🔥ReZero 论文](https://arxiv.org/abs/2404.16364)

> LightZero 是一个轻量、高效、易懂的 MCTS+RL 开源算法库。
> 有关 LightZero 的任何疑问,您都可以咨询基于 RAG 技术的问答助手:[ZeroPal](https://huggingface.co/spaces/OpenDILabCommunity/ZeroPal)


## 🔍 背景

以 AlphaZero, MuZero 为代表的结合蒙特卡洛树搜索 (Monte Carlo Tree Search, MCTS) 和深度强化学习 (Deep Reinforcemeent Learning, DRL) 的方法,在诸如围棋,Atari 等各种游戏上取得了超人的水平,也在诸如蛋白质结构预测,矩阵乘法算法寻找等科学领域取得了可喜的进展。下图为蒙特卡洛树搜索(MCTS)算法族的发展历史:
Expand Down
62 changes: 0 additions & 62 deletions docs/Makefile

This file was deleted.

11 changes: 11 additions & 0 deletions docs/en/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.puml.eps
*.puml.jpg
*.puml.svg
.DS_Store
../build/
source/_build
_build/
.vscode/
venv/
.idea/
src/pytorch-sphinx-theme/
35 changes: 35 additions & 0 deletions docs/en/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Minimal makefile for Sphinx documentation
DIAGRAMS_MK := diagrams.mk
DIAGRAMS := $(MAKE) -f "${DIAGRAMS_MK}"

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXLIVE = sphinx-autobuild
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# Build & clean the documentation
diagrams:
@$(DIAGRAMS) build
html: diagrams
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" ./source/**/*_zh.* $(SPHINXOPTS) $(O) -D master_doc=index_zh
live: diagrams
@$(SPHINXLIVE) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
build: html
clean:
@$(DIAGRAMS) clean
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help diagrams html build clean Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(DIAGRAMS) build
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
43 changes: 43 additions & 0 deletions docs/en/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Welcome to LightZero Docs

[![Documentation Status](https://readthedocs.org/projects/lightzero-docs/badge/?version=latest)](https://lightzero-docs.readthedocs.io/en/latest/?badge=latest)

[LightZero](https://arxiv.org/pdf/2310.08348.pdf) is a lightweight, efficient, and easy-to-understand open-source algorithm toolkit that combines Monte Carlo Tree Search (MCTS) and Deep Reinforcement Learning (RL).

For those interested in customizing environments and algorithms, we provide relevant guides:

- [Customize Environments](https://github.com/opendilab/LightZero/blob/main/docs/source/tutorials/envs/customize_envs.md)
- [Customize Algorithms](https://github.com/opendilab/LightZero/blob/main/docs/source/tutorials/algos/customize_algos.md)
- [How to Set Configuration Files?](https://github.com/opendilab/LightZero/blob/main/docs/source/tutorials/config/config.md)
- [Logging and Monitoring System](https://github.com/opendilab/LightZero/blob/main/docs/source/tutorials/logs/logs.md)

Should you have any questions, feel free to contact us for support.


# Local Docs Generation
```bash
# step 1: install
cd LightZero
pip install -r requirements-doc.txt
# step 2: compile docs
cd LightZero/docs/en/source
make live
# step 3: open http://127.0.0.1:8000 in your browser, and explore it!
```

# Citing LightZero-docs
```latex
@misc{ding,
title={{LightZero-docs:} A Unified Benchmark for Monte Carlo Tree Search in General Sequential Decision Scenarios},
author={LightZero-docs Contributors},
publisher = {GitHub},
howpublished = {\url{https://github.com/opendilab/LightZero-docs}},
year={2023},
}
```
# Contact Us
If you have any questions about documentation, please add a new issue or contact `opendilab@pjlab.org.cn`

# License

LightZero-Docs released under the Apache 2.0 license
2 changes: 1 addition & 1 deletion docs/source/diagrams.mk → docs/en/diagrams.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SVGS := $(addsuffix .puml.svg, $(basename ${PUMLS}))

build: ${SVGS} ${PNGS}

all: build
all: ../build

clean:
rm -rf \
Expand Down
35 changes: 35 additions & 0 deletions docs/en/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions docs/en/source/_static/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.header-logo {
background-image: url("../../../../LightZero.png");
background-size: 180px 40px;
height: 40px;
width: 180px;
}
Empty file added docs/en/source/_templates/.keep
Empty file.
4 changes: 4 additions & 0 deletions docs/en/source/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "!layout.html" %}
{% block extrahead %}
<link href="{{ pathto("_static/css/style.css", True) }}" rel="stylesheet" type="text/css">
{% endblock %}
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions docs/en/source/api_doc/agent/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Agent
==========

.. autoclass:: lzero.agent.alphazero.AlphaZeroAgent
:members:

.. autoclass:: lzero.agent.muzero.MuZeroAgent
:members:

.. autoclass:: lzero.agent.efficientzero.EfficientZeroAgent
:members:

.. autoclass:: lzero.agent.gumbel_muzero.GumbelMuZeroAgent
:members:

.. autoclass:: lzero.agent.sampled_efficientzero.SampledEfficientZeroAgent
:members:

.. autoclass:: lzero.agent.sampled_alphazero.SampledAlphaZeroAgent
:members:


7 changes: 7 additions & 0 deletions docs/en/source/api_doc/config/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Config
=====================

.. toctree::
:maxdepth: 2

meta
File renamed without changes.
23 changes: 23 additions & 0 deletions docs/en/source/api_doc/entry/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Entry
==============================

.. autoclass:: lzero.entry.train_alphazero.train_alphazero
:members:

.. autoclass:: lzero.entry.eval_alphazero.eval_alphazero
:members:

.. autoclass:: lzero.entry.train_muzero.train_muzero
:members:

.. autoclass:: lzero.entry.eval_muzero.eval_muzero
:members:

.. autoclass:: lzero.entry.train_muzero_with_gym_env.train_muzero_with_gym_env
:members:

.. autoclass:: lzero.entry.eval_muzero_with_gym_env.eval_muzero_with_gym_env
:members:

.. autoclass:: lzero.entry.train_muzero_with_reward_model.train_muzero_with_reward_model
:members:
11 changes: 11 additions & 0 deletions docs/en/source/api_doc/envs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Envs
==========

.. autoclass:: lzero.envs.wrappers.lightzero_env_wrapper.LightZeroEnvWrapper
:members:

.. autoclass:: lzero.envs.wrappers.action_discretization_env_wrapper.ActionDiscretizationEnvWrapper
:members:

.. autoclass:: lzero.envs.get_wrappered_env.get_wrappered_env
:members:
Loading

0 comments on commit 230a4a5

Please sign in to comment.