mirror of
https://github.com/snowykami/mbcp.git
synced 2024-11-22 06:07:37 +08:00
📝 优化文档显示
This commit is contained in:
parent
e0b4610161
commit
2c0be2c6f0
8
.github/workflows/deploy-docs.yml
vendored
8
.github/workflows/deploy-docs.yml
vendored
@ -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 -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
|
||||
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/en/api -l en -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
|
||||
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
|
||||
|
@ -51,8 +51,11 @@ function generateSidebarConfig(): any[] {
|
||||
console.log(generateSidebarConfig())
|
||||
|
||||
export const common = defineConfig({
|
||||
title: "MBCP docs",
|
||||
description: "MBCP library docs",
|
||||
head: [
|
||||
[
|
||||
'link', {rel: 'icon', type: 'image/svg+xml', href: '/mbcp-logo.svg'}
|
||||
]
|
||||
],
|
||||
markdown: {
|
||||
math: true
|
||||
},
|
||||
@ -60,6 +63,7 @@ export const common = defineConfig({
|
||||
[`${defaultLocale}/:rest*`]: ":rest*",
|
||||
},
|
||||
themeConfig: {
|
||||
logo: '/mbcp-logo.svg',
|
||||
sidebar: generateSidebar(
|
||||
[
|
||||
...generateSidebarConfig()
|
||||
@ -68,9 +72,6 @@ export const common = defineConfig({
|
||||
socialLinks: [
|
||||
{icon: 'github', link: 'https://github.com/snowykami/mbcp'}
|
||||
],
|
||||
editLink: {
|
||||
pattern: 'https://github.com/snowykami/mbcp/tree/main/docs/:path'
|
||||
},
|
||||
outline: [2, 6]
|
||||
},
|
||||
sitemap: {
|
||||
|
@ -1,15 +1,24 @@
|
||||
import {defineConfig} from 'vitepress'
|
||||
import {ThemeConfig} from "./utils";
|
||||
|
||||
export const en = defineConfig({
|
||||
lang: "en-US",
|
||||
description: "A library made for Minecraft particle generation",
|
||||
title: "MBCP docs",
|
||||
description: "MBCP library docs",
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{text: 'Get Start', link: '/en/guide/'},
|
||||
{text: 'Reference', link: '/en/refer'},
|
||||
{text: 'API Document', link: '/en/api/'},
|
||||
{text: 'API Reference', link: '/en/api/'},
|
||||
{text: 'Demo', link: '/en/demo/'},
|
||||
],
|
||||
docFooter: {
|
||||
prev: 'Prev Page',
|
||||
next: 'Next Page'
|
||||
},
|
||||
editLink: ThemeConfig.getEditLink(
|
||||
'Edit this page on GitHub',
|
||||
),
|
||||
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>',
|
||||
copyright: 'Copyright (C) 2020-2024 SnowyKami. All Rights Reserved'
|
||||
|
@ -1,15 +1,24 @@
|
||||
import {defineConfig} from 'vitepress'
|
||||
import {ThemeConfig} from "./utils";
|
||||
|
||||
export const ja = defineConfig({
|
||||
lang: "ja-JP",
|
||||
description: "Minecraftのパーティクル生成用のライブラリ",
|
||||
title: "MBCP ドキュメント",
|
||||
description: "MBCP ライブラリ ドキュメント",
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{text: 'スタート', link: '/ja/guide/'},
|
||||
{text: 'リファレンス', link: '/ja/refer'},
|
||||
{text: 'APIドキュメント', link: '/ja/api/'},
|
||||
{text: 'APIリファレンス', link: '/ja/api/'},
|
||||
{text: 'インスタンス', link: '/ja/demo/'},
|
||||
],
|
||||
docFooter: {
|
||||
prev: '前のページ',
|
||||
next: '次のページ'
|
||||
},
|
||||
editLink: ThemeConfig.getEditLink(
|
||||
'このページをGitHubで編集する',
|
||||
),
|
||||
footer: {
|
||||
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'
|
||||
|
23
docs/.vitepress/config/utils.ts
Normal file
23
docs/.vitepress/config/utils.ts
Normal 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
|
||||
};
|
||||
}
|
||||
}
|
@ -1,15 +1,24 @@
|
||||
import {defineConfig} from 'vitepress'
|
||||
import {ThemeConfig} from "./utils";
|
||||
|
||||
export const zh = defineConfig({
|
||||
lang: "zh-Hans",
|
||||
description: "一个用于Minecraft粒子计算和生成的库",
|
||||
title: "MBCP 文档",
|
||||
description: "MBCP 粒子计算和生成库文档",
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{text: '快速开始', link: '/guide/'},
|
||||
{text: '参考', link: '/refer'},
|
||||
{text: 'API文档', link: '/api/'},
|
||||
{text: 'API引用', link: '/api/'},
|
||||
{text: '实例', link: '/demo/'},
|
||||
],
|
||||
docFooter: {
|
||||
prev: '上一页',
|
||||
next: '下一页'
|
||||
},
|
||||
editLink: ThemeConfig.getEditLink(
|
||||
'在 GitHub 上编辑此页',
|
||||
),
|
||||
footer: {
|
||||
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'
|
||||
|
@ -1,16 +1,24 @@
|
||||
import {defineConfig} from 'vitepress'
|
||||
import {ThemeConfig} from "./utils";
|
||||
|
||||
export const zht = defineConfig({
|
||||
|
||||
lang: "zh-Hant",
|
||||
description: "一個用於Minecraft粒子計算和生成的軟體庫",
|
||||
title: "MBCP 文檔",
|
||||
description: "MBCP 粒子計算和生成庫文檔",
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{text: '指引', link: '/zht/guide/'},
|
||||
{text: '參考', link: '/zht/refer'},
|
||||
{text: 'API文檔', link: '/zht/api/'},
|
||||
{text: 'API引用', link: '/zht/api/'},
|
||||
{text: '示範', link: '/zht/demo/'},
|
||||
],
|
||||
docFooter: {
|
||||
prev: '上一頁',
|
||||
next: '下一頁'
|
||||
},
|
||||
editLink: ThemeConfig.getEditLink(
|
||||
'於 GitHub 上編輯這頁',
|
||||
),
|
||||
footer: {
|
||||
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'
|
||||
|
@ -3,9 +3,9 @@
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "MBCP docs"
|
||||
name: "MBCP"
|
||||
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:
|
||||
- theme: brand
|
||||
text: Get Started
|
||||
@ -13,6 +13,9 @@ hero:
|
||||
- theme: alt
|
||||
text: API Reference
|
||||
link: ./api/
|
||||
image:
|
||||
src: /mbcp-logo.svg
|
||||
alt: MBCP logo
|
||||
|
||||
features:
|
||||
- title: Easy to use
|
||||
|
@ -3,7 +3,7 @@
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "MBCP docs"
|
||||
name: "MBCP"
|
||||
text: "More basic change particle"
|
||||
tagline: ジオメトリ演算とパーティクル作成のためのライブラリ
|
||||
actions:
|
||||
@ -13,6 +13,9 @@ hero:
|
||||
- theme: alt
|
||||
text: API リファレンス
|
||||
link: ./api/
|
||||
image:
|
||||
src: /mbcp-logo.svg
|
||||
alt: MBCP logo
|
||||
|
||||
features:
|
||||
- title: 高可用性
|
||||
|
7
docs/public/mbcp-logo.svg
Normal file
7
docs/public/mbcp-logo.svg
Normal 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 |
@ -3,9 +3,9 @@
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "MBCP docs"
|
||||
text: "More basic change particle"
|
||||
tagline: 用于几何运算和粒子制作的库
|
||||
name: "MBCP"
|
||||
text: "更多基础变换粒子"
|
||||
tagline: 用于几何运算和Minecraft粒子制作的库
|
||||
actions:
|
||||
- theme: brand
|
||||
text: 快速开始
|
||||
@ -13,6 +13,9 @@ hero:
|
||||
- theme: alt
|
||||
text: API文档
|
||||
link: ./api/
|
||||
image:
|
||||
src: /mbcp-logo.svg
|
||||
alt: MBCP logo
|
||||
|
||||
features:
|
||||
- title: 高可用性
|
||||
|
@ -3,9 +3,9 @@
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "MBCP docs"
|
||||
text: "More basic change particle"
|
||||
tagline: 用於幾何運算和粒子製作的軟體庫
|
||||
name: "MBCP"
|
||||
text: "更多基礎變化粒子"
|
||||
tagline: 用於幾何運算和 當個創世神 粒子製作的軟體庫
|
||||
actions:
|
||||
- theme: brand
|
||||
text: 跟隨引導
|
||||
@ -13,6 +13,9 @@ hero:
|
||||
- theme: alt
|
||||
text: API文檔
|
||||
link: ./api/
|
||||
image:
|
||||
src: /mbcp-logo.svg
|
||||
alt: MBCP logo
|
||||
|
||||
features:
|
||||
- title: 高度易用
|
||||
@ -22,3 +25,21 @@ features:
|
||||
- title: 內置預設
|
||||
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>
|
@ -85,18 +85,4 @@ def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...],
|
||||
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
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
AAA
|
||||
"""
|
||||
|
||||
from .mp_math_typing import ThreeSingleVarsFunc
|
||||
from .mp_math_typing import MultiVarsFunc, OneVarFunc, ThreeSingleVarsFunc, Var
|
||||
from .point import Point3
|
||||
from .vector import Vector3
|
||||
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)
|
||||
dz = (func(p.x, p.y, p.z + epsilon) - func(p.x, p.y, p.z - epsilon)) / (2 * epsilon)
|
||||
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
|
||||
|
@ -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 -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
|
||||
litedoc mbcp -o docs/zh/api -l zh-Hans -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
|
||||
litedoc mbcp -o docs/ja/api -l ja -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
|
Loading…
Reference in New Issue
Block a user