From 982b309fb39132d7d01e39c087e69b059131646b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E6=89=8D=E6=98=AF=E4=BA=8C=E4=BA=AE?= Date: Sun, 6 Mar 2016 19:51:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=95=B0=E6=8D=AE=E5=BA=93=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E6=9E=84=E5=BB=BA=E6=88=90markdown=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarkdownBuildClass.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/MarkdownBuildClass.py b/MarkdownBuildClass.py index 0371118..532f2da 100644 --- a/MarkdownBuildClass.py +++ b/MarkdownBuildClass.py @@ -1,6 +1,17 @@ # -*- coding:utf-8 -*- -import re -content = "`id` mediumint(8) NOT NULL AUTO_INCREMENT COMMENT='hello'," -pattern = r'NOT(.*?)AUTO_INCREMENT' -print re.match(pattern, content.strip()).group(1) -# print(re.match(pattern, content).group(1)) \ No newline at end of file +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' + for table in table_data: + text = text + '## ' + table[0][0] + '表(' + table[0][1] + ')\n' + text += self.table_header + for column in table[1]: + text = text + '|' + column[0] + '|' + column[1] + '|' + column[2] + '|\n' + return text \ No newline at end of file