summaryrefslogtreecommitdiff
path: root/panfry/document.py
diff options
context:
space:
mode:
Diffstat (limited to 'panfry/document.py')
-rwxr-xr-xpanfry/document.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/panfry/document.py b/panfry/document.py
index 0b450da..aa29561 100755
--- a/panfry/document.py
+++ b/panfry/document.py
@@ -14,9 +14,20 @@ class Document:
self.src_path = path
self.meta = self.get_meta(path)
self.pages = self.get_pages(path)
+ self.full_toc = True
- css_file = 'css/style.css'
- workdir = 'stdocs-work'
+ self.css_file = 'css/style.css'
+
+ @property
+ def set_simple_toc(self):
+ self.full_toc = False
+
+ @property
+ def set_full_toc(self):
+ self.full_toc = True
+
+ def set_templater(self, templater):
+ self.templater = templater
@property
def title(self):
@@ -56,9 +67,6 @@ class Document:
return meta
- def set_templater(self, templater):
- self.templater = templater
-
def next_page(self, page):
try:
idx = self.pages.index(page)
@@ -85,11 +93,17 @@ class Document:
'''
links = []
for page in self.pages:
- title, level = page.title
- links.append(dict(link=unicode(page.htmlfile, "utf8"),
- text=unicode(title, "utf8"),
- level=level,
- ))
+ if self.full_toc:
+ toc = page.toc
+ else:
+ toc = [page.toc[0]]
+
+ for tocitem in toc:
+ link = '%s#%s' % (page.htmlfile, tocitem.section_id)
+ links.append(dict(link=unicode(link, "utf8"),
+ text=unicode(tocitem.heading, "utf8"),
+ level=tocitem.level,
+ ))
return links