Skip to content

Commit

Permalink
📝 优化文档显示
Browse files Browse the repository at this point in the history
  • Loading branch information
snowykami committed Aug 30, 2024
1 parent fbfb2b4 commit d4fdd90
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
- name: Setup API markdown
run: |-
python -m pip install litedoc
python -m litedoc mbcp -o docs/zh/api -l zh-Hans -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/en/api -l en -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/ja/api -l ja -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/zht/api -l zh-Hant -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/zh/api -l zh-Hans -f editLink=false -cd class -fd def -md def -vd var -cs
python -m litedoc mbcp -o docs/en/api -l en -f editLink=false -cd class -fd def -md def -vd var -cs
python -m litedoc mbcp -o docs/ja/api -l ja -f editLink=false -cd class -fd def -md def -vd var -cs
python -m litedoc mbcp -o docs/zht/api -l zh-Hant -f editLink=false -cd class -fd def -md def -vd var -cs
- name: 安装 pnpm
uses: pnpm/action-setup@v2
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ litedoc/
docs/zh/api/
docs/zht/api/
docs/en/api/
docs/ja/api/
docs/ja/api/

# litedoc
mkdoc.bat
mkdoc_exp.bat
53 changes: 36 additions & 17 deletions docs/.vitepress/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,42 @@ const commonSidebarOptions = {
useFolderTitleFromIndexFile: true,
useFolderLinkFromIndexFile: true,
includeFolderIndexFile: true,
rootGroupText: 'MBCP',
}

/**
* Generate sidebar config
* multiple languages and sections
* @returns {any[]}
*/
function generateSidebarConfig(): any[] {
let sections = ["api", "refer", "guide"]
let languages = ['zh', 'en', 'ja', 'zht']
let ret = []
for (let language of languages) {
for (let section of sections) {
if (language === defaultLocale) {
ret.push({
basePath: `/${section}/`,
scanStartPath: `${language}/${section}`,
resolvePath: `/${section}/`,
...commonSidebarOptions
})
} else {
ret.push({
basePath: `/${language}/${section}/`,
scanStartPath: `${language}/${section}`,
resolvePath: `/${language}/${section}/`,
...commonSidebarOptions
})
}
}
}
return ret
}

console.log(generateSidebarConfig())

export const common = defineConfig({
title: "MBCP docs",
description: "MBCP library docs",
Expand All @@ -27,23 +62,7 @@ export const common = defineConfig({
themeConfig: {
sidebar: generateSidebar(
[
...[defaultLocale, 'en', 'ja', 'zht'].map((locale) => {
if (locale === defaultLocale) {
return {
basePath: '/api/',
scanStartPath: `${locale}/api`,
resolvePath: '/api/',
...commonSidebarOptions
}
} else {
return {
basePath: `/${locale}/api/`,
scanStartPath: `${locale}/api`,
resolvePath: `/${locale}/api/`,
...commonSidebarOptions
}
}
})
...generateSidebarConfig()
]
),
socialLinks: [
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const en = defineConfig({
themeConfig: {
nav: [
{text: 'Get Start', link: '/en/guide/'},
{text: 'Reference', link: '/en/refer'},
{text: 'API Document', link: '/en/api/'},
{text: 'Demo', link: '/en/demo/'},
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const ja = defineConfig({
themeConfig: {
nav: [
{text: 'スタート', link: '/ja/guide/'},
{text: 'リファレンス', link: '/ja/refer'},
{text: 'APIドキュメント', link: '/ja/api/'},
{text: 'インスタンス', link: '/ja/demo/'},
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const zh = defineConfig({
themeConfig: {
nav: [
{text: '快速开始', link: '/guide/'},
{text: '参考', link: '/refer'},
{text: 'API文档', link: '/api/'},
{text: '实例', link: '/demo/'},
],
Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config/zht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const zht = defineConfig({
themeConfig: {
nav: [
{text: '指引', link: '/zht/guide/'},
{text: '參考', link: '/zht/refer'},
{text: 'API文檔', link: '/zht/api/'},
{text: '示範', link: '/zht/demo/'},
],
Expand Down
3 changes: 3 additions & 0 deletions docs/en/refer/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Reference
help us to improve the documentation
```
4 changes: 4 additions & 0 deletions docs/ja/refer/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

Help us to improve the documentation
```
3 changes: 3 additions & 0 deletions docs/zh/refer/function/curry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: 柯里化
---
3 changes: 3 additions & 0 deletions docs/zh/refer/function/function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: 函数
---
8 changes: 8 additions & 0 deletions docs/zh/refer/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: 参考
---

# Reference

Help us to improve the documentation
```
4 changes: 4 additions & 0 deletions docs/zht/refer/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

Help us to improve the documentation
```
8 changes: 4 additions & 4 deletions mkdoc.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
chcp 65001
python -m litedoc mbcp -o docs/zh/api -l zh-Hans -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/en/api -l en -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/ja/api -l ja -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/zht/api -l zh-Hant -f editLink=false -cd class -fd def -md def -vd var
python -m litedoc mbcp -o docs/zh/api -l zh-Hans -f editLink=false -cd class -fd def -md def -vd var -cs
python -m litedoc mbcp -o docs/en/api -l en -f editLink=false -cd class -fd def -md def -vd var -cs
python -m litedoc mbcp -o docs/ja/api -l ja -f editLink=false -cd class -fd def -md def -vd var -cs
python -m litedoc mbcp -o docs/zht/api -l zh-Hant -f editLink=false -cd class -fd def -md def -vd var -cs

0 comments on commit d4fdd90

Please sign in to comment.