Browse Source

Support for bulletpoint lists and 1.1 release

develop
Sven Slootweg 9 years ago
parent
commit
fc3f2c3e3c
  1. 2
      setup.py
  2. 15
      site/documentation.zpy
  3. 4
      src/zippydoc/block_markup.py
  4. 3
      src/zippydoc/document.py
  5. 3
      src/zippydoc/transformation_ruleset.py
  6. 3
      zpy2html

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.',

15
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!

4
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))

3
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)

3
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

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…
Cancel
Save