From 309c332f1f69a8554524c29add98721a06da636e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 5 Dec 2006 21:42:31 +0000 Subject: [PATCH] got a rudimentary one-page display going --- doc/build/components/content_layout.myt | 2 +- doc/build/components/formatting.myt | 5 +++-- doc/build/components/nav.myt | 14 +++++++++----- doc/build/components/toc.myt | 18 +++++++++++------- doc/build/content/index.myt | 5 ++++- doc/build/genhtml.py | 2 ++ doc/build/lib/toc.py | 18 ++++++++++++------ doc/build/read_markdown.py | 7 ++++--- 8 files changed, 46 insertions(+), 25 deletions(-) diff --git a/doc/build/components/content_layout.myt b/doc/build/components/content_layout.myt index c44a6f38de..22656c5c99 100644 --- a/doc/build/components/content_layout.myt +++ b/doc/build/components/content_layout.myt @@ -9,7 +9,7 @@ -<& nav.myt:topnav, item=current, extension=extension &> +<& nav.myt:topnav, item=current, extension=extension, onepage=True &>
% m.call_next(toc=toc, extension=extension)
diff --git a/doc/build/components/formatting.myt b/doc/build/components/formatting.myt index da1c81df05..1668f7a60c 100644 --- a/doc/build/components/formatting.myt +++ b/doc/build/components/formatting.myt @@ -11,6 +11,7 @@ toc path description=None + onepage=False <%init> item = toc.get_by_path(path) @@ -36,13 +37,13 @@ <% content %> -% if item.depth > 1: +% if onepage or item.depth > 1: % if (item.next and item.next.depth >= item.depth): back to section top % % else: back to section top - <& nav.myt:pagenav, item=item &> + <& nav.myt:pagenav, item=item, onepage=onepage &> % diff --git a/doc/build/components/nav.myt b/doc/build/components/nav.myt index a045df8ce7..cdf372028f 100644 --- a/doc/build/components/nav.myt +++ b/doc/build/components/nav.myt @@ -5,11 +5,12 @@ individual hyperlinks as well as navigational toolbars and table-of-content list <%args> item anchor=True + usefilename=True <%args scope="request"> extension='myt' - <% item.description %> + <% item.description %> <%method toclink trim="both"> @@ -18,6 +19,7 @@ individual hyperlinks as well as navigational toolbars and table-of-content list path description=None extension + usefilename=True <%init> item = toc.get_by_path(path) @@ -28,7 +30,7 @@ individual hyperlinks as well as navigational toolbars and table-of-content list description = path % if item: - <% description %> + <% description %> % else: <% description %> % @@ -48,6 +50,7 @@ individual hyperlinks as well as navigational toolbars and table-of-content list <%args> item extension + onepage=False
@@ -75,7 +78,7 @@ Next: <& itemlink, item=item.next, anchor=False &>
<% item.description %>
- <& toc.myt:printtoc, root=item, current=None, full=True, extension=extension, anchor_toplevel=True &> + <& toc.myt:printtoc, root=item, current=None, full=True, extension=extension, anchor_toplevel=True, onepage=False &>
@@ -85,12 +88,13 @@ Next: <& itemlink, item=item.next, anchor=False &> <%method pagenav> <%args> item + onepage=False
% if item.previous is not None: - Previous: <& itemlink, item=item.previous &> + Previous: <& itemlink, item=item.previous, usefilename=not onepage &> % # end if % if item.next is not None: @@ -98,7 +102,7 @@ Next: <& itemlink, item=item.next, anchor=False &> | % # end if - Next: <& itemlink, item=item.next &> + Next: <& itemlink, item=item.next, usefilename=not onepage &> % # end if
diff --git a/doc/build/components/toc.myt b/doc/build/components/toc.myt index 6580a39c50..ac45140b12 100644 --- a/doc/build/components/toc.myt +++ b/doc/build/components/toc.myt @@ -4,6 +4,7 @@ <%args> toc extension + onepage=False @@ -16,7 +17,7 @@

- <& printtoc, root = toc, current = None, full = False, children=False, extension=extension, anchor_toplevel=False &> + <& printtoc, root = toc, current = None, full = False, children=False, extension=extension, anchor_toplevel=False, onepage=onepage &>
@@ -30,7 +31,7 @@

- <& printtoc, root = toc, current = None, full = True, children=True, extension=extension, anchor_toplevel=False &> + <& printtoc, root = toc, current = None, full = True, children=True, extension=extension, anchor_toplevel=False, onepage=onepage &>
@@ -45,11 +46,12 @@ children = True extension anchor_toplevel=False + onepage=False @@ -63,14 +65,15 @@ children = True extension anchor_toplevel + onepage=False -
  • " href="<% item.get_link(extension=extension, anchor=anchor_toplevel) %>"><% item.description %>
  • +
  • " href="<% item.get_link(extension=extension, anchor=anchor_toplevel, usefilename=not onepage) %>"><% item.description %>
  • % if children: % @@ -81,13 +84,14 @@ item children = False extension + onepage=False -
  • <% item.description %>
  • +
  • <% item.description %>
  • % if children: % diff --git a/doc/build/content/index.myt b/doc/build/content/index.myt index 524a43b1a8..7f77c05e5d 100644 --- a/doc/build/content/index.myt +++ b/doc/build/content/index.myt @@ -2,6 +2,9 @@ <%args> extension toc + onepage=False -<& toc.myt:toc, toc=toc, extension=extension &> +Multiple Pages | +One Page
    +<& toc.myt:toc, toc=toc, extension=extension, onepage=onepage &> diff --git a/doc/build/genhtml.py b/doc/build/genhtml.py index 89bbddbfa7..24d400abb5 100644 --- a/doc/build/genhtml.py +++ b/doc/build/genhtml.py @@ -30,6 +30,7 @@ root = toc.TOCElement('', 'root', '', version=version, doctitle=title) shutil.copy('./content/index.myt', './output/index.myt') shutil.copy('./content/docstrings.myt', './output/docstrings.myt') +shutil.copy('./content/documentation.myt', './output/documentation.myt') read_markdown.parse_markdown_files(root, files) docstrings = gen_docstrings.make_all_docs() @@ -56,6 +57,7 @@ def genfile(name, toc): try: for filename in files: genfile(filename, root) + genfile("documentation", root) except exception.Error, e: sys.stderr.write(e.textformat()) diff --git a/doc/build/lib/toc.py b/doc/build/lib/toc.py index ebf7e95471..91cfb0d50e 100644 --- a/doc/build/lib/toc.py +++ b/doc/build/lib/toc.py @@ -8,6 +8,7 @@ import time toc_by_file = {} toc_by_path = {} +filenames = [] class TOCElement(object): def __init__(self, filename, name, description, parent=None, version=None, last_updated=None, doctitle=None, **kwargs): @@ -18,6 +19,7 @@ class TOCElement(object): self.content = None self.toc_by_path = toc_by_path self.toc_by_file = toc_by_file + self.filenames = filenames self.last_updated = time.time() self.version = version self.doctitle = doctitle @@ -31,7 +33,8 @@ class TOCElement(object): self.is_top = (self.parent is not None and self.parent.filename != self.filename) or self.parent is None if self.is_top: toc_by_file[self.filename] = self - + if self.filename: + filenames.append(self.filename) self.root = self.parent or self self.content = None @@ -53,12 +56,15 @@ class TOCElement(object): def get_by_file(self, filename): return self.toc_by_file[filename] - def get_link(self, extension='html', anchor=True): - if anchor: - return "%s.%s#%s" % (self.filename, extension, self.path) + def get_link(self, extension='html', anchor=True, usefilename=True): + if usefilename: + if anchor: + return "%s.%s#%s" % (self.filename, extension, self.path) + else: + return "%s.%s" % (self.filename, extension) else: - return "%s.%s" % (self.filename, extension) - + return "#%s" % (self.path) + def _create_path(self): elem = self tokens = [] diff --git a/doc/build/read_markdown.py b/doc/build/read_markdown.py index eee09ef3ef..0b4c8b3eb6 100644 --- a/doc/build/read_markdown.py +++ b/doc/build/read_markdown.py @@ -80,7 +80,7 @@ def create_toc(filename, tree, tocroot): level[0] = taglevel - tag = et.Element("MYGHTY:formatting.myt:section", path=literal(current[0].path), toc="toc") + tag = et.Element("MYGHTY:formatting.myt:section", path=literal(current[0].path), toc="toc", onepage="onepage") tag.text = (node.tail or "") + '\n' tag.tail = '\n' tag[:] = content @@ -123,9 +123,9 @@ def process_rel_href(tree): (bold, path) = m.group(1,2) text = a.text if text == path: - tag = et.Element("MYGHTY:nav.myt:toclink", path=literal(path), toc="toc", extension="extension") + tag = et.Element("MYGHTY:nav.myt:toclink", path=literal(path), toc="toc", extension="extension", onepage="onepage") else: - tag = et.Element("MYGHTY:nav.myt:toclink", path=literal(path), description=literal(text), toc="toc", extension="extension") + tag = et.Element("MYGHTY:nav.myt:toclink", path=literal(path), description=literal(text), toc="toc", extension="extension", onepage="onepage") a_parent = parent[a] if bold: bold = et.Element('strong') @@ -207,6 +207,7 @@ def header(toc, title, filename): <%%args> toc extension + onepage=False <%%attr> title='%s - %s' -- 2.47.2