]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
got a rudimentary one-page display going
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 5 Dec 2006 21:42:31 +0000 (21:42 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 5 Dec 2006 21:42:31 +0000 (21:42 +0000)
doc/build/components/content_layout.myt
doc/build/components/formatting.myt
doc/build/components/nav.myt
doc/build/components/toc.myt
doc/build/content/index.myt
doc/build/genhtml.py
doc/build/lib/toc.py
doc/build/read_markdown.py

index c44a6f38deeddec3c7666febf380a1bb0c2c6570..22656c5c99669317ed2c10b6103fdb695bd6fedf 100644 (file)
@@ -9,7 +9,7 @@
 </%init>
 
 <A name="<% current.path %>"></a>
-<& nav.myt:topnav, item=current, extension=extension &>
+<& nav.myt:topnav, item=current, extension=extension, onepage=True &>
 <div class="sectioncontent">
 % m.call_next(toc=toc, extension=extension)
 </div>
index da1c81df05b265432fc2c485a99c4acf7d32b7a2..1668f7a60cb5a4115d29435ecb3c3b696a82a61c 100644 (file)
@@ -11,6 +11,7 @@
     toc
     path
     description=None
+    onepage=False
 </%args>
 <%init>
     item = toc.get_by_path(path)
     <% content %>
     </div>
 
-% if item.depth > 1:
+% if onepage or item.depth > 1:
 %   if (item.next and item.next.depth >= item.depth):
     <a href="#<% item.get_page_root().path %>" class="toclink">back to section top</a>
 %
 % else:
     <a href="#<% item.get_page_root().path %>" class="toclink">back to section top</a>
-    <& nav.myt:pagenav, item=item &>
+    <& nav.myt:pagenav, item=item, onepage=onepage &>
 % 
 </div>
 
index a045df8ce74b32deb927976a3a8e63f56eb911c5..cdf372028fec1aafb75ba96c4a0fa63107fb605f 100644 (file)
@@ -5,11 +5,12 @@ individual hyperlinks as well as navigational toolbars and table-of-content list
     <%args>
     item
     anchor=True
+    usefilename=True
     </%args>
     <%args scope="request">
         extension='myt'
     </%args>
-    <a href="<% item.get_link(extension=extension, anchor=anchor) %>"><% item.description %></a>
+    <a href="<% item.get_link(extension=extension, anchor=anchor, usefilename=usefilename) %>"><% item.description %></a>
 </%method>
 
 <%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
     </%args>
     <%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
     </%init>
 % if item:
-    <a href="<% item.get_link(extension=extension) %>"><% description %></a>
+    <a href="<% item.get_link(extension=extension, usefilename=usefilename) %>"><% description %></a>
 % else:
     <b><% description %></b>
 %
@@ -48,6 +50,7 @@ individual hyperlinks as well as navigational toolbars and table-of-content list
        <%args>
                item
                extension
+               onepage=False
        </%args>
 <div class="topnav">
 
@@ -75,7 +78,7 @@ Next: <& itemlink, item=item.next, anchor=False &>
 <div class="topnavmain">
        <div class="topnavheader"><% item.description %></div>
        <div class="topnavitems">
-       <& 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 &>
        </div>
 </div>
 
@@ -85,12 +88,13 @@ Next: <& itemlink, item=item.next, anchor=False &>
 <%method pagenav>
 <%args>
     item
+    onepage=False
 </%args>
 <div class="sectionnavblock">
 <div class="sectionnav">
 
 %       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
 
 </div>
index 6580a39c5021807c84d8d82d2bd1e20c4e368396..ac45140b120d20132d9ae2d7f91ddf432430289c 100644 (file)
@@ -4,6 +4,7 @@
        <%args>
                toc
                extension
+               onepage=False
        </%args>
        
        
@@ -16,7 +17,7 @@
        <br/><br/>
        
        <div style="margin-left:50px;">
-       <& 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 &>
        </div>
 
        </div>
@@ -30,7 +31,7 @@
        <br/><br/>
 
        <div style="margin-left:50px;">
-       <& 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 &>
        </div>
 
        </div>
     children = True
     extension
     anchor_toplevel=False
+    onepage=False
 </%args>
 
 <ul class="toc_list">
 % for i in root.children:
-    <& printtocelement, item=i, bold = (i == current), full = full, children=children, extension=extension, anchor_toplevel=anchor_toplevel &>
+    <& printtocelement, item=i, bold = (i == current), full = full, children=children, extension=extension, anchor_toplevel=anchor_toplevel,onepage=onepage &>
 %
 </ul>
 </%method>
         children = True
         extension
         anchor_toplevel
+        onepage=False
     </%args>
     
-        <li><A style="<% bold and "font-weight:bold;" or "" %>" href="<% item.get_link(extension=extension, anchor=anchor_toplevel) %>"><% item.description %></a></li>
+        <li><A style="<% bold and "font-weight:bold;" or "" %>" href="<% item.get_link(extension=extension, anchor=anchor_toplevel, usefilename=not onepage) %>"><% item.description %></a></li>
     
 % if children:  
     <ul class="small_toc_list">
 %   for i in item.children:
-        <& printsmtocelem, item=i, children=full, extension=extension &>
+        <& printsmtocelem, item=i, children=full, extension=extension, onepage=onepage &>
 %
     </ul>
 %
         item
         children = False
         extension
+        onepage=False
     </%args>    
-    <li><A href="<% item.get_link(extension=extension) %>"><% item.description %></a></li>
+    <li><A href="<% item.get_link(extension=extension, usefilename=not onepage) %>"><% item.description %></a></li>
 
 % if children:
     <ul class="small_toc_list">
 %   for i in item.children:
-        <& printsmtocelem, item = i, extension=extension &>
+        <& printsmtocelem, item = i, extension=extension, onepage=onepage, children=children &>
 %
     </ul>
 %
index 524a43b1a88904a0f8f2976ba60a7630dee7702b..7f77c05e5d04354f422a95d3cb34b9aaa261f8e1 100644 (file)
@@ -2,6 +2,9 @@
 <%args>
     extension
     toc
+    onepage=False
 </%args>
 
-<& toc.myt:toc, toc=toc, extension=extension &>
+<a href="index.<% extension %>">Multiple Pages</a> | 
+<a href="documentation.<% extension %>">One Page</a><br/>
+<& toc.myt:toc, toc=toc, extension=extension, onepage=onepage &>
index 89bbddbfa79a93641d710d476bff00d36ddff07a..24d400abb5acf16d558d13b6a0895b312452276e 100644 (file)
@@ -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())
 
index ebf7e954718e7dea9ccd6170b551b7e65c6b1e4f..91cfb0d50ebdfe66ba1afb5d69166bf454c2b3e9 100644 (file)
@@ -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 = []
index eee09ef3ef2b2e047ff0718d44ba328f0f62a96e..0b4c8b3eb68d0255abe8c735dc8a0e76fc0d781b 100644 (file)
@@ -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
 </%%args>
 <%%attr>
     title='%s - %s'