-
Notifications
You must be signed in to change notification settings - Fork 23
131 lines (118 loc) · 4.55 KB
/
docs.yml
File metadata and controls
131 lines (118 loc) · 4.55 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
121
122
123
124
125
126
127
128
129
130
131
name: Documentation → GitHub Pages
on:
push:
branches: [development, master]
paths:
- 'docs/**'
- 'backtrader/**'
- '.github/workflows/docs.yml'
pull_request:
branches: [development, master]
paths: ['docs/**']
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: false
env:
DEPLOY_URL: https://cloudquant.github.io/backtrader
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
pip install -e .
- name: Build English documentation
env:
DEPLOY_URL: ${{ env.DEPLOY_URL }}
run: |
cd docs
sphinx-build -b html source build/html/en -D language=en -j auto
- name: Build Chinese documentation
env:
DEPLOY_URL: ${{ env.DEPLOY_URL }}
BUILD_LANGUAGE: zh
run: |
cd docs
sphinx-build -b html source build/html/zh \
-D language=zh_CN \
-D root_doc=index_zh \
-D master_doc=index_zh \
-j auto
- name: Create landing page (auto-redirect to English)
run: |
cat > docs/build/html/index.html << 'LANDING'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Backtrader Documentation</title>
<meta http-equiv="refresh" content="0;url=en/index.html">
<link rel="canonical" href="https://cloudquant.github.io/backtrader/en/">
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:system-ui,-apple-system,sans-serif;min-height:100vh;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#E3F2FD,#BBDEFB,#E8EAF6);padding:20px}
.card{background:#fff;border-radius:16px;padding:48px 40px;box-shadow:0 8px 32px rgba(21,101,192,.12);text-align:center;max-width:520px;width:100%}
h1{color:#1565C0;font-size:2rem;margin-bottom:8px}
p{color:#546E7A;margin-bottom:24px}
.btns{display:flex;gap:16px;justify-content:center;margin-bottom:20px}
.btn{padding:14px 36px;border-radius:10px;font-size:1rem;font-weight:600;text-decoration:none;transition:transform .15s,box-shadow .15s}
.btn:hover{transform:translateY(-2px);box-shadow:0 4px 16px rgba(0,0,0,.15)}
.btn-en{background:#1565C0;color:#fff}
.btn-zh{background:#C71D23;color:#fff}
.links{display:flex;gap:12px;justify-content:center}
.links a{padding:8px 20px;border-radius:8px;font-size:.9rem;text-decoration:none;border:1px solid #B0BEC5;color:#37474F}
.links a:hover{background:#ECEFF1}
.redirect{color:#90A4AE;font-size:.85rem;margin-top:16px}
</style>
</head>
<body>
<div class="card">
<h1>Backtrader</h1>
<p>Select language / 选择语言</p>
<div class="btns">
<a class="btn btn-en" href="en/index.html">English</a>
<a class="btn btn-zh" href="zh/index_zh.html">中文</a>
</div>
<div class="links">
<a href="https://github.com/cloudQuant/backtrader" target="_blank">GitHub</a>
<a href="https://gitee.com/yunjinqi/backtrader" target="_blank">Gitee</a>
</div>
<p class="redirect">Redirecting to English documentation…</p>
</div>
</body>
</html>
LANDING
- name: Add .nojekyll
run: touch docs/build/html/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './docs/build/html'
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master')
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4