📝 优化文档显示

This commit is contained in:
远野千束 2024-08-31 06:06:32 +08:00
parent e0b4610161
commit 2c0be2c6f0
15 changed files with 155 additions and 47 deletions

View File

@ -40,10 +40,10 @@ jobs:
- name: Setup API markdown - name: Setup API markdown
run: |- run: |-
python -m pip install litedoc 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 -cs 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 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 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 litedoc mbcp -o docs/zht/api -l zh-Hant -f editLink=false -cd class -fd def -md def -vd var -cs
- name: 安装 pnpm - name: 安装 pnpm
uses: pnpm/action-setup@v2 uses: pnpm/action-setup@v2

View File

@ -51,8 +51,11 @@ function generateSidebarConfig(): any[] {
console.log(generateSidebarConfig()) console.log(generateSidebarConfig())
export const common = defineConfig({ export const common = defineConfig({
title: "MBCP docs", head: [
description: "MBCP library docs", [
'link', {rel: 'icon', type: 'image/svg+xml', href: '/mbcp-logo.svg'}
]
],
markdown: { markdown: {
math: true math: true
}, },
@ -60,6 +63,7 @@ export const common = defineConfig({
[`${defaultLocale}/:rest*`]: ":rest*", [`${defaultLocale}/:rest*`]: ":rest*",
}, },
themeConfig: { themeConfig: {
logo: '/mbcp-logo.svg',
sidebar: generateSidebar( sidebar: generateSidebar(
[ [
...generateSidebarConfig() ...generateSidebarConfig()
@ -68,9 +72,6 @@ export const common = defineConfig({
socialLinks: [ socialLinks: [
{icon: 'github', link: 'https://github.com/snowykami/mbcp'} {icon: 'github', link: 'https://github.com/snowykami/mbcp'}
], ],
editLink: {
pattern: 'https://github.com/snowykami/mbcp/tree/main/docs/:path'
},
outline: [2, 6] outline: [2, 6]
}, },
sitemap: { sitemap: {

View File

@ -1,15 +1,24 @@
import {defineConfig} from 'vitepress' import {defineConfig} from 'vitepress'
import {ThemeConfig} from "./utils";
export const en = defineConfig({ export const en = defineConfig({
lang: "en-US", lang: "en-US",
description: "A library made for Minecraft particle generation", title: "MBCP docs",
description: "MBCP library docs",
themeConfig: { themeConfig: {
nav: [ nav: [
{text: 'Get Start', link: '/en/guide/'}, {text: 'Get Start', link: '/en/guide/'},
{text: 'Reference', link: '/en/refer'}, {text: 'Reference', link: '/en/refer'},
{text: 'API Document', link: '/en/api/'}, {text: 'API Reference', link: '/en/api/'},
{text: 'Demo', link: '/en/demo/'}, {text: 'Demo', link: '/en/demo/'},
], ],
docFooter: {
prev: 'Prev Page',
next: 'Next Page'
},
editLink: ThemeConfig.getEditLink(
'Edit this page on GitHub',
),
footer: { footer: {
message: 'Documentation built with <a href="https://vitepress.dev/">VitePress</a> | API references generated by <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a>', message: 'Documentation built with <a href="https://vitepress.dev/">VitePress</a> | API references generated by <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a>',
copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved' copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved'

View File

@ -1,15 +1,24 @@
import {defineConfig} from 'vitepress' import {defineConfig} from 'vitepress'
import {ThemeConfig} from "./utils";
export const ja = defineConfig({ export const ja = defineConfig({
lang: "ja-JP", lang: "ja-JP",
description: "Minecraftのパーティクル生成用のライブラリ", title: "MBCP ドキュメント",
description: "MBCP ライブラリ ドキュメント",
themeConfig: { themeConfig: {
nav: [ nav: [
{text: 'スタート', link: '/ja/guide/'}, {text: 'スタート', link: '/ja/guide/'},
{text: 'リファレンス', link: '/ja/refer'}, {text: 'リファレンス', link: '/ja/refer'},
{text: 'APIドキュメント', link: '/ja/api/'}, {text: 'APIリファレンス', link: '/ja/api/'},
{text: 'インスタンス', link: '/ja/demo/'}, {text: 'インスタンス', link: '/ja/demo/'},
], ],
docFooter: {
prev: '前のページ',
next: '次のページ'
},
editLink: ThemeConfig.getEditLink(
'このページをGitHubで編集する',
),
footer: { footer: {
message: '<a href="https://vitepress.dev/">VitePress</a> で構築されたドキュメント | <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> によって生成されたAPIリファレンス', message: '<a href="https://vitepress.dev/">VitePress</a> で構築されたドキュメント | <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> によって生成されたAPIリファレンス',
copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved' copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved'

View File

@ -0,0 +1,23 @@
/**
* GetEditLink Options
* @param text Edit link text
*/
export const ThemeConfig = {
getEditLink: (editPageText: string): { pattern: (params: { filePath: string; }) => string; text: string; } => {
return {
pattern: ({filePath}: { filePath: string; }): string => {
const regex = /^[^\/]+\/api/;
if (regex.test(filePath)) {
// remove {lang}/api prefix
filePath = filePath.replace(regex, '')
.replace('index.md', '__init__.py')
.replace('.md', '.py');
return `https://github.com/snowykami/mbcp/tree/main/mbcp/${filePath}`;
} else {
return `https://github.com/snowykami/mbcp/tree/main/docs/${filePath}`;
}
},
text: editPageText
};
}
}

View File

@ -1,15 +1,24 @@
import {defineConfig} from 'vitepress' import {defineConfig} from 'vitepress'
import {ThemeConfig} from "./utils";
export const zh = defineConfig({ export const zh = defineConfig({
lang: "zh-Hans", lang: "zh-Hans",
description: "一个用于Minecraft粒子计算和生成的库", title: "MBCP 文档",
description: "MBCP 粒子计算和生成库文档",
themeConfig: { themeConfig: {
nav: [ nav: [
{text: '快速开始', link: '/guide/'}, {text: '快速开始', link: '/guide/'},
{text: '参考', link: '/refer'}, {text: '参考', link: '/refer'},
{text: 'API文档', link: '/api/'}, {text: 'API引用', link: '/api/'},
{text: '实例', link: '/demo/'}, {text: '实例', link: '/demo/'},
], ],
docFooter: {
prev: '上一页',
next: '下一页'
},
editLink: ThemeConfig.getEditLink(
'在 GitHub 上编辑此页',
),
footer: { footer: {
message: '文档由 <a href="https://vitepress.dev/">VitePress</a> 构建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成', message: '文档由 <a href="https://vitepress.dev/">VitePress</a> 构建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成',
copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved' copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved'

View File

@ -1,16 +1,24 @@
import {defineConfig} from 'vitepress' import {defineConfig} from 'vitepress'
import {ThemeConfig} from "./utils";
export const zht = defineConfig({ export const zht = defineConfig({
lang: "zh-Hant", lang: "zh-Hant",
description: "一個用於Minecraft粒子計算和生成的軟體庫", title: "MBCP 文檔",
description: "MBCP 粒子計算和生成庫文檔",
themeConfig: { themeConfig: {
nav: [ nav: [
{text: '指引', link: '/zht/guide/'}, {text: '指引', link: '/zht/guide/'},
{text: '參考', link: '/zht/refer'}, {text: '參考', link: '/zht/refer'},
{text: 'API文檔', link: '/zht/api/'}, {text: 'API引用', link: '/zht/api/'},
{text: '示範', link: '/zht/demo/'}, {text: '示範', link: '/zht/demo/'},
], ],
docFooter: {
prev: '上一頁',
next: '下一頁'
},
editLink: ThemeConfig.getEditLink(
'於 GitHub 上編輯這頁',
),
footer: { footer: {
message: '文檔由 <a href="https://vitepress.dev/">VitePress</a> 構建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成', message: '文檔由 <a href="https://vitepress.dev/">VitePress</a> 構建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成',
copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved' copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved'

View File

@ -3,9 +3,9 @@
layout: home layout: home
hero: hero:
name: "MBCP docs" name: "MBCP"
text: "More basic change particle" text: "More basic change particle"
tagline: A Library for Python to create particle effects and geometric figures tagline: A Library for Python to create Minecraft particle effects and geometric figures
actions: actions:
- theme: brand - theme: brand
text: Get Started text: Get Started
@ -13,6 +13,9 @@ hero:
- theme: alt - theme: alt
text: API Reference text: API Reference
link: ./api/ link: ./api/
image:
src: /mbcp-logo.svg
alt: MBCP logo
features: features:
- title: Easy to use - title: Easy to use

View File

@ -3,7 +3,7 @@
layout: home layout: home
hero: hero:
name: "MBCP docs" name: "MBCP"
text: "More basic change particle" text: "More basic change particle"
tagline: ジオメトリ演算とパーティクル作成のためのライブラリ tagline: ジオメトリ演算とパーティクル作成のためのライブラリ
actions: actions:
@ -13,6 +13,9 @@ hero:
- theme: alt - theme: alt
text: API リファレンス text: API リファレンス
link: ./api/ link: ./api/
image:
src: /mbcp-logo.svg
alt: MBCP logo
features: features:
- title: 高可用性 - title: 高可用性

View File

@ -0,0 +1,7 @@
<svg width="1000" height="1000" xmlns="http://www.w3.org/2000/svg">
<g id="Layer_1">
<title>Layer 1</title>
<ellipse stroke-width="0" stroke="#000" ry="436" rx="436" id="svg_1" cy="312" cx="690" fill="#d0e9ff"/>
<ellipse stroke-width="0" ry="270" rx="270" id="svg_2" cy="809" cx="191" stroke="#000" fill="#a2d8f4"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 335 B

View File

@ -3,9 +3,9 @@
layout: home layout: home
hero: hero:
name: "MBCP docs" name: "MBCP"
text: "More basic change particle" text: "更多基础变换粒子"
tagline: 用于几何运算和粒子制作的库 tagline: 用于几何运算和Minecraft粒子制作的库
actions: actions:
- theme: brand - theme: brand
text: 快速开始 text: 快速开始
@ -13,6 +13,9 @@ hero:
- theme: alt - theme: alt
text: API文档 text: API文档
link: ./api/ link: ./api/
image:
src: /mbcp-logo.svg
alt: MBCP logo
features: features:
- title: 高可用性 - title: 高可用性

View File

@ -3,9 +3,9 @@
layout: home layout: home
hero: hero:
name: "MBCP docs" name: "MBCP"
text: "More basic change particle" text: "更多基礎變化粒子"
tagline: 用於幾何運算和粒子製作的軟體庫 tagline: 用於幾何運算和 當個創世神 粒子製作的軟體庫
actions: actions:
- theme: brand - theme: brand
text: 跟隨引導 text: 跟隨引導
@ -13,6 +13,9 @@ hero:
- theme: alt - theme: alt
text: API文檔 text: API文檔
link: ./api/ link: ./api/
image:
src: /mbcp-logo.svg
alt: MBCP logo
features: features:
- title: 高度易用 - title: 高度易用
@ -22,3 +25,21 @@ features:
- title: 內置預設 - title: 內置預設
details: 提供了大量的預設,包括常見的幾何圖形、粒子效果等,便於快速生產 details: 提供了大量的預設,包括常見的幾何圖形、粒子效果等,便於快速生產
--- ---
<style>
:root {
--vp-home-hero-name-color: transparent;
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #bd34fe 30%, #41d1ff);
}
@media (min-width: 640px) {
:root {
--vp-home-hero-image-filter: blur(56px);
}
}
@media (min-width: 960px) {
:root {
--vp-home-hero-image-filter: blur(68px);
}
}
</style>

View File

@ -85,18 +85,4 @@ def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...],
raise ValueError("Invalid var type") raise ValueError("Invalid var type")
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
"""
对多参数函数进行柯里化
> [!tip]
> 有关函数柯里化可参考[函数式编程--柯理化Currying](https://zhuanlan.zhihu.com/p/355859667)
Args:
func: 函数
*args: 参数
Returns:
柯里化后的函数
"""
def curried_func(*args2: Var) -> Var:
"""@litedoc-hide"""
return func(*args, *args2)
return curried_func

View File

@ -2,7 +2,7 @@
AAA AAA
""" """
from .mp_math_typing import ThreeSingleVarsFunc from .mp_math_typing import MultiVarsFunc, OneVarFunc, ThreeSingleVarsFunc, Var
from .point import Point3 from .point import Point3
from .vector import Vector3 from .vector import Vector3
from .const import EPSILON from .const import EPSILON
@ -25,3 +25,29 @@ def cal_gradient_3vf(func: ThreeSingleVarsFunc, p: Point3, epsilon: float = EPSI
dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon) dy = (func(p.x, p.y + epsilon, p.z) - func(p.x, p.y - epsilon, p.z)) / (2 * epsilon)
dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon) dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
return Vector3(dx, dy, dz) return Vector3(dx, dy, dz)
def curry(func: MultiVarsFunc, *args: Var) -> OneVarFunc:
r"""
对多参数函数进行柯里化
> [!tip]
> 有关函数柯里化可参考[函数式编程--柯理化Currying](https://zhuanlan.zhihu.com/p/355859667)
Args:
func: 函数
*args: 参数
Returns:
柯里化后的函数
Examples:
```python
def add(a: int, b: int, c: int) -> int:
return a + b + c
add_curried = curry(add, 1, 2)
add_curried(3) # 6
```
"""
def curried_func(*args2: Var) -> Var:
"""@litedoc-hide"""
return func(*args, *args2)
return curried_func

View File

@ -1,5 +1,5 @@
chcp 65001 chcp 65001
python -m litedoc mbcp -o docs/zh/api -l zh-Hans -f editLink=false -cd class -fd def -md def -vd var -cs litedoc mbcp -o docs/zh/api -l zh-Hans -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 litedoc mbcp -o docs/en/api -l en -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 litedoc mbcp -o docs/ja/api -l ja -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 litedoc mbcp -o docs/zht/api -l zh-Hant -cd class -fd def -md def -vd var -cs