Skip to content

Commit

Permalink
Add documentation for the unsigned modules.
Browse files Browse the repository at this point in the history
And some other small tweaks to the documentation to make cross-references work and things generally look good.
  • Loading branch information
jamadden committed Mar 5, 2020
1 parent f0f1d39 commit f6c9726
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 148 deletions.
12 changes: 6 additions & 6 deletions BTrees/BTreeModuleTemplate.c
Expand Up @@ -509,30 +509,30 @@ static char *search_keywords[] = {"min", "max",

static struct PyMethodDef module_methods[] = {
{"difference", (PyCFunction) difference_m, METH_VARARGS,
"difference(o1, o2) -- "
"difference(o1, o2)\n"
"compute the difference between o1 and o2"
},
{"union", (PyCFunction) union_m, METH_VARARGS,
"union(o1, o2) -- compute the union of o1 and o2\n"
"union(o1, o2)\ncompute the union of o1 and o2\n"
},
{"intersection", (PyCFunction) intersection_m, METH_VARARGS,
"intersection(o1, o2) -- "
"intersection(o1, o2)\n"
"compute the intersection of o1 and o2"
},
#ifdef MERGE
{"weightedUnion", (PyCFunction) wunion_m, METH_VARARGS,
"weightedUnion(o1, o2 [, w1, w2]) -- compute the union of o1 and o2\n"
"weightedUnion(o1, o2 [, w1, w2])\ncompute the union of o1 and o2\n"
"\nw1 and w2 are weights."
},
{"weightedIntersection", (PyCFunction) wintersection_m, METH_VARARGS,
"weightedIntersection(o1, o2 [, w1, w2]) -- "
"weightedIntersection(o1, o2 [, w1, w2])\n"
"compute the intersection of o1 and o2\n"
"\nw1 and w2 are weights."
},
#endif
#ifdef MULTI_INT_UNION
{"multiunion", (PyCFunction) multiunion_m, METH_VARARGS,
"multiunion(seq) -- compute union of a sequence of integer sets.\n"
"multiunion(seq)\ncompute union of a sequence of integer sets.\n"
"\n"
"Each element of seq must be an integer set, or convertible to one\n"
"via the set iteration protocol. The union returned is an IISet."
Expand Down
28 changes: 14 additions & 14 deletions BTrees/SetTemplate.c
Expand Up @@ -37,7 +37,7 @@ _Set_update(Bucket *self, PyObject *seq)
{
int n=0, ind=0;
PyObject *iter, *v;

iter = PyObject_GetIter(seq);
if (iter == NULL)
return -1;
Expand Down Expand Up @@ -177,49 +177,49 @@ set_setstate(Bucket *self, PyObject *args)

static struct PyMethodDef Set_methods[] = {
{"__getstate__", (PyCFunction) bucket_getstate, METH_VARARGS,
"__getstate__() -- Return the picklable state of the object"},
"__getstate__()\nReturn the picklable state of the object"},

{"__setstate__", (PyCFunction) set_setstate, METH_VARARGS,
"__setstate__() -- Set the state of the object"},
"__setstate__()\nSet the state of the object"},

{"keys", (PyCFunction) bucket_keys, METH_VARARGS | METH_KEYWORDS,
"keys() -- Return the keys"},
"keys()\nReturn the keys"},

{"has_key", (PyCFunction) bucket_has_key, METH_O,
"has_key(key) -- Test whether the bucket contains the given key"},
"has_key(key)\nTest whether the bucket contains the given key"},

{"clear", (PyCFunction) bucket_clear, METH_VARARGS,
"clear() -- Remove all of the items from the bucket"},
"clear()\nRemove all of the items from the bucket"},

{"maxKey", (PyCFunction) Bucket_maxKey, METH_VARARGS,
"maxKey([key]) -- Find the maximum key\n\n"
"maxKey([key])\nFind the maximum key\n\n"
"If an argument is given, find the maximum <= the argument"},

{"minKey", (PyCFunction) Bucket_minKey, METH_VARARGS,
"minKey([key]) -- Find the minimum key\n\n"
"minKey([key])\nFind the minimum key\n\n"
"If an argument is given, find the minimum >= the argument"},

#ifdef PERSISTENT
{"_p_resolveConflict",
(PyCFunction) bucket__p_resolveConflict, METH_VARARGS,
"_p_resolveConflict() -- Reinitialize from a newly created copy"},
"_p_resolveConflict()\nReinitialize from a newly created copy"},

{"_p_deactivate",
(PyCFunction) bucket__p_deactivate, METH_VARARGS | METH_KEYWORDS,
"_p_deactivate() -- Reinitialize from a newly created copy"},
"_p_deactivate()\nReinitialize from a newly created copy"},
#endif

{"add", (PyCFunction)Set_insert, METH_VARARGS,
"add(id) -- Add a key to the set"},
"add(id)\nAdd a key to the set"},

{"insert", (PyCFunction)Set_insert, METH_VARARGS,
"insert(id) -- Add a key to the set"},
"insert(id)\nAdd a key to the set"},

{"update", (PyCFunction)Set_update, METH_VARARGS,
"update(seq) -- Add the items from the given sequence to the set"},
"update(seq)\nAdd the items from the given sequence to the set"},

{"remove", (PyCFunction)Set_remove, METH_VARARGS,
"remove(id) -- Remove an id from the set"},
"remove(id)\nRemove an id from the set"},

{NULL, NULL} /* sentinel */
};
Expand Down
20 changes: 19 additions & 1 deletion BTrees/__init__.py
Expand Up @@ -19,8 +19,23 @@
@zope.interface.implementer(BTrees.Interfaces.IBTreeFamily)
class _Family(object):
from BTrees import OOBTree as OO
_BITSIZE = 0
minint = maxint = maxuint = 0

def __str__(self):
return (
"BTree family using {} bits. "
"Supports signed integer values from {:,} to {:,} "
"and maximum unsigned integer value {:,}."
).format(self._BITSIZE, self.minint, self.maxint, self.maxuint)

def __repr__(self):
return "<%s>" % (
self
)

class _Family32(_Family):
_BITSIZE = 32
from BTrees import OIBTree as OI
from BTrees import OUBTree as OU

Expand All @@ -42,6 +57,7 @@ def __reduce__(self):
return _family32, ()

class _Family64(_Family):
_BITSIZE = 64
from BTrees import OLBTree as OI
from BTrees import OQBTree as OU

Expand Down Expand Up @@ -70,8 +86,10 @@ def _family64():
return family64
_family64.__safe_for_unpickling__ = True


#: 32-bit BTree family.
family32 = _Family32()

#: 64-bit BTree family.
family64 = _Family64()

for _family in family32, family64:
Expand Down
2 changes: 0 additions & 2 deletions CHANGES.rst
Expand Up @@ -17,8 +17,6 @@
consistent between Python 2 and Python 3 and between 32-bit and
64-bit variants.

- Fix the value for ``BTrees.OIBTree`` when using the pure Python
implementation (PyPy and when ``PURE_PYTHON`` is in the environment).

4.6.1 (2019-11-07)
==================
Expand Down
1 change: 1 addition & 0 deletions doc-requirements.txt
@@ -1,3 +1,4 @@
sphinx >= 1.8
pip>=8.1.2
setuptools>=23.0.0
repoze.sphinx.autointerface
Expand Down
9 changes: 9 additions & 0 deletions docs/_static/custom.css
@@ -0,0 +1,9 @@
/*
sphinx_rtd_theme pulls from wyrm, which applies white-space: nowrap to tables.
https://github.com/snide/wyrm/blob/fd41b56978f009e8c33cb26f384dd0dfaf430a7d/sass/wyrm_core/_table.sass#L144
That makes it hard to have a table with more than three columns without
pointless scrolling.
*/
.wrapped td, .wrapped th {
white-space: normal !important;
}

0 comments on commit f6c9726

Please sign in to comment.