From fc3f2c3e3c6b83089e2a63eb0b1681356c0acc81 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 24 Nov 2013 14:37:56 +0100 Subject: [PATCH] Support for bulletpoint lists and 1.1 release --- setup.py | 2 +- site/documentation.zpy | 15 +++++++++++++++ src/zippydoc/block_markup.py | 4 ++++ src/zippydoc/document.py | 3 +++ src/zippydoc/transformation_ruleset.py | 3 +++ zpy2html | 3 +++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 920e824..c6856cf 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ print repr(package_data) setup( name='zippydoc', - version='1.0', + version='1.1', maintainer='Sven Slootweg', maintainer_email='admin@cryto.net', description='Documentation markup language and library, including HTML converter.', diff --git a/site/documentation.zpy b/site/documentation.zpy index 7304ec2..79f9440 100644 --- a/site/documentation.zpy +++ b/site/documentation.zpy @@ -231,6 +231,21 @@ starting a new block. $$ ####### This is a level 7 (smallest) header. +^ List block + + ! This block cannot have child elements! + + A list block is a list containing items. In HTML, it's rendered as a bulletpoint list. Each item is prefixed with an asterisk. Items can consist of multiple lines. + + @ Using list blocks + + * This is item one. + * This is item three. + * This is item two. We can + even make it continue + onto the next lines. + * This is item four. + ^ Text block ! This block cannot have child elements! diff --git a/src/zippydoc/block_markup.py b/src/zippydoc/block_markup.py index cec6fd0..d3282ce 100644 --- a/src/zippydoc/block_markup.py +++ b/src/zippydoc/block_markup.py @@ -35,6 +35,10 @@ class Text(TreeLevel): def transform(self, ruleset): return ruleset.transform_text(Value(self.data)) +class List(TreeLevel): + def transform(self, ruleset): + return ruleset.transform_list([Value(line) for line in self.data]) + class Exclamation(TreeLevel): def transform(self, ruleset): return ruleset.transform_exclamation(Value(self.data), self.transform_children(ruleset)) diff --git a/src/zippydoc/document.py b/src/zippydoc/document.py index dc1d5be..7aa47e8 100644 --- a/src/zippydoc/document.py +++ b/src/zippydoc/document.py @@ -63,6 +63,9 @@ class Document(object): # Exclamation lines[0] = lines[0].lstrip("! ") element = block_markup.Exclamation(indentation, " ".join(lines)) + elif lines[0].startswith("* "): + items = [item.replace("\n", " ") for item in "\n".join(lines)[2:].split("\n*")] + element = block_markup.List(indentation, items) elif re.match(".*::\s*$", lines[0]): # Argument definition argname = re.match("(.*)::\s*$", lines[0]).group(1) diff --git a/src/zippydoc/transformation_ruleset.py b/src/zippydoc/transformation_ruleset.py index 13a5c2d..a916e4c 100644 --- a/src/zippydoc/transformation_ruleset.py +++ b/src/zippydoc/transformation_ruleset.py @@ -25,6 +25,9 @@ class TransformationRuleset(object): def transform_text(self, text): pass + + def transform_list(self, items): + pass def transform_reference(self, target, description): pass diff --git a/zpy2html b/zpy2html index 36139a8..be61534 100755 --- a/zpy2html +++ b/zpy2html @@ -60,6 +60,9 @@ class HtmlRuleset(zippydoc.TransformationRuleset): def transform_text(self, text): return '
%s
' % text.transform(self) + + def transform_list(self, items): + return '' % "".join("
  • %s
  • " % item.transform(self) for item in items) def transform_reference(self, target, description): return '%s' % (target, description.transform(self))