forked from 2liang/AutoBuildDocFromDB
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMarkdownBuildClass.py
More file actions
executable file
·23 lines (20 loc) · 960 Bytes
/
MarkdownBuildClass.py
File metadata and controls
executable file
·23 lines (20 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding:utf-8 -*-
class MarkDownBuild:
table_header = '|字段名称|字段类型|字段含义|\n|:---:|:---:|:---:|\n'
table_content_template = '|%s|%s|%s|\n'
def __init__(self):
pass
def buildMarkdown(self, table_data):
text = '# 数据库文档\n\n'
text += '<a name="返回顶部"></a>\n\n## 数据表列表\n\n'
for table in table_data:
text = text + '* [' + table[0][0] + '(' + table[0][1] + ')](#' + table[0][0] + '_pointer)\n\n'
text += '\n\n## 数据表说明\n\n'
for table in table_data:
text = text + '<a name="'+table[0][0]+'_pointer"></a>\n\n'
text = text + '* ' + table[0][0] + '表(' + table[0][1] + ')[↑](#返回顶部)\n\n'
text += self.table_header
for column in table[1]:
text = text + '|' + column[0] + '|' + column[1] + '|' + column[2] + '|\n'
text += '\n'
return text