[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44391] trunk/blender/source/blender/ python: bmesh python api - add/improve rst docstrings.

Campbell Barton ideasman42 at gmail.com
Fri Feb 24 05:59:25 CET 2012


Revision: 44391
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44391
Author:   campbellbarton
Date:     2012-02-24 04:59:13 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
bmesh python api - add/improve rst docstrings.

Modified Paths:
--------------
    trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types.h
    trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c
    trunk/blender/source/blender/python/intern/bpy_interface.c

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_api.c	2012-02-23 21:23:49 UTC (rev 44390)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_api.c	2012-02-24 04:59:13 UTC (rev 44391)
@@ -49,7 +49,10 @@
 PyDoc_STRVAR(bpy_bm_from_mesh_doc,
 ".. method:: from_mesh(mesh)\n"
 "\n"
-"   todo.\n"
+"   Return a BMesh from this mesh, currently the mesh must already be in editmode.\n"
+"\n"
+"   :return: the BMesh assosiated with this mesh.\n"
+"   :rtype: :class:`bmesh.types.BMesh`\n"
 );
 
 static PyObject *bpy_bm_from_mesh(PyObject *UNUSED(self), PyObject *value)
@@ -88,15 +91,22 @@
 
 PyObject *BPyInit_bmesh(void)
 {
+	PyObject *mod;
 	PyObject *submodule;
+	PyObject *sys_modules = PySys_GetObject("modules"); /* not pretty */
 
 	BPy_BM_init_types();
 
-	submodule = PyModule_Create(&BPy_BM_module_def);
+	mod = PyModule_Create(&BPy_BM_module_def);
 
 	/* bmesh.types */
-	PyModule_AddObject(submodule, "types", BPyInit_bmesh_types());
-	PyModule_AddObject(submodule, "utils", BPyInit_bmesh_utils());
+	PyModule_AddObject(mod, "types", (submodule=BPyInit_bmesh_types()));
+	PyDict_SetItemString(sys_modules, "bmesh.types", submodule);
+	Py_INCREF(submodule);
 
-	return submodule;
+	PyModule_AddObject(mod, "utils", (submodule=BPyInit_bmesh_utils()));
+	PyDict_SetItemString(sys_modules, "bmesh.utils", submodule);
+	Py_INCREF(submodule);
+
+	return mod;
 }

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c	2012-02-23 21:23:49 UTC (rev 44390)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c	2012-02-24 04:59:13 UTC (rev 44391)
@@ -86,11 +86,10 @@
 /* bmesh elems
  * ----------- */
 
-PyDoc_STRVAR(bpy_bm_elem_select_doc, "Selected state of this element (boolean)");
-PyDoc_STRVAR(bpy_bm_elem_hide_doc, "Hidden state of this element (boolean)");
-PyDoc_STRVAR(bpy_bm_elem_tag_doc, "Tag state of this element (boolean)");
-PyDoc_STRVAR(bpy_bm_elem_smooth_doc, "Smooth state of this element (boolean)");
-PyDoc_STRVAR(bpy_bm_elem_index_doc, "Index of this element");
+PyDoc_STRVAR(bpy_bm_elem_select_doc,  "Selected state of this element.\n\n:type: boolean");
+PyDoc_STRVAR(bpy_bm_elem_hide_doc,    "Hidden state of this element.\n\n:type: boolean");
+PyDoc_STRVAR(bpy_bm_elem_tag_doc,     "Generic attribute scripts can use for own logic\n\n:type: boolean");
+PyDoc_STRVAR(bpy_bm_elem_smooth_doc,  "Smooth state of this element.\n\n:type: boolean");
 
 
 static PyObject *bpy_bm_elem_hflag_get(BPy_BMElem *self, void *flag)
@@ -127,6 +126,19 @@
 	}
 }
 
+PyDoc_STRVAR(bpy_bm_elem_index_doc,
+"Index of this element.\n"
+"\n"
+":type: int\n"
+"\n"
+".. note::\n"
+"\n"
+"   This value is not necessarily valid, while editing the mesh it can become *dirty*.\n"
+"\n"
+"   It's also possible to assign any number to this attribute for a scripts internal logic.\n"
+"\n"
+"   To ensure the value is up to date - see :class:`BMesh.update` **index** argument.\n"
+);
 static PyObject *bpy_bm_elem_index_get(BPy_BMElem *self, void *UNUSED(flag))
 {
 	BPY_BM_CHECK_OBJ(self);
@@ -165,20 +177,66 @@
 /* Mesh
  * ^^^^ */
 
-static PyObject *bpy_bmesh_seq_get(BPy_BMesh *self, void *itype)
+/* doc-strings for all uses of this funcion */
+PyDoc_STRVAR(bpy_bmesh_verts_doc,
+"This meshes vert sequence (readonly).\n\n:type: :class:`BMElemSeq`"
+);
+PyDoc_STRVAR(bpy_bmesh_edges_doc,
+"This meshes edge sequence (readonly).\n\n:type: :class:`BMElemSeq`"
+);
+PyDoc_STRVAR(bpy_bmesh_faces_doc,
+"This meshes face sequence (readonly).\n\n:type: :class:`BMElemSeq`"
+);
+
+static PyObject *bpy_bmelemseq_get(BPy_BMesh *self, void *itype)
 {
 	BPY_BM_CHECK_OBJ(self);
 	return BPy_BMElemSeq_CreatePyObject(self->bm, NULL, GET_INT_FROM_POINTER(itype));
 }
 
-static PyObject *bpy_bmesh_seq_elem_get(BPy_BMElem *self, void *itype)
+/* vert */
+PyDoc_STRVAR(bpy_bmvert_link_edges_doc,
+"Edges connected to this vertex (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMVert`"
+);
+PyDoc_STRVAR(bpy_bmvert_link_faces_doc,
+"Faces connected to this vertex (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMFace`"
+);
+PyDoc_STRVAR(bpy_bmvert_link_loops_doc,
+"Loops that use this vertex (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMLoop`"
+);
+/* edge */
+PyDoc_STRVAR(bpy_bmedge_verts_doc,
+"Verts this edge uses (always 2), (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMVert`"
+);
+PyDoc_STRVAR(bpy_bmedge_link_faces_doc,
+"Faces connected to this edge, (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMFace`"
+);
+PyDoc_STRVAR(bpy_bmedge_link_loops_doc,
+"Loops connected to this edge, (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMLoop`"
+);
+/* face */
+PyDoc_STRVAR(bpy_bmface_verts_doc,
+"Verts of this face, (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMVert`"
+);
+PyDoc_STRVAR(bpy_bmface_edges_doc,
+"Edges of this face, (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMEdge`"
+);
+PyDoc_STRVAR(bpy_bmface_loops_doc,
+"Loops of this face, (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMLoop`"
+);
+/* loop */
+PyDoc_STRVAR(bpy_bmloops_link_loops_doc,
+"Loops connected to this loop, (readonly).\n\n:type: :class:`BMElemSeq` of :class:`BMLoop`"
+);
+
+static PyObject *bpy_bmelemseq_elem_get(BPy_BMElem *self, void *itype)
 {
 	BPY_BM_CHECK_OBJ(self);
 	return BPy_BMElemSeq_CreatePyObject(self->bm, self, GET_INT_FROM_POINTER(itype));
 }
 
 PyDoc_STRVAR(bpy_bm_is_valid_doc,
-"True when this element is valid (hasn't been removed)"
+"True when this element is valid (hasn't been removed).\n\n:type: boolean"
 );
 static PyObject *bpy_bm_is_valid_get(BPy_BMGeneric *self)
 {
@@ -187,7 +245,7 @@
 
 
 PyDoc_STRVAR(bpy_bmesh_select_mode_doc,
-"The selection mode for this mesh"
+"The selection mode, values can be {'VERT', 'EDGE', 'FACE'}, can't be assigned an empty set.\n\n:type: set"
 );
 static PyObject *bpy_bmesh_select_mode_get(BPy_BMesh *self)
 {
@@ -219,7 +277,7 @@
  * ^^^^ */
 
 PyDoc_STRVAR(bpy_bmvert_co_doc,
-"The coordinates for this vertex"
+"The coordinates for this vertex as a 3D, wrapped vector.\n\n:type: :class:`mathutils.Vector`"
 );
 static PyObject *bpy_bmvert_co_get(BPy_BMVert *self)
 {
@@ -240,7 +298,7 @@
 }
 
 PyDoc_STRVAR(bpy_bmvert_normal_doc,
-"The normal for this vertex"
+"The normal for this vertex as a 3D, wrapped vector.\n\n:type: :class:`mathutils.Vector`"
 );
 static PyObject *bpy_bmvert_normal_get(BPy_BMVert *self)
 {
@@ -261,7 +319,7 @@
 }
 
 PyDoc_STRVAR(bpy_bmvert_is_manifold_doc,
-"True when this vertex is manifold (readonly)"
+"True when this vertex is manifold (readonly).\n\n:type: boolean"
 );
 static PyObject *bpy_bmvert_is_manifold_get(BPy_BMVert *self)
 {
@@ -270,7 +328,7 @@
 }
 
 PyDoc_STRVAR(bpy_bmvert_is_wire_doc,
-"True when this vertex is not connected to any faces (readonly)"
+"True when this vertex is not connected to any faces (readonly).\n\n:type: boolean"
 );
 static PyObject *bpy_bmvert_is_wire_get(BPy_BMVert *self)
 {
@@ -282,7 +340,7 @@
  * ^^^^ */
 
 PyDoc_STRVAR(bpy_bmedge_is_manifold_doc,
-"True when this edge is manifold (readonly)"
+"True when this edge is manifold (readonly).\n\n:type: boolean"
 );
 static PyObject *bpy_bmedge_is_manifold_get(BPy_BMEdge *self)
 {
@@ -291,7 +349,7 @@
 }
 
 PyDoc_STRVAR(bpy_bmedge_is_wire_doc,
-"True when this edge is not connected to any faces (readonly)"
+"True when this edge is not connected to any faces (readonly).\n\n:type: boolean"
 );
 static PyObject *bpy_bmedge_is_wire_get(BPy_BMEdge *self)
 {
@@ -300,7 +358,7 @@
 }
 
 PyDoc_STRVAR(bpy_bmedge_is_boundry_doc,
-"True when this edge is at the boundry of a face (readonly)"
+"True when this edge is at the boundry of a face (readonly).\n\n:type: boolean"
 );
 static PyObject *bpy_bmedge_is_boundry_get(BPy_BMEdge *self)
 {
@@ -312,7 +370,7 @@
  * ^^^^ */
 
 PyDoc_STRVAR(bpy_bmface_normal_doc,
-"The normal for this face"
+"The normal for this face as a 3D, wrapped vector.\n\n:type: boolean"
 );
 static PyObject *bpy_bmface_normal_get(BPy_BMFace *self)
 {
@@ -333,9 +391,9 @@
 }
 
 static PyGetSetDef bpy_bmesh_getseters[] = {
-    {(char *)"verts", (getter)bpy_bmesh_seq_get, (setter)NULL, NULL, (void *)BM_VERTS_OF_MESH},
-    {(char *)"edges", (getter)bpy_bmesh_seq_get, (setter)NULL, NULL, (void *)BM_EDGES_OF_MESH},
-    {(char *)"faces", (getter)bpy_bmesh_seq_get, (setter)NULL, NULL, (void *)BM_FACES_OF_MESH},
+    {(char *)"verts", (getter)bpy_bmelemseq_get, (setter)NULL, (char *)bpy_bmesh_verts_doc, (void *)BM_VERTS_OF_MESH},
+    {(char *)"edges", (getter)bpy_bmelemseq_get, (setter)NULL, (char *)bpy_bmesh_edges_doc, (void *)BM_EDGES_OF_MESH},
+    {(char *)"faces", (getter)bpy_bmelemseq_get, (setter)NULL, (char *)bpy_bmesh_faces_doc, (void *)BM_FACES_OF_MESH},
     {(char *)"select_mode", (getter)bpy_bmesh_select_mode_get, (setter)bpy_bmesh_select_mode_set, (char *)bpy_bmesh_select_mode_doc, NULL},
 
     /* readonly checks */
@@ -355,9 +413,9 @@
     {(char *)"normal", (getter)bpy_bmvert_normal_get, (setter)bpy_bmvert_normal_set, (char *)bpy_bmvert_normal_doc, NULL},
 
     /* connectivity data */
-    {(char *)"link_edges", (getter)bpy_bmesh_seq_elem_get, (setter)NULL, NULL, (void *)BM_EDGES_OF_VERT},
-    {(char *)"link_faces", (getter)bpy_bmesh_seq_elem_get, (setter)NULL, NULL, (void *)BM_FACES_OF_VERT},
-    {(char *)"link_loops", (getter)bpy_bmesh_seq_elem_get, (setter)NULL, NULL, (void *)BM_LOOPS_OF_VERT},
+    {(char *)"link_edges", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_edges_doc, (void *)BM_EDGES_OF_VERT},
+    {(char *)"link_faces", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_faces_doc, (void *)BM_FACES_OF_VERT},
+    {(char *)"link_loops", (getter)bpy_bmelemseq_elem_get, (setter)NULL, (char *)bpy_bmvert_link_loops_doc, (void *)BM_LOOPS_OF_VERT},
 
     /* readonly checks */
     {(char *)"is_manifold",  (getter)bpy_bmvert_is_manifold_get,  (setter)NULL, (char *)bpy_bmvert_is_manifold_doc, NULL},
@@ -378,10 +436,10 @@
     {(char *)"seam",   (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_smooth_doc, (void *)BM_ELEM_SEAM},
 
     /* connectivity data */
-    {(char *)"verts", (getter)bpy_bmesh_seq_elem_get, (setter)NULL, NULL, (void *)BM_VERTS_OF_EDGE},

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list