From: <pj...@us...> - 2009-10-14 06:02:21
|
Revision: 6856 http://jython.svn.sourceforge.net/jython/?rev=6856&view=rev Author: pjenvey Date: 2009-10-14 06:02:01 +0000 (Wed, 14 Oct 2009) Log Message: ----------- docs galore, enable test_descr.descrdoc Modified Paths: -------------- trunk/jython/Lib/test/test_descr.py trunk/jython/Misc/make_pydocs.py trunk/jython/src/org/python/core/BuiltinDocs.java trunk/jython/src/org/python/core/PyBaseString.java trunk/jython/src/org/python/core/PyBoolean.java trunk/jython/src/org/python/core/PyClassMethod.java trunk/jython/src/org/python/core/PyComplex.java trunk/jython/src/org/python/core/PyDictionary.java trunk/jython/src/org/python/core/PyEnumerate.java trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/PyFloat.java trunk/jython/src/org/python/core/PyFunction.java trunk/jython/src/org/python/core/PyInteger.java trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/core/PyLong.java trunk/jython/src/org/python/core/PyMethod.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyProperty.java trunk/jython/src/org/python/core/PySlice.java trunk/jython/src/org/python/core/PyStaticMethod.java trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PySuper.java trunk/jython/src/org/python/core/PyTuple.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/core/PyUnicode.java trunk/jython/src/org/python/core/PyXRange.java Modified: trunk/jython/Lib/test/test_descr.py =================================================================== --- trunk/jython/Lib/test/test_descr.py 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/Lib/test/test_descr.py 2009-10-14 06:02:01 UTC (rev 6856) @@ -4396,9 +4396,6 @@ # takes 1 arg) specials, - # Jython file lacks doc strings - descrdoc, - # New style classes don't support __del__: # http://bugs.jython.org/issue1057 delhook, Modified: trunk/jython/Misc/make_pydocs.py =================================================================== --- trunk/jython/Misc/make_pydocs.py 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/Misc/make_pydocs.py 2009-10-14 06:02:01 UTC (rev 6856) @@ -2,15 +2,21 @@ import __builtin__ def print_doc(out, obj, meth): - doc = (getattr(obj, meth)).__doc__ - if doc == None: + if meth == '__doc__': + doc = getattr(obj, meth) + bdname = '%s_doc' % obj.__name__ + else: + doc = getattr(obj, meth).__doc__ + bdname = '%s_%s_doc' % (obj.__name__, meth) + + if doc is None: doc = "" lines = doc.split("\n") - outstring = '\\n" + \n "'.join(lines) - print >> out, (' public final static String %s_%s_doc = ' - % (obj.__name__, meth)) + outstring = '\\n" + \n "'.join(format(line) for line in lines) + print >> out, (' public final static String %s = ' % bdname) print >> outfile, ' "%s";\n' % outstring +format = lambda line: line.replace('\\', '\\\\').replace('"', r'\"') opt = lambda n: getattr(__builtin__, n, None) def f(): pass @@ -58,13 +64,13 @@ ] outfile = open("BuiltinDocs.java", "w") -print >> outfile, '//generated by make_pydocs.py\n' +print >> outfile, '// generated by make_pydocs.py\n' print >> outfile, 'package org.python.core;\n' print >> outfile, 'public class BuiltinDocs {\n' for obj in types_list: - print >> outfile, ' //Docs for %s' % obj + print >> outfile, ' // Docs for %s' % obj for meth in dir(obj): print_doc(outfile, obj, meth) Modified: trunk/jython/src/org/python/core/BuiltinDocs.java =================================================================== --- trunk/jython/src/org/python/core/BuiltinDocs.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/BuiltinDocs.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -1,10 +1,10 @@ -//generated by make_pydocs.py +// generated by make_pydocs.py package org.python.core; public class BuiltinDocs { - //Docs for <type 'object'> + // Docs for <type 'object'> public final static String object___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -12,11 +12,8 @@ public final static String object___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String object___doc___doc = - "str(object) -> string\n" + - "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + public final static String object_doc = + "The most base type"; public final static String object___getattribute___doc = "x.__getattribute__('name') <==> x.name"; @@ -45,7 +42,7 @@ public final static String object___str___doc = "x.__str__() <==> str(x)"; - //Docs for <type 'type'> + // Docs for <type 'type'> public final static String type___base___doc = "The most base type"; @@ -91,11 +88,9 @@ "non-string. If the argument is outside the integer range a long object\n" + "will be returned instead."; - public final static String type___doc___doc = - "str(object) -> string\n" + - "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + public final static String type_doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; public final static String type___flags___doc = "int(x[, base]) -> integer\n" + @@ -179,7 +174,7 @@ "mro() -> list\n" + "return a type's method resolution order"; - //Docs for <type 'unicode'> + // Docs for <type 'unicode'> public final static String unicode___add___doc = "x.__add__(y) <==> x+y"; @@ -193,11 +188,12 @@ public final static String unicode___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String unicode___doc___doc = - "str(object) -> string\n" + + public final static String unicode_doc = + "unicode(string [, encoding[, errors]]) -> object\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Create a new Unicode object from the given encoded string.\n" + + "encoding defaults to the current default string encoding.\n" + + "errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'."; public final static String unicode___eq___doc = "x.__eq__(y) <==> x==y"; @@ -327,7 +323,7 @@ "S.find(sub [,start [,end]]) -> int\n" + "\n" + "Return the lowest index in S where substring sub is found,\n" + - "such that sub is contained within s[start:end]. Optional\n" + + "such that sub is contained within s[start,end]. Optional\n" + "arguments start and end are interpreted as in slice notation.\n" + "\n" + "Return -1 on failure."; @@ -435,7 +431,7 @@ "S.rfind(sub [,start [,end]]) -> int\n" + "\n" + "Return the highest index in S where substring sub is found,\n" + - "such that sub is contained within s[start:end]. Optional\n" + + "such that sub is contained within s[start,end]. Optional\n" + "arguments start and end are interpreted as in slice notation.\n" + "\n" + "Return -1 on failure."; @@ -537,7 +533,7 @@ "Pad a numeric string x with zeros on the left, to fill a field\n" + "of the specified width. The string x is never truncated."; - //Docs for <type 'dict'> + // Docs for <type 'dict'> public final static String dict___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -554,11 +550,16 @@ public final static String dict___delitem___doc = "x.__delitem__(y) <==> del x[y]"; - public final static String dict___doc___doc = - "str(object) -> string\n" + - "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + public final static String dict_doc = + "dict() -> new empty dictionary.\n" + + "dict(mapping) -> new dictionary initialized from a mapping object's\n" + + " (key, value) pairs.\n" + + "dict(seq) -> new dictionary initialized as if via:\n" + + " d = {}\n" + + " for k, v in seq:\n" + + " d[k] = v\n" + + "dict(**kwargs) -> new dictionary initialized with the name=value pairs\n" + + " in the keyword argument list. For example: dict(one=1, two=2)"; public final static String dict___eq___doc = "x.__eq__(y) <==> x==y"; @@ -666,7 +667,7 @@ public final static String dict_values_doc = "D.values() -> list of D's values"; - //Docs for <type 'list'> + // Docs for <type 'list'> public final static String list___add___doc = "x.__add__(y) <==> x+y"; @@ -688,11 +689,9 @@ " \n" + " Use of negative indices is not supported."; - public final static String list___doc___doc = - "str(object) -> string\n" + - "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + public final static String list_doc = + "list() -> new list\n" + + "list(sequence) -> new list initialized from sequence's items"; public final static String list___eq___doc = "x.__eq__(y) <==> x==y"; @@ -804,7 +803,7 @@ "L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;\n" + "cmp(x, y) -> -1, 0, 1"; - //Docs for <type 'slice'> + // Docs for <type 'slice'> public final static String slice___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -815,11 +814,10 @@ public final static String slice___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String slice___doc___doc = - "str(object) -> string\n" + + public final static String slice_doc = + "slice([start,] stop[, step])\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Create a slice object. This is used for extended slicing (e.g. a[0:10:2])."; public final static String slice___getattribute___doc = "x.__getattribute__('name') <==> x.name"; @@ -865,7 +863,7 @@ public final static String slice_stop_doc = ""; - //Docs for <type 'super'> + // Docs for <type 'super'> public final static String super___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -873,11 +871,14 @@ public final static String super___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String super___doc___doc = - "str(object) -> string\n" + - "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + public final static String super_doc = + "super(type) -> unbound super object\n" + + "super(type, obj) -> bound super object; requires isinstance(obj, type)\n" + + "super(type, type2) -> bound super object; requires issubclass(type2, type)\n" + + "Typical use to call a cooperative superclass method:\n" + + "class C(B):\n" + + " def meth(self, arg):\n" + + " super(C, self).meth(arg)"; public final static String super___get___doc = "descr.__get__(obj[, type]) -> value"; @@ -918,7 +919,7 @@ public final static String super___thisclass___doc = "the class invoking super()"; - //Docs for <type 'staticmethod'> + // Docs for <type 'staticmethod'> public final static String staticmethod___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -926,11 +927,23 @@ public final static String staticmethod___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String staticmethod___doc___doc = - "str(object) -> string\n" + + public final static String staticmethod_doc = + "staticmethod(function) -> method\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Convert a function to be a static method.\n" + + "\n" + + "A static method does not receive an implicit first argument.\n" + + "To declare a static method, use this idiom:\n" + + "\n" + + " class C:\n" + + " def f(arg1, arg2, ...): ...\n" + + " f = staticmethod(f)\n" + + "\n" + + "It can be called either on the class (e.g. C.f()) or on an instance\n" + + "(e.g. C().f()). The instance is ignored except for its class.\n" + + "\n" + + "Static methods in Python are similar to those found in Java or C++.\n" + + "For a more advanced concept, see the classmethod builtin."; public final static String staticmethod___get___doc = "descr.__get__(obj[, type]) -> value"; @@ -962,7 +975,7 @@ public final static String staticmethod___str___doc = "x.__str__() <==> str(x)"; - //Docs for <type 'float'> + // Docs for <type 'float'> public final static String float___abs___doc = "x.__abs__() <==> abs(x)"; @@ -985,11 +998,10 @@ public final static String float___divmod___doc = "x.__divmod__(y) <==> divmod(x, y)"; - public final static String float___doc___doc = - "str(object) -> string\n" + + public final static String float_doc = + "float(x) -> floating point number\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Convert a string or number to a floating point number, if possible."; public final static String float___eq___doc = "x.__eq__(y) <==> x==y"; @@ -1125,7 +1137,7 @@ public final static String float___truediv___doc = "x.__truediv__(y) <==> x/y"; - //Docs for <type 'enumerate'> + // Docs for <type 'enumerate'> public final static String enumerate___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -1133,11 +1145,13 @@ public final static String enumerate___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String enumerate___doc___doc = - "str(object) -> string\n" + + public final static String enumerate_doc = + "enumerate(iterable) -> iterator for index, value of iterable\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Return an enumerate object. iterable must be an other object that supports\n" + + "iteration. The enumerate object yields pairs containing a count (from\n" + + "zero) and a value yielded by the iterable argument. enumerate is useful\n" + + "for obtaining an indexed list: (0, seq[0]), (1, seq[1]), (2, seq[2]), ..."; public final static String enumerate___getattribute___doc = "x.__getattribute__('name') <==> x.name"; @@ -1172,7 +1186,7 @@ public final static String enumerate_next_doc = "x.next() -> the next value, or raise StopIteration"; - //Docs for <type 'basestring'> + // Docs for <type 'basestring'> public final static String basestring___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -1180,11 +1194,8 @@ public final static String basestring___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String basestring___doc___doc = - "str(object) -> string\n" + - "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + public final static String basestring_doc = + "Type basestring cannot be instantiated; it is the base for str and unicode."; public final static String basestring___getattribute___doc = "x.__getattribute__('name') <==> x.name"; @@ -1213,7 +1224,7 @@ public final static String basestring___str___doc = "x.__str__() <==> str(x)"; - //Docs for <type 'long'> + // Docs for <type 'long'> public final static String long___abs___doc = "x.__abs__() <==> abs(x)"; @@ -1242,11 +1253,14 @@ public final static String long___divmod___doc = "x.__divmod__(y) <==> divmod(x, y)"; - public final static String long___doc___doc = - "str(object) -> string\n" + + public final static String long_doc = + "long(x[, base]) -> integer\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Convert a string or number to a long integer, if possible. A floating\n" + + "point argument will be truncated towards zero (this does not include a\n" + + "string representation of a floating point number!) When converting a\n" + + "string, use the optional base. It is an error to supply a base when\n" + + "converting a non-string."; public final static String long___float___doc = "x.__float__() <==> float(x)"; @@ -1380,7 +1394,7 @@ public final static String long___xor___doc = "x.__xor__(y) <==> x^y"; - //Docs for <type 'tuple'> + // Docs for <type 'tuple'> public final static String tuple___add___doc = "x.__add__(y) <==> x+y"; @@ -1394,11 +1408,11 @@ public final static String tuple___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String tuple___doc___doc = - "str(object) -> string\n" + + public final static String tuple_doc = + "tuple() -> an empty tuple\n" + + "tuple(sequence) -> tuple initialized from sequence's items\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "If the argument is a tuple, the return value is the same object."; public final static String tuple___eq___doc = "x.__eq__(y) <==> x==y"; @@ -1468,7 +1482,7 @@ public final static String tuple___str___doc = "x.__str__() <==> str(x)"; - //Docs for <type 'str'> + // Docs for <type 'str'> public final static String str___add___doc = "x.__add__(y) <==> x+y"; @@ -1482,7 +1496,7 @@ public final static String str___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String str___doc___doc = + public final static String str_doc = "str(object) -> string\n" + "\n" + "Return a nice string representation of the object.\n" + @@ -1616,7 +1630,7 @@ "S.find(sub [,start [,end]]) -> int\n" + "\n" + "Return the lowest index in S where substring sub is found,\n" + - "such that sub is contained within s[start:end]. Optional\n" + + "such that sub is contained within s[start,end]. Optional\n" + "arguments start and end are interpreted as in slice notation.\n" + "\n" + "Return -1 on failure."; @@ -1712,7 +1726,7 @@ "S.rfind(sub [,start [,end]]) -> int\n" + "\n" + "Return the highest index in S where substring sub is found,\n" + - "such that sub is contained within s[start:end]. Optional\n" + + "such that sub is contained within s[start,end]. Optional\n" + "arguments start and end are interpreted as in slice notation.\n" + "\n" + "Return -1 on failure."; @@ -1813,7 +1827,7 @@ "Pad a numeric string S with zeros on the left, to fill a field\n" + "of the specified width. The string S is never truncated."; - //Docs for <type 'property'> + // Docs for <type 'property'> public final static String property___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -1824,11 +1838,17 @@ public final static String property___delete___doc = "descr.__delete__(obj)"; - public final static String property___doc___doc = - "str(object) -> string\n" + + public final static String property_doc = + "property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "fget is a function to be used for getting an attribute value, and likewise\n" + + "fset is a function for setting, and fdel a function for del'ing, an\n" + + "attribute. Typical use is to define a managed attribute x:\n" + + "class C(object):\n" + + " def getx(self): return self.__x\n" + + " def setx(self, value): self.__x = value\n" + + " def delx(self): del self.__x\n" + + " x = property(getx, setx, delx, \"I'm the 'x' property.\")"; public final static String property___get___doc = "descr.__get__(obj[, type]) -> value"; @@ -1872,7 +1892,7 @@ public final static String property_fset_doc = ""; - //Docs for <type 'int'> + // Docs for <type 'int'> public final static String int___abs___doc = "x.__abs__() <==> abs(x)"; @@ -1901,11 +1921,15 @@ public final static String int___divmod___doc = "x.__divmod__(y) <==> divmod(x, y)"; - public final static String int___doc___doc = - "str(object) -> string\n" + + public final static String int_doc = + "int(x[, base]) -> integer\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Convert a string or number to an integer, if possible. A floating point\n" + + "argument will be truncated towards zero (this does not include a string\n" + + "representation of a floating point number!) When converting a string, use\n" + + "the optional base. It is an error to supply a base when converting a\n" + + "non-string. If the argument is outside the integer range a long object\n" + + "will be returned instead."; public final static String int___float___doc = "x.__float__() <==> float(x)"; @@ -2039,7 +2063,7 @@ public final static String int___xor___doc = "x.__xor__(y) <==> x^y"; - //Docs for <type 'xrange'> + // Docs for <type 'xrange'> public final static String xrange___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -2047,11 +2071,12 @@ public final static String xrange___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String xrange___doc___doc = - "str(object) -> string\n" + + public final static String xrange_doc = + "xrange([start,] stop[, step]) -> xrange object\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Like range(), but instead of returning a list, returns an object that\n" + + "generates the numbers in the range on demand. For looping, this is \n" + + "slightly faster than range() and more memory efficient."; public final static String xrange___getattribute___doc = "x.__getattribute__('name') <==> x.name"; @@ -2092,7 +2117,7 @@ public final static String xrange___str___doc = "x.__str__() <==> str(x)"; - //Docs for <type 'file'> + // Docs for <type 'file'> public final static String file___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -2100,11 +2125,24 @@ public final static String file___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String file___doc___doc = - "str(object) -> string\n" + + public final static String file_doc = + "file(name[, mode[, buffering]]) -> file object\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Open a file. The mode can be 'r', 'w' or 'a' for reading (default),\n" + + "writing or appending. The file will be created if it doesn't exist\n" + + "when opened for writing or appending; it will be truncated when\n" + + "opened for writing. Add a 'b' to the mode for binary files.\n" + + "Add a '+' to the mode to allow simultaneous reading and writing.\n" + + "If the buffering argument is given, 0 means unbuffered, 1 means line\n" + + "buffered, and larger numbers specify the buffer size.\n" + + "Add a 'U' to mode to open the file for input with universal newline\n" + + "support. Any line ending in the input file will be seen as a '\\n'\n" + + "in Python. Also, a file so opened gains the attribute 'newlines';\n" + + "the value for this attribute is one of None (no newline read yet),\n" + + "'\\r', '\\n', '\\r\\n' or a tuple containing all the newline types seen.\n" + + "\n" + + "'U' cannot be combined with 'w' or '+' mode.\n" + + ""; public final static String file___enter___doc = "__enter__() -> self."; @@ -2244,7 +2282,7 @@ "For backward compatibility. File objects now include the performance\n" + "optimizations previously implemented in the xreadlines module."; - //Docs for <type 'complex'> + // Docs for <type 'complex'> public final static String complex___abs___doc = "x.__abs__() <==> abs(x)"; @@ -2267,11 +2305,11 @@ public final static String complex___divmod___doc = "x.__divmod__(y) <==> divmod(x, y)"; - public final static String complex___doc___doc = - "str(object) -> string\n" + + public final static String complex_doc = + "complex(real[, imag]) -> complex number\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Create a complex number from a real part and an optional imaginary part.\n" + + "This is equivalent to (real + imag*1j) where imag defaults to 0."; public final static String complex___eq___doc = "x.__eq__(y) <==> x==y"; @@ -2393,7 +2431,7 @@ public final static String complex_real_doc = "the real part of a complex number"; - //Docs for <type 'bool'> + // Docs for <type 'bool'> public final static String bool___abs___doc = "x.__abs__() <==> abs(x)"; @@ -2422,11 +2460,12 @@ public final static String bool___divmod___doc = "x.__divmod__(y) <==> divmod(x, y)"; - public final static String bool___doc___doc = - "str(object) -> string\n" + + public final static String bool_doc = + "bool(x) -> bool\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Returns True when the argument x is true, False otherwise.\n" + + "The builtins True and False are the only two instances of the class bool.\n" + + "The class bool is a subclass of the class int, and cannot be subclassed."; public final static String bool___float___doc = "x.__float__() <==> float(x)"; @@ -2560,7 +2599,7 @@ public final static String bool___xor___doc = "x.__xor__(y) <==> x^y"; - //Docs for <type 'classmethod'> + // Docs for <type 'classmethod'> public final static String classmethod___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -2568,11 +2607,26 @@ public final static String classmethod___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String classmethod___doc___doc = - "str(object) -> string\n" + + public final static String classmethod_doc = + "classmethod(function) -> method\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Convert a function to be a class method.\n" + + "\n" + + "A class method receives the class as implicit first argument,\n" + + "just like an instance method receives the instance.\n" + + "To declare a class method, use this idiom:\n" + + "\n" + + " class C:\n" + + " def f(cls, arg1, arg2, ...): ...\n" + + " f = classmethod(f)\n" + + "\n" + + "It can be called either on the class (e.g. C.f()) or on an instance\n" + + "(e.g. C().f()). The instance is ignored except for its class.\n" + + "If a class method is called for a derived class, the derived class\n" + + "object is passed as the implied first argument.\n" + + "\n" + + "Class methods are different than C++ or Java static methods.\n" + + "If you want those, see the staticmethod builtin."; public final static String classmethod___get___doc = "descr.__get__(obj[, type]) -> value"; @@ -2604,7 +2658,7 @@ public final static String classmethod___str___doc = "x.__str__() <==> str(x)"; - //Docs for <type 'function'> + // Docs for <type 'function'> public final static String function___call___doc = "x.__call__(...) <==> x(...)"; @@ -2618,11 +2672,13 @@ public final static String function___dict___doc = ""; - public final static String function___doc___doc = - "str(object) -> string\n" + + public final static String function_doc = + "function(code, globals[, name[, argdefs[, closure]]])\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Create a function object from a code object and a dictionary.\n" + + "The optional name string overrides the name from the code object.\n" + + "The optional argdefs tuple specifies the default argument values.\n" + + "The optional closure tuple supplies the bindings for free variables."; public final static String function___get___doc = "descr.__get__(obj[, type]) -> value"; @@ -2687,7 +2743,7 @@ public final static String function_func_name_doc = ""; - //Docs for <type 'instancemethod'> + // Docs for <type 'instancemethod'> public final static String instancemethod___call___doc = "x.__call__(...) <==> x(...)"; @@ -2701,11 +2757,10 @@ public final static String instancemethod___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String instancemethod___doc___doc = - "str(object) -> string\n" + + public final static String instancemethod_doc = + "instancemethod(function, instance, class)\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Create an instance method object."; public final static String instancemethod___get___doc = "descr.__get__(obj[, type]) -> value"; @@ -2746,7 +2801,7 @@ public final static String instancemethod_im_self_doc = "the instance to which a method is bound; None for unbound methods"; - //Docs for <type 'code'> + // Docs for <type 'code'> public final static String code___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -2757,11 +2812,11 @@ public final static String code___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String code___doc___doc = - "str(object) -> string\n" + + public final static String code_doc = + "code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n" + + " varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])\n" + "\n" + - "Return a nice string representation of the object.\n" + - "If the argument is a string, the return value is the same object."; + "Create a code object. Not for the faint of heart."; public final static String code___getattribute___doc = "x.__getattribute__('name') <==> x.name"; @@ -2832,7 +2887,7 @@ public final static String code_co_varnames_doc = ""; - //Docs for <type 'frame'> + // Docs for <type 'frame'> public final static String frame___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -2840,7 +2895,7 @@ public final static String frame___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String frame___doc___doc = + public final static String frame_doc = ""; public final static String frame___getattribute___doc = @@ -2906,7 +2961,7 @@ public final static String frame_f_trace_doc = ""; - //Docs for <type 'traceback'> + // Docs for <type 'traceback'> public final static String traceback___class___doc = "type(object) -> the object's type\n" + "type(name, bases, dict) -> a new type"; @@ -2914,7 +2969,7 @@ public final static String traceback___delattr___doc = "x.__delattr__('name') <==> del x.name"; - public final static String traceback___doc___doc = + public final static String traceback_doc = ""; public final static String traceback___getattribute___doc = Modified: trunk/jython/src/org/python/core/PyBaseString.java =================================================================== --- trunk/jython/src/org/python/core/PyBaseString.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyBaseString.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -5,7 +5,7 @@ /** * base class for jython strings. */ -@ExposedType(name = "basestring", base = PyObject.class) +@ExposedType(name = "basestring", base = PyObject.class, doc = BuiltinDocs.basestring_doc) public abstract class PyBaseString extends PySequence { public static final PyType TYPE = PyType.fromClass(PyBaseString.class); Modified: trunk/jython/src/org/python/core/PyBoolean.java =================================================================== --- trunk/jython/src/org/python/core/PyBoolean.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyBoolean.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -8,7 +8,7 @@ /** * A builtin python bool. */ -@ExposedType(name = "bool", isBaseType = false) +@ExposedType(name = "bool", isBaseType = false, doc = BuiltinDocs.bool_doc) public class PyBoolean extends PyInteger { public static final PyType TYPE = PyType.fromClass(PyBoolean.class); Modified: trunk/jython/src/org/python/core/PyClassMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyClassMethod.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyClassMethod.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -7,7 +7,7 @@ /** * The classmethod descriptor. */ -@ExposedType(name = "classmethod") +@ExposedType(name = "classmethod", doc = BuiltinDocs.classmethod_doc) public class PyClassMethod extends PyObject { public static final PyType TYPE = PyType.fromClass(PyClassMethod.class); Modified: trunk/jython/src/org/python/core/PyComplex.java =================================================================== --- trunk/jython/src/org/python/core/PyComplex.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyComplex.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -10,14 +10,17 @@ /** * A builtin python complex number */ -@ExposedType(name = "complex") +@ExposedType(name = "complex", doc = BuiltinDocs.complex_doc) public class PyComplex extends PyObject { public static final PyType TYPE = PyType.fromClass(PyComplex.class); - @ExposedGet - public double real, imag; + @ExposedGet(doc = BuiltinDocs.complex_real_doc) + public double real; + @ExposedGet(doc = BuiltinDocs.complex_imag_doc) + public double imag; + static PyComplex J = new PyComplex(0, 1.); @ExposedNew Modified: trunk/jython/src/org/python/core/PyDictionary.java =================================================================== --- trunk/jython/src/org/python/core/PyDictionary.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyDictionary.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -22,7 +22,7 @@ /** * A builtin python dictionary. */ -@ExposedType(name = "dict") +@ExposedType(name = "dict", doc = BuiltinDocs.dict_doc) public class PyDictionary extends PyObject implements ConcurrentMap { public static final PyType TYPE = PyType.fromClass(PyDictionary.class); Modified: trunk/jython/src/org/python/core/PyEnumerate.java =================================================================== --- trunk/jython/src/org/python/core/PyEnumerate.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyEnumerate.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -8,7 +8,7 @@ /** * The Python builtin enumerate type. */ -@ExposedType(name = "enumerate", base = PyObject.class) +@ExposedType(name = "enumerate", base = PyObject.class, doc = BuiltinDocs.enumerate_doc) public class PyEnumerate extends PyIterator { public static final PyType TYPE = PyType.fromClass(PyEnumerate.class); Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyFile.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -32,20 +32,20 @@ /** * The Python file type. Wraps an {@link TextIOBase} object. */ -@ExposedType(name = "file") +@ExposedType(name = "file", doc = BuiltinDocs.file_doc) public class PyFile extends PyObject { public static final PyType TYPE = PyType.fromClass(PyFile.class); /** The filename */ - @ExposedGet + @ExposedGet(doc = BuiltinDocs.file_name_doc) public PyObject name; /** The mode string */ - @ExposedGet + @ExposedGet(doc = BuiltinDocs.file_mode_doc) public String mode; - @ExposedGet + @ExposedGet(doc = BuiltinDocs.file_encoding_doc) public String encoding; /** Indicator dictating whether a space should be written to this @@ -525,17 +525,17 @@ file.checkClosed(); } - @ExposedGet(name = "closed") + @ExposedGet(name = "closed", doc = BuiltinDocs.file_closed_doc) public boolean getClosed() { return file.closed(); } - @ExposedGet(name = "newlines") + @ExposedGet(name = "newlines", doc = BuiltinDocs.file_newlines_doc) public PyObject getNewlines() { return file.getNewlines(); } - @ExposedGet(name = "softspace") + @ExposedGet(name = "softspace", doc = BuiltinDocs.file_softspace_doc) public PyObject getSoftspace() { // NOTE: not actual bools because CPython is this way return softspace ? Py.One : Py.Zero; Modified: trunk/jython/src/org/python/core/PyFloat.java =================================================================== --- trunk/jython/src/org/python/core/PyFloat.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyFloat.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -13,7 +13,7 @@ /** * A builtin python float. */ -@ExposedType(name = "float") +@ExposedType(name = "float", doc = BuiltinDocs.float_doc) public class PyFloat extends PyObject { /** Precisions used by repr() and str(), respectively. */ Modified: trunk/jython/src/org/python/core/PyFunction.java =================================================================== --- trunk/jython/src/org/python/core/PyFunction.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyFunction.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -11,7 +11,7 @@ /** * A Python function. */ -@ExposedType(name = "function", isBaseType = false) +@ExposedType(name = "function", isBaseType = false, doc = BuiltinDocs.function_doc) public class PyFunction extends PyObject { public static final PyType TYPE = PyType.fromClass(PyFunction.class); Modified: trunk/jython/src/org/python/core/PyInteger.java =================================================================== --- trunk/jython/src/org/python/core/PyInteger.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyInteger.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -12,7 +12,7 @@ /** * A builtin python int. */ -@ExposedType(name = "int") +@ExposedType(name = "int", doc = BuiltinDocs.int_doc) public class PyInteger extends PyObject { public static final PyType TYPE = PyType.fromClass(PyInteger.class); Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyList.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -19,7 +19,7 @@ import java.lang.reflect.Array; -@ExposedType(name = "list", base = PyObject.class) +@ExposedType(name = "list", base = PyObject.class, doc = BuiltinDocs.list_doc) public class PyList extends PySequenceList implements List { public static final PyType TYPE = PyType.fromClass(PyList.class); Modified: trunk/jython/src/org/python/core/PyLong.java =================================================================== --- trunk/jython/src/org/python/core/PyLong.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyLong.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -14,7 +14,7 @@ * A builtin python long. This is implemented as a * java.math.BigInteger. */ -@ExposedType(name = "long") +@ExposedType(name = "long", doc = BuiltinDocs.long_doc) public class PyLong extends PyObject { public static final PyType TYPE = PyType.fromClass(PyLong.class); Modified: trunk/jython/src/org/python/core/PyMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyMethod.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyMethod.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -10,21 +10,21 @@ /** * A Python method. */ -@ExposedType(name = "instancemethod", isBaseType = false) +@ExposedType(name = "instancemethod", isBaseType = false, doc = BuiltinDocs.instancemethod_doc) public class PyMethod extends PyObject { public static final PyType TYPE = PyType.fromClass(PyMethod.class); /** The class associated with a method. */ - @ExposedGet + @ExposedGet(doc = BuiltinDocs.instancemethod_im_class_doc) public PyObject im_class; /** The function (or other callable) implementing a method. */ - @ExposedGet + @ExposedGet(doc = BuiltinDocs.instancemethod_im_func_doc) public PyObject im_func; /** The instance to which a method is bound; None for unbound methods. */ - @ExposedGet + @ExposedGet(doc = BuiltinDocs.instancemethod_im_self_doc) public PyObject im_self; public PyMethod(PyObject function, PyObject self, PyObject type) { Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyObject.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -20,7 +20,7 @@ * All objects known to the Jython runtime system are represented by an instance * of the class <code>PyObject</code> or one of its subclasses. */ -@ExposedType(name = "object") +@ExposedType(name = "object", doc = BuiltinDocs.object_doc) public class PyObject implements Serializable { public static final PyType TYPE = PyType.fromClass(PyObject.class); Modified: trunk/jython/src/org/python/core/PyProperty.java =================================================================== --- trunk/jython/src/org/python/core/PyProperty.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyProperty.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -3,21 +3,20 @@ import org.python.expose.ExposedGet; import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; -import org.python.expose.ExposedSet; import org.python.expose.ExposedType; -@ExposedType(name = "property") +@ExposedType(name = "property", doc = BuiltinDocs.property_doc) public class PyProperty extends PyObject { public static final PyType TYPE = PyType.fromClass(PyProperty.class); - @ExposedGet + @ExposedGet(doc = BuiltinDocs.property_fget_doc) protected PyObject fget; - @ExposedGet + @ExposedGet(doc = BuiltinDocs.property_fset_doc) protected PyObject fset; - @ExposedGet + @ExposedGet(doc = BuiltinDocs.property_fdel_doc) protected PyObject fdel; @ExposedGet(name = "__doc__") Modified: trunk/jython/src/org/python/core/PySlice.java =================================================================== --- trunk/jython/src/org/python/core/PySlice.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PySlice.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -9,18 +9,18 @@ /** * The Python slice object. */ -@ExposedType(name = "slice", isBaseType = false) +@ExposedType(name = "slice", isBaseType = false, doc = BuiltinDocs.slice_doc) public class PySlice extends PyObject { public static final PyType TYPE = PyType.fromClass(PySlice.class); - @ExposedGet + @ExposedGet(doc = BuiltinDocs.slice_start_doc) public PyObject start = Py.None; - @ExposedGet + @ExposedGet(doc = BuiltinDocs.slice_stop_doc) public PyObject stop = Py.None; - @ExposedGet + @ExposedGet(doc = BuiltinDocs.slice_step_doc) public PyObject step = Py.None; public PySlice() { Modified: trunk/jython/src/org/python/core/PyStaticMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyStaticMethod.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyStaticMethod.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -7,7 +7,7 @@ /** * The staticmethod descriptor. */ -@ExposedType(name = "staticmethod") +@ExposedType(name = "staticmethod", doc = BuiltinDocs.staticmethod_doc) public class PyStaticMethod extends PyObject { public static final PyType TYPE = PyType.fromClass(PyStaticMethod.class); Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyString.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -13,7 +13,7 @@ /** * A builtin python string. */ -@ExposedType(name = "str") +@ExposedType(name = "str", doc = BuiltinDocs.str_doc) public class PyString extends PyBaseString { public static final PyType TYPE = PyType.fromClass(PyString.class); Modified: trunk/jython/src/org/python/core/PySuper.java =================================================================== --- trunk/jython/src/org/python/core/PySuper.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PySuper.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -9,18 +9,18 @@ /** * The Python super type. */ -@ExposedType(name = "super") +@ExposedType(name = "super", doc = BuiltinDocs.super_doc) public class PySuper extends PyObject { public static final PyType TYPE = PyType.fromClass(PySuper.class); - @ExposedGet(name = "__thisclass__") + @ExposedGet(name = "__thisclass__", doc = BuiltinDocs.super___thisclass___doc) protected PyType superType; - @ExposedGet(name = "__self__") + @ExposedGet(name = "__self__", doc = BuiltinDocs.super___self___doc) protected PyObject obj; - @ExposedGet(name = "__self_class__") + @ExposedGet(name = "__self_class__", doc = BuiltinDocs.super___self_class___doc) protected PyType objType; public PySuper() { Modified: trunk/jython/src/org/python/core/PyTuple.java =================================================================== --- trunk/jython/src/org/python/core/PyTuple.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyTuple.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -17,7 +17,7 @@ /** * A builtin python tuple. */ -@ExposedType(name = "tuple", base = PyObject.class) +@ExposedType(name = "tuple", base = PyObject.class, doc = BuiltinDocs.tuple_doc) public class PyTuple extends PySequenceList implements List { public static final PyType TYPE = PyType.fromClass(PyTuple.class); Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyType.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -25,7 +25,7 @@ /** * The Python Type object implementation. */ -@ExposedType(name = "type") +@ExposedType(name = "type", doc = BuiltinDocs.type_doc) public class PyType extends PyObject implements Serializable { public static PyType TYPE = fromClass(PyType.class); @@ -640,7 +640,6 @@ bases = cleanedBases.toArray(new PyObject[cleanedBases.size()]); } - //XXX: needs __doc__ @ExposedGet(name = "__base__") public PyObject getBase() { if (base == null) @@ -648,7 +647,6 @@ return base; } - //XXX: needs __doc__ @ExposedGet(name = "__bases__") public PyObject getBases() { return new PyTuple(bases); Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyUnicode.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -17,7 +17,7 @@ /** * a builtin python unicode string. */ -@ExposedType(name = "unicode", base = PyBaseString.class) +@ExposedType(name = "unicode", base = PyBaseString.class, doc = BuiltinDocs.unicode_doc) public class PyUnicode extends PyString implements Iterable { private enum Plane { Modified: trunk/jython/src/org/python/core/PyXRange.java =================================================================== --- trunk/jython/src/org/python/core/PyXRange.java 2009-10-14 03:19:24 UTC (rev 6855) +++ trunk/jython/src/org/python/core/PyXRange.java 2009-10-14 06:02:01 UTC (rev 6856) @@ -8,7 +8,8 @@ /** * The builtin xrange type. */ -@ExposedType(name = "xrange", base = PyObject.class, isBaseType = false) +@ExposedType(name = "xrange", base = PyObject.class, isBaseType = false, + doc = BuiltinDocs.xrange_doc) public class PyXRange extends PySequence { public static final PyType TYPE = PyType.fromClass(PyXRange.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |