Skip to content

Commit dc245d4

Browse files
committed
initial refactoring commit
0 parents  commit dc245d4

File tree

669 files changed

+37953
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

669 files changed

+37953
-0
lines changed

.github/workflows/build.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: build
2+
on:
3+
push:
4+
branches: [ main, develop, gh-build, fresh ]
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
# runs on weblate commit
11+
weblate-commit-build:
12+
if: ${{ contains(github.event.head_commit.message, 'Translated using Weblate') }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: TODO - start full build (delayed)
16+
run: echo "TODO - start delayed full build, maybe 15mins?"
17+
18+
# on regular commit (auto excludes self-commited pot/po files)
19+
full-build:
20+
if: ${{ ! contains(github.event.head_commit.message, 'Translated using Weblate') }}
21+
concurrency:
22+
group: ${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
runs-on: ubuntu-latest
26+
container:
27+
image: sphinxdoc/sphinx
28+
#options: --user 1001 (only if we don't need apt-get)
29+
30+
env:
31+
MAIN_LANGS: en
32+
OTHER_LANGS: de es fr ru nl it ja el bg da et fi lv lt pl pt ro sv sk sl cs hu zh_CN
33+
34+
steps:
35+
- name: Install git
36+
run: |
37+
apt-get -y update
38+
apt-get -y install git ssh curl
39+
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: additional python packages
44+
run: pip3 install -r requirements.txt
45+
46+
- name: quick build docs
47+
run: |
48+
mkdir -p dist/en
49+
mkdir -p build/en/doctrees
50+
sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en
51+
rm -rf dist/en/_sources
52+
53+
- name: upload quick build artifact
54+
id: upload-quick
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: generated documentation (en)
58+
path: dist
59+
60+
- name: trigger docs server to download artifact
61+
uses: appleboy/[email protected]
62+
with:
63+
host: ${{ secrets.DOCS_HOST }}
64+
username: docs
65+
port: ${{ secrets.DOCS_PORT }}
66+
key: ${{ secrets.DEPLOY_AUTH_KEY }}
67+
script: /var/www/docs/deploy/github-trigger.sh en ${{ steps.upload-quick.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }}
68+
69+
- name: checkout data repository
70+
uses: actions/checkout@v4
71+
with:
72+
repository: nitrokey/nitrokey-documentation-data
73+
ref: main
74+
ssh-key: ${{ secrets.DEPLOY_AUTH_KEY }}
75+
path: data.git
76+
77+
- name: build pot files
78+
run: sphinx-build -b gettext source data.git/locales/
79+
80+
- name: build po files from pot files
81+
shell: bash
82+
run: |
83+
lang=($OTHER_LANGS)
84+
sphinx-intl update -p data.git/locales/ ${lang[@]/*/'-l '&' '}
85+
rm -rf data.git/locales/.doctrees
86+
87+
# this one looks like a upstream bug for the auto-translation
88+
# we will replace all backslashes '\\' with '/bs/' and revert
89+
# this operation before actually building the language
90+
# let's hope this works
91+
- name: WORKAROUND - replace double backslashes in .po files
92+
shell: bash
93+
run: |
94+
sed -ie 's@\\\\@/bs/@g' $(find data.git/locales -name "*.po" | xargs)
95+
96+
# - name: prepare commit data repository
97+
# run: |
98+
# cp -r locales locales.full
99+
# rm -rf locales/.doctrees
100+
101+
- name: commit `locales` into data repository (on changes)
102+
shell: bash
103+
run: |
104+
#rm -rf data.git/locales
105+
cd data.git
106+
# not needed if run on --user 1001
107+
git config --global --add safe.directory $(pwd)
108+
git config --global user.name "GitHub Action"
109+
git config --global user.email "[email protected]"
110+
#if (git commit -m "Automated locales generation" locales); then
111+
# git push
112+
#fi
113+
git status
114+
115+
# - name: put original `locales` back
116+
# run: |
117+
# rm -rf locales
118+
# cp -r locales.full locales
119+
120+
# - name: TODO - weblate
121+
# shell: bash
122+
# run: |
123+
# # have some time for commit/push before to propagate
124+
# sleep 30
125+
# bash trigger_weblate.sh ${{ secrets.WEBLATE_API_URL }} none ${{ secrets.WEBLATE_TOKEN }} pull
126+
127+
# for lang in $OTHER_LANGS
128+
# do
129+
# bash trigger_weblate.sh ${{ secrets.WEBLATE_API_URL }} $lang ${{ secrets.WEBLATE_TOKEN }} translate
130+
# done
131+
132+
# bash trigger_weblate.sh ${{ secrets.WEBLATE_API_URL }} none ${{ secrets.WEBLATE_TOKEN }} push
133+
134+
# - name: WORKAROUND - revert replace double backslashes in .po files
135+
# shell: bash
136+
# run: |
137+
# sed -ie 's@/bs/@\\\\@g' $(find locales -name "*.po" | xargs)
138+
139+
# - name: build full docs
140+
# run: |
141+
# # one _images is enough
142+
# mv dist/en/_images dist
143+
144+
# cp -r locales source/locales
145+
# for lang in $MAIN_LANGS $OTHER_LANGS
146+
# do
147+
# mkdir -p dist/$lang
148+
# mkdir -p build/$lang/doctrees
149+
# sphinx-build -j auto -b html -D language=$lang -d build/$lang/doctrees source dist/$lang
150+
# rm -rf dist/$lang/_sources dist/$lang/_images
151+
# done
152+
153+
# - name: upload full build artifact
154+
# id: upload-full
155+
# uses: actions/upload-artifact@v4
156+
# with:
157+
# name: generated documentation (all)
158+
# path: dist
159+
160+
# - name: trigger docs server to download (FULL) artifact
161+
# uses: appleboy/[email protected]
162+
# with:
163+
# host: ${{ secrets.DOCS_HOST }}
164+
# username: docs
165+
# port: ${{ secrets.DOCS_PORT }}
166+
# key: ${{ secrets.DEPLOY_AUTH_KEY }}
167+
# script: /var/www/docs/deploy/github-trigger.sh all ${{ steps.upload-full.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }}
168+
169+
170+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
dist
3+
venv

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
4+
all: venv
5+
venv/bin/sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en
6+
7+
8+
venv:
9+
python -m venv venv
10+
venv/bin/pip3 install -r requirements.txt
11+

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Nitrokey Documentation
2+
3+
4+
5+
### Local build
6+
7+
Be sure to have a recent python installed, then:
8+
9+
```
10+
make
11+
```
12+
13+
The (english) result is to be found in `dist/en`, to show run:
14+
```
15+
firefox dist/en/index.html
16+
```

requirements.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
alabaster==0.7.13
2+
Babel==2.12.1
3+
beautifulsoup4==4.12.2
4+
certifi==2023.5.7
5+
charset-normalizer==3.1.0
6+
docutils==0.18.1
7+
furo==2023.3.27
8+
idna==3.4
9+
imagesize==1.4.1
10+
Jinja2==3.1.2
11+
MarkupSafe==2.1.2
12+
packaging==23.1
13+
Pygments==2.15.1
14+
requests==2.30.0
15+
rstcheck==6.2.0
16+
snowballstemmer==2.2.0
17+
soupsieve==2.4.1
18+
Sphinx==6.2.1
19+
sphinx-basic-ng==1.0.0b1
20+
sphinx-copybutton==0.5.2
21+
sphinx-intl==2.3.0
22+
sphinx-tabs==3.4.1
23+
sphinxcontrib-applehelp==1.0.4
24+
sphinxcontrib-devhelp==1.0.2
25+
sphinxcontrib-htmlhelp==2.0.1
26+
sphinxcontrib-jsmath==1.0.1
27+
sphinxcontrib-qthelp==1.0.3
28+
sphinxcontrib-serializinghtml==1.1.5
29+
sphinxprettysearchresults==0.3.5
30+
urllib3==2.0.2
31+
setuptools==70.3.0

0 commit comments

Comments
 (0)