Repository navigation
120 lines (110 loc) · 3.67 KB
/
Copy pathdocs.yml
File metadata and controls
120 lines (110 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Deploy Documentation to GitHub Pages
on:
push:
branches: ["master", "main"]
paths:
- "README.md"
- "doc/**"
- "python/**/*.md"
- "benchmark/**/*.md"
- "lite/**/*.md"
- "mkdocs.yml"
- ".github/workflows/docs.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.11"
- name: Install MkDocs Material & Awesome Pages Plugin
run: pip install mkdocs-material mkdocs-awesome-pages-plugin
- name: Prepare _docs_build directory (preserving all relative links, order & MathJax config)
run: |
mkdir -p _docs_build/doc _docs_build/python _docs_build/benchmark _docs_build/lite _docs_build/contrib/docker _docs_build/javascripts
cp README.md _docs_build/index.md
sed -i \
-e 's|(CONTRIBUTING.md)|(https://github.com/google/sentencepiece/blob/master/CONTRIBUTING.md)|g' \
-e 's|(LICENSE)|(https://github.com/google/sentencepiece/blob/master/LICENSE)|g' \
-e 's|(python/)|(python/README.md)|g' \
_docs_build/index.md
cp doc/*.md _docs_build/doc/
cp python/*.md _docs_build/python/
cp benchmark/*.md _docs_build/benchmark/ 2>/dev/null || true
cp lite/*.md _docs_build/lite/ 2>/dev/null || true
cp contrib/docker/*.md _docs_build/contrib/docker/ 2>/dev/null || true
cat << 'EOF' > _docs_build/.pages
nav:
- Overview: index.md
- Python Module: python
- SentencePiece Lite: lite
- Guides & References: doc
- Benchmark Suite: benchmark
- ...
EOF
cat << 'EOF' > _docs_build/doc/.pages
nav:
- cli.md
- cpp.md
- options.md
- auto_character_coverage.md
- sparse_l1_unigram.md
- piece_constraints.md
- normalization.md
- special_symbols.md
- model_proto.md
- cmake.md
- bazel.md
- performance_benchmark.md
- ...
EOF
cat << 'EOF' > _docs_build/javascripts/mathjax.js
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
document$.subscribe(() => {
MathJax.startup.output.clearCache();
MathJax.typesetClear();
MathJax.texReset();
MathJax.typesetPromise();
});
EOF
- name: Build MkDocs site
run: mkdocs build
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: ./site
deploy:
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1