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

feat(docs): build documents with sphinx #2406

Merged
merged 7 commits into from
Aug 30, 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
76 changes: 76 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: documents

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- main
tags:
- v*
paths:
- .github/workflows/doc.yml
- 'docs/**'
pull_request:
paths:
- .github/workflows/doc.yml
- 'docs/**'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

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

- name: setup poetry
run: |
pipx install poetry

- name: doc build (pr)
working-directory: docs
if: github.event_name == 'pull_request'
run: |
make all-local

- name: doc build (branch)
working-directory: docs
if: github.event_name == 'push'
run: |
make

- name: upload artifact
if: github.event_name == 'push'
uses: actions/upload-pages-artifact@v1
with:
path: docs/build/

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
steps:
# This action expects an artifact named github-pages to have been created prior to execution.
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./build/
33 changes: 33 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.PHONY: all en zh en-local zh-local clean init all-local

MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))

POETRY_PRG ?= $(shell (command -v poetry || echo poetry))
OUT_DIR ?= $(MAKEFILE_DIR)/build


all: en zh

en: init
$(POETRY_PRG) run sphinx-multiversion "$(MAKEFILE_DIR)/en" "$(OUT_DIR)/en"
echo '<!DOCTYPE html> <html><head><meta http-equiv="refresh" content="0; url=main" /></head></html>' > $(OUT_DIR)/en/index.html

zh: init
$(POETRY_PRG) run sphinx-multiversion "$(MAKEFILE_DIR)/zh" "$(OUT_DIR)/zh"
echo '<!DOCTYPE html> <html><head><meta http-equiv="refresh" content="0; url=main" /></head></html>' > $(OUT_DIR)/zh/index.html

# for local build, you may need compile current branch only, use the three jobs
all-local: en-local zh-local

en-local: init
$(POETRY_PRG) run sphinx-build "$(MAKEFILE_DIR)/en" "$(OUT_DIR)/en-local"

zh-local: init
$(POETRY_PRG) run sphinx-build "$(MAKEFILE_DIR)/zh" "$(OUT_DIR)/zh-local"

init:
$(POETRY_PRG) install

clean:
rm -rvf "$(OUT_DIR)"
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you fail to create conda envs by `environment.yml`, try following commands.
4. pip3 install sphinx-multiversion
5. pip3 install myst-parser
6. pip3 install sphinx-book-theme
7. pip3 install sphinx_copybutton
7. pip3 install sphinx-copybutton
8. pip3 install myst-parser[linkify]
```
## Tips
Expand Down
15 changes: 15 additions & 0 deletions docs/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,18 @@

html_logo = "about/images/openmldb_logo.png"


# ================================== #
# sphinx multiversion configuration #
# ================================== #

# Whitelist pattern for tags (set to None to ignore all tags)
# no tags included
smv_tag_whitelist = None

# Whitelist pattern for branches (set to None to ignore all branches)
# include branch that is main or v{X}.{Y}
smv_branch_whitelist = r"^(main|v\d+\.\d+)$"

# allow remote origin or upstream
smv_remote_whitelist = r"^(origin|upstream)$"
7 changes: 5 additions & 2 deletions docs/environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: sphinx
channels:
- conda-forge
- defaults
dependencies:
- alabaster=0.7.12
- babel=2.9.1
Expand Down Expand Up @@ -28,7 +31,7 @@ dependencies:
- requests=2.27.1
- setuptools=58.0.4
- snowballstemmer=2.2.0
- sphinx=4.4.0
- sphinx=4.5.0
- sphinxcontrib-applehelp=1.0.2
- sphinxcontrib-devhelp=1.0.2
- sphinxcontrib-htmlhelp=2.0.0
Expand Down Expand Up @@ -58,4 +61,4 @@ dependencies:
- sphinx-multiversion==0.2.4
- typing-extensions==4.1.1
- uc-micro-py==1.0.1
- sphinx-copybutton==0.5.0
- sphinx-copybutton==0.5.0
Loading