-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
414 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# AnnotationTypeEnum 枚举 | ||
|
||
## 概述 | ||
|
||
`AnnotationTypeEnum` 枚举是所有注释种类枚举类的基类。内部无枚举值,只用于被继承。 | ||
|
||
模块:[pymaidol.AnnotationType](AnnotationType模块.md) | ||
|
||
继承自:`enum.Enum` | ||
|
||
## 导入 | ||
|
||
```python | ||
from pymaidol import AnnotationTypeEnum | ||
``` | ||
|
||
或 | ||
|
||
```python | ||
from pymaidol.AnnotationType import AnnotationTypeEnum | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# AnnotationType 模块 | ||
|
||
## 概述 | ||
|
||
`AnnotationType` 模块提供了可在模板设计文件中`.pymd`使用的注释的枚举类型。 | ||
|
||
模块:`pymaidol` | ||
|
||
## 导入 | ||
|
||
```python | ||
from pymaidol import AnnotationType | ||
``` | ||
|
||
## 类 | ||
|
||
名称 | 描述 | ||
--- | --- | ||
[AnnotationTypeEnum 枚举](AnnotationTypeEnum枚举.md) | `AnnotationTypeEnum` 枚举是所有注释种类枚举类的基类。内部无枚举值,只用于被继承。 | ||
[SingleLineAnnotationTypeEnum 枚举](SingleLineAnnotationTypeEnum枚举.md) | 包含了可在模板设计文件中`.pymd`使用的单行注释的类型。 | ||
[MultiLineAnnotationTypeEnum 枚举](MultiLineAnnotationTypeEnum枚举.md) | 包含了可在模板设计文件中`.pymd`使用的多行注释的类型。 | ||
|
||
## 静态变量 | ||
|
||
名称 | 类型 | 描述 | ||
--- | --- | --- | ||
FULL_ANNOTATION_TYPE | `list[AnnotationTypeEnum]` | 包含了所有注释种类枚举类的枚举值的列表。 |
29 changes: 29 additions & 0 deletions
29
docs/zh-cn/AnnotationType/MultiLineAnnotationTypeEnum枚举.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# MultiLineAnnotationTypeEnum 枚举 | ||
|
||
## 概述 | ||
|
||
包含了可在模板设计文件中`.pymd`使用的多行注释的类型。 | ||
|
||
模块:[pymaidol.AnnotationType](AnnotationType模块.md) | ||
|
||
继承自:[pymaidol.AnnotationType.AnnotationTypeEnum](AnnotationTypeEnum枚举.md) | ||
|
||
## 导入 | ||
|
||
```python | ||
from pymaidol import MultiLineAnnotationTypeEnum | ||
``` | ||
|
||
或 | ||
|
||
```python | ||
from pymaidol.AnnotationType import MultiLineAnnotationTypeEnum | ||
``` | ||
|
||
## 枚举项 | ||
|
||
名称 | 值 | 描述 | ||
--- | --- | --- | ||
Python | ''' | Python 的多行注释,即以 `'''` 开头和结尾的注释。 | ||
C | /\* | C 的多行注释,即以 `/\*` 开头和 `*/` 结尾的注释。 | ||
HTML | \<!-- | HTML 的多行注释,即以 `<!--` 开头和 `-->` 结尾的注释。 |
32 changes: 32 additions & 0 deletions
32
docs/zh-cn/AnnotationType/SingleLineAnnotationTypeEnum枚举.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SingleLineAnnotationTypeEnum 枚举 | ||
|
||
## 概述 | ||
|
||
包含了可在模板设计文件中`.pymd`使用的单行注释的类型。 | ||
|
||
模块:[pymaidol.AnnotationType](AnnotationType模块.md) | ||
|
||
继承自:[pymaidol.AnnotationType.AnnotationTypeEnum](AnnotationTypeEnum枚举.md) | ||
|
||
## 导入 | ||
|
||
```python | ||
from pymaidol import SingleLineAnnotationTypeEnum | ||
``` | ||
|
||
或 | ||
|
||
```python | ||
from pymaidol.AnnotationType import SingleLineAnnotationTypeEnum | ||
``` | ||
|
||
## 枚举项 | ||
|
||
名称 | 值 | 描述 | ||
--- | --- | --- | ||
Python | # | Python 的单行注释,即以 `#` 开头的注释。 | ||
C | // | C 的单行注释,即以 `//` 开头的注释。 | ||
|
||
## 另请参阅 | ||
|
||
[AnnotationTypeEnum 枚举](AnnotationTypeEnum枚举.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Position 类 | ||
|
||
## 概述 | ||
|
||
`Position` 类用于定位在原始模板字符串中的位置。 | ||
|
||
`Position` 的对象里的属性是只读的,初始化之后不允许被修改。 | ||
|
||
注意:当 `Position` 类用于结束位置时,是包括该位置的字符的。比如:如果 `start.total = 20`, `end.total = 30`,那么对原模板字符串的切片应该为 `template[20:31]`。 | ||
|
||
模块:pymaidol.Positions | ||
|
||
## 导入 | ||
|
||
```python | ||
from pymaidol import Position | ||
``` | ||
|
||
或 | ||
|
||
```python | ||
from pymaidol.Positions import Position | ||
``` | ||
|
||
## 构造函数 | ||
|
||
### `Position(line_index, char_index, total)` | ||
|
||
#### 参数 | ||
|
||
- `line_index` (int): 行索引。从 0 开始。 | ||
- `char_index` (int): 当前行的字符索引。从 0 开始。 | ||
- `total` (int): 字符索引。从 0 开始。 | ||
|
||
## 属性 | ||
|
||
### `line_index` (int,readonly) | ||
|
||
行索引。从 0 开始。 | ||
|
||
### `char_index` (int,readonly) | ||
|
||
当前行的字符索引。从 0 开始。 | ||
|
||
### `total` (int,readonly) | ||
|
||
字符索引。从 0 开始。 | ||
|
||
### `full_description` (str,readonly) | ||
|
||
完整的、人类可读的位置描述。 | ||
|
||
## 方法 | ||
|
||
### `Position.Default()` | ||
|
||
@ classmethod | ||
|
||
新建并返回一个默认的 `Position` 对象,其所有属性均为 0。 | ||
|
||
#### 参数 | ||
|
||
无。 | ||
|
||
#### 返回值 (`Position`) | ||
|
||
默认的 `Position` 对象。 | ||
|
||
### `Copy()` | ||
|
||
复制并返回一个新的 `Position` 对象。 | ||
|
||
#### 参数 | ||
|
||
无。 | ||
|
||
#### 返回值 (`Position`) | ||
|
||
新的 `Position` 对象,且其所有属性与原对象相同。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Pymaidol API 目录 | ||
|
||
## 模块 | ||
|
||
名称 | 描述 | ||
--- | --- | ||
[AnnotationType 模块](AnnotationType/AnnotationType模块.md) | 提供了可在模板设计文件中`.pymd`使用的注释的枚举类型。 | ||
|
||
## 类 | ||
|
||
名称 | 描述 | ||
--- | --- | ||
[Position 类](Position类.md) | 用于定位在原始模板字符串中的位置。 | ||
[TemplateBase 类](TemplateBase类.md) | Pymaidol 模板的后台类,是所有 Pymaidol 模板类的基类。 | ||
[TemplateRenderer 类](TemplateRenderer类.md) | 将模板字符串渲染为字符串的类。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# TemplateBase 类 | ||
|
||
## 概述 | ||
|
||
`TemplateBase` 类是 Pymaidol 模板的后台类,是所有 Pymaidol 模板类的基类。是不可实例化的抽象类,需要被继承使用。 | ||
|
||
模块:pymaidol.TemplateBase | ||
|
||
继承自:abc.ABC | ||
|
||
## 导入 | ||
|
||
```python | ||
from pymaidol import TemplateBase | ||
``` | ||
|
||
或 | ||
|
||
```python | ||
from pymaidol.TemplateBase import TemplateBase | ||
``` | ||
|
||
## 构造函数 | ||
|
||
### `TemplateBase(template, template_file_path, supported_annotation_types)` (virtual) | ||
|
||
#### 参数 | ||
|
||
- `template` (str, optional): 模板字符串。默认为 `None`。 | ||
- `template_file_path` (str, optional): 模板文件路径。默认为 `None`。 | ||
- `supported_annotation_types` (list[AnnotationTypeEnum], optional): 支持的注释类型列表。默认为所有注释类型(Python、C的单行与多行注释、HTML注释)。 | ||
|
||
当 `template` 与 `template_file_path` 都为 `None` 时,`TemplateBase` 类及其子类将试图读取在与其同一目录下、与其同名的模板文件 `.pymd`。如果两个都不为空,则优先使用 `template`。 | ||
|
||
## 属性 | ||
|
||
### `rendered`(str,readonly) | ||
|
||
渲染后的字符串。如果自初始化或调用 `HotReload()` 方法以来没有调用过 `Render()` 方法,则为 `None`。 | ||
|
||
### `template`(str,readonly) | ||
|
||
模板字符串。 | ||
|
||
## 方法 | ||
|
||
### `HotReload(template, template_file_path)` (final) | ||
|
||
重新加载模板。 | ||
|
||
#### 参数 | ||
|
||
- `template` (str, optional): 模板字符串。默认为 `None`。 | ||
- `template_file_path` (str, optional): 模板文件路径。默认为 `None`。 | ||
|
||
当 `template` 与 `template_file_path` 都为 `None` 时,`TemplateBase` 类及其子类将试图读取在与其同一目录下、与其同名的模板文件 `.pymd`。如果两个都不为空,则优先使用 `template`。 | ||
|
||
#### 返回值 (`None`) | ||
|
||
无。 | ||
|
||
|
||
### `Render(inject_kwargs)` (final) | ||
|
||
给与数据并渲染模板字符串。 | ||
|
||
#### 参数 | ||
|
||
- `inject_kwargs` (dict, Optional): 用于渲染模板字符串的外部注入变量。默认为 `None`。注入的变量将会作为局部变量。 | ||
|
||
#### 返回值 (`str`) | ||
|
||
渲染后的字符串。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# TemplateRenderer 类 | ||
|
||
## 概述 | ||
|
||
将模板字符串渲染为字符串的类。 | ||
|
||
模块:pymaidol.TemplateRenderer | ||
|
||
## 导入 | ||
|
||
```python | ||
from pymaidol import TemplateRenderer | ||
``` | ||
|
||
或 | ||
|
||
```python | ||
from pymaidol.TemplateRenderer import TemplateRenderer | ||
``` | ||
|
||
## 构造函数 | ||
|
||
### `TemplateRenderer(template, supported_annotation_types)` | ||
|
||
#### 参数 | ||
|
||
- `template` (str): 模板字符串。 | ||
- `supported_annotation_types` (list[AnnotationTypeEnum], optional): 支持的注释类型列表。默认为所有注释类型(Python、C的单行与多行注释、HTML注释)。 | ||
|
||
## 属性 | ||
|
||
### `template`(str,readonly) | ||
|
||
模板字符串。 | ||
|
||
## 方法 | ||
|
||
### `TemplateRenderer.ReadFromFile(template_file_path, supported_annotation_types)` (classmethod) | ||
|
||
给定模板文件路径,返回一个 `TemplateRenderer` 对象。 | ||
|
||
#### 参数 | ||
|
||
- `template_file_path` (str): 模板文件路径。 | ||
- `supported_annotation_types` (list[AnnotationTypeEnum]): 支持的注释类型列表。 | ||
|
||
#### 返回值 | ||
|
||
`TemplateRenderer`: `TemplateRenderer` 对象。 | ||
|
||
### `Render(local_vars, global_vars)` (final) | ||
|
||
给与数据并渲染模板字符串。 | ||
|
||
#### 参数 | ||
|
||
- `local_vars` (dict): 用于渲染模板字符串的局部变量。 | ||
- `global_vars` (dict,可选): 用于渲染模板字符串的全局变量。默认为 `None`。 | ||
|
||
#### 返回值 | ||
|
||
`str`: 渲染后的字符串。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.