Skip to content

Commit 29e1b43

Browse files
committed
Fixed some more __doc__s.
Fixed the doc of _csv.PyReader, added doc of _csv.PyWriter. Some cosmetics in docs of itertools.
1 parent 8f1a96f commit 29e1b43

5 files changed

Lines changed: 43 additions & 42 deletions

File tree

src/org/python/modules/_csv/PyReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
*
1616
* Analogous to CPython's _csv.c::ReaderObj struct.
1717
*/
18-
@ExposedType(name = "_csv.reader")
18+
@ExposedType(name = "_csv.reader", doc = PyReader.reader_doc)
1919
public class PyReader extends PyIterator {
2020

2121
public static final PyType TYPE = PyType.fromClass(PyReader.class);
2222

23-
public PyString __doc__ = Py.newString(
23+
public static final String reader_doc =
2424
"CSV reader\n" +
2525
"\n" +
2626
"Reader objects are responsible for reading and parsing tabular data\n" +
27-
"in CSV format.\n");
27+
"in CSV format.\n";
2828

2929
/** Parsing Dialect. */
3030
@ExposedGet

src/org/python/modules/_csv/PyWriter.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@
1616
*
1717
* Analogous to CPython's _csv.c::WriterObj struct.
1818
*/
19-
@ExposedType(name = "_csv.writer")
19+
@ExposedType(name = "_csv.writer", doc = PyWriter.writer_doc)
2020
public class PyWriter extends PyObject {
2121

22+
public static final String writer_doc =
23+
"CSV writer\n" +
24+
"\n" +
25+
"Writer objects are responsible for generating tabular data\n" +
26+
"in CSV format from sequence input.\n";
27+
2228
public static final PyType TYPE = PyType.fromClass(PyWriter.class);
2329

2430
/** Parsing dialect. */
@@ -131,14 +137,14 @@ final boolean writer_writerow(PyObject seq) {
131137
} else if (field == Py.None) {
132138
append_ok = join_append("", len == 1);
133139
} else {
134-
140+
135141
PyObject str;
136142
//XXX: in 3.x this check can go away and we can just always use
137143
// __str__
138144
if (field.getClass() == PyFloat.class) {
139-
str = field.__repr__();
145+
str = field.__repr__();
140146
} else {
141-
str = field.__str__();
147+
str = field.__str__();
142148
}
143149

144150
if (str == null) {

src/org/python/modules/itertools/PyTeeIterator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
import org.python.expose.ExposedType;
1414
import org.python.util.Generic;
1515

16-
@ExposedType(name = "itertools.tee", base = PyObject.class, isBaseType = false)
16+
@ExposedType(name = "itertools.tee", base = PyObject.class,
17+
isBaseType = false, doc = PyTeeIterator.tee_doc)
1718
public class PyTeeIterator extends PyIterator {
1819

20+
public static final String tee_doc = "Iterator wrapped to make it copyable";
21+
1922
private static class PyTeeData {
2023
private PyObject iterator;
2124
private int total;

src/org/python/modules/itertools/itertools.java

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@
1919
public class itertools implements ClassDictInit {
2020

2121
public static final PyString __doc__ = new PyString(
22-
"Functional tools for creating and using iterators.\n\nInfinite iterators:\n"
23-
+ "count([n]) --> n, n+1, n+2, ...\n"
24-
+ "cycle(p) --> p0, p1, ... plast, p0, p1, ...\n"
25-
+ "repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times\n\n"
26-
27-
+ "Iterators terminating on the shortest input sequence:\n"
28-
+ "chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ...\n"
29-
+ "compress(data, selectors) --> (d[0] if s[0]), (d[1] if s[1]), ...\n"
30-
+ "dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails\n"
31-
+ "groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)\n"
32-
+ "ifilter(pred, seq) --> elements of seq where pred(elem) is True\n"
33-
+ "ifilterfalse(pred, seq) --> elements of seq where pred(elem) is False\n"
34-
+ "islice(seq, [start,] stop [, step]) --> elements from seq[start:stop:step]\n"
35-
+ "imap(fun, p, q, ...) --> fun(p0, q0), fun(p1, q1), ...\n"
36-
+ "starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n"
37-
+ "tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n\n"
38-
+ "takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n"
39-
+ "izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...\n"
40-
+ "izip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...\n\n"
41-
42-
+ "Combinatoric generators:\n"
43-
+ "product(p, q, ... [repeat=1]) --> cartesian product\n"
44-
+ "permutations(p[, r])\n"
45-
+ "combinations(p, r)\n"
46-
+ "combinations_with_replacement(p, r)");
22+
"Functional tools for creating and using iterators.\n\nInfinite iterators:\n" +
23+
"count([n]) --> n, n+1, n+2, ...\n" +
24+
"cycle(p) --> p0, p1, ... plast, p0, p1, ...\n" +
25+
"repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times\n\n" +
26+
27+
"Iterators terminating on the shortest input sequence:\n" +
28+
"chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ...\n" +
29+
"compress(data, selectors) --> (d[0] if s[0]), (d[1] if s[1]), ...\n" +
30+
"dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails\n" +
31+
"groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)\n" +
32+
"ifilter(pred, seq) --> elements of seq where pred(elem) is True\n" +
33+
"ifilterfalse(pred, seq) --> elements of seq where pred(elem) is False\n" +
34+
"islice(seq, [start,] stop [, step]) --> elements from seq[start:stop:step]\n" +
35+
"imap(fun, p, q, ...) --> fun(p0, q0), fun(p1, q1), ...\n" +
36+
"starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n" +
37+
"tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n\n" +
38+
"takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n" +
39+
"izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...\n" +
40+
"izip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...\n\n" +
41+
42+
"Combinatoric generators:\n" +
43+
"product(p, q, ... [repeat=1]) --> cartesian product\n" +
44+
"permutations(p[, r])\n" +
45+
"combinations(p, r)\n" +
46+
"combinations_with_replacement(p, r)");
4747

4848
/**
4949
* Iterator base class used by most methods.
@@ -98,14 +98,6 @@ public static void classDictInit(PyObject dict) {
9898
dict.__setitem__("initClassExceptions", null);
9999
}
100100

101-
public static PyString __doc__islice = new PyString(
102-
"islice(iterable, [start,] stop [, step]) --> islice object\n"
103-
+ "\nReturn an iterator whose next() method returns selected values from an\n"
104-
+ "iterable. If start is specified, will skip all preceding elements;\notherwise, start defaults to zero."
105-
+ "Step defaults to one. If\nspecified as another value, step determines how manyvalues are \n"
106-
+ "skipped between successive calls. Works like a slice() on a list\nbut returns an iterator.");
107-
108-
109101
static int py2int(PyObject obj, int defaultValue, String msg) {
110102
if (obj instanceof PyNone) {
111103
return defaultValue;

src/org/python/modules/itertools/takewhile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public takewhile(PyObject predicate, PyObject iterable) {
3232

3333
public static final String takewhile_doc =
3434
"takewhile(predicate, iterable) --> takewhile object\n\n" +
35-
"Return successive entries from an iterable as long as the \n" +
35+
"Return successive entries from an iterable as long as the\n" +
3636
"predicate evaluates to true for each entry.";
3737

3838
/**

0 commit comments

Comments
 (0)