Support for bulletpoint lists and 1.1 release
This commit is contained in:
parent
242f4b9331
commit
fc3f2c3e3c
2
setup.py
2
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.',
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
3
zpy2html
3
zpy2html
|
@ -60,6 +60,9 @@ class HtmlRuleset(zippydoc.TransformationRuleset):
|
|||
|
||||
def transform_text(self, text):
|
||||
return '<div class="text">%s</div>' % text.transform(self)
|
||||
|
||||
def transform_list(self, items):
|
||||
return '<ul>%s</ul>' % "".join("<li>%s</li>" % item.transform(self) for item in items)
|
||||
|
||||
def transform_reference(self, target, description):
|
||||
return '<a href="%s.html">%s</a>' % (target, description.transform(self))
|
||||
|
|
Loading…
Reference in a new issue