]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed textual select elements that got broke the other day
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 29 Apr 2007 16:08:36 +0000 (16:08 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 29 Apr 2007 16:08:36 +0000 (16:08 +0000)
- docstring work

doc/build/genhtml.py
doc/build/lib/docstring.py
doc/build/templates/pydoc.html
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/sql.py
lib/sqlalchemy/util.py

index 4f7e2d00ee88ad44579b0657ca7c2d4363f2e5f1..6ebedff1c9bb0ddc9c63f2178be8c09fd2f51834 100644 (file)
@@ -8,10 +8,11 @@ import gen_docstrings, read_markdown, toc
 from mako.lookup import TemplateLookup
 from mako import exceptions, runtime
 import time
+import optparse
 
 files = [
     'index',
-    'documentation',
+#    'documentation',
     'tutorial',
     'dbengine',
     'metadata',
@@ -25,10 +26,14 @@ files = [
     'docstrings'
     ]
 
-argfile = len(sys.argv) > 1 and sys.argv[1]
-if argfile:
-    files = [argfile]
-    
+parser = optparse.OptionParser(usage = "usage: %prog [options] [tests...]")
+parser.add_option("--file", action="store", dest="file", help="only generate file <file>")
+parser.add_option("--docstrings", action="store_true", dest="docstrings", help="only generate docstrings")
+
+(options, args) = parser.parse_args()
+if options.file:
+    files = [file]
+
 title='SQLAlchemy 0.3 Documentation'
 version = '0.3.6'
 
@@ -38,9 +43,10 @@ shutil.copy('./content/index.html', './output/index.html')
 shutil.copy('./content/docstrings.html', './output/docstrings.html')
 shutil.copy('./content/documentation.html', './output/documentation.html')
 
-read_markdown.parse_markdown_files(root, files)
+if not options.docstrings:
+    read_markdown.parse_markdown_files(root, files)
 
-if not argfile:
+if not options.file or options.docstrings:
     docstrings = gen_docstrings.make_all_docs()
     doc_files = gen_docstrings.create_docstring_toc(docstrings, root)
 
@@ -60,13 +66,14 @@ def genfile(name, outname):
     t = lookup.get_template(infile)
     outfile.write(t.render(attributes={}))
 
-for filename in files:
-    try:
-        genfile(filename, os.path.join(os.getcwd(), '../', filename + ".html"))
-    except:
-        print exceptions.text_error_template().render()
+if not options.docstrings:
+    for filename in files:
+        try:
+            genfile(filename, os.path.join(os.getcwd(), '../', filename + ".html"))
+        except:
+            print exceptions.text_error_template().render()
 
-if not argfile:
+if not options.file or options.docstrings:
     for filename in doc_files:
         try:
             genfile(filename, os.path.join(os.getcwd(), '../', os.path.basename(filename) + ".html"))
index e878aa9b27c34df95bee4dd587286479c9f5fb8d..f0aebe92baa2bd83b66051076f52b9bc6abfd27a 100644 (file)
@@ -55,7 +55,7 @@ class ObjectDoc(AbstractDoc):
                     and 
                     (getattr(obj, x).__name__ == '__init__' or not getattr(obj,x).__name__[0] == '_')
                     ] + 
-                    [(x, getattr(obj, x)) for x in obj.__dict__.keys() if isinstance(getattr(obj,x), property
+                    [(x, getattr(obj, x)) for x in obj.__dict__.keys() if _is_property(getattr(obj,x)
                     and 
                     not x[0] == '_'
                     ]
@@ -111,6 +111,9 @@ class ObjectDoc(AbstractDoc):
     def accept_visitor(self, visitor):
         visitor.visit_object(self)
 
+def _is_property(elem):
+    return isinstance(elem, property) or (hasattr(elem, '__get__') and hasattr(elem, '__set__'))
+    
 class FunctionDoc(AbstractDoc):
     def __init__(self, func):
         super(FunctionDoc, self).__init__(func)
index 4fa6e5ca96312bfdef06302193a924c076418c32..34bb5e7bc34933490c8f16b4a3e760245219c0af 100644 (file)
@@ -83,7 +83,7 @@ def formatdocstring(content):
                 % if isinstance(func, docstring.FunctionDoc):
                     ${function_doc(func=func, toc=toc, extension=extension, paged=paged)}
                 % elif isinstance(func, docstring.PropertyDoc):
-                    ${property_doc(prop=func)}
+                    ${property_doc(prop=func, toc=toc, extension=extension, paged=paged)}
                 % endif
             % endfor
         % endif
@@ -113,12 +113,12 @@ def formatdocstring(content):
     </div>
 </%def>
 
-<%def name="property_doc(prop)">
+<%def name="property_doc(prop, toc, extension, paged)">
          <div class="darkcell">
          <A name=""></a>
          <b>${prop.name} = property()</b>
          <div class="docstring">
-         ${prop.doc or '' | formatdocstring}
+         ${prop.doc or '' | formatdocstring, inline_links(toc, extension, paged)}
          </div> 
          </div>
 </%def>
index 5083b1cff91e700b7cd9140aee90063bd99fee23..1cea9ffc3549eb8c64575eeeddef9c9cba817847 100644 (file)
@@ -399,11 +399,8 @@ class Connectable(sql.Executor):
     def execute(self, object, *multiparams, **params):
         raise NotImplementedError()
 
-    def _not_impl(self):
-        raise NotImplementedError()
-
-    engine = property(_not_impl, doc="The Engine which this Connectable is associated with.")
-    dialect = property(_not_impl, doc="Dialect which this Connectable is associated with.")
+    engine = util.NotImplProperty("The Engine which this Connectable is associated with.")
+    dialect = util.NotImplProperty("Dialect which this Connectable is associated with.")
 
 class Connection(Connectable):
     """Represent a single DBAPI connection returned from the underlying connection pool.
index f4ece3d6b551dba0be8527a818682fe304c0a3ef..9c327bd53d41e2375f1bcd3099a0b2356c82612f 100644 (file)
@@ -1342,7 +1342,17 @@ class _CompareMixin(object):
         return obj.type
 
 class Selectable(ClauseElement):
-    """Represent a column list-holding object."""
+    """Represent a column list-holding object.
+    
+    this is the common base class of [sqlalchemy.sql#ColumnElement]
+    and [sqlalchemy.sql#FromClause].  The reason ``ColumnElement``
+    is marked as a "list-holding" object is so that it can be treated
+    similarly to ``FromClause`` in column-selection scenarios; it 
+    contains a list of columns consisting of itself.
+    
+    """
+
+    columns = util.NotImplProperty("""a [sqlalchemy.sql#ColumnCollection] containing ``ColumnElement`` instances.""")
 
     def _selectable(self):
         return self
@@ -2792,7 +2802,7 @@ class Select(_SelectBaseMixin, FromClause):
 
     def append_column(self, column):
         if _is_literal(column):
-            column = literal_column(str(column), table=self)
+            column = literal_column(str(column))
 
         self._raw_columns.append(column)
 
index 08b281684cc91280a06b1fc16e301b82ac545465..d4627974b558e2ab2c7b78846185d847c3e58df9 100644 (file)
@@ -127,6 +127,24 @@ class SimpleProperty(object):
         else:
             return getattr(obj, self.key)
 
+class NotImplProperty(object):
+  """a property that raises ``NotImplementedError``."""
+  
+  def __init__(self, doc):
+      self.__doc__ = doc
+      
+  def __set__(self, obj, value):
+      raise NotImplementedError()
+
+  def __delete__(self, obj):
+      raise NotImplementedError()
+
+  def __get__(self, obj, owner):
+      if obj is None:
+          return self
+      else:
+          raise NotImplementedError()
+  
 class OrderedProperties(object):
     """An object that maintains the order in which attributes are set upon it.