提交 b70a3db8 编写于 作者: L luxin

add title field for config files

上级 66b55577
......@@ -33,5 +33,6 @@
],
"export": [
"helloworld.json"
]
],
"title": "C语言发展史"
}
\ No newline at end of file
......@@ -82,5 +82,6 @@
"export": [
"features.json"
],
"node_id": "c-946fc2eeba644ecf93e68974bf69f42a"
"node_id": "c-946fc2eeba644ecf93e68974bf69f42a",
"title": "C语言特点"
}
\ No newline at end of file
......@@ -72,5 +72,6 @@
"export": [
"standard.json"
],
"node_id": "c-3a6b78e1a4804917a5d48231f0cd87ea"
"node_id": "c-3a6b78e1a4804917a5d48231f0cd87ea",
"title": "C语言标准"
}
\ No newline at end of file
......@@ -97,5 +97,6 @@
"export": [
"compiler.json"
],
"node_id": "c-be9d40c8fc0e49c9bbc1e3a0b60b7960"
"node_id": "c-be9d40c8fc0e49c9bbc1e3a0b60b7960",
"title": "编程机制"
}
\ No newline at end of file
......@@ -4,5 +4,6 @@
"概述",
"C语言概述",
"C语言"
]
],
"title": "C语言概述"
}
\ No newline at end of file
......@@ -7,5 +7,6 @@
"children": [],
"export": [
"variables.json"
]
],
"title": "变量"
}
\ No newline at end of file
......@@ -7,5 +7,6 @@
"export": [
"constants.json"
],
"node_id": "c-d3cd094b74334fa3b123b896788aa1ca"
"node_id": "c-d3cd094b74334fa3b123b896788aa1ca",
"title": "常量"
}
\ No newline at end of file
......@@ -49,5 +49,6 @@
"export": [
"basic_data_types.json"
],
"node_id": "c-4fd1baa5eb72451aa52e5ef801376f6f"
"node_id": "c-4fd1baa5eb72451aa52e5ef801376f6f",
"title": "基本数据类型"
}
\ No newline at end of file
......@@ -5,5 +5,6 @@
],
"children": [],
"export": [],
"node_id": "c-c7ef387bd4bf4bd0a87d1886e66160c5"
"node_id": "c-c7ef387bd4bf4bd0a87d1886e66160c5",
"title": "数据类型"
}
\ No newline at end of file
......@@ -11,5 +11,6 @@
"children": [],
"export": [
"assignment_op.json"
]
],
"title": "赋值运算符与表达式"
}
\ No newline at end of file
......@@ -82,5 +82,6 @@
"export": [
"arithmetic_op.json"
],
"node_id": "c-e985fb409a3a43798aa3103cebe813e3"
"node_id": "c-e985fb409a3a43798aa3103cebe813e3",
"title": "算术运算符与表达式"
}
\ No newline at end of file
......@@ -72,5 +72,6 @@
"export": [
"relational_op.json"
],
"node_id": "c-08dec025530542b695719ef950730a69"
"node_id": "c-08dec025530542b695719ef950730a69",
"title": "关系运算符与表达式"
}
\ No newline at end of file
......@@ -45,5 +45,6 @@
"export": [
"logical_op.json"
],
"node_id": "c-d4ed32eedaed4d44be139eb578ed9f92"
"node_id": "c-d4ed32eedaed4d44be139eb578ed9f92",
"title": "逻辑运算符与表达式"
}
\ No newline at end of file
......@@ -11,5 +11,6 @@
"children": [],
"export": [
"comma_op.json"
]
],
"title": "逗号运算符与表达式"
}
\ No newline at end of file
......@@ -11,5 +11,6 @@
"export": [
"conditional_op.json"
],
"node_id": "c-1d3d9e97b98b4151b87c4433d987af83"
"node_id": "c-1d3d9e97b98b4151b87c4433d987af83",
"title": "条件运算符"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"sizeof_op.json"
]
],
"title": "sizeof运算符"
}
\ No newline at end of file
......@@ -11,5 +11,6 @@
"children": [],
"export": [
"precedence.json"
]
],
"title": "运算符优先级与求值顺序"
}
\ No newline at end of file
......@@ -6,5 +6,6 @@
],
"children": [],
"export": [],
"node_id": "c-5002624ecc8d4be1a3d8eab4579ac7b8"
"node_id": "c-5002624ecc8d4be1a3d8eab4579ac7b8",
"title": "运算符与表达式"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"statements_n_blocks.json"
]
],
"title": "语句与程序块"
}
\ No newline at end of file
......@@ -61,5 +61,6 @@
"ifelse.json",
"elseif.json",
"switch.json"
]
],
"title": "判断语句"
}
\ No newline at end of file
......@@ -77,5 +77,6 @@
"for.json",
"goto.json",
"while.json"
]
],
"title": "循环语句"
}
\ No newline at end of file
......@@ -7,5 +7,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "语句与控制流"
}
\ No newline at end of file
{
"node_id": "c-97bc6d47966c47979a9c78cc36741ade",
"keywords": []
"keywords": [],
"title": "C语言初阶"
}
\ No newline at end of file
......@@ -11,5 +11,6 @@
"children": [],
"export": [
"definition.json"
]
],
"title": "函数的声明与定义"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"parameter_n_argument.json"
]
],
"title": "函数的参数"
}
\ No newline at end of file
......@@ -10,5 +10,6 @@
"children": [],
"export": [
"return.json"
]
],
"title": "函数的返回"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"function_call.json"
]
],
"title": "函数的调用"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"recursion.json"
]
],
"title": "函数的递归"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"global_n_local_var.json"
]
],
"title": "局部变量和全局变量"
}
\ No newline at end of file
......@@ -5,5 +5,8 @@
"C语言"
],
"children": [],
"export": ["header.json"]
"export": [
"header.json"
],
"title": "头文件"
}
\ No newline at end of file
......@@ -6,5 +6,8 @@
"C语言"
],
"children": [],
"export": ["ex_in_function.json"]
"export": [
"ex_in_function.json"
],
"title": "内部函数和外部函数"
}
\ No newline at end of file
......@@ -4,5 +4,6 @@
"函数",
"程序结构",
"C语言"
]
],
"title": "函数与程序结构"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"array_def.json"
]
],
"title": "数组简介"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"bubble_sort.json"
]
],
"title": "一维数组"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"matrix.json"
]
],
"title": "二维数组"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"vla.json"
]
],
"title": "变长数组"
}
\ No newline at end of file
......@@ -5,5 +5,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "数组"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"pointers.json"
]
],
"title": "指针与地址"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"pointers_n_func.json"
]
],
"title": "指针与函数参数"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"pointers_n_array.json"
]
],
"title": "指针与数组"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"pointers_arithmetic_op.json"
]
],
"title": "地址算术运算"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"pointers_array.json"
]
],
"title": "指针数组以及指向指针的指针"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"pointers_2_func.json"
]
],
"title": "指向函数的指针"
}
\ No newline at end of file
......@@ -5,5 +5,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "指针"
}
\ No newline at end of file
......@@ -11,5 +11,6 @@
"export": [
"string_io.json"
],
"node_id": "c-bbd1310e647846018a1ff37d29c70ff0"
"node_id": "c-bbd1310e647846018a1ff37d29c70ff0",
"title": "字符串输入与输出"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"export": [
"string_func.json"
],
"node_id": "c-2aa6707a4e0244dfab606b030f5c35c9"
"node_id": "c-2aa6707a4e0244dfab606b030f5c35c9",
"title": "字符串函数"
}
\ No newline at end of file
......@@ -5,5 +5,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "字符串"
}
\ No newline at end of file
{
"node_id": "c-0b3c295f0ba24708845505ee4583303e",
"keywords": []
"keywords": [],
"title": "C语言中阶"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"structures.json"
]
],
"title": "结构体简介"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"structures_array.json"
]
],
"title": "结构体数组"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"structures_pointers.json"
]
],
"title": "结构体指针"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"structures_n_func.json"
]
],
"title": "结构体与函数"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"linked_list.json"
]
],
"title": "链式结构"
}
\ No newline at end of file
......@@ -3,5 +3,6 @@
"keywords": [
"结构体",
"C语言"
]
],
"title": "结构体"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"unions.json"
]
],
"title": "联合体"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"enum.json"
]
],
"title": "枚举类型"
}
\ No newline at end of file
......@@ -7,5 +7,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "联合体与枚举类型"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"check.json"
]
],
"title": "位和字节"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"count.json"
]
],
"title": "二进制"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"oct.json"
]
],
"title": "八进制"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"bin_to_hex.json"
]
],
"title": "十六进制"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"bit_op.json"
]
],
"title": "位逻辑运算符"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"export": [
"pack01.json",
"pack02.json"
]
],
"title": "对齐特性"
}
\ No newline at end of file
......@@ -7,5 +7,6 @@
"children": [],
"export": [
"bit_field.json"
]
],
"title": "位字段"
}
\ No newline at end of file
......@@ -6,5 +6,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "位运算"
}
\ No newline at end of file
......@@ -10,5 +10,6 @@
"define_func_1.json",
"define_func_2.json",
"define_func_3.json"
]
],
"title": "宏定义"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"export": [
"calc.json",
"calc_test.json"
]
],
"title": "#include指令"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"undef.json"
]
],
"title": "#undef指令"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"export": [
"ifdef01.json",
"ifdef02.json"
]
],
"title": "条件编译"
}
\ No newline at end of file
......@@ -7,5 +7,6 @@
"children": [],
"export": [
"inline01.json"
]
],
"title": "内联函数"
}
\ No newline at end of file
......@@ -6,5 +6,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "预处理器"
}
\ No newline at end of file
......@@ -39,5 +39,6 @@
}
}
],
"export": []
"export": [],
"title": "文件的基本操作"
}
\ No newline at end of file
......@@ -8,5 +8,6 @@
"children": [],
"export": [
"file_hash.json"
]
],
"title": "文件的读写"
}
\ No newline at end of file
......@@ -5,5 +5,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "文件"
}
\ No newline at end of file
......@@ -5,5 +5,8 @@
"C语言"
],
"children": [],
"export": ["storage_categories.json"]
"export": [
"storage_categories.json"
],
"title": "存储类别"
}
\ No newline at end of file
......@@ -32,5 +32,6 @@
],
"export": [
"memory_management.json"
]
],
"title": "内存动态管理"
}
\ No newline at end of file
......@@ -6,5 +6,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "存储管理"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"math.json"
]
],
"title": "数学库"
}
\ No newline at end of file
......@@ -7,5 +7,8 @@
"C语言"
],
"children": [],
"export": ["qsort.json"]
"export": [
"qsort.json"
],
"title": "通用工具库"
}
\ No newline at end of file
......@@ -9,5 +9,6 @@
"children": [],
"export": [
"assert.json"
]
],
"title": "断言库"
}
\ No newline at end of file
......@@ -6,5 +6,6 @@
"C语言"
],
"children": [],
"export": []
"export": [],
"title": "标准函数库"
}
\ No newline at end of file
{
"node_id": "c-29426c5de15a472ba147b32bd24b73a5",
"keywords": []
"keywords": [],
"title": "C语言高阶"
}
\ No newline at end of file
{
"tree_name": "C",
"keywords": [],
"node_id": "c-569d5e11c4fc5de7844053d9a733c5e8"
"node_id": "c-569d5e11c4fc5de7844053d9a733c5e8",
"title": "C"
}
\ No newline at end of file
......@@ -68,6 +68,7 @@ def gen_tree(data_path):
def ensure_id_helper(node):
flag = False
if (node.get('node_id') is None) or node.get('node_id') in id_set:
node['node_id'] = gen_node_id()
flag = True
......@@ -83,6 +84,25 @@ def gen_tree(data_path):
def ensure_node_id(cfg):
return ensure_id_helper(cfg)
def ensure_title_helper(node, cfg_path, title=""):
flag = False
if node.get('title') is None:
if cfg_path:
node['title'] = re.sub("^[0-9]{1,3}\.", "", os.path.split(os.path.dirname(cfg_path))[-1])
else:
node['title'] = title
flag = True
if 'children' in node:
for c in node["children"]:
flag = flag or ensure_title_helper(list(c.values())[0], None, list(c.keys())[0])
return flag
def ensure_title(cfg, cfg_path):
return ensure_title_helper(cfg, cfg_path)
def make_node(name, node_id, keywords, children=None):
node = {}
node_children = children or []
......@@ -98,6 +118,10 @@ def gen_tree(data_path):
cfg = load_json(cfg_path)
if ensure_node_id(cfg):
dump_json(cfg_path, cfg)
if ensure_title(cfg, cfg_path):
cfg["title"] = "C"
dump_json(cfg_path, cfg, exist_ok=True, override=True)
tree_node = {
"node_id": cfg['node_id'],
"keywords": cfg['keywords'],
......@@ -113,6 +137,8 @@ def gen_tree(data_path):
level_cfg = load_json(level_path)
if ensure_node_id(level_cfg) or check_export(level_no_dir, level_cfg):
dump_json(level_path, level_cfg, exist_ok=True, override=True)
if ensure_title(level_cfg, level_path):
dump_json(level_path, level_cfg, exist_ok=True, override=True)
level_node, level_node_children = make_node(
level_name, level_cfg['node_id'], level_cfg['keywords'])
......@@ -125,6 +151,8 @@ def gen_tree(data_path):
chapter_cfg = load_json(chapter_path)
if ensure_node_id(chapter_cfg) or check_export(chapter_no_dir, chapter_cfg):
dump_json(chapter_path, chapter_cfg, exist_ok=True, override=True)
if ensure_title(chapter_cfg, chapter_path):
dump_json(chapter_path, chapter_cfg, exist_ok=True, override=True)
chapter_node, chapter_node_children = make_node(
chapter_name, chapter_cfg['node_id'], chapter_cfg['keywords'])
......@@ -156,6 +184,9 @@ def gen_tree(data_path):
if flag:
dump_json(sec_path, sec_cfg, exist_ok=True, override=True)
if ensure_title(sec_cfg, sec_path):
dump_json(sec_path, sec_cfg, exist_ok=True, override=True)
# 保存技能树骨架
tree_path = os.path.join(data_path, 'tree.json')
dump_json(tree_path, root, exist_ok=True, override=True)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册