Skip to content

Commit 42429cc

Browse files
author
James William Pye
committed
doc-string improvements for sphinx rendering
1 parent f7d29c5 commit 42429cc

1 file changed

Lines changed: 26 additions & 18 deletions

File tree

postgresql/types.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
except ImportError:
1717
import xml.etree.ElementTree as etree
1818

19+
# XXX: Would be nicer to generate these from a header file...
1920
InvalidOid = 0
2021

2122
RECORDOID = 2249
@@ -455,33 +456,34 @@ class box(tuple):
455456
456457
http://www.postgresql.org/docs/current/static/datatype-geometric.html
457458
458-
>>> box(( (0,0), (-2, -2) ))
459-
postgresql.types.box(((0.0, 0.0), (-2.0, -2.0)))
459+
>>> box(( (0,0), (-2, -2) ))
460+
postgresql.types.box(((0.0, 0.0), (-2.0, -2.0)))
460461
461462
It will also relocate values to enforce the high-low expectation:
462463
463-
>>> t.box(((-4,0),(-2,-3)))
464-
postgresql.types.box(((-2.0, 0.0), (-4.0, -3.0)))
464+
>>> t.box(((-4,0),(-2,-3)))
465+
postgresql.types.box(((-2.0, 0.0), (-4.0, -3.0)))
465466
466-
That is:
467+
::
468+
469+
(-2, 0) `high`
470+
|
471+
|
472+
(-4,-3) -------+-x
473+
`low` y
467474
468-
(-2, 0) `high`
469-
|
470-
|
471-
(-4,-3) -------+-x
472-
`low` y
473-
474475
This happens because ``-4`` is less than ``-2``; therefore the ``-4``
475476
belongs on the low point. This is consistent with what PostgreSQL does
476477
with its ``box`` type.
477478
"""
478-
high = property(fget = get0)
479-
low = property(fget = get1)
479+
high = property(fget = get0, doc = "high point of the box")
480+
low = property(fget = get1, doc = "low point of the box")
480481
center = property(
481482
fget = lambda s: point((
482483
(s[0][0] + s[1][0]) / 2.0,
483484
(s[0][1] + s[1][1]) / 2.0
484-
))
485+
)),
486+
doc = "center of the box as a point"
485487
)
486488

487489
def __new__(subtype, hl):
@@ -515,9 +517,9 @@ def __str__(self):
515517
return '%s,%s' %(self[0], self[1])
516518

517519
class circle(tuple):
518-
'circle type--center point and radius'
519-
center = property(fget = get0)
520-
radius = property(fget = get1)
520+
'type for PostgreSQL circles'
521+
center = property(fget = get0, doc = "center of the circle (point)")
522+
radius = property(fget = get1, doc = "radius of the circle (radius >= 0)")
521523

522524
def __new__(subtype, pair):
523525
center, radius = pair
@@ -537,6 +539,10 @@ def __str__(self):
537539
return '<%s,%s>' %(self[0], self[1])
538540

539541
class Array(object):
542+
"""
543+
Type used to mimic PostgreSQL arrays.
544+
"""
545+
540546
@staticmethod
541547
def unroll_nest(hier, dimensions):
542548
"return an iterator over the absolute elements of a nested sequence"
@@ -776,7 +782,7 @@ def column_names(self):
776782
def transform(self, *args, **kw):
777783
"""
778784
Make a new Row after processing the values with the callables associated
779-
with the values either by index, *args, or my column name, **kw.
785+
with the values either by index, \*args, or my column name, \*\*kw.
780786
781787
>>> r=Row.from_sequence({'col1':0,'col2':1}, (1,'two'))
782788
>>> r.transform(str)
@@ -792,6 +798,7 @@ def transform(self, *args, **kw):
792798
>>> xf = operator.methodcaller('transform', col2 = str.upper)
793799
>>> list(map(xf, rowseq))
794800
[(1,'TWO')]
801+
795802
"""
796803
r = list(self)
797804
i = 0
@@ -844,6 +851,7 @@ def transform(self, *args, **kw):
844851
TIMEOID: datetime.time,
845852
TIMETZOID: datetime.time,
846853

854+
# XXX: doesn't support months.
847855
INTERVALOID: datetime.timedelta,
848856

849857
RECORDOID : tuple,

0 commit comments

Comments
 (0)