From: <fwi...@us...> - 2008-12-23 00:35:36
|
Revision: 5788 http://jython.svn.sourceforge.net/jython/?rev=5788&view=rev Author: fwierzbicki Date: 2008-12-23 00:35:32 +0000 (Tue, 23 Dec 2008) Log Message: ----------- First cut at generating the __doc__ test for builtin types. So far I am only generating the docs for str and unicode, and I have only exposed the docs for str. Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java Added Paths: ----------- trunk/jython/Misc/make_pydocs.py trunk/jython/src/org/python/core/BuiltinDocs.java Added: trunk/jython/Misc/make_pydocs.py =================================================================== --- trunk/jython/Misc/make_pydocs.py (rev 0) +++ trunk/jython/Misc/make_pydocs.py 2008-12-23 00:35:32 UTC (rev 5788) @@ -0,0 +1,26 @@ +class PyDocGenerator(object): + def __init__(self): + self.out = open("BuiltinDocs.java", "w") + print >> self.out, '//generated by make_pydocs.py\n' + print >> self.out, 'package org.python.core;\n' + print >> self.out, 'public class BuiltinDocs {\n' + objects = [str, unicode] + for obj in objects: + print >> self.out, ' //Docs for %s' % obj + for meth in dir(obj): + self.print_doc(obj, meth) + print >> self.out, '}' + + + def print_doc(self, obj, meth): + doc = (getattr(obj, meth)).__doc__ + if doc == None: + doc = "" + lines = doc.split("\n") + out = '\\n" + \n "'.join(lines) + print >> self.out, (' public final static String %s_%s_doc = ' + % (obj.__name__, meth)) + print >> self.out, ' "%s";\n' % out + +if __name__ == '__main__': + PyDocGenerator() Added: trunk/jython/src/org/python/core/BuiltinDocs.java =================================================================== --- trunk/jython/src/org/python/core/BuiltinDocs.java (rev 0) +++ trunk/jython/src/org/python/core/BuiltinDocs.java 2008-12-23 00:35:32 UTC (rev 5788) @@ -0,0 +1,710 @@ +//generated by make_pydocs.py + +package org.python.core; + +public class BuiltinDocs { + + //Docs for <type 'str'> + public final static String str___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String str___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String str___contains___doc = + "x.__contains__(y) <==> y in x"; + + public final static String str___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String str___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 str___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String str___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String str___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String str___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String str___getnewargs___doc = + ""; + + public final static String str___getslice___doc = + "x.__getslice__(i, j) <==> x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String str___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String str___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String str___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String str___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String str___len___doc = + "x.__len__() <==> len(x)"; + + public final static String str___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String str___mod___doc = + "x.__mod__(y) <==> x%y"; + + public final static String str___mul___doc = + "x.__mul__(n) <==> x*n"; + + public final static String str___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String str___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String str___reduce___doc = + "helper for pickle"; + + public final static String str___reduce_ex___doc = + "helper for pickle"; + + public final static String str___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String str___rmod___doc = + "x.__rmod__(y) <==> y%x"; + + public final static String str___rmul___doc = + "x.__rmul__(n) <==> n*x"; + + public final static String str___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String str___str___doc = + "x.__str__() <==> str(x)"; + + public final static String str_capitalize_doc = + "S.capitalize() -> string\n" + + "\n" + + "Return a copy of the string S with only its first character\n" + + "capitalized."; + + public final static String str_center_doc = + "S.center(width[, fillchar]) -> string\n" + + "\n" + + "Return S centered in a string of length width. Padding is\n" + + "done using the specified fill character (default is a space)"; + + public final static String str_count_doc = + "S.count(sub[, start[, end]]) -> int\n" + + "\n" + + "Return the number of non-overlapping occurrences of substring sub in\n" + + "string S[start:end]. Optional arguments start and end are interpreted\n" + + "as in slice notation."; + + public final static String str_decode_doc = + "S.decode([encoding[,errors]]) -> object\n" + + "\n" + + "Decodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n" + + "as well as any other name registerd with codecs.register_error that is\n" + + "able to handle UnicodeDecodeErrors."; + + public final static String str_encode_doc = + "S.encode([encoding[,errors]]) -> object\n" + + "\n" + + "Encodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n" + + "'xmlcharrefreplace' as well as any other name registered with\n" + + "codecs.register_error that is able to handle UnicodeEncodeErrors."; + + public final static String str_endswith_doc = + "S.endswith(suffix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S ends with the specified suffix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "suffix can also be a tuple of strings to try."; + + public final static String str_expandtabs_doc = + "S.expandtabs([tabsize]) -> string\n" + + "\n" + + "Return a copy of S where all tab characters are expanded using spaces.\n" + + "If tabsize is not given, a tab size of 8 characters is assumed."; + + public final static String str_find_doc = + "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" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String str_index_doc = + "S.index(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.find() but raise ValueError when the substring is not found."; + + public final static String str_isalnum_doc = + "S.isalnum() -> bool\n" + + "\n" + + "Return True if all characters in S are alphanumeric\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_isalpha_doc = + "S.isalpha() -> bool\n" + + "\n" + + "Return True if all characters in S are alphabetic\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_isdigit_doc = + "S.isdigit() -> bool\n" + + "\n" + + "Return True if all characters in S are digits\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_islower_doc = + "S.islower() -> bool\n" + + "\n" + + "Return True if all cased characters in S are lowercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String str_isspace_doc = + "S.isspace() -> bool\n" + + "\n" + + "Return True if all characters in S are whitespace\n" + + "and there is at least one character in S, False otherwise."; + + public final static String str_istitle_doc = + "S.istitle() -> bool\n" + + "\n" + + "Return True if S is a titlecased string and there is at least one\n" + + "character in S, i.e. uppercase characters may only follow uncased\n" + + "characters and lowercase characters only cased ones. Return False\n" + + "otherwise."; + + public final static String str_isupper_doc = + "S.isupper() -> bool\n" + + "\n" + + "Return True if all cased characters in S are uppercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String str_join_doc = + "S.join(sequence) -> string\n" + + "\n" + + "Return a string which is the concatenation of the strings in the\n" + + "sequence. The separator between elements is S."; + + public final static String str_ljust_doc = + "S.ljust(width[, fillchar]) -> string\n" + + "\n" + + "Return S left justified in a string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String str_lower_doc = + "S.lower() -> string\n" + + "\n" + + "Return a copy of the string S converted to lowercase."; + + public final static String str_lstrip_doc = + "S.lstrip([chars]) -> string or unicode\n" + + "\n" + + "Return a copy of the string S with leading whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is unicode, S will be converted to unicode before stripping"; + + public final static String str_partition_doc = + "S.partition(sep) -> (head, sep, tail)\n" + + "\n" + + "Searches for the separator sep in S, and returns the part before it,\n" + + "the separator itself, and the part after it. If the separator is not\n" + + "found, returns S and two empty strings."; + + public final static String str_replace_doc = + "S.replace (old, new[, count]) -> string\n" + + "\n" + + "Return a copy of string S with all occurrences of substring\n" + + "old replaced by new. If the optional argument count is\n" + + "given, only the first count occurrences are replaced."; + + public final static String str_rfind_doc = + "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" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String str_rindex_doc = + "S.rindex(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.rfind() but raise ValueError when the substring is not found."; + + public final static String str_rjust_doc = + "S.rjust(width[, fillchar]) -> string\n" + + "\n" + + "Return S right justified in a string of length width. Padding is\n" + + "done using the specified fill character (default is a space)"; + + public final static String str_rpartition_doc = + "S.rpartition(sep) -> (tail, sep, head)\n" + + "\n" + + "Searches for the separator sep in S, starting at the end of S, and returns\n" + + "the part before it, the separator itself, and the part after it. If the\n" + + "separator is not found, returns two empty strings and S."; + + public final static String str_rsplit_doc = + "S.rsplit([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in the string S, using sep as the\n" + + "delimiter string, starting at the end of the string and working\n" + + "to the front. If maxsplit is given, at most maxsplit splits are\n" + + "done. If sep is not specified or is None, any whitespace string\n" + + "is a separator."; + + public final static String str_rstrip_doc = + "S.rstrip([chars]) -> string or unicode\n" + + "\n" + + "Return a copy of the string S with trailing whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is unicode, S will be converted to unicode before stripping"; + + public final static String str_split_doc = + "S.split([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in the string S, using sep as the\n" + + "delimiter string. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified or is None, any\n" + + "whitespace string is a separator."; + + public final static String str_splitlines_doc = + "S.splitlines([keepends]) -> list of strings\n" + + "\n" + + "Return a list of the lines in S, breaking at line boundaries.\n" + + "Line breaks are not included in the resulting list unless keepends\n" + + "is given and true."; + + public final static String str_startswith_doc = + "S.startswith(prefix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S starts with the specified prefix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "prefix can also be a tuple of strings to try."; + + public final static String str_strip_doc = + "S.strip([chars]) -> string or unicode\n" + + "\n" + + "Return a copy of the string S with leading and trailing\n" + + "whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is unicode, S will be converted to unicode before stripping"; + + public final static String str_swapcase_doc = + "S.swapcase() -> string\n" + + "\n" + + "Return a copy of the string S with uppercase characters\n" + + "converted to lowercase and vice versa."; + + public final static String str_title_doc = + "S.title() -> string\n" + + "\n" + + "Return a titlecased version of S, i.e. words start with uppercase\n" + + "characters, all remaining cased characters have lowercase."; + + public final static String str_translate_doc = + "S.translate(table [,deletechars]) -> string\n" + + "\n" + + "Return a copy of the string S, where all characters occurring\n" + + "in the optional argument deletechars are removed, and the\n" + + "remaining characters have been mapped through the given\n" + + "translation table, which must be a string of length 256."; + + public final static String str_upper_doc = + "S.upper() -> string\n" + + "\n" + + "Return a copy of the string S converted to uppercase."; + + public final static String str_zfill_doc = + "S.zfill(width) -> string\n" + + "\n" + + "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 'unicode'> + public final static String unicode___add___doc = + "x.__add__(y) <==> x+y"; + + public final static String unicode___class___doc = + "type(object) -> the object's type\n" + + "type(name, bases, dict) -> a new type"; + + public final static String unicode___contains___doc = + "x.__contains__(y) <==> y in x"; + + public final static String unicode___delattr___doc = + "x.__delattr__('name') <==> del x.name"; + + public final static String unicode___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 unicode___eq___doc = + "x.__eq__(y) <==> x==y"; + + public final static String unicode___ge___doc = + "x.__ge__(y) <==> x>=y"; + + public final static String unicode___getattribute___doc = + "x.__getattribute__('name') <==> x.name"; + + public final static String unicode___getitem___doc = + "x.__getitem__(y) <==> x[y]"; + + public final static String unicode___getnewargs___doc = + ""; + + public final static String unicode___getslice___doc = + "x.__getslice__(i, j) <==> x[i:j]\n" + + " \n" + + " Use of negative indices is not supported."; + + public final static String unicode___gt___doc = + "x.__gt__(y) <==> x>y"; + + public final static String unicode___hash___doc = + "x.__hash__() <==> hash(x)"; + + public final static String unicode___init___doc = + "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"; + + public final static String unicode___le___doc = + "x.__le__(y) <==> x<=y"; + + public final static String unicode___len___doc = + "x.__len__() <==> len(x)"; + + public final static String unicode___lt___doc = + "x.__lt__(y) <==> x<y"; + + public final static String unicode___mod___doc = + "x.__mod__(y) <==> x%y"; + + public final static String unicode___mul___doc = + "x.__mul__(n) <==> x*n"; + + public final static String unicode___ne___doc = + "x.__ne__(y) <==> x!=y"; + + public final static String unicode___new___doc = + "T.__new__(S, ...) -> a new object with type S, a subtype of T"; + + public final static String unicode___reduce___doc = + "helper for pickle"; + + public final static String unicode___reduce_ex___doc = + "helper for pickle"; + + public final static String unicode___repr___doc = + "x.__repr__() <==> repr(x)"; + + public final static String unicode___rmod___doc = + "x.__rmod__(y) <==> y%x"; + + public final static String unicode___rmul___doc = + "x.__rmul__(n) <==> n*x"; + + public final static String unicode___setattr___doc = + "x.__setattr__('name', value) <==> x.name = value"; + + public final static String unicode___str___doc = + "x.__str__() <==> str(x)"; + + public final static String unicode_capitalize_doc = + "S.capitalize() -> unicode\n" + + "\n" + + "Return a capitalized version of S, i.e. make the first character\n" + + "have upper case."; + + public final static String unicode_center_doc = + "S.center(width[, fillchar]) -> unicode\n" + + "\n" + + "Return S centered in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)"; + + public final static String unicode_count_doc = + "S.count(sub[, start[, end]]) -> int\n" + + "\n" + + "Return the number of non-overlapping occurrences of substring sub in\n" + + "Unicode string S[start:end]. Optional arguments start and end are\n" + + "interpreted as in slice notation."; + + public final static String unicode_decode_doc = + "S.decode([encoding[,errors]]) -> string or unicode\n" + + "\n" + + "Decodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n" + + "as well as any other name registerd with codecs.register_error that is\n" + + "able to handle UnicodeDecodeErrors."; + + public final static String unicode_encode_doc = + "S.encode([encoding[,errors]]) -> string or unicode\n" + + "\n" + + "Encodes S using the codec registered for encoding. encoding defaults\n" + + "to the default encoding. errors may be given to set a different error\n" + + "handling scheme. Default is 'strict' meaning that encoding errors raise\n" + + "a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n" + + "'xmlcharrefreplace' as well as any other name registered with\n" + + "codecs.register_error that can handle UnicodeEncodeErrors."; + + public final static String unicode_endswith_doc = + "S.endswith(suffix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S ends with the specified suffix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "suffix can also be a tuple of strings to try."; + + public final static String unicode_expandtabs_doc = + "S.expandtabs([tabsize]) -> unicode\n" + + "\n" + + "Return a copy of S where all tab characters are expanded using spaces.\n" + + "If tabsize is not given, a tab size of 8 characters is assumed."; + + public final static String unicode_find_doc = + "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" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String unicode_index_doc = + "S.index(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.find() but raise ValueError when the substring is not found."; + + public final static String unicode_isalnum_doc = + "S.isalnum() -> bool\n" + + "\n" + + "Return True if all characters in S are alphanumeric\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_isalpha_doc = + "S.isalpha() -> bool\n" + + "\n" + + "Return True if all characters in S are alphabetic\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_isdecimal_doc = + "S.isdecimal() -> bool\n" + + "\n" + + "Return True if there are only decimal characters in S,\n" + + "False otherwise."; + + public final static String unicode_isdigit_doc = + "S.isdigit() -> bool\n" + + "\n" + + "Return True if all characters in S are digits\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_islower_doc = + "S.islower() -> bool\n" + + "\n" + + "Return True if all cased characters in S are lowercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String unicode_isnumeric_doc = + "S.isnumeric() -> bool\n" + + "\n" + + "Return True if there are only numeric characters in S,\n" + + "False otherwise."; + + public final static String unicode_isspace_doc = + "S.isspace() -> bool\n" + + "\n" + + "Return True if all characters in S are whitespace\n" + + "and there is at least one character in S, False otherwise."; + + public final static String unicode_istitle_doc = + "S.istitle() -> bool\n" + + "\n" + + "Return True if S is a titlecased string and there is at least one\n" + + "character in S, i.e. upper- and titlecase characters may only\n" + + "follow uncased characters and lowercase characters only cased ones.\n" + + "Return False otherwise."; + + public final static String unicode_isupper_doc = + "S.isupper() -> bool\n" + + "\n" + + "Return True if all cased characters in S are uppercase and there is\n" + + "at least one cased character in S, False otherwise."; + + public final static String unicode_join_doc = + "S.join(sequence) -> unicode\n" + + "\n" + + "Return a string which is the concatenation of the strings in the\n" + + "sequence. The separator between elements is S."; + + public final static String unicode_ljust_doc = + "S.ljust(width[, fillchar]) -> int\n" + + "\n" + + "Return S left justified in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String unicode_lower_doc = + "S.lower() -> unicode\n" + + "\n" + + "Return a copy of the string S converted to lowercase."; + + public final static String unicode_lstrip_doc = + "S.lstrip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with leading whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_partition_doc = + "S.partition(sep) -> (head, sep, tail)\n" + + "\n" + + "Searches for the separator sep in S, and returns the part before it,\n" + + "the separator itself, and the part after it. If the separator is not\n" + + "found, returns S and two empty strings."; + + public final static String unicode_replace_doc = + "S.replace (old, new[, maxsplit]) -> unicode\n" + + "\n" + + "Return a copy of S with all occurrences of substring\n" + + "old replaced by new. If the optional argument maxsplit is\n" + + "given, only the first maxsplit occurrences are replaced."; + + public final static String unicode_rfind_doc = + "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" + + "arguments start and end are interpreted as in slice notation.\n" + + "\n" + + "Return -1 on failure."; + + public final static String unicode_rindex_doc = + "S.rindex(sub [,start [,end]]) -> int\n" + + "\n" + + "Like S.rfind() but raise ValueError when the substring is not found."; + + public final static String unicode_rjust_doc = + "S.rjust(width[, fillchar]) -> unicode\n" + + "\n" + + "Return S right justified in a Unicode string of length width. Padding is\n" + + "done using the specified fill character (default is a space)."; + + public final static String unicode_rpartition_doc = + "S.rpartition(sep) -> (tail, sep, head)\n" + + "\n" + + "Searches for the separator sep in S, starting at the end of S, and returns\n" + + "the part before it, the separator itself, and the part after it. If the\n" + + "separator is not found, returns two empty strings and S."; + + public final static String unicode_rsplit_doc = + "S.rsplit([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in S, using sep as the\n" + + "delimiter string, starting at the end of the string and\n" + + "working to the front. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified, any whitespace string\n" + + "is a separator."; + + public final static String unicode_rstrip_doc = + "S.rstrip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with trailing whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_split_doc = + "S.split([sep [,maxsplit]]) -> list of strings\n" + + "\n" + + "Return a list of the words in S, using sep as the\n" + + "delimiter string. If maxsplit is given, at most maxsplit\n" + + "splits are done. If sep is not specified or is None,\n" + + "any whitespace string is a separator."; + + public final static String unicode_splitlines_doc = + "S.splitlines([keepends]]) -> list of strings\n" + + "\n" + + "Return a list of the lines in S, breaking at line boundaries.\n" + + "Line breaks are not included in the resulting list unless keepends\n" + + "is given and true."; + + public final static String unicode_startswith_doc = + "S.startswith(prefix[, start[, end]]) -> bool\n" + + "\n" + + "Return True if S starts with the specified prefix, False otherwise.\n" + + "With optional start, test S beginning at that position.\n" + + "With optional end, stop comparing S at that position.\n" + + "prefix can also be a tuple of strings to try."; + + public final static String unicode_strip_doc = + "S.strip([chars]) -> unicode\n" + + "\n" + + "Return a copy of the string S with leading and trailing\n" + + "whitespace removed.\n" + + "If chars is given and not None, remove characters in chars instead.\n" + + "If chars is a str, it will be converted to unicode before stripping"; + + public final static String unicode_swapcase_doc = + "S.swapcase() -> unicode\n" + + "\n" + + "Return a copy of S with uppercase characters converted to lowercase\n" + + "and vice versa."; + + public final static String unicode_title_doc = + "S.title() -> unicode\n" + + "\n" + + "Return a titlecased version of S, i.e. words start with title case\n" + + "characters, all remaining cased characters have lower case."; + + public final static String unicode_translate_doc = + "S.translate(table) -> unicode\n" + + "\n" + + "Return a copy of the string S, where all characters have been mapped\n" + + "through the given translation table, which must be a mapping of\n" + + "Unicode ordinals to Unicode ordinals, Unicode strings or None.\n" + + "Unmapped characters are left untouched. Characters mapped to None\n" + + "are deleted."; + + public final static String unicode_upper_doc = + "S.upper() -> unicode\n" + + "\n" + + "Return a copy of S converted to uppercase."; + + public final static String unicode_zfill_doc = + "S.zfill(width) -> unicode\n" + + "\n" + + "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."; + +} Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-12-22 03:29:57 UTC (rev 5787) +++ trunk/jython/src/org/python/core/PyString.java 2008-12-23 00:35:32 UTC (rev 5788) @@ -92,7 +92,7 @@ return str___str__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___str___doc) final PyString str___str__() { if (getClass() == PyString.class) { return this; @@ -104,6 +104,7 @@ return str___unicode__(); } + //XXX: need doc @ExposedMethod final PyUnicode str___unicode__() { return new PyUnicode(this); @@ -113,7 +114,7 @@ return str___len__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___len___doc) final int str___len__() { return string.length(); } @@ -122,6 +123,7 @@ return string; } + //XXX: need doc @ExposedMethod final String str_toString() { return toString(); @@ -141,7 +143,7 @@ return str___repr__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___repr___doc) final PyString str___repr__() { return new PyString(encode_UnicodeEscape(string, true)); } @@ -471,7 +473,7 @@ return false; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___getitem___doc) final PyObject str___getitem__(PyObject index) { PyObject ret = seq___finditem__(index); if (ret == null) { @@ -480,6 +482,7 @@ return ret; } + //XXX: need doc @ExposedMethod(defaults = "null") final PyObject str___getslice__(PyObject start, PyObject stop, PyObject step) { return seq___getslice__(start, stop, step); @@ -502,7 +505,7 @@ return str___eq__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___eq___doc) final PyObject str___eq__(PyObject other) { String s = coerce(other); if (s == null) @@ -514,7 +517,7 @@ return str___ne__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___ne___doc) final PyObject str___ne__(PyObject other) { String s = coerce(other); if (s == null) @@ -526,7 +529,7 @@ return str___lt__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___lt___doc) final PyObject str___lt__(PyObject other){ String s = coerce(other); if (s == null) @@ -538,7 +541,7 @@ return str___le__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___le___doc) final PyObject str___le__(PyObject other){ String s = coerce(other); if (s == null) @@ -550,7 +553,7 @@ return str___gt__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___gt___doc) final PyObject str___gt__(PyObject other){ String s = coerce(other); if (s == null) @@ -562,7 +565,7 @@ return str___ge__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___ge___doc) final PyObject str___ge__(PyObject other){ String s = coerce(other); if (s == null) @@ -580,7 +583,7 @@ return str___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___hash___doc) final int str___hash__() { if (cached_hashcode == 0) cached_hashcode = string.hashCode(); @@ -651,7 +654,7 @@ return str___contains__(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___contains___doc) final boolean str___contains__(PyObject o) { if (!(o instanceof PyString)) throw Py.TypeError("'in <string>' requires string as left operand"); @@ -683,7 +686,7 @@ return str___mul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___mul___doc) final PyObject str___mul__(PyObject o) { if (!o.isIndex()) { return null; @@ -696,7 +699,7 @@ return str___rmul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___rmul___doc) final PyObject str___rmul__(PyObject o) { if (!o.isIndex()) { return null; @@ -708,7 +711,7 @@ return str___add__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___add___doc) final PyObject str___add__(PyObject other) { if (other instanceof PyUnicode) { return decode().__add__(other); @@ -720,7 +723,7 @@ return null; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___getnewargs___doc) final PyTuple str___getnewargs__() { return new PyTuple(new PyString(this.string)); } @@ -733,7 +736,7 @@ return str___mod__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str___mod___doc) public PyObject str___mod__(PyObject other){ StringFormatter fmt = new StringFormatter(string, false); return fmt.format(other); @@ -904,7 +907,7 @@ return str_lower(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_lower_doc) final String str_lower() { return string.toLowerCase(); } @@ -913,7 +916,7 @@ return str_upper(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_upper_doc) final String str_upper() { return string.toUpperCase(); } @@ -922,7 +925,7 @@ return str_title(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_title_doc) final String str_title() { char[] chars = string.toCharArray(); int n = chars.length; @@ -949,7 +952,7 @@ return str_swapcase(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_swapcase_doc) final String str_swapcase() { char[] chars = string.toCharArray(); int n=chars.length; @@ -973,7 +976,7 @@ return str_strip(sep); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_strip_doc) final String str_strip(String sep) { char[] chars = string.toCharArray(); int n=chars.length; @@ -1009,7 +1012,7 @@ return str_lstrip(sep); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_lstrip_doc) final String str_lstrip(String sep) { char[] chars = string.toCharArray(); int n=chars.length; @@ -1028,7 +1031,7 @@ return str_rstrip(sep); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_rstrip_doc) final String str_rstrip(String sep) { char[] chars = string.toCharArray(); int n=chars.length; @@ -1056,7 +1059,7 @@ return str_split(sep, maxsplit); } - @ExposedMethod(defaults = {"null", "-1"}) + @ExposedMethod(defaults = {"null", "-1"}, doc = BuiltinDocs.str_split_doc) final PyList str_split(String sep, int maxsplit) { if (sep != null) { if (sep.length() == 0) { @@ -1107,7 +1110,7 @@ return str_rsplit(sep, maxsplit); } - @ExposedMethod(defaults = {"null", "-1"}) + @ExposedMethod(defaults = {"null", "-1"}, doc = BuiltinDocs.str_rsplit_doc) final PyList str_rsplit(String sep, int maxsplit) { if (sep != null) { if (sep.length() == 0) { @@ -1169,7 +1172,7 @@ return str_partition(sepObj); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_partition_doc) final PyTuple str_partition(PyObject sepObj) { String sep; @@ -1220,7 +1223,7 @@ return str_rpartition(sepObj); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_rpartition_doc) final PyTuple str_rpartition(PyObject sepObj) { String sep; @@ -1338,7 +1341,7 @@ return str_splitlines(keepends); } - @ExposedMethod(defaults = "false") + @ExposedMethod(defaults = "false", doc = BuiltinDocs.str_splitlines_doc) final PyList str_splitlines(boolean keepends) { PyList list = new PyList(); @@ -1387,7 +1390,7 @@ return str_index(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_index_doc) final int str_index(String sub, int start, PyObject end) { int index = str_find(sub, start, end); if (index == -1) @@ -1407,7 +1410,7 @@ return str_rindex(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_rindex_doc) final int str_rindex(String sub, int start, PyObject end) { int index = str_rfind(sub, start, end); if(index == -1) @@ -1427,7 +1430,7 @@ return str_count(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_count_doc) final int str_count(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int n = sub.length(); @@ -1461,7 +1464,7 @@ return str_find(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_find_doc) final int str_find(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int index = string.indexOf(sub, indices[0]); @@ -1483,7 +1486,7 @@ return str_rfind(sub, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_rfind_doc) final int str_rfind(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int index = string.lastIndexOf(sub, indices[1] - sub.length()); @@ -1690,7 +1693,7 @@ return str_ljust(width, padding); } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.str_ljust_doc) final String str_ljust(int width, String fillchar) { char pad = parse_fillchar("ljust", fillchar); int n = width-string.length(); @@ -1703,7 +1706,7 @@ return str_rjust(width, null); } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.str_rjust_doc) final String str_rjust(int width, String fillchar) { char pad = parse_fillchar("rjust", fillchar); int n = width-string.length(); @@ -1716,7 +1719,7 @@ return str_center(width, null); } - @ExposedMethod(defaults="null") + @ExposedMethod(defaults="null", doc = BuiltinDocs.str_center_doc) final String str_center(int width, String fillchar) { char pad = parse_fillchar("center", fillchar); int n = width-string.length(); @@ -1733,7 +1736,7 @@ return str_zfill(width); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_zfill_doc) final String str_zfill(int width) { String s = string; int n = s.length(); @@ -1767,7 +1770,7 @@ return str_expandtabs(tabsize); } - @ExposedMethod(defaults = "8") + @ExposedMethod(defaults = "8", doc = BuiltinDocs.str_expandtabs_doc) final String str_expandtabs(int tabsize) { String s = string; StringBuilder buf = new StringBuilder((int)(s.length()*1.5)); @@ -1798,7 +1801,7 @@ return str_capitalize(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_capitalize_doc) final String str_capitalize() { if (string.length() == 0) return string; @@ -1806,7 +1809,7 @@ return first.concat(string.substring(1).toLowerCase()); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_replace_doc) final PyString str_replace(PyObject oldPiece, PyObject newPiece, PyObject maxsplit) { if(!(oldPiece instanceof PyString) || !(newPiece instanceof PyString)) { throw Py.TypeError("str or unicode required for replace"); @@ -1853,7 +1856,7 @@ return str_join(seq); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_join_doc) final PyString str_join(PyObject obj) { PySequence seq = fastSequence(obj, ""); int seqLen = seq.__len__(); @@ -1987,7 +1990,7 @@ return str_startswith(prefix, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_startswith_doc) final boolean str_startswith(PyObject prefix, int start, PyObject end) { int[] indices = translateIndices(start, end); @@ -2029,7 +2032,7 @@ return str_endswith(suffix, start, Py.newInteger(end)); } - @ExposedMethod(defaults = {"0", "null"}) + @ExposedMethod(defaults = {"0", "null"}, doc = BuiltinDocs.str_endswith_doc) final boolean str_endswith(PyObject suffix, int start, PyObject end) { int[] indices = translateIndices(start, end); @@ -2097,7 +2100,7 @@ return str_translate(table, deletechars); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.str_translate_doc) final String str_translate(String table, String deletechars) { if (table.length() != 256) throw Py.ValueError( @@ -2161,7 +2164,7 @@ return str_islower(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_islower_doc) final boolean str_islower() { int n = string.length(); @@ -2185,7 +2188,7 @@ return str_isupper(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isupper_doc) final boolean str_isupper() { int n = string.length(); @@ -2209,7 +2212,7 @@ return str_isalpha(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isalpha_doc) final boolean str_isalpha() { int n = string.length(); @@ -2233,7 +2236,7 @@ return str_isalnum(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isalnum_doc) final boolean str_isalnum() { int n = string.length(); @@ -2266,7 +2269,7 @@ return str_isdecimal(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isdecimal_doc) final boolean str_isdecimal() { int n = string.length(); @@ -2297,7 +2300,7 @@ return str_isdigit(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isdigit_doc) final boolean str_isdigit() { int n = string.length(); @@ -2321,7 +2324,7 @@ return str_isnumeric(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.unicode_isnumeric_doc) final boolean str_isnumeric() { int n = string.length(); @@ -2351,7 +2354,7 @@ return str_istitle(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_istitle_doc) final boolean str_istitle() { int n = string.length(); @@ -2387,7 +2390,7 @@ return str_isspace(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.str_isspace_doc) final boolean str_isspace() { int n = string.length(); @@ -2411,7 +2414,8 @@ return str_isunicode(); } - @ExposedMethod + //XXX: need doc + @ExposedMethod/*(doc = BuiltinDocs.unicode_isunicode_doc)*/ final boolean str_isunicode() { int n = string.length(); for (int i = 0; i < n; i++) { @@ -2434,7 +2438,7 @@ return str_encode(encoding, errors); } - @ExposedMethod(defaults = {"null", "null"}) + @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.str_encode_doc) final String str_encode(String encoding, String errors) { return codecs.encode(this, encoding, errors); } @@ -2451,7 +2455,7 @@ return str_decode(encoding, errors); } - @ExposedMethod(defaults = {"null", "null"}) + @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.str_decode_doc) final PyObject str_decode(String encoding, String errors) { return codecs.decode(this, encoding, errors); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |