Add v1.20 documentation (#28)

Modified `loop_docs.sh` to take `version` and `locale` and params so do not need other `loop_docs*` scripts.

Need confirmation with version information for 1.20 and latest.
Like version in `static/20-swagger.json` and `static/latest-swagger.json`, and version used to replace `{{< version >}}`

Will wait for a stable version for 1.20

![Screen Shot 2023-06-14 at 12.12.18](/attachments/1b316978-0daf-46bb-90a7-632a0fc80898)

Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/28
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: HesterG <hestergong@gmail.com>
Co-committed-by: HesterG <hestergong@gmail.com>
This commit is contained in:
HesterG
2023-06-14 07:05:13 +00:00
committed by Lunny Xiao
parent 9bc53d050e
commit 7ca358b43e
12 changed files with 212 additions and 214 deletions

View File

@@ -19,6 +19,10 @@ jobs:
run: |
make prepare-latest
make prepare-latest-zh-cn
- name: prepare 1.20 docs
run: |
make prepare\#20
make prepare-zh-cn\#20
- name: prepare 1.19 docs
run: |
make prepare\#19

2
.gitignore vendored
View File

@@ -26,5 +26,7 @@ static/_headers
static/_redirects
static/latest-swagger.json
static/19-swagger.json
static/20-swagger.json
i18n/zh-cn/docusaurus-plugin-content-docs/current
i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19
i18n/zh-cn/docusaurus-plugin-content-docs/version-1.20

View File

@@ -25,7 +25,7 @@ prepare-latest: clone_main
rsync -avz --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/doc/ docs/
cp .tmp/upstream-docs-latest/docs/content/page/index.en-us.md docs/intro.md
cp .tmp/upstream-docs-latest/templates/swagger/v1_json.tmpl static/latest-swagger.json
bash loop_docs.sh
bash loop_docs.sh lastest en-us
.PHONY: prepare-latest-zh-cn
prepare-latest-zh-cn:
@@ -34,7 +34,7 @@ prepare-latest-zh-cn:
mkdir -p i18n/zh-cn/docusaurus-plugin-content-docs/current
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/doc/ i18n/zh-cn/docusaurus-plugin-content-docs/current/
cp .tmp/upstream-docs-latest/docs/content/page/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
bash loop_docs-zh-cn.sh
bash loop_docs.sh lastest zh-cn
.PHONY: clone_\#%
clone_\#%: create_dir
@@ -50,8 +50,7 @@ prepare\#%: clone_\#%
rsync -a --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/doc/ versioned_docs/version-1.$*/
cp .tmp/upstream-docs-$*/docs/content/page/index.en-us.md versioned_docs/version-1.$*/intro.md
cp .tmp/upstream-docs-$*/templates/swagger/v1_json.tmpl static/$*-swagger.json
bash loop_docs-$*.sh
rm versioned_docs/version-1.$*/help/search.md || true
bash loop_docs.sh $* en-us
.PHONY: prepare-zh-cn\#%
prepare-zh-cn\#%:
@@ -59,9 +58,8 @@ prepare-zh-cn\#%:
# cp -r .tmp/upstream-docs-$*/docs/static/* static/
mkdir -p i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/doc/ i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/
cp .tmp/upstream-docs-19/docs/content/page/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/intro.md
bash loop_docs-$*-zh-cn.sh
rm i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/help/search.md || true
cp .tmp/upstream-docs-$*/docs/content/page/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/intro.md
bash loop_docs.sh $* zh-cn
.PHONY: install
install:
@@ -83,4 +81,5 @@ clean:
rm -rf versioned_docs/
rm -rf static/_*
rm -rf static/latest-swagger.json
rm -rf static/19-swagger.json
rm -rf static/19-swagger.json
rm -rf static/20-swagger.json

View File

@@ -55,12 +55,18 @@ const config = {
},
versions: {
current: {
label: '1.20-dev', // path is kept as next for dev (so users can always find "nightly" docs)
label: 'next', // path is kept as next for dev (so users can always find "nightly" docs)
banner: 'unreleased',
},
1.19 : {
label: '1.19.3'
'1.20': {
label: '1.20.0-rc0',
banner: 'none',
},
'1.19': {
label: '1.19.3',
}
},
lastVersion: '1.19',
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
const {item} = args;
// Use the provided data to generate a custom sidebar slice

View File

@@ -0,0 +1,8 @@
{
"sidebar.docs.category.actions": {
"message": "Actions"
},
"sidebar.docs.category.packages": {
"message": "Packages"
}
}

View File

@@ -0,0 +1,29 @@
{
"sidebar.docs.category.Installation": {
"message": "安装"
},
"sidebar.docs.category.Administration": {
"message": "管理"
},
"sidebar.docs.category.Usage": {
"message": "使用"
},
"sidebar.docs.category.actions": {
"message": "Actions"
},
"sidebar.docs.category.packages": {
"message": "软件包"
},
"sidebar.docs.category.Development": {
"message": "开发"
},
"sidebar.docs.category.Contributing": {
"message": "贡献"
},
"sidebar.docs.category.Help": {
"message": "帮助"
},
"sidebar.docs.doc.What is Gitea?": {
"message": "Gitea是什么?"
}
}

View File

@@ -1,66 +0,0 @@
#!/bin/bash
set -xe
if sed --version 2>/dev/null | grep -q GNU; then
SED_INPLACE="sed -i"
else
SED_INPLACE="sed -i ''"
fi
$SED_INPLACE 's/\\<empty>/<empty\\>/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/installation/with-docker.zh-cn.md
$SED_INPLACE 's/\\<empty\\>/<empty\\>/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/administration/config-cheat-sheet.zh-cn.md
$SED_INPLACE 's/^url:.*//' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/intro.md
$SED_INPLACE 's/^slug:.*/slug: \//' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< min-go-version >}}/1.19/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< go-version >}}/1.20/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/installation/from-source.zh-cn.md
$SED_INPLACE 's/{{< min-go-version >}}/1.19/' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/installation/from-source.zh-cn.md
$SED_INPLACE 's/"version":.*/"version":"1.19.0"/' static/19-swagger.json
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19 -name "*.md"`; do
# note only works on linux, forget about it when attempting to run on macos
# hide hugo toc
$SED_INPLACE 's/{{< toc >}}//' $file
$SED_INPLACE 's/{{< version >}}/1.19.0/g' $file
$SED_INPLACE 's/{{< relref "doc\///g' $file
$SED_INPLACE 's/.zh-cn.md/.md/g' $file
$SED_INPLACE 's/" >}}//g' $file
$SED_INPLACE 's/\*\*Table of Contents\*\*//' $file
$SED_INPLACE 's/weight:/sidebar_position:/g' $file
done
for file in i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/*; do
if [ -d $file ]; then
continue
fi
if [ "$file" == "i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/intro.md" ]; then
continue
fi
rm $file
done
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19 -name "*.zh-cn.md"`; do
mv "${file}" "${file/.zh-cn/}"
done
# for file in `find ./version ed_docs/version-1.19/zh-cn/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done
# for file in `find ./i18n/zh-tw/docusaurus-plugin-content-docs/version-1.19/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done
# for file in `find ./i18n/fr-fr/docusaurus-plugin-content-docs/version-1.19/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done
# for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done

View File

@@ -1,51 +0,0 @@
#!/bin/bash
set -xe
if sed --version 2>/dev/null | grep -q GNU; then
SED_INPLACE="sed -i"
else
SED_INPLACE="sed -i ''"
fi
$SED_INPLACE 's/\\<empty/<empty/' versioned_docs/version-1.19/administration/config-cheat-sheet.en-us.md
$SED_INPLACE 's/<empty>/<empty\\>/' versioned_docs/version-1.19/administration/config-cheat-sheet.en-us.md
$SED_INPLACE 's/^url:.*//' versioned_docs/version-1.19/intro.md
$SED_INPLACE 's/^slug:.*/slug: \//' versioned_docs/version-1.19/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' versioned_docs/version-1.19/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' versioned_docs/version-1.19/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< min-go-version >}}/1.19/' versioned_docs/version-1.19/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< go-version >}}/1.20/' versioned_docs/version-1.19/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' versioned_docs/version-1.19/installation/from-source.en-us.md
$SED_INPLACE 's/{{< min-go-version >}}/1.19/' versioned_docs/version-1.19/installation/from-source.en-us.md
$SED_INPLACE 's/"version":.*/"version":"1.19.3"/' static/19-swagger.json
for file in `find ./versioned_docs/version-1.19 -name "*.md"`; do
# hide hugo toc
$SED_INPLACE 's/{{< toc >}}//' $file
$SED_INPLACE 's/{{< version >}}/1.19.3/g' $file
$SED_INPLACE 's/{{< relref "doc\///g' $file
$SED_INPLACE 's/.en-us.md/.md/g' $file
$SED_INPLACE 's/" >}}//g' $file
$SED_INPLACE 's/\*\*Table of Contents\*\*//' $file
$SED_INPLACE 's/weight:/sidebar_position:/g' $file
#sed -i 's/^slug:.*//' $file
done
$SED_INPLACE 's/</&#8288;/' versioned_docs/version-1.19/contributing/guidelines-backend.en-us.md
for file in versioned_docs/version-1.19/*; do
if [ -d $file ]; then
continue
fi
if [ "$file" == "versioned_docs/version-1.19/intro.md" ]; then
continue
fi
rm $file
done
# file names under ./versioned_docs/version-1.19 and i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/ should be the same for docusaurus
# to recognize them as tanslated.
for file in `find ./versioned_docs/version-1.19 -name "*.en-us.md"`; do
mv "${file}" "${file/.en-us/}"
done

View File

@@ -1,68 +0,0 @@
#!/bin/bash
set -xe
if sed --version 2>/dev/null | grep -q GNU; then
SED_INPLACE="sed -i"
else
SED_INPLACE="sed -i ''"
fi
$SED_INPLACE 's/\\<empty>/<empty\\>/' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/with-docker.zh-cn.md
$SED_INPLACE 's/\\<empty\\>/<empty\\>/' i18n/zh-cn/docusaurus-plugin-content-docs/current/administration/config-cheat-sheet.zh-cn.md
$SED_INPLACE 's/^url:.*//' i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
$SED_INPLACE 's/^slug:.*/slug: \//' i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' i18n/zh-cn/docusaurus-plugin-content-docs/current/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' i18n/zh-cn/docusaurus-plugin-content-docs/current/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< min-go-version >}}/1.20/' i18n/zh-cn/docusaurus-plugin-content-docs/current/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< go-version >}}/1.20/' i18n/zh-cn/docusaurus-plugin-content-docs/current/development/hacking-on-gitea.zh-cn.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/from-source.zh-cn.md
$SED_INPLACE 's/{{< min-go-version >}}/1.20/' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/from-source.zh-cn.md
$SED_INPLACE 's/"version":.*/"version":"1.20-dev"/' static/latest-swagger.json
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/current -name "*.md"`; do
# note only works on linux, forget about it when attempting to run on macos
# hide hugo toc
$SED_INPLACE 's/{{< toc >}}//' $file
$SED_INPLACE 's/dl.gitea.com\/gitea\/{{< version >}}/dl.gitea.com\/gitea\/main/g' $file
$SED_INPLACE 's/{{< version >}}/main-nightly/g' $file
$SED_INPLACE 's/{{< relref "doc\///g' $file
$SED_INPLACE 's/.zh-cn.md/.md/g' $file
$SED_INPLACE 's/" >}}//g' $file
$SED_INPLACE 's/\*\*Table of Contents\*\*//' $file
$SED_INPLACE 's/weight:/sidebar_position:/g' $file
done
for file in i18n/zh-cn/docusaurus-plugin-content-docs/current/*; do
if [ -d $file ]; then
continue
fi
if [ "$file" == "i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md" ]; then
continue
fi
rm $file
done
for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/current -name "*.zh-cn.md"`; do
mv "${file}" "${file/.zh-cn/}"
done
# for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/current/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done
# for file in `find ./i18n/zh-tw/docusaurus-plugin-content-docs/zh-cn/current/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done
# for file in `find ./i18n/fr-fr/docusaurus-plugin-content-docs/zh-cn/current/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done
# for file in `find ./i18n/zh-cn/docusaurus-plugin-content-docs/zh-cn/current/ -name "*.md"`; do
# trimmed=$(echo $file | cut -f 2 -d '.')
# mv $file .$trimmed.md
# done

83
loop_docs.sh Normal file → Executable file
View File

@@ -1,5 +1,9 @@
#!/bin/bash
# The script takes two params:
# version: "latest" or a specific version number
# locale
set -xe
if sed --version 2>/dev/null | grep -q GNU; then
@@ -8,37 +12,76 @@ else
SED_INPLACE="sed -i ''"
fi
$SED_INPLACE 's/\\<empty/<empty/' docs/administration/config-cheat-sheet.en-us.md
$SED_INPLACE 's/<empty>/<empty\\>/' docs/administration/config-cheat-sheet.en-us.md
$SED_INPLACE 's/^url:.*//' docs/intro.md
$SED_INPLACE 's/^slug:.*/slug: \//' docs/intro.md
$SED_INPLACE 's/.\/guidelines-frontend.md/.\/guidelines-frontend/' docs/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' docs/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< min-go-version >}}/1.20/' docs/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< go-version >}}/1.20/' docs/development/hacking-on-gitea.en-us.md
$SED_INPLACE 's/{{< min-node-version >}}/16/' docs/installation/from-source.en-us.md
$SED_INPLACE 's/{{< min-go-version >}}/1.20/' docs/installation/from-source.en-us.md
version="$1"
if [ "$version" != "lastest" ]; then
version="1.$1"
fi
locale="$2"
minNodeVer="16"
minGoVer="1.20"
goVer="1.20"
minorVer="main-nightly"
if ["$version" == "1.19"]; then
minorVer="1.19.3"
minGoVer="1.19"
elif ["$version" == "1.20"]; then
minorVer="1.20.0-rc0"
fi
$SED_INPLACE 's/"version":.*/"version":"1.20-dev"/' static/latest-swagger.json
docs_dir="versioned_docs/version-$version"
if [ "$version" == "lastest" ]; then
if [ "$locale" == "en-us" ]; then
docs_dir="docs"
else
docs_dir="i18n/$locale/docusaurus-plugin-content-docs/current"
fi
else
if [ "$locale" != "en-us" ]; then
docs_dir="i18n/$locale/docusaurus-plugin-content-docs/version-$version"
fi
fi
for file in `find ./docs -name "*.md"`; do
if [ -f "$docs_dir/installation/with-docker.$locale.md" ]; then
$SED_INPLACE 's/\\<empty>/<empty\\>/' "$docs_dir/installation/with-docker.$locale.md"
fi
$SED_INPLACE 's/\\<empty/<empty/' "$docs_dir/administration/config-cheat-sheet.$locale.md"
$SED_INPLACE 's/<empty>/<empty\\>/' "$docs_dir/administration/config-cheat-sheet.$locale.md"
$SED_INPLACE 's/^url:.*//' "$docs_dir/intro.md"
$SED_INPLACE 's/^slug:.*/slug: \//' "$docs_dir/intro.md"
$SED_INPLACE "s/{{< min-node-version >}}/$minNodeVer/" "$docs_dir/development/hacking-on-gitea.$locale.md"
$SED_INPLACE "s/{{< min-go-version >}}/$minGoVer/" "$docs_dir/development/hacking-on-gitea.$locale.md"
$SED_INPLACE "s/{{< go-version >}}/$goVer/" "$docs_dir/development/hacking-on-gitea.$locale.md"
$SED_INPLACE "s/{{< min-node-version >}}/$minNodeVer/" "$docs_dir/installation/from-source.$locale.md"
$SED_INPLACE "s/{{< min-go-version >}}/$minGoVer/" "$docs_dir/installation/from-source.$locale.md"
# TODO: improve this sed
# need confirmation
if [ "$version" == "lastest" ]; then
$SED_INPLACE 's/"version":.*/"version":"1.21-dev"/' static/latest-swagger.json
elif [ "$version" == "1.20" ]; then
$SED_INPLACE 's/"version":.*/"version":"1.20.0-rc0"/' static/20-swagger.json
elif [ "$version" == "1.19" ]; then
$SED_INPLACE 's/"version":.*/"version":"1.19.3"/' static/19-swagger.json
fi
for file in `find ./"$docs_dir" -name "*.md"`; do
# hide hugo toc
$SED_INPLACE 's/{{< toc >}}//' $file
$SED_INPLACE 's/dl.gitea.com\/gitea\/{{< version >}}/dl.gitea.com\/gitea\/main/g' $file
$SED_INPLACE 's/{{< version >}}/main-nightly/g' $file
$SED_INPLACE "s/{{< version >}}/$minorVer/g" $file
$SED_INPLACE 's/{{< relref "doc\///g' $file
$SED_INPLACE 's/.en-us.md/.md/g' $file
$SED_INPLACE "s/.$locale.md/.md/g" $file
$SED_INPLACE 's/" >}}//g' $file
$SED_INPLACE 's/\*\*Table of Contents\*\*//' $file
$SED_INPLACE 's/weight:/sidebar_position:/g' $file
#sed -i 's/^slug:.*//' $file
done
for file in docs/*; do
for file in "$docs_dir"/*; do
if [ -d $file ]; then
continue
fi
if [ "$file" == "docs/intro.md" ]; then
if [ "$file" == "$docs_dir/intro.md" ]; then
continue
fi
rm $file || true
@@ -46,6 +89,10 @@ done
# file names under docs/ and i18n/zh-cn/docusaurus-plugin-content-docs/current/ should be the same for docusaurus
# to recognize them as tanslated.
for file in `find ./docs -name "*.en-us.md"`; do
mv "${file}" "${file/.en-us/}"
for file in `find "$docs_dir" -name "*.$locale.md"`; do
mv "${file}" "${file/.$locale/}"
done
if [ -f "$docs_dir/help/search.md" ]; then
rm "$docs_dir/help/search.md"
fi

View File

@@ -0,0 +1,87 @@
{
"docs": [
{
"type": "doc",
"id": "intro",
"label": "What is Gitea?"
},
{
"type": "category",
"label": "Installation",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
"dirName": "installation"
}
]
},
{
"type": "category",
"label": "Administration",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
"dirName": "administration"
}
]
},
{
"type": "category",
"label": "Usage",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
"dirName": "usage"
}
]
},
{
"type": "category",
"label": "Development",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
"dirName": "development"
}
]
},
{
"type": "category",
"label": "Contributing",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
"dirName": "contributing"
}
]
},
{
"type": "category",
"label": "Help",
"link": {
"type": "generated-index"
},
"items": [
{
"type": "autogenerated",
"dirName": "help"
}
]
}
]
}

View File

@@ -1,3 +1,4 @@
[
"1.20",
"1.19"
]