From 9640592a1d2ea87e56b189d73307fe5dc12a517b Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 10 Dec 2016 18:09:30 -0600 Subject: [PATCH] doc: extract: further cleanups --- doc/extract.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/extract.py b/doc/extract.py index 7d62cc1..5f97208 100644 --- a/doc/extract.py +++ b/doc/extract.py @@ -21,8 +21,17 @@ class Comment: for line in lines: if line[0:3] == ' * ': cleanlines.append(line[3:]) + elif len(line) == 2: + cleanlines.append('') return '\n'.join(cleanlines) + @property + def doc_text(self): + text = self.clean_text + if '!doc' in text[0:4]: + return text[5:] + return None + class FileError(Exception): pass @@ -135,4 +144,6 @@ if __name__ == '__main__': import sys from pprint import pprint - pprint([c.clean_text for c in extract_comments(sys.argv[1])]) + comments = [comment for comment in extract_comments(sys.argv[1]) if comment.doc_text] + for comment in comments: + print(comment.doc_text)