Skip to content

Commit e6479bd

Browse files
authored
Merge pull request #19322 from anntzer/pathdoc
Improve docs of _path C-extension.
2 parents e453e26 + 42023cc commit e6479bd

File tree

1 file changed

+83
-23
lines changed

1 file changed

+83
-23
lines changed

src/_path_wrapper.cpp

Lines changed: 83 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ PyObject *convert_polygon_vector(std::vector<Polygon> &polygons)
2828
return pyresult;
2929
}
3030

31-
const char *Py_point_in_path__doc__ = "point_in_path(x, y, radius, path, trans)";
31+
const char *Py_point_in_path__doc__ =
32+
"point_in_path(x, y, radius, path, trans)\n"
33+
"--\n\n";
3234

3335
static PyObject *Py_point_in_path(PyObject *self, PyObject *args, PyObject *kwds)
3436
{
@@ -58,7 +60,9 @@ static PyObject *Py_point_in_path(PyObject *self, PyObject *args, PyObject *kwds
5860
}
5961
}
6062

61-
const char *Py_points_in_path__doc__ = "points_in_path(points, radius, path, trans)";
63+
const char *Py_points_in_path__doc__ =
64+
"points_in_path(points, radius, path, trans)\n"
65+
"--\n\n";
6266

6367
static PyObject *Py_points_in_path(PyObject *self, PyObject *args, PyObject *kwds)
6468
{
@@ -87,7 +91,9 @@ static PyObject *Py_points_in_path(PyObject *self, PyObject *args, PyObject *kwd
8791
return results.pyobj();
8892
}
8993

90-
const char *Py_point_on_path__doc__ = "point_on_path(x, y, radius, path, trans)";
94+
const char *Py_point_on_path__doc__ =
95+
"point_on_path(x, y, radius, path, trans)\n"
96+
"--\n\n";
9197

9298
static PyObject *Py_point_on_path(PyObject *self, PyObject *args, PyObject *kwds)
9399
{
@@ -117,7 +123,9 @@ static PyObject *Py_point_on_path(PyObject *self, PyObject *args, PyObject *kwds
117123
}
118124
}
119125

120-
const char *Py_points_on_path__doc__ = "points_on_path(points, radius, path, trans)";
126+
const char *Py_points_on_path__doc__ =
127+
"points_on_path(points, radius, path, trans)\n"
128+
"--\n\n";
121129

122130
static PyObject *Py_points_on_path(PyObject *self, PyObject *args, PyObject *kwds)
123131
{
@@ -146,7 +154,9 @@ static PyObject *Py_points_on_path(PyObject *self, PyObject *args, PyObject *kwd
146154
return results.pyobj();
147155
}
148156

149-
const char *Py_get_path_extents__doc__ = "get_path_extents(path, trans)";
157+
const char *Py_get_path_extents__doc__ =
158+
"get_path_extents(path, trans)\n"
159+
"--\n\n";
150160

151161
static PyObject *Py_get_path_extents(PyObject *self, PyObject *args, PyObject *kwds)
152162
{
@@ -174,7 +184,8 @@ static PyObject *Py_get_path_extents(PyObject *self, PyObject *args, PyObject *k
174184
}
175185

176186
const char *Py_update_path_extents__doc__ =
177-
"update_path_extents(path, trans, rect, minpos, ignore)";
187+
"update_path_extents(path, trans, rect, minpos, ignore)\n"
188+
"--\n\n";
178189

179190
static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject *kwds)
180191
{
@@ -250,8 +261,10 @@ static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject
250261
"NNi", outextents.pyobj(), outminpos.pyobj(), changed);
251262
}
252263

253-
const char *Py_get_path_collection_extents__doc__ = "get_path_collection_extents("
254-
"master_transform, paths, transforms, offsets, offset_transform)";
264+
const char *Py_get_path_collection_extents__doc__ =
265+
"get_path_collection_extents("
266+
"master_transform, paths, transforms, offsets, offset_transform)\n"
267+
"--\n\n";
255268

256269
static PyObject *Py_get_path_collection_extents(PyObject *self, PyObject *args, PyObject *kwds)
257270
{
@@ -305,8 +318,10 @@ static PyObject *Py_get_path_collection_extents(PyObject *self, PyObject *args,
305318
}
306319

307320
const char *Py_point_in_path_collection__doc__ =
308-
"point_in_path_collection(x, y, radius, master_transform, paths, transforms, offsets, "
309-
"offset_trans, filled, offset_position)";
321+
"point_in_path_collection("
322+
"x, y, radius, master_transform, paths, transforms, offsets, "
323+
"offset_trans, filled, offset_position)\n"
324+
"--\n\n";
310325

311326
static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyObject *kwds)
312327
{
@@ -371,7 +386,9 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO
371386
return pyresult.pyobj();
372387
}
373388

374-
const char *Py_path_in_path__doc__ = "path_in_path(path_a, trans_a, path_b, trans_b)";
389+
const char *Py_path_in_path__doc__ =
390+
"path_in_path(path_a, trans_a, path_b, trans_b)\n"
391+
"--\n\n";
375392

376393
static PyObject *Py_path_in_path(PyObject *self, PyObject *args, PyObject *kwds)
377394
{
@@ -403,7 +420,9 @@ static PyObject *Py_path_in_path(PyObject *self, PyObject *args, PyObject *kwds)
403420
}
404421
}
405422

406-
const char *Py_clip_path_to_rect__doc__ = "clip_path_to_rect(path, rect, inside)";
423+
const char *Py_clip_path_to_rect__doc__ =
424+
"clip_path_to_rect(path, rect, inside)\n"
425+
"--\n\n";
407426

408427
static PyObject *Py_clip_path_to_rect(PyObject *self, PyObject *args, PyObject *kwds)
409428
{
@@ -428,7 +447,9 @@ static PyObject *Py_clip_path_to_rect(PyObject *self, PyObject *args, PyObject *
428447
return convert_polygon_vector(result);
429448
}
430449

431-
const char *Py_affine_transform__doc__ = "affine_transform(points, trans)";
450+
const char *Py_affine_transform__doc__ =
451+
"affine_transform(points, trans)\n"
452+
"--\n\n";
432453

433454
static PyObject *Py_affine_transform(PyObject *self, PyObject *args, PyObject *kwds)
434455
{
@@ -465,7 +486,9 @@ static PyObject *Py_affine_transform(PyObject *self, PyObject *args, PyObject *k
465486
}
466487
}
467488

468-
const char *Py_count_bboxes_overlapping_bbox__doc__ = "count_bboxes_overlapping_bbox(bbox, bboxes)";
489+
const char *Py_count_bboxes_overlapping_bbox__doc__ =
490+
"count_bboxes_overlapping_bbox(bbox, bboxes)\n"
491+
"--\n\n";
469492

470493
static PyObject *Py_count_bboxes_overlapping_bbox(PyObject *self, PyObject *args, PyObject *kwds)
471494
{
@@ -488,7 +511,9 @@ static PyObject *Py_count_bboxes_overlapping_bbox(PyObject *self, PyObject *args
488511
return PyLong_FromLong(result);
489512
}
490513

491-
const char *Py_path_intersects_path__doc__ = "path_intersects_path(path1, path2, filled=False)";
514+
const char *Py_path_intersects_path__doc__ =
515+
"path_intersects_path(path1, path2, filled=False)\n"
516+
"--\n\n";
492517

493518
static PyObject *Py_path_intersects_path(PyObject *self, PyObject *args, PyObject *kwds)
494519
{
@@ -531,7 +556,10 @@ static PyObject *Py_path_intersects_path(PyObject *self, PyObject *args, PyObjec
531556
}
532557
}
533558

534-
const char *Py_path_intersects_rectangle__doc__ = "path_intersects_rectangle(path, rect_x1, rect_y1, rect_x2, rect_y2, filled=False)";
559+
const char *Py_path_intersects_rectangle__doc__ =
560+
"path_intersects_rectangle("
561+
"path, rect_x1, rect_y1, rect_x2, rect_y2, filled=False)\n"
562+
"--\n\n";
535563

536564
static PyObject *Py_path_intersects_rectangle(PyObject *self, PyObject *args, PyObject *kwds)
537565
{
@@ -566,7 +594,8 @@ static PyObject *Py_path_intersects_rectangle(PyObject *self, PyObject *args, Py
566594
}
567595

568596
const char *Py_convert_path_to_polygons__doc__ =
569-
"convert_path_to_polygons(path, trans, width=0, height=0)";
597+
"convert_path_to_polygons(path, trans, width=0, height=0)\n"
598+
"--\n\n";
570599

571600
static PyObject *Py_convert_path_to_polygons(PyObject *self, PyObject *args, PyObject *kwds)
572601
{
@@ -598,8 +627,10 @@ static PyObject *Py_convert_path_to_polygons(PyObject *self, PyObject *args, PyO
598627
}
599628

600629
const char *Py_cleanup_path__doc__ =
601-
"cleanup_path(path, trans, remove_nans, clip_rect, snap_mode, stroke_width, simplify, "
602-
"return_curves, sketch)";
630+
"cleanup_path("
631+
"path, trans, remove_nans, clip_rect, snap_mode, stroke_width, simplify, "
632+
"return_curves, sketch)\n"
633+
"--\n\n";
603634

604635
static PyObject *Py_cleanup_path(PyObject *self, PyObject *args, PyObject *kwds)
605636
{
@@ -678,8 +709,35 @@ static PyObject *Py_cleanup_path(PyObject *self, PyObject *args, PyObject *kwds)
678709
return Py_BuildValue("NN", pyvertices.pyobj(), pycodes.pyobj());
679710
}
680711

681-
const char *Py_convert_to_string__doc__ = "convert_to_string(path, trans, "
682-
"clip_rect, simplify, sketch, precision, codes, postfix)";
712+
const char *Py_convert_to_string__doc__ =
713+
"convert_to_string("
714+
"path, trans, clip_rect, simplify, sketch, precision, codes, postfix)\n"
715+
"--\n\n"
716+
"Convert *path* to a bytestring.\n"
717+
"\n"
718+
"The first five parameters (up to *sketch*) are interpreted as in \n"
719+
"`.cleanup_path`. The following ones are detailed below.\n"
720+
"\n"
721+
"Parameters\n"
722+
"----------\n"
723+
"path : Path\n"
724+
"trans : Transform or None\n"
725+
"clip_rect : sequence of 4 floats, or None\n"
726+
"simplify : bool\n"
727+
"sketch : tuple of 3 floats, or None\n"
728+
"precision : int\n"
729+
" The precision used to \"%.*f\"-format the values. Trailing zeros\n"
730+
" and decimal points are always removed. (precision=-1 is a special \n"
731+
" case used to implement ttconv-back-compatible conversion.)\n"
732+
"codes : sequence of 5 bytestrings\n"
733+
" The bytes representation of each opcode (MOVETO, LINETO, CURVE3,\n"
734+
" CURVE4, CLOSEPOLY), in that order. If the bytes for CURVE3 is\n"
735+
" empty, quad segments are automatically converted to cubic ones\n"
736+
" (this is used by backends such as pdf and ps, which do not support\n"
737+
" quads).\n"
738+
"postfix : bool\n"
739+
" Whether the opcode comes after the values (True) or before (False).\n"
740+
;
683741

684742
static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *kwds)
685743
{
@@ -741,8 +799,10 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
741799
}
742800

743801

744-
const char *Py_is_sorted__doc__ = "is_sorted(array)\n\n"
745-
"Returns True if 1-D array is monotonically increasing, ignoring NaNs\n";
802+
const char *Py_is_sorted__doc__ =
803+
"is_sorted(array)\n"
804+
"--\n\n"
805+
"Return whether the 1D *array* is monotonically increasing, ignoring NaNs.\n";
746806

747807
static PyObject *Py_is_sorted(PyObject *self, PyObject *obj)
748808
{

0 commit comments

Comments
 (0)