From de42d34e3838a5486ed49ea9de9e59f845959d58 Mon Sep 17 00:00:00 2001 From: snowy Date: Wed, 28 Aug 2024 21:27:52 +0800 Subject: [PATCH] =?UTF-8?q?:memo:=20=E6=B5=8B=E8=AF=95=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/mp_math/angle.md | 136 +++++++++--------- docs/api/mp_math/equation.md | 38 ++--- docs/api/mp_math/line.md | 118 +++++++-------- docs/api/mp_math/plane.md | 179 +++++++++++------------ docs/api/mp_math/point.md | 78 +++++++--- docs/api/mp_math/segment.md | 12 +- docs/api/mp_math/utils.md | 44 +++--- docs/api/mp_math/vector.md | 184 ++++++++++++------------ docs/api/presets/model/index.md | 10 +- liteyuki_autodoc/docstring/docstring.py | 16 +-- liteyuki_autodoc/docstring/parser.py | 13 +- liteyuki_autodoc/style/markdown.py | 14 +- liteyuki_autodoc/syntax/astparser.py | 40 +++++- liteyuki_autodoc/syntax/node.py | 11 +- mbcp/mp_math/plane.py | 2 + mbcp/mp_math/point.py | 24 ++-- 16 files changed, 493 insertions(+), 426 deletions(-) diff --git a/docs/api/mp_math/angle.md b/docs/api/mp_math/angle.md index 042a44d..d5e1065 100644 --- a/docs/api/mp_math/angle.md +++ b/docs/api/mp_math/angle.md @@ -5,19 +5,19 @@ title: mbcp.mp_math.angle ### ***class*** `AnyAngle` -- #### *def* `__init__(self, value: float, is_radian: bool = False)` +### *def* `__init__(self, value: float, is_radian: bool = False)` 任意角度。 参数: -value: 角度或弧度值 +- value: 角度或弧度值 + +- is_radian: 是否为弧度,默认为否 -is_radian: 是否为弧度,默认为否 -- #
源码 @@ -36,18 +36,18 @@ def __init__(self, value: float, is_radian: bool=False): ```
-- #### `@property` -- #### *def* `complementary(self)` +### `@property` +### *def* `complementary(self) -> 'AnyAngle'` 余角:两角的和为90°。 返回: -余角 +- 余角 + -- #
源码 @@ -63,18 +63,18 @@ def complementary(self) -> 'AnyAngle': ```
-- #### `@property` -- #### *def* `supplementary(self)` +### `@property` +### *def* `supplementary(self) -> 'AnyAngle'` 补角:两角的和为180°。 返回: -补角 +- 补角 + -- #
源码 @@ -90,18 +90,18 @@ def supplementary(self) -> 'AnyAngle': ```
-- #### `@property` -- #### *def* `degree(self)` +### `@property` +### *def* `degree(self) -> float` 角度。 返回: -弧度 +- 弧度 + -- #
源码 @@ -117,18 +117,18 @@ def degree(self) -> float: ```
-- #### `@property` -- #### *def* `minimum_positive(self)` +### `@property` +### *def* `minimum_positive(self) -> 'AnyAngle'` 最小正角。 返回: -最小正角度 +- 最小正角度 + -- #
源码 @@ -144,18 +144,18 @@ def minimum_positive(self) -> 'AnyAngle': ```
-- #### `@property` -- #### *def* `maximum_negative(self)` +### `@property` +### *def* `maximum_negative(self) -> 'AnyAngle'` 最大负角。 返回: -最大负角度 +- 最大负角度 + -- #
源码 @@ -171,18 +171,18 @@ def maximum_negative(self) -> 'AnyAngle': ```
-- #### `@property` -- #### *def* `sin(self)` +### `@property` +### *def* `sin(self) -> float` 正弦值。 返回: -正弦值 +- 正弦值 + -- #
源码 @@ -198,18 +198,18 @@ def sin(self) -> float: ```
-- #### `@property` -- #### *def* `cos(self)` +### `@property` +### *def* `cos(self) -> float` 余弦值。 返回: -余弦值 +- 余弦值 + -- #
源码 @@ -225,18 +225,18 @@ def cos(self) -> float: ```
-- #### `@property` -- #### *def* `tan(self)` +### `@property` +### *def* `tan(self) -> float` 正切值。 返回: -正切值 +- 正切值 + -- #
源码 @@ -252,18 +252,18 @@ def tan(self) -> float: ```
-- #### `@property` -- #### *def* `cot(self)` +### `@property` +### *def* `cot(self) -> float` 余切值。 返回: -余切值 +- 余切值 + -- #
源码 @@ -279,18 +279,18 @@ def cot(self) -> float: ```
-- #### `@property` -- #### *def* `sec(self)` +### `@property` +### *def* `sec(self) -> float` 正割值。 返回: -正割值 +- 正割值 + -- #
源码 @@ -306,18 +306,18 @@ def sec(self) -> float: ```
-- #### `@property` -- #### *def* `csc(self)` +### `@property` +### *def* `csc(self) -> float` 余割值。 返回: -余割值 +- 余割值 + -- #
源码 @@ -333,9 +333,9 @@ def csc(self) -> float: ```
-- #### *def* `__add__(self, other: 'AnyAngle')` +### *def* `__add__(self, other: 'AnyAngle') -> 'AnyAngle'` + -- #
源码 @@ -345,9 +345,9 @@ def __add__(self, other: 'AnyAngle') -> 'AnyAngle': ```
-- #### *def* `__eq__(self, other)` +### *def* `__eq__(self, other)` + -- #
源码 @@ -357,9 +357,9 @@ def __eq__(self, other): ```
-- #### *def* `__sub__(self, other: 'AnyAngle')` +### *def* `__sub__(self, other: 'AnyAngle') -> 'AnyAngle'` + -- #
源码 @@ -369,9 +369,9 @@ def __sub__(self, other: 'AnyAngle') -> 'AnyAngle': ```
-- #### *def* `__mul__(self, other: float)` +### *def* `__mul__(self, other: float) -> 'AnyAngle'` + -- #
源码 @@ -381,9 +381,9 @@ def __mul__(self, other: float) -> 'AnyAngle': ```
-- #### *def* `__repr__(self)` +### *def* `__repr__(self)` + -- #
源码 @@ -393,9 +393,9 @@ def __repr__(self): ```
-- #### *def* `__str__(self)` +### *def* `__str__(self)` + -- #
源码 @@ -405,10 +405,10 @@ def __str__(self): ```
-- #### `@overload` -- #### *def* `__truediv__(self, other: float)` +### `@overload` +### *def* `__truediv__(self, other: float) -> 'AnyAngle'` + -- #
源码 @@ -419,10 +419,10 @@ def __truediv__(self, other: float) -> 'AnyAngle': ```
-- #### `@overload` -- #### *def* `__truediv__(self, other: 'AnyAngle')` +### `@overload` +### *def* `__truediv__(self, other: 'AnyAngle') -> float` + -- #
源码 @@ -433,9 +433,9 @@ def __truediv__(self, other: 'AnyAngle') -> float: ```
-- #### *def* `__truediv__(self, other)` +### *def* `__truediv__(self, other)` + -- #
源码 diff --git a/docs/api/mp_math/equation.md b/docs/api/mp_math/equation.md index a051e91..e34924d 100644 --- a/docs/api/mp_math/equation.md +++ b/docs/api/mp_math/equation.md @@ -1,20 +1,18 @@ --- title: mbcp.mp_math.equation --- -### ***var*** `result_func = get_partial_derivative_func(result_func, v, epsilon)` - -### *def* `get_partial_derivative_func(func: MultiVarsFunc = EPSILON)` +### *def* `get_partial_derivative_func(func: MultiVarsFunc = EPSILON) -> MultiVarsFunc` 求N元函数一阶偏导函数。这玩意不太稳定,慎用。 参数: -func: 函数 +- func: 函数 -var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导) +- var: 变量位置,可为整数(一阶偏导)或整数元组(高阶偏导) -epsilon: 偏移量 +- epsilon: 偏移量 @@ -56,7 +54,7 @@ def get_partial_derivative_func(func: MultiVarsFunc, var: int | tuple[int, ...], ```
-### *def* `partial_derivative_func()` +### *def* `partial_derivative_func() -> Var`
@@ -72,7 +70,7 @@ def partial_derivative_func(*args: Var) -> Var: ```
-### *def* `high_order_partial_derivative_func()` +### *def* `high_order_partial_derivative_func() -> Var`
@@ -89,21 +87,21 @@ def high_order_partial_derivative_func(*args: Var) -> Var: ### ***class*** `CurveEquation` -- #### *def* `__init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)` +### *def* `__init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc)` 曲线方程。 参数: -x_func: x函数 +- x_func: x函数 -y_func: y函数 +- y_func: y函数 + +- z_func: z函数 -z_func: z函数 -- #
源码 @@ -122,19 +120,19 @@ def __init__(self, x_func: OneVarFunc, y_func: OneVarFunc, z_func: OneVarFunc): ```
-- #### *def* `__call__(self)` +### *def* `__call__(self) -> Point3 | tuple[Point3, ...]` 计算曲线上的点。 参数: -*t: +- *t: + +- 参数: -参数: -- #
源码 @@ -155,9 +153,9 @@ def __call__(self, *t: Var) -> Point3 | tuple[Point3, ...]: ```
-- #### *def* `__str__(self)` +### *def* `__str__(self)` + -- #
源码 @@ -167,3 +165,5 @@ def __str__(self): ```
+### ***var*** `result_func = get_partial_derivative_func(result_func, v, epsilon)` + diff --git a/docs/api/mp_math/line.md b/docs/api/mp_math/line.md index e564aa8..d12dac8 100644 --- a/docs/api/mp_math/line.md +++ b/docs/api/mp_math/line.md @@ -3,19 +3,19 @@ title: mbcp.mp_math.line --- ### ***class*** `Line3` -- #### *def* `__init__(self, point: 'Point3', direction: 'Vector3')` +### *def* `__init__(self, point: 'Point3', direction: 'Vector3')` 三维空间中的直线。由一个点和一个方向向量确定。 参数: -point: 直线上的一点 +- point: 直线上的一点 + +- direction: 直线的方向向量 -direction: 直线的方向向量 -- #
源码 @@ -32,19 +32,19 @@ def __init__(self, point: 'Point3', direction: 'Vector3'): ```
-- #### *def* `approx(self, other: 'Line3', epsilon: float = APPROX)` +### *def* `approx(self, other: 'Line3', epsilon: float = APPROX) -> bool` 判断两条直线是否近似相等。 参数: -other: 另一条直线 +- other: 另一条直线 + +- epsilon: 误差 -epsilon: 误差 -- #
源码 @@ -62,17 +62,17 @@ def approx(self, other: 'Line3', epsilon: float=APPROX) -> bool: ```
-- #### *def* `cal_angle(self, other: 'Line3')` +### *def* `cal_angle(self, other: 'Line3') -> 'AnyAngle'` 计算直线和直线之间的夹角。 参数: -other: 另一条直线 +- other: 另一条直线 + -- #
源码 @@ -91,17 +91,17 @@ def cal_angle(self, other: 'Line3') -> 'AnyAngle': ```
-- #### *def* `cal_distance(self, other: 'Line3 | Point3')` +### *def* `cal_distance(self, other: 'Line3 | Point3') -> float` 计算直线和直线或点之间的距离。 参数: -other: 平行直线或点 +- other: 平行直线或点 + -- #
源码 @@ -133,17 +133,17 @@ def cal_distance(self, other: 'Line3 | Point3') -> float: ```
-- #### *def* `cal_intersection(self, other: 'Line3')` +### *def* `cal_intersection(self, other: 'Line3') -> 'Point3'` 计算两条直线的交点。 参数: -other: 另一条直线 +- other: 另一条直线 + -- #
源码 @@ -167,17 +167,17 @@ def cal_intersection(self, other: 'Line3') -> 'Point3': ```
-- #### *def* `cal_perpendicular(self, point: 'Point3')` +### *def* `cal_perpendicular(self, point: 'Point3') -> 'Line3'` 计算直线经过指定点p的垂线。 参数: -point: 指定点 +- point: 指定点 + -- #
源码 @@ -194,17 +194,17 @@ def cal_perpendicular(self, point: 'Point3') -> 'Line3': ```
-- #### *def* `get_point(self, t: RealNumber)` +### *def* `get_point(self, t: RealNumber) -> 'Point3'` 获取直线上的点。同一条直线,但起始点和方向向量不同,则同一个t对应的点不同。 参数: -t: 参数t +- t: 参数t + -- #
源码 @@ -221,17 +221,17 @@ def get_point(self, t: RealNumber) -> 'Point3': ```
-- #### *def* `get_parametric_equations(self)` +### *def* `get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, OneSingleVarFunc]` 获取直线的参数方程。 返回: -x(t), y(t), z(t) +- x(t), y(t), z(t) + -- #
源码 @@ -246,19 +246,19 @@ def get_parametric_equations(self) -> tuple[OneSingleVarFunc, OneSingleVarFunc, ```
-- #### *def* `is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06)` +### *def* `is_approx_parallel(self, other: 'Line3', epsilon: float = 1e-06) -> bool` 判断两条直线是否近似平行。 参数: -other: 另一条直线 +- other: 另一条直线 + +- epsilon: 误差 -epsilon: 误差 -- #
源码 @@ -276,17 +276,17 @@ def is_approx_parallel(self, other: 'Line3', epsilon: float=1e-06) -> bool: ```
-- #### *def* `is_parallel(self, other: 'Line3')` +### *def* `is_parallel(self, other: 'Line3') -> bool` 判断两条直线是否平行。 参数: -other: 另一条直线 +- other: 另一条直线 + -- #
源码 @@ -303,17 +303,17 @@ def is_parallel(self, other: 'Line3') -> bool: ```
-- #### *def* `is_collinear(self, other: 'Line3')` +### *def* `is_collinear(self, other: 'Line3') -> bool` 判断两条直线是否共线。 参数: -other: 另一条直线 +- other: 另一条直线 + -- #
源码 @@ -330,17 +330,17 @@ def is_collinear(self, other: 'Line3') -> bool: ```
-- #### *def* `is_point_on(self, point: 'Point3')` +### *def* `is_point_on(self, point: 'Point3') -> bool` 判断点是否在直线上。 参数: -point: 点 +- point: 点 + -- #
源码 @@ -357,7 +357,7 @@ def is_point_on(self, point: 'Point3') -> bool: ```
-- #### *def* `is_coplanar(self, other: 'Line3')` +### *def* `is_coplanar(self, other: 'Line3') -> bool` 判断两条直线是否共面。 @@ -365,10 +365,10 @@ def is_point_on(self, point: 'Point3') -> bool: 参数: -other: 另一条直线 +- other: 另一条直线 + -- #
源码 @@ -386,7 +386,7 @@ def is_coplanar(self, other: 'Line3') -> bool: ```
-- #### *def* `simplify(self)` +### *def* `simplify(self)` 简化直线方程,等价相等。 @@ -395,7 +395,7 @@ def is_coplanar(self, other: 'Line3') -> bool: 按照可行性一次对x y z 化 0 处理,并对向量单位化 -- # +
源码 @@ -417,20 +417,20 @@ def simplify(self): ```
-- #### `@classmethod` -- #### *def* `from_two_points(cls, p1: 'Point3', p2: 'Point3')` +### `@classmethod` +### *def* `from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3'` 工厂函数 由两点构造直线。 参数: -p1: 点1 +- p1: 点1 + +- p2: 点2 -p2: 点2 -- #
源码 @@ -450,17 +450,17 @@ def from_two_points(cls, p1: 'Point3', p2: 'Point3') -> 'Line3': ```
-- #### *def* `__and__(self, other: 'Line3')` +### *def* `__and__(self, other: 'Line3') -> 'Line3 | Point3 | None'` 计算两条直线点集合的交集。重合线返回自身,平行线返回None,交线返回交点。 参数: -other: 另一条直线 +- other: 另一条直线 + -- #
源码 @@ -482,7 +482,7 @@ def __and__(self, other: 'Line3') -> 'Line3 | Point3 | None': ```
-- #### *def* `__eq__(self, other)` +### *def* `__eq__(self, other) -> bool` 判断两条直线是否等价。 @@ -491,10 +491,10 @@ v1 // v2 ∧ (p1 - p2) // v1 参数: -other: +- other: + -- #
源码 @@ -514,13 +514,13 @@ def __eq__(self, other) -> bool: ```
-- #### *def* `__str__(self)` +### *def* `__str__(self)` + -- #
源码 @@ -542,9 +542,9 @@ def __str__(self): ```
-- #### *def* `__repr__(self)` +### *def* `__repr__(self)` + -- #
源码 diff --git a/docs/api/mp_math/plane.md b/docs/api/mp_math/plane.md index 9a598b7..e069db8 100644 --- a/docs/api/mp_math/plane.md +++ b/docs/api/mp_math/plane.md @@ -1,45 +1,25 @@ --- title: mbcp.mp_math.plane --- -### ***var*** `k = other.a / self.a` - -### ***var*** `A = np.array([[self.b, self.c], [other.b, other.c]])` - -### ***var*** `B = np.array([-self.d, -other.d])` - -### ***var*** `v2 = l2.get_point(1) - l1.point` - -### ***var*** `k = other.b / self.b` - -### ***var*** `A = np.array([[self.a, self.c], [other.a, other.c]])` - -### ***var*** `B = np.array([-self.d, -other.d])` - -### ***var*** `k = other.c / self.c` - -### ***var*** `A = np.array([[self.a, self.b], [other.a, other.b]])` - -### ***var*** `B = np.array([-self.d, -other.d])` - ### ***class*** `Plane3` -- #### *def* `__init__(self, a: float, b: float, c: float, d: float)` +### *def* `__init__(self, a: float, b: float, c: float, d: float)` 平面方程:ax + by + cz + d = 0 参数: -a: +- a: -b: +- b: -c: +- c: + +- d: -d: -- #
源码 @@ -60,17 +40,17 @@ def __init__(self, a: float, b: float, c: float, d: float): ```
-- #### *def* `approx(self, other: 'Plane3')` +### *def* `approx(self, other: 'Plane3') -> bool` 判断两个平面是否近似相等。 参数: -other: +- other: + -- #
源码 @@ -84,6 +64,7 @@ def approx(self, other: 'Plane3') -> bool: Returns: 是否近似相等 """ + a = 3 if self.a != 0: k = other.a / self.a return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k) @@ -98,17 +79,17 @@ def approx(self, other: 'Plane3') -> bool: ```
-- #### *def* `cal_angle(self, other: 'Line3 | Plane3')` +### *def* `cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle'` 计算平面与平面之间的夹角。 参数: -other: 另一个平面 +- other: 另一个平面 + -- #
源码 @@ -132,17 +113,17 @@ def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle': ```
-- #### *def* `cal_distance(self, other: 'Plane3 | Point3')` +### *def* `cal_distance(self, other: 'Plane3 | Point3') -> float` 计算平面与平面或点之间的距离。 参数: -other: 另一个平面或点 +- other: 另一个平面或点 + -- #
源码 @@ -166,17 +147,17 @@ def cal_distance(self, other: 'Plane3 | Point3') -> float: ```
-- #### *def* `cal_intersection_line3(self, other: 'Plane3')` +### *def* `cal_intersection_line3(self, other: 'Plane3') -> 'Line3'` 计算两平面的交线。该方法有问题,待修复。 参数: -other: 另一个平面 +- other: 另一个平面 + -- #
源码 @@ -210,17 +191,17 @@ def cal_intersection_line3(self, other: 'Plane3') -> 'Line3': ```
-- #### *def* `cal_intersection_point3(self, other: 'Line3')` +### *def* `cal_intersection_point3(self, other: 'Line3') -> 'Point3'` 计算平面与直线的交点。 参数: -other: 不与平面平行或在平面上的直线 +- other: 不与平面平行或在平面上的直线 + -- #
源码 @@ -243,17 +224,17 @@ def cal_intersection_point3(self, other: 'Line3') -> 'Point3': ```
-- #### *def* `cal_parallel_plane3(self, point: 'Point3')` +### *def* `cal_parallel_plane3(self, point: 'Point3') -> 'Plane3'` 计算平行于该平面且过指定点的平面。 参数: -point: 指定点 +- point: 指定点 + -- #
源码 @@ -270,17 +251,17 @@ def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3': ```
-- #### *def* `is_parallel(self, other: 'Plane3')` +### *def* `is_parallel(self, other: 'Plane3') -> bool` 判断两个平面是否平行。 参数: -other: 另一个平面 +- other: 另一个平面 + -- #
源码 @@ -297,18 +278,18 @@ def is_parallel(self, other: 'Plane3') -> bool: ```
-- #### `@property` -- #### *def* `normal(self)` +### `@property` +### *def* `normal(self) -> 'Vector3'` 平面的法向量。 返回: -法向量 +- 法向量 + -- #
源码 @@ -324,20 +305,20 @@ def normal(self) -> 'Vector3': ```
-- #### `@classmethod` -- #### *def* `from_point_and_normal(cls, point: 'Point3', normal: 'Vector3')` +### `@classmethod` +### *def* `from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3'` 工厂函数 由点和法向量构造平面(点法式构造)。 参数: -point: 平面上的一点 +- point: 平面上的一点 + +- normal: 法向量 -normal: 法向量 -- #
源码 @@ -358,22 +339,22 @@ def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3': ```
-- #### `@classmethod` -- #### *def* `from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3')` +### `@classmethod` +### *def* `from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3'` 工厂函数 由三点构造平面。 参数: -p1: 点1 +- p1: 点1 -p2: 点2 +- p2: 点2 + +- p3: 点3 -p3: 点3 -- #
源码 @@ -396,20 +377,20 @@ def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3' ```
-- #### `@classmethod` -- #### *def* `from_two_lines(cls, l1: 'Line3', l2: 'Line3')` +### `@classmethod` +### *def* `from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3'` 工厂函数 由两直线构造平面。 参数: -l1: 直线1 +- l1: 直线1 + +- l2: 直线2 -l2: 直线2 -- #
源码 @@ -432,20 +413,20 @@ def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3': ```
-- #### `@classmethod` -- #### *def* `from_point_and_line(cls, point: 'Point3', line: 'Line3')` +### `@classmethod` +### *def* `from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3'` 工厂函数 由点和直线构造平面。 参数: -point: 面上一点 +- point: 面上一点 + +- line: 面上直线,不包含点 -line: 面上直线,不包含点 -- #
源码 @@ -464,9 +445,9 @@ def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3': ```
-- #### *def* `__repr__(self)` +### *def* `__repr__(self)` + -- #
源码 @@ -476,9 +457,9 @@ def __repr__(self): ```
-- #### *def* `__str__(self)` +### *def* `__str__(self)` + -- #
源码 @@ -497,10 +478,10 @@ def __str__(self): ```
-- #### `@overload` -- #### *def* `__and__(self, other: 'Line3')` +### `@overload` +### *def* `__and__(self, other: 'Line3') -> 'Point3 | None'` + -- #
源码 @@ -511,10 +492,10 @@ def __and__(self, other: 'Line3') -> 'Point3 | None': ```
-- #### `@overload` -- #### *def* `__and__(self, other: 'Plane3')` +### `@overload` +### *def* `__and__(self, other: 'Plane3') -> 'Line3 | None'` + -- #
源码 @@ -525,17 +506,17 @@ def __and__(self, other: 'Plane3') -> 'Line3 | None': ```
-- #### *def* `__and__(self, other)` +### *def* `__and__(self, other)` 取两平面的交集(人话:交线) 参数: -other: +- other: + -- #
源码 @@ -561,9 +542,9 @@ def __and__(self, other): ```
-- #### *def* `__eq__(self, other)` +### *def* `__eq__(self, other) -> bool` + -- #
源码 @@ -573,9 +554,9 @@ def __eq__(self, other) -> bool: ```
-- #### *def* `__rand__(self, other: 'Line3')` +### *def* `__rand__(self, other: 'Line3') -> 'Point3'` + -- #
源码 @@ -585,3 +566,23 @@ def __rand__(self, other: 'Line3') -> 'Point3': ```
+### ***var*** `k = other.a / self.a` + +### ***var*** `A = np.array([[self.b, self.c], [other.b, other.c]])` + +### ***var*** `B = np.array([-self.d, -other.d])` + +### ***var*** `v2 = l2.get_point(1) - l1.point` + +### ***var*** `k = other.b / self.b` + +### ***var*** `A = np.array([[self.a, self.c], [other.a, other.c]])` + +### ***var*** `B = np.array([-self.d, -other.d])` + +### ***var*** `k = other.c / self.c` + +### ***var*** `A = np.array([[self.a, self.b], [other.a, other.b]])` + +### ***var*** `B = np.array([-self.d, -other.d])` + diff --git a/docs/api/mp_math/point.md b/docs/api/mp_math/point.md index f040766..abb2706 100644 --- a/docs/api/mp_math/point.md +++ b/docs/api/mp_math/point.md @@ -3,21 +3,21 @@ title: mbcp.mp_math.point --- ### ***class*** `Point3` -- #### *def* `__init__(self, x: float, y: float, z: float)` +### *def* `__init__(self, x: float, y: float, z: float)` 笛卡尔坐标系中的点。 参数: -x: x 坐标 +- x: x 坐标 -y: y 坐标 +- y: y 坐标 + +- z: z 坐标 -z: z 坐标 -- #
源码 @@ -36,19 +36,19 @@ def __init__(self, x: float, y: float, z: float): ```
-- #### *def* `approx(self, other: 'Point3', epsilon: float = APPROX)` +### *def* `approx(self, other: 'Point3', epsilon: float = APPROX) -> bool` 判断两个点是否近似相等。 参数: -other: +- other: + +- epsilon: -epsilon: -- #
源码 @@ -67,9 +67,9 @@ def approx(self, other: 'Point3', epsilon: float=APPROX) -> bool: ```
-- #### *def* `__str__(self)` +### *def* `__str__(self)` + -- #
源码 @@ -79,10 +79,10 @@ def __str__(self): ```
-- #### `@overload` -- #### *def* `__add__(self, other: 'Vector3')` +### `@overload` +### *def* `__add__(self, other: 'Vector3') -> 'Point3'` + -- #
源码 @@ -93,10 +93,10 @@ def __add__(self, other: 'Vector3') -> 'Point3': ```
-- #### `@overload` -- #### *def* `__add__(self, other: 'Point3')` +### `@overload` +### *def* `__add__(self, other: 'Point3') -> 'Point3'` + -- #
源码 @@ -107,7 +107,7 @@ def __add__(self, other: 'Point3') -> 'Point3': ```
-- #### *def* `__add__(self, other)` +### *def* `__add__(self, other)` P + V -> P @@ -115,10 +115,10 @@ P + P -> P 参数: -other: +- other: + -- #
源码 @@ -135,17 +135,17 @@ def __add__(self, other): ```
-- #### *def* `__eq__(self, other)` +### *def* `__eq__(self, other)` 判断两个点是否相等。 参数: -other: +- other: + -- #
源码 @@ -161,3 +161,35 @@ def __eq__(self, other): ```
+### *def* `__sub__(self, other: 'Point3') -> 'Vector3'` + + +P - P -> V + +P - V -> P 已在 :class:`Vector3` 中实现 + +参数: + +- other: + + + +
+源码 + +```python +def __sub__(self, other: 'Point3') -> 'Vector3': + """ + P - P -> V + + P - V -> P 已在 :class:`Vector3` 中实现 + Args: + other: + Returns: + + """ + from .vector import Vector3 + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z) +``` +
+ diff --git a/docs/api/mp_math/segment.md b/docs/api/mp_math/segment.md index 13a897a..0e39845 100644 --- a/docs/api/mp_math/segment.md +++ b/docs/api/mp_math/segment.md @@ -3,7 +3,7 @@ title: mbcp.mp_math.segment --- ### ***class*** `Segment3` -- #### *def* `__init__(self, p1: 'Point3', p2: 'Point3')` +### *def* `__init__(self, p1: 'Point3', p2: 'Point3')` 三维空间中的线段。 @@ -11,7 +11,7 @@ title: mbcp.mp_math.segment :param p2: -- # +
源码 @@ -33,9 +33,9 @@ def __init__(self, p1: 'Point3', p2: 'Point3'): ```
-- #### *def* `__repr__(self)` +### *def* `__repr__(self)` + -- #
源码 @@ -45,9 +45,9 @@ def __repr__(self): ```
-- #### *def* `__str__(self)` +### *def* `__str__(self)` + -- #
源码 diff --git a/docs/api/mp_math/utils.md b/docs/api/mp_math/utils.md index 9406a53..40ac31e 100644 --- a/docs/api/mp_math/utils.md +++ b/docs/api/mp_math/utils.md @@ -1,18 +1,18 @@ --- title: mbcp.mp_math.utils --- -### *def* `clamp()` +### *def* `clamp() -> float` 区间截断函数。 参数: -x: +- x: -min_: +- min_: -max_: +- max_: @@ -35,18 +35,18 @@ def clamp(x: float, min_: float, max_: float) -> float: ```
-### *def* `approx(x: float = 0.0, y: float = APPROX)` +### *def* `approx(x: float = 0.0, y: float = APPROX) -> bool` 判断两个数是否近似相等。或包装一个实数,用于判断是否近似于0。 参数: -x: +- x: -y: +- y: -epsilon: +- epsilon: @@ -69,16 +69,16 @@ def approx(x: float, y: float=0.0, epsilon: float=APPROX) -> bool: ```
-### *def* `sign(x: float = False)` +### *def* `sign(x: float = False) -> str` 获取数的符号。 参数: -x: 数 +- x: 数 -only_neg: 是否只返回负数的符号 +- only_neg: 是否只返回负数的符号 @@ -103,7 +103,7 @@ def sign(x: float, only_neg: bool=False) -> str: ```
-### *def* `sign_format(x: float = False)` +### *def* `sign_format(x: float = False) -> str` 格式化符号数 @@ -113,9 +113,9 @@ def sign(x: float, only_neg: bool=False) -> str: 参数: -x: 数 +- x: 数 -only_neg: 是否只返回负数的符号 +- only_neg: 是否只返回负数的符号 @@ -145,9 +145,9 @@ def sign_format(x: float, only_neg: bool=False) -> str: ### ***class*** `Approx` -- #### *def* `__init__(self, value: RealNumber)` +### *def* `__init__(self, value: RealNumber)` + -- #
源码 @@ -157,9 +157,9 @@ def __init__(self, value: RealNumber): ```
-- #### *def* `__eq__(self, other)` +### *def* `__eq__(self, other)` + -- #
源码 @@ -178,9 +178,9 @@ def __eq__(self, other): ```
-- #### *def* `raise_type_error(self, other)` +### *def* `raise_type_error(self, other)` + -- #
源码 @@ -190,9 +190,9 @@ def raise_type_error(self, other): ```
-- #### *def* `__ne__(self, other)` +### *def* `__ne__(self, other)` + -- #
源码 diff --git a/docs/api/mp_math/vector.md b/docs/api/mp_math/vector.md index 988ae57..cb8973c 100644 --- a/docs/api/mp_math/vector.md +++ b/docs/api/mp_math/vector.md @@ -1,31 +1,23 @@ --- title: mbcp.mp_math.vector --- -### ***var*** `zero_vector3 = Vector3(0, 0, 0)` - -### ***var*** `x_axis = Vector3(1, 0, 0)` - -### ***var*** `y_axis = Vector3(0, 1, 0)` - -### ***var*** `z_axis = Vector3(0, 0, 1)` - ### ***class*** `Vector3` -- #### *def* `__init__(self, x: float, y: float, z: float)` +### *def* `__init__(self, x: float, y: float, z: float)` 3维向量 参数: -x: x轴分量 +- x: x轴分量 -y: y轴分量 +- y: y轴分量 + +- z: z轴分量 -z: z轴分量 -- #
源码 @@ -44,19 +36,19 @@ def __init__(self, x: float, y: float, z: float): ```
-- #### *def* `approx(self, other: 'Vector3', epsilon: float = APPROX)` +### *def* `approx(self, other: 'Vector3', epsilon: float = APPROX) -> bool` 判断两个向量是否近似相等。 参数: -other: +- other: + +- epsilon: -epsilon: -- #
源码 @@ -75,17 +67,17 @@ def approx(self, other: 'Vector3', epsilon: float=APPROX) -> bool: ```
-- #### *def* `cal_angle(self, other: 'Vector3')` +### *def* `cal_angle(self, other: 'Vector3') -> 'AnyAngle'` 计算两个向量之间的夹角。 参数: -other: 另一个向量 +- other: 另一个向量 + -- #
源码 @@ -102,7 +94,7 @@ def cal_angle(self, other: 'Vector3') -> 'AnyAngle': ```
-- #### *def* `cross(self, other: 'Vector3')` +### *def* `cross(self, other: 'Vector3') -> 'Vector3'` 向量积 叉乘:v1 cross v2 -> v3 @@ -112,7 +104,7 @@ def cal_angle(self, other: 'Vector3') -> 'AnyAngle': -- # +
源码 @@ -141,19 +133,19 @@ def cross(self, other: 'Vector3') -> 'Vector3': ```
-- #### *def* `is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX)` +### *def* `is_approx_parallel(self, other: 'Vector3', epsilon: float = APPROX) -> bool` 判断两个向量是否近似平行。 参数: -other: 另一个向量 +- other: 另一个向量 + +- epsilon: 允许的误差 -epsilon: 允许的误差 -- #
源码 @@ -171,17 +163,17 @@ def is_approx_parallel(self, other: 'Vector3', epsilon: float=APPROX) -> bool: ```
-- #### *def* `is_parallel(self, other: 'Vector3')` +### *def* `is_parallel(self, other: 'Vector3') -> bool` 判断两个向量是否平行。 参数: -other: 另一个向量 +- other: 另一个向量 + -- #
源码 @@ -198,7 +190,7 @@ def is_parallel(self, other: 'Vector3') -> bool: ```
-- #### *def* `normalize(self)` +### *def* `normalize(self)` 将向量归一化。 @@ -206,7 +198,7 @@ def is_parallel(self, other: 'Vector3') -> bool: 自体归一化,不返回值。 -- # +
源码 @@ -224,14 +216,14 @@ def normalize(self): ```
-- #### `@property` -- #### *def* `np_array(self)` +### `@property` +### *def* `np_array(self) -> 'np.ndarray'` + -- #
源码 @@ -246,18 +238,18 @@ def np_array(self) -> 'np.ndarray': ```
-- #### `@property` -- #### *def* `length(self)` +### `@property` +### *def* `length(self) -> float` 向量的模。 返回: -模 +- 模 + -- #
源码 @@ -273,18 +265,18 @@ def length(self) -> float: ```
-- #### `@property` -- #### *def* `unit(self)` +### `@property` +### *def* `unit(self) -> 'Vector3'` 获取该向量的单位向量。 返回: -单位向量 +- 单位向量 + -- #
源码 @@ -300,9 +292,9 @@ def unit(self) -> 'Vector3': ```
-- #### *def* `__abs__(self)` +### *def* `__abs__(self)` + -- #
源码 @@ -312,10 +304,10 @@ def __abs__(self): ```
-- #### `@overload` -- #### *def* `__add__(self, other: 'Vector3')` +### `@overload` +### *def* `__add__(self, other: 'Vector3') -> 'Vector3'` + -- #
源码 @@ -326,10 +318,10 @@ def __add__(self, other: 'Vector3') -> 'Vector3': ```
-- #### `@overload` -- #### *def* `__add__(self, other: 'Point3')` +### `@overload` +### *def* `__add__(self, other: 'Point3') -> 'Point3'` + -- #
源码 @@ -340,7 +332,7 @@ def __add__(self, other: 'Point3') -> 'Point3': ```
-- #### *def* `__add__(self, other)` +### *def* `__add__(self, other)` V + P -> P @@ -349,10 +341,10 @@ V + V -> V 参数: -other: +- other: + -- #
源码 @@ -376,17 +368,17 @@ def __add__(self, other): ```
-- #### *def* `__eq__(self, other)` +### *def* `__eq__(self, other)` 判断两个向量是否相等。 参数: -other: +- other: + -- #
源码 @@ -403,7 +395,7 @@ def __eq__(self, other): ```
-- #### *def* `__radd__(self, other: 'Point3')` +### *def* `__radd__(self, other: 'Point3') -> 'Point3'` P + V -> P @@ -413,7 +405,7 @@ P + V -> P :return: -- # +
源码 @@ -430,10 +422,10 @@ def __radd__(self, other: 'Point3') -> 'Point3': ```
-- #### `@overload` -- #### *def* `__sub__(self, other: 'Vector3')` +### `@overload` +### *def* `__sub__(self, other: 'Vector3') -> 'Vector3'` + -- #
源码 @@ -444,10 +436,10 @@ def __sub__(self, other: 'Vector3') -> 'Vector3': ```
-- #### `@overload` -- #### *def* `__sub__(self, other: 'Point3')` +### `@overload` +### *def* `__sub__(self, other: 'Point3') -> 'Point3'` + -- #
源码 @@ -458,7 +450,7 @@ def __sub__(self, other: 'Point3') -> 'Point3': ```
-- #### *def* `__sub__(self, other)` +### *def* `__sub__(self, other)` V - P -> P @@ -467,10 +459,10 @@ V - V -> V 参数: -other: +- other: + -- #
源码 @@ -493,17 +485,17 @@ def __sub__(self, other): ```
-- #### *def* `__rsub__(self, other: 'Point3')` +### *def* `__rsub__(self, other: 'Point3')` P - V -> P 参数: -other: +- other: + -- #
源码 @@ -523,10 +515,10 @@ def __rsub__(self, other: 'Point3'): ```
-- #### `@overload` -- #### *def* `__mul__(self, other: 'Vector3')` +### `@overload` +### *def* `__mul__(self, other: 'Vector3') -> 'Vector3'` + -- #
源码 @@ -537,10 +529,10 @@ def __mul__(self, other: 'Vector3') -> 'Vector3': ```
-- #### `@overload` -- #### *def* `__mul__(self, other: RealNumber)` +### `@overload` +### *def* `__mul__(self, other: RealNumber) -> 'Vector3'` + -- #
源码 @@ -551,17 +543,17 @@ def __mul__(self, other: RealNumber) -> 'Vector3': ```
-- #### *def* `__mul__(self, other: 'int | float | Vector3')` +### *def* `__mul__(self, other: 'int | float | Vector3') -> 'Vector3'` 数组运算 非点乘。点乘使用@,叉乘使用cross。 参数: -other: +- other: + -- #
源码 @@ -583,9 +575,9 @@ def __mul__(self, other: 'int | float | Vector3') -> 'Vector3': ```
-- #### *def* `__rmul__(self, other: 'RealNumber')` +### *def* `__rmul__(self, other: 'RealNumber') -> 'Vector3'` + -- #
源码 @@ -595,17 +587,17 @@ def __rmul__(self, other: 'RealNumber') -> 'Vector3': ```
-- #### *def* `__matmul__(self, other: 'Vector3')` +### *def* `__matmul__(self, other: 'Vector3') -> 'RealNumber'` 点乘。 参数: -other: +- other: + -- #
源码 @@ -621,9 +613,9 @@ def __matmul__(self, other: 'Vector3') -> 'RealNumber': ```
-- #### *def* `__truediv__(self, other: RealNumber)` +### *def* `__truediv__(self, other: RealNumber) -> 'Vector3'` + -- #
源码 @@ -633,9 +625,9 @@ def __truediv__(self, other: RealNumber) -> 'Vector3': ```
-- #### *def* `__neg__(self)` +### *def* `__neg__(self)` + -- #
源码 @@ -645,9 +637,9 @@ def __neg__(self): ```
-- #### *def* `__repr__(self)` +### *def* `__repr__(self)` + -- #
源码 @@ -657,9 +649,9 @@ def __repr__(self): ```
-- #### *def* `__str__(self)` +### *def* `__str__(self)` + -- #
源码 @@ -669,3 +661,11 @@ def __str__(self): ```
+### ***var*** `zero_vector3 = Vector3(0, 0, 0)` + +### ***var*** `x_axis = Vector3(1, 0, 0)` + +### ***var*** `y_axis = Vector3(0, 1, 0)` + +### ***var*** `z_axis = Vector3(0, 0, 1)` + diff --git a/docs/api/presets/model/index.md b/docs/api/presets/model/index.md index fee2a50..53ad44e 100644 --- a/docs/api/presets/model/index.md +++ b/docs/api/presets/model/index.md @@ -3,20 +3,20 @@ title: mbcp.presets.model --- ### ***class*** `GeometricModels` -- #### `@staticmethod` -- #### *def* `sphere(radius: float, density: float)` +### `@staticmethod` +### *def* `sphere(radius: float, density: float)` 生成球体上的点集。 参数: -radius: +- radius: + +- density: -density: -- #
源码 diff --git a/liteyuki_autodoc/docstring/docstring.py b/liteyuki_autodoc/docstring/docstring.py index f1e9855..de17c8a 100644 --- a/liteyuki_autodoc/docstring/docstring.py +++ b/liteyuki_autodoc/docstring/docstring.py @@ -121,29 +121,29 @@ class Docstring(BaseModel): """ PREFIX = "" * indent - if is_classmethod: - PREFIX = " -" ret = "" ret += self.desc + "\n\n" + # print(self.reduction()) + # print(self.desc, self.return_) if self.args: ret += PREFIX + f"{get_text(lang, 'docstring.args')}:\n\n" for arg in self.args: - ret += PREFIX + f"{arg.name}: {arg.type} {arg.desc}\n\n" + ret += PREFIX + f"- {arg.name}: {arg.type} {arg.desc}\n\n" if self.attrs: ret += PREFIX + f"{get_text(lang, 'docstring.attrs')}:\n\n" for attr in self.attrs: - ret += PREFIX + f"{attr.name}: {attr.type} {attr.desc}\n\n" - if self.return_: + ret += PREFIX + f"- {attr.name}: {attr.type} {attr.desc}\n\n" + if self.return_ is not None: ret += PREFIX + f"{get_text(lang, 'docstring.return')}:\n\n" - ret += PREFIX + f"{self.return_.desc}\n\n" + ret += PREFIX + f"- {self.return_.desc}\n\n" if self.raise_: ret += PREFIX + f"{get_text(lang, 'docstring.raises')}:\n\n" for exception in self.raise_: - ret += PREFIX + f"{exception.name} {exception.desc}\n\n" + ret += PREFIX + f"- {exception.name} {exception.desc}\n\n" if self.example: ret += PREFIX + f"{get_text(lang, 'docstring.example')}:\n\n" for example in self.example: - ret += PREFIX + f"{example.desc}\n Input: {example.input}\n Output: {example.output}\n\n" + ret += PREFIX + f"- {example.desc}\n Input: {example.input}\n Output: {example.output}\n\n" return ret def __str__(self): diff --git a/liteyuki_autodoc/docstring/parser.py b/liteyuki_autodoc/docstring/parser.py index 35d05c3..52e6b7c 100644 --- a/liteyuki_autodoc/docstring/parser.py +++ b/liteyuki_autodoc/docstring/parser.py @@ -115,17 +115,17 @@ class GoogleDocstringParser(Parser): 在一个子解析器中,解析下一行,直到缩进小于等于当前行的缩进 Returns: """ - while self.lineno + 1 < len(self.lines): + while (self.lineno + 1) < len(self.lines): line = self.lines[self.lineno + 1] - if line.startswith(" " * self.indent): line = line[self.indent:] + self.lineno += 1 + return line else: + self.lineno += 1 return None - if not line: - return None - self.lineno += 1 - return line + self.lineno += 1 + return None def parse(self) -> Docstring: """ @@ -146,7 +146,6 @@ class GoogleDocstringParser(Parser): add_desc = False match token: - case "args": self.parse_args() case "return": diff --git a/liteyuki_autodoc/style/markdown.py b/liteyuki_autodoc/style/markdown.py index 730becf..4f45d52 100644 --- a/liteyuki_autodoc/style/markdown.py +++ b/liteyuki_autodoc/style/markdown.py @@ -26,7 +26,6 @@ def generate(parser: AstParser, lang: str, frontmatter: Optional[dict] = None) - Returns: markdown style document """ - print(parser.variables) if frontmatter is not None: md = "---\n" for k, v in frontmatter.items(): @@ -36,20 +35,13 @@ def generate(parser: AstParser, lang: str, frontmatter: Optional[dict] = None) - md = "" # var > func > class - for var in parser.variables: - if var.type == TypeHint.NO_TYPEHINT: - md += f"### ***var*** `{var.name} = {var.value}`\n\n" - else: - md += f"### ***var*** `{var.name}: {var.type} = {var.value}`\n\n" for func in parser.functions: - md += func.markdown(lang) for cls in parser.classes: md += f"### ***class*** `{cls.name}`\n\n" for mtd in cls.methods: - md += mtd.markdown(lang, 2, True) for attr in cls.attrs: @@ -58,4 +50,10 @@ def generate(parser: AstParser, lang: str, frontmatter: Optional[dict] = None) - else: md += f"#### ***attr*** `{attr.name}: {attr.type} = {attr.value}`\n\n" + for var in parser.variables: + if var.type == TypeHint.NO_TYPEHINT: + md += f"### ***var*** `{var.name} = {var.value}`\n\n" + else: + md += f"### ***var*** `{var.name}: {var.type} = {var.value}`\n\n" + return md diff --git a/liteyuki_autodoc/syntax/astparser.py b/liteyuki_autodoc/syntax/astparser.py index c94e240..ae3889b 100644 --- a/liteyuki_autodoc/syntax/astparser.py +++ b/liteyuki_autodoc/syntax/astparser.py @@ -139,18 +139,18 @@ class AstParser: ) for default in node.args.defaults ], - return_=ast.unparse(node.returns).strip() if node.returns else TypeHint.NO_TYPEHINT, + return_=ast.unparse(node.returns).strip() if node.returns else TypeHint.NO_RETURN, decorators=[ast.unparse(decorator).strip() for decorator in node.decorator_list], is_async=isinstance(node, ast.AsyncFunctionDef), src=ast.unparse(node).strip() )) elif isinstance(node, (ast.Assign, ast.AnnAssign)): - if not self._is_module_level_variable(node): + if not self._is_module_level_variable2(node): # print("变量不在模块级别", ast.unparse(node)) continue else: - print("变量在模块级别", ast.unparse(node)) + pass if isinstance(node, ast.Assign): for target in node.targets: if isinstance(target, ast.Name): @@ -180,7 +180,39 @@ class AstParser: return False return True - def _is_module_level_variable(self, node: ast.Assign): + def _is_module_level_variable(self, node: ast.Assign | ast.AnnAssign): + """在类方法或函数内部的变量不会被记录""" + + # for parent in ast.walk(self.tree): + # if isinstance(parent, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)): + # if node in parent.body: + # return False + # else: + # for sub_node in parent.body: + # if isinstance(sub_node, (ast.FunctionDef, ast.AsyncFunctionDef)): + # if node in sub_node.body: + # return False + # return True + # 递归检查 + def _check(_node, _parent): + if isinstance(_parent, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)): + if _node in _parent.body: + return False + else: + for sub_node in _parent.body: + if isinstance(sub_node, (ast.FunctionDef, ast.AsyncFunctionDef)): + return _check(_node, sub_node) + return True + + for parent in ast.walk(self.tree): + if not _check(node, parent): + return False + return True + + def _is_module_level_variable2(self, node: ast.Assign | ast.AnnAssign) -> bool: + """ + 检查变量是否在模块级别定义。 + """ for parent in ast.walk(self.tree): if isinstance(parent, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)): if node in parent.body: diff --git a/liteyuki_autodoc/syntax/node.py b/liteyuki_autodoc/syntax/node.py index aecb3a5..1a31919 100644 --- a/liteyuki_autodoc/syntax/node.py +++ b/liteyuki_autodoc/syntax/node.py @@ -119,7 +119,7 @@ class FunctionNode(BaseModel): kw_defaults: list[ConstantNode] = [] defaults: list[ConstantNode] = [] - return_: str = Field(TypeHint.NO_RETURN, alias="return") + return_: str = TypeHint.NO_RETURN decorators: list[str] = [] src: str is_async: bool = False @@ -153,8 +153,8 @@ class FunctionNode(BaseModel): """ self.complete_default_args() PREFIX = "" * indent - if is_classmethod: - PREFIX = "- #" + # if is_classmethod: + # PREFIX = "- #" md = "" @@ -211,11 +211,14 @@ class FunctionNode(BaseModel): md += ", ".join(args) + ")" + if self.return_ != TypeHint.NO_RETURN: + md += f" -> {self.return_}" + md += "`\n\n" # code end """此处预留docstring""" if self.docs is not None: - md += f"\n{self.docs.markdown(lang, indent)}\n" + md += f"\n{self.docs.markdown(lang, indent, is_classmethod)}\n" else: pass # 源码展示 diff --git a/mbcp/mp_math/plane.py b/mbcp/mp_math/plane.py index dc260cb..121d31e 100644 --- a/mbcp/mp_math/plane.py +++ b/mbcp/mp_math/plane.py @@ -41,6 +41,8 @@ class Plane3: Returns: 是否近似相等 """ + + a = 3 # 测试变量 if self.a != 0: k = other.a / self.a return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k) diff --git a/mbcp/mp_math/point.py b/mbcp/mp_math/point.py index 35facf1..7a1bed6 100644 --- a/mbcp/mp_math/point.py +++ b/mbcp/mp_math/point.py @@ -62,15 +62,15 @@ class Point3: """ return approx(self.x, other.x) and approx(self.y, other.y) and approx(self.z, other.z) - # def __sub__(self, other: "Point3") -> "Vector3": - # """ - # P - P -> V - # - # P - V -> P 已在 :class:`Vector3` 中实现 - # Args: - # other: - # Returns: - # - # """ - # from .vector import Vector3 - # return Vector3(self.x - other.x, self.y - other.y, self.z - other.z) + def __sub__(self, other: "Point3") -> "Vector3": + """ + P - P -> V + + P - V -> P 已在 :class:`Vector3` 中实现 + Args: + other: + Returns: + + """ + from .vector import Vector3 + return Vector3(self.x - other.x, self.y - other.y, self.z - other.z)