diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index f5b227bd..0fe40440 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 8f85ba80..b1db1cd8 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile b/Makefile index e409e784..7b5fc6e3 100644 --- a/Makefile +++ b/Makefile @@ -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 \ No newline at end of file + rm -rf static/19-swagger.json + rm -rf static/20-swagger.json diff --git a/docusaurus.config.js b/docusaurus.config.js index 1d051dde..62941c4a 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -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 diff --git a/i18n/en-us/docusaurus-plugin-content-docs/version-1.20.json b/i18n/en-us/docusaurus-plugin-content-docs/version-1.20.json new file mode 100644 index 00000000..46868db6 --- /dev/null +++ b/i18n/en-us/docusaurus-plugin-content-docs/version-1.20.json @@ -0,0 +1,8 @@ +{ + "sidebar.docs.category.actions": { + "message": "Actions" + }, + "sidebar.docs.category.packages": { + "message": "Packages" + } +} diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.20.json b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.20.json new file mode 100644 index 00000000..a3739122 --- /dev/null +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/version-1.20.json @@ -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是什么?" + } +} diff --git a/loop_docs-19-zh-cn.sh b/loop_docs-19-zh-cn.sh deleted file mode 100644 index 2b8ff434..00000000 --- a/loop_docs-19-zh-cn.sh +++ /dev/null @@ -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/\\//' i18n/zh-cn/docusaurus-plugin-content-docs/version-1.19/installation/with-docker.zh-cn.md -$SED_INPLACE 's/\\//' 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 diff --git a/loop_docs-19.sh b/loop_docs-19.sh deleted file mode 100644 index a7c94cb9..00000000 --- a/loop_docs-19.sh +++ /dev/null @@ -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/\\//' 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//dev/null | grep -q GNU; then - SED_INPLACE="sed -i" -else - SED_INPLACE="sed -i ''" -fi - -$SED_INPLACE 's/\\//' i18n/zh-cn/docusaurus-plugin-content-docs/current/installation/with-docker.zh-cn.md -$SED_INPLACE 's/\\//' 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 diff --git a/loop_docs.sh b/loop_docs.sh old mode 100644 new mode 100755 index 83fd4fad..56e7a64b --- a/loop_docs.sh +++ b/loop_docs.sh @@ -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/\\//' 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/\\//' "$docs_dir/installation/with-docker.$locale.md" +fi +$SED_INPLACE 's/\\//' "$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 diff --git a/versioned_sidebars/version-1.20-sidebars.json b/versioned_sidebars/version-1.20-sidebars.json new file mode 100644 index 00000000..d56dfea5 --- /dev/null +++ b/versioned_sidebars/version-1.20-sidebars.json @@ -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" + } + ] + } + ] +} \ No newline at end of file diff --git a/versions.json b/versions.json index 084c8dd1..ced0695d 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,4 @@ [ + "1.20", "1.19" ]