Compare commits
No commits in common. "1127dff969670cf5c5db49d4634bca442df42d29" and "14dd7b1cfa46e1a080e943f58fdef8c36137b2e5" have entirely different histories.
1127dff969
...
14dd7b1cfa
9
.idea/.gitignore
generated
vendored
9
.idea/.gitignore
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
# 默认忽略的文件
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# 基于编辑器的 HTTP 客户端请求
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
*
|
|
@ -1,5 +1,21 @@
|
|||||||
---
|
---
|
||||||
module
|
```toml
|
||||||
|
tags = [
|
||||||
|
"小型模块",
|
||||||
|
"算术运算模块",
|
||||||
|
"加/减法器",
|
||||||
|
"二级模块",
|
||||||
|
"静音",
|
||||||
|
"传统红石",
|
||||||
|
"无容器",
|
||||||
|
"Java版"
|
||||||
|
]
|
||||||
|
authors = ["Fredbill"]
|
||||||
|
title = "CCA-vertial-20gt-32bit"
|
||||||
|
description = "竖式 32位 20gt 加法器"
|
||||||
|
[version]
|
||||||
|
java = "1.16+"
|
||||||
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
# 32位封闭进位加法器
|
# 32位封闭进位加法器
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pprint import pprint
|
|
||||||
|
|
||||||
import mistune
|
import mistune
|
||||||
|
|
||||||
@ -10,7 +9,6 @@ from lib_not_dr.types.options import Options
|
|||||||
|
|
||||||
|
|
||||||
ast_markdown = mistune.create_markdown(renderer='ast')
|
ast_markdown = mistune.create_markdown(renderer='ast')
|
||||||
ast_type = list[dict[str, str | dict]]
|
|
||||||
|
|
||||||
|
|
||||||
class TagParser(Options):
|
class TagParser(Options):
|
||||||
@ -61,48 +59,7 @@ class TagParser(Options):
|
|||||||
def init(self, **kwargs) -> bool:
|
def init(self, **kwargs) -> bool:
|
||||||
self.logger = loggers.get_logger()
|
self.logger = loggers.get_logger()
|
||||||
self.logger.global_level = 0
|
self.logger.global_level = 0
|
||||||
self.load_tags()
|
return True
|
||||||
return False
|
|
||||||
|
|
||||||
def load_tags(self):
|
|
||||||
tag_list_path = Path("./tags/readme.md")
|
|
||||||
if not tag_list_path.exists():
|
|
||||||
self.logger.error("未找到 tags/readme.md")
|
|
||||||
return False
|
|
||||||
|
|
||||||
with open(tag_list_path, 'r', encoding='utf-8') as f:
|
|
||||||
file = f.read()
|
|
||||||
|
|
||||||
tag_ast: ast_type = ast_markdown(file)
|
|
||||||
start_tag = -1
|
|
||||||
for i, node in enumerate(tag_ast):
|
|
||||||
if node['type'] != 'heading':
|
|
||||||
continue
|
|
||||||
if node['attrs']['level'] != 2:
|
|
||||||
continue
|
|
||||||
# 说明是二级标题
|
|
||||||
start_tag = i
|
|
||||||
break
|
|
||||||
if start_tag == -1:
|
|
||||||
self.logger.error("未找到二级标题")
|
|
||||||
return False
|
|
||||||
# 获取 tag
|
|
||||||
tag_ast: ast_type = tag_ast[start_tag + 1:]
|
|
||||||
|
|
||||||
start_tag = -1
|
|
||||||
for i, node in enumerate(tag_ast):
|
|
||||||
if node['type'] != 'list':
|
|
||||||
continue
|
|
||||||
start_tag = i
|
|
||||||
break
|
|
||||||
if start_tag == -1:
|
|
||||||
self.logger.error("未找到 tag 列表")
|
|
||||||
return False
|
|
||||||
tag_ast: ast_type = [item['children'] for item in tag_ast[start_tag]['children'] if item.get('type') == 'list_item']
|
|
||||||
# 顺手过滤一下
|
|
||||||
pprint(tag_ast)
|
|
||||||
self.logger.info(tag_ast)
|
|
||||||
# 获取 tag 列表
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -4,10 +4,7 @@
|
|||||||
|
|
||||||
## 所有可用标签
|
## 所有可用标签
|
||||||
|
|
||||||
- [小型模块](./tags/small_module.md)
|
- [小型模块](./tags/small_module.md) : 方块数量小于10000的模块
|
||||||
- 方块数量小于10000的模块
|
|
||||||
- 别名
|
|
||||||
- 小模块
|
|
||||||
- [中型模块](./tags/middle_size_module.md) : 方块数量在10001-100000之间的模块。
|
- [中型模块](./tags/middle_size_module.md) : 方块数量在10001-100000之间的模块。
|
||||||
- [大型模块](./tags/large_module.md) : 方块数量>100000的模块。
|
- [大型模块](./tags/large_module.md) : 方块数量>100000的模块。
|
||||||
- [算术单元](./tags/au.md) : 具有运算功能的模块。
|
- [算术单元](./tags/au.md) : 具有运算功能的模块。
|
||||||
|
Loading…
Reference in New Issue
Block a user