mirror of
https://github.com/mii443/tokenizers.git
synced 2025-08-22 08:15:49 +00:00
Doc - Add CI for automatic deployment
This commit is contained in:
49
.github/deploy_doc.sh
vendored
Executable file
49
.github/deploy_doc.sh
vendored
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
LANGUAGES=('rust' 'python' 'node')
|
||||
|
||||
function deploy_doc(){
|
||||
echo "Creating doc at commit $1 for language $3 and pushing to folder $2"
|
||||
git checkout $1
|
||||
cd "$GITHUB_WORKSPACE/docs"
|
||||
if [ "$2" == "master" ]; then
|
||||
echo "Pushing master"
|
||||
for LANG in "${LANGUAGES[@]}"; do
|
||||
make clean
|
||||
make html O="-t $LANG"
|
||||
ssh "$HOST_NAME" "mkdir -p $DOC_PATH/$LANG"
|
||||
scp -r build/html "$HOST_NAME:$DOC_PATH/$LANG/$2"
|
||||
cp -r build/html/_static .
|
||||
done
|
||||
elif [ "$2" == "latest" ]; then
|
||||
echo "Pushing latest for" $3
|
||||
make clean
|
||||
make html O="-t $3"
|
||||
ssh "$HOST_NAME" "mkdir -p $DOC_PATH/$3"
|
||||
scp -r build/html "$HOST_NAME:$DOC_PATH/$3/$2"
|
||||
elif ssh "$HOST_NAME" "[ -d $DOC_PATH/$3/$2 ]"; then
|
||||
echo "Directory" $2 "already exists"
|
||||
scp -r _static/* "$HOST_NAME:$DOC_PATH/$3/$2/_static/"
|
||||
else
|
||||
echo "Pushing version" $2 "for" $3
|
||||
make clean
|
||||
make html O="-t $3"
|
||||
rm -rf build/html/_static
|
||||
cp -r _static build/html
|
||||
scp -r build/html "$HOST_NAME:$DOC_PATH/$3/$2"
|
||||
fi
|
||||
}
|
||||
|
||||
# `master` for all languages
|
||||
deploy_doc "$GITHUB_SHA" master
|
||||
|
||||
# Rust versions
|
||||
deploy_doc "$GITHUB_SHA" latest rust
|
||||
|
||||
# Node versions
|
||||
deploy_doc "$GITHUB_SHA" latest node
|
||||
|
||||
# Python versions
|
||||
deploy_doc "$GITHUB_SHA" v0.9.0 python
|
||||
deploy_doc "$GITHUB_SHA" latest python
|
36
.github/workflows/docs-deploy.yml
vendored
Normal file
36
.github/workflows/docs-deploy.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
name: Deploy Documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
# branches:
|
||||
# - master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install SSH Key
|
||||
uses: shimataro/ssh-key-action@v2
|
||||
with:
|
||||
key: ${{ secrets.DOC_SSH_KEY }}
|
||||
name: id_rsa
|
||||
known_hosts: ${{ secrets.DOC_KNOWN_HOST }}
|
||||
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.6
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install sphinx sphinx_rtd_theme
|
||||
|
||||
- name: Deploy documentation
|
||||
env:
|
||||
HOST_NAME: ${{ secrets.DOC_HOST }}
|
||||
DOC_PATH: ${{ secrets.DOC_PATH }}
|
||||
run: ./.github/deploy_doc.sh
|
@ -2,26 +2,24 @@
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
# from the environment for those with `?=`
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
BUILDDIR ?= build
|
||||
SOURCEDIR = source
|
||||
RUSTBUILDDIR = build/rust
|
||||
PYTHONBUILDDIR = build/python
|
||||
NODEBUILDDIR = build/node
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(RUSTBUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
# Put it first so that "make" without argument is like "make html_all".
|
||||
html_all:
|
||||
@echo "Generating doc for Rust"
|
||||
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)/rust" $(SPHINXOPTS) $(O) -t rust
|
||||
@echo "Generating doc for Python"
|
||||
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)/python" $(SPHINXOPTS) $(O) -t python
|
||||
@echo "Generating doc for Node.js"
|
||||
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)/node" $(SPHINXOPTS) $(O) -t node
|
||||
|
||||
.PHONY: help Makefile
|
||||
.PHONY: html_all 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
|
||||
@echo "Generating doc for Rust"
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(RUSTBUILDDIR)" $(SPHINXOPTS) $(O) -t Rust
|
||||
@echo "Generating doc for Python"
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(PYTHONBUILDDIR)" $(SPHINXOPTS) $(O) -t Python
|
||||
@echo "Generating doc for Node.js"
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(NODEBUILDDIR)" $(SPHINXOPTS) $(O) -t Node
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
@ -114,9 +114,12 @@ function addVersionControl() {
|
||||
// If a version is specified, update it
|
||||
if (parts[versionIndex] != "" && !parts[versionIndex].endsWith(".html")) {
|
||||
version = parts[versionIndex];
|
||||
// Otherwise redirect to the latest
|
||||
} else {
|
||||
// Otherwise redirect to the latest (if not opening locally)
|
||||
} else if (!parts[parts.length - 1].endsWith(".html")) {
|
||||
return window.location.pathname = [language, version, parts.splice(versionIndex)].join("/");
|
||||
// Opening locally, just don't show the version/language selector
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
// Language Menu
|
||||
|
@ -40,7 +40,7 @@ Load an existing tokenizer:
|
||||
|
||||
Loading a previously saved tokenizer is extremely simple and requires a single line of code:
|
||||
|
||||
.. only:: Rust
|
||||
.. only:: rust
|
||||
|
||||
.. literalinclude:: ../../tokenizers/tests/documentation.rs
|
||||
:language: rust
|
||||
@ -48,7 +48,7 @@ Loading a previously saved tokenizer is extremely simple and requires a single l
|
||||
:end-before: END load_tokenizer
|
||||
:dedent: 4
|
||||
|
||||
.. only:: Python
|
||||
.. only:: python
|
||||
|
||||
.. literalinclude:: ../../bindings/python/tests/documentation/test_load.py
|
||||
:language: python
|
||||
@ -56,7 +56,7 @@ Loading a previously saved tokenizer is extremely simple and requires a single l
|
||||
:end-before: END load_tokenizer
|
||||
:dedent: 4
|
||||
|
||||
.. only:: Node
|
||||
.. only:: node
|
||||
|
||||
.. literalinclude:: ../../bindings/node/examples/load.test.js
|
||||
:language: javascript
|
||||
@ -70,7 +70,7 @@ Train a tokenizer:
|
||||
|
||||
Small guide of :ref:`how to create a Tokenizer options<tokenizer_blocks>`.
|
||||
|
||||
.. only:: Rust
|
||||
.. only:: rust
|
||||
|
||||
.. literalinclude:: ../../tokenizers/tests/documentation.rs
|
||||
:language: rust
|
||||
@ -78,7 +78,7 @@ Small guide of :ref:`how to create a Tokenizer options<tokenizer_blocks>`.
|
||||
:end-before: END train_tokenizer
|
||||
:dedent: 4
|
||||
|
||||
.. only:: Python
|
||||
.. only:: python
|
||||
|
||||
.. literalinclude:: ../../bindings/python/tests/documentation/test_train.py
|
||||
:language: python
|
||||
@ -86,7 +86,7 @@ Small guide of :ref:`how to create a Tokenizer options<tokenizer_blocks>`.
|
||||
:end-before: END train_tokenizer
|
||||
:dedent: 4
|
||||
|
||||
.. only:: Node
|
||||
.. only:: node
|
||||
|
||||
.. literalinclude:: ../../bindings/node/examples/train.test.js
|
||||
:language: javascript
|
||||
|
Reference in New Issue
Block a user