From 11278f495be49c0d0bd8edfa2ac67406c1e9d526 Mon Sep 17 00:00:00 2001 From: Zihao Ye Date: Sat, 20 Jan 2024 02:06:49 -0800 Subject: [PATCH] [Doc] Setup documentation (#76) --- .github/workflows/build-doc.yml | 35 +++++++++++++++++++++++++++++++++ docs/.gitignore | 1 + docs/Makefile | 20 +++++++++++++++++++ docs/conf.py | 30 ++++++++++++++++++++++++++++ docs/index.rst | 20 +++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++ docs/requirements.txt | 4 ++++ scripts/gh_deploy_doc.sh | 23 ++++++++++++++++++++++ 8 files changed, 168 insertions(+) create mode 100644 .github/workflows/build-doc.yml create mode 100644 docs/.gitignore create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat create mode 100644 docs/requirements.txt create mode 100755 scripts/gh_deploy_doc.sh diff --git a/.github/workflows/build-doc.yml b/.github/workflows/build-doc.yml new file mode 100644 index 00000000..224f0255 --- /dev/null +++ b/.github/workflows/build-doc.yml @@ -0,0 +1,35 @@ +name: Build FlashInfer Docs + +on: + push: + branches: + - main + +jobs: + test_linux: + name: Deploy Docs + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Configuring build Environment + run: | + sudo apt-get update + python -m pip install -U pip wheel + + - name: Installing dependencies + run: | + python -m pip install -r requirements.txt + + - name: Deploying on GitHub Pages + env: + GITHUB_TOKEN: ${{ secrets.FLASHINFER_GITHUB_TOKEN }} + if: github.ref == 'refs/heads/main' + run: | + git config --global user.name 'Git bot' + git config --global user.email 'bot@noreply.github.com' + git remote set-url origin https://$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY + ./scripts/gh_deploy_doc.sh diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..69fa449d --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +_build/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..d4bb2cbb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help 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 + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..7a737e59 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,30 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'FlashInfer' +author = "FlashInfer Contributors" +copyright = '2023-2024, {}'.format(author) + +version = "0.0.1" +release = "0.0.1" + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinxdoc' +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..3a23a81a --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. FlashInfer documentation master file, created by + sphinx-quickstart on Sat Jan 20 12:31:26 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to FlashInfer's documentation! +====================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..32bb2452 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%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.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..10373a3a --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +sphinx == 5.2.3 +sphinxcontrib_httpdomain==1.8.1 +sphinxcontrib-napoleon==0.7 +sphinx-reredirects==0.1.2 diff --git a/scripts/gh_deploy_doc.sh b/scripts/gh_deploy_doc.sh new file mode 100755 index 00000000..8354562a --- /dev/null +++ b/scripts/gh_deploy_doc.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# NOTE: this script is triggered by github action automatically +# when megred into main + +set -euxo pipefail + +cd docs +make html +mv _build/html/* . +rm -rf _build/ +cd .. + +git grep --cached -l '' | xargs rm +git fetch +git checkout -B gh-pages origin/gh-pages +echo "3rdparty/" >> .gitignore + +DATE=`date` +git add . && git commit -am "Build at ${DATE}" +git push origin gh-pages +git checkout main && git submodule update +echo "Finish deployment at ${DATE}" +