Skip to content

Commit ad4633f

Browse files
authored
Merge pull request matplotlib#21746 from anntzer/cdoc
Fix/add docstring signatures to many C++ methods.
2 parents 756d1d4 + 35a8ad0 commit ad4633f

File tree

4 files changed

+82
-63
lines changed

4 files changed

+82
-63
lines changed

src/_contour_wrapper.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static void PyQuadContourGenerator_dealloc(PyQuadContourGenerator* self)
7777
}
7878

7979
const char* PyQuadContourGenerator_create_contour__doc__ =
80-
"create_contour(level)\n"
80+
"create_contour(self, level)\n"
8181
"--\n\n"
8282
"Create and return a non-filled contour.";
8383

@@ -94,7 +94,7 @@ static PyObject* PyQuadContourGenerator_create_contour(PyQuadContourGenerator* s
9494
}
9595

9696
const char* PyQuadContourGenerator_create_filled_contour__doc__ =
97-
"create_filled_contour(lower_level, upper_level)\n"
97+
"create_filled_contour(self, lower_level, upper_level)\n"
9898
"--\n\n"
9999
"Create and return a filled contour";
100100

@@ -123,13 +123,19 @@ static PyObject* PyQuadContourGenerator_create_filled_contour(PyQuadContourGener
123123
static PyTypeObject* PyQuadContourGenerator_init_type(PyObject* m, PyTypeObject* type)
124124
{
125125
static PyMethodDef methods[] = {
126-
{"create_contour", (PyCFunction)PyQuadContourGenerator_create_contour, METH_VARARGS, PyQuadContourGenerator_create_contour__doc__},
127-
{"create_filled_contour", (PyCFunction)PyQuadContourGenerator_create_filled_contour, METH_VARARGS, PyQuadContourGenerator_create_filled_contour__doc__},
126+
{"create_contour",
127+
(PyCFunction)PyQuadContourGenerator_create_contour,
128+
METH_VARARGS,
129+
PyQuadContourGenerator_create_contour__doc__},
130+
{"create_filled_contour",
131+
(PyCFunction)PyQuadContourGenerator_create_filled_contour,
132+
METH_VARARGS,
133+
PyQuadContourGenerator_create_filled_contour__doc__},
128134
{NULL}
129135
};
130136

131137
memset(type, 0, sizeof(PyTypeObject));
132-
type->tp_name = "matplotlib.QuadContourGenerator";
138+
type->tp_name = "matplotlib._contour.QuadContourGenerator";
133139
type->tp_doc = PyQuadContourGenerator_init__doc__;
134140
type->tp_basicsize = sizeof(PyQuadContourGenerator);
135141
type->tp_dealloc = (destructor)PyQuadContourGenerator_dealloc;

src/_image_wrapper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
* */
1010

1111
const char* image_resample__doc__ =
12-
"resample(input_array, output_array, matrix, interpolation=NEAREST, alpha=1.0, norm=False, radius=1)\n\n"
12+
"resample(input_array, output_array, matrix, interpolation=NEAREST, alpha=1.0, norm=False, radius=1)\n"
13+
"--\n\n"
1314

1415
"Resample input_array, blending it in-place into output_array, using an\n"
1516
"affine transformation.\n\n"

src/ft2font_wrapper.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void PyFT2Image_dealloc(PyFT2Image *self)
6262
}
6363

6464
const char *PyFT2Image_draw_rect__doc__ =
65-
"draw_rect(x0, y0, x1, y1)\n"
65+
"draw_rect(self, x0, y0, x1, y1)\n"
6666
"--\n\n"
6767
"Draw an empty rectangle to the image.\n";
6868

@@ -80,7 +80,7 @@ static PyObject *PyFT2Image_draw_rect(PyFT2Image *self, PyObject *args)
8080
}
8181

8282
const char *PyFT2Image_draw_rect_filled__doc__ =
83-
"draw_rect_filled(x0, y0, x1, y1)\n"
83+
"draw_rect_filled(self, x0, y0, x1, y1)\n"
8484
"--\n\n"
8585
"Draw a filled rectangle to the image.\n";
8686

@@ -421,7 +421,7 @@ static void PyFT2Font_dealloc(PyFT2Font *self)
421421
}
422422

423423
const char *PyFT2Font_clear__doc__ =
424-
"clear()\n"
424+
"clear(self)\n"
425425
"--\n\n"
426426
"Clear all the glyphs, reset for a new call to `.set_text`.\n";
427427

@@ -433,7 +433,7 @@ static PyObject *PyFT2Font_clear(PyFT2Font *self, PyObject *args)
433433
}
434434

435435
const char *PyFT2Font_set_size__doc__ =
436-
"set_size(ptsize, dpi)\n"
436+
"set_size(self, ptsize, dpi)\n"
437437
"--\n\n"
438438
"Set the point size and dpi of the text.\n";
439439

@@ -452,7 +452,7 @@ static PyObject *PyFT2Font_set_size(PyFT2Font *self, PyObject *args)
452452
}
453453

454454
const char *PyFT2Font_set_charmap__doc__ =
455-
"set_charmap(i)\n"
455+
"set_charmap(self, i)\n"
456456
"--\n\n"
457457
"Make the i-th charmap current.\n";
458458

@@ -470,7 +470,7 @@ static PyObject *PyFT2Font_set_charmap(PyFT2Font *self, PyObject *args)
470470
}
471471

472472
const char *PyFT2Font_select_charmap__doc__ =
473-
"select_charmap(i)\n"
473+
"select_charmap(self, i)\n"
474474
"--\n\n"
475475
"Select a charmap by its FT_Encoding number.\n";
476476

@@ -488,7 +488,7 @@ static PyObject *PyFT2Font_select_charmap(PyFT2Font *self, PyObject *args)
488488
}
489489

490490
const char *PyFT2Font_get_kerning__doc__ =
491-
"get_kerning(left, right, mode)\n"
491+
"get_kerning(self, left, right, mode)\n"
492492
"--\n\n"
493493
"Get the kerning between *left* and *right* glyph indices.\n"
494494
"*mode* is a kerning mode constant:\n"
@@ -511,7 +511,7 @@ static PyObject *PyFT2Font_get_kerning(PyFT2Font *self, PyObject *args)
511511
}
512512

513513
const char *PyFT2Font_set_text__doc__ =
514-
"set_text(string, angle, flags=32)\n"
514+
"set_text(self, string, angle, flags=32)\n"
515515
"--\n\n"
516516
"Set the text *string* and *angle*.\n"
517517
"*flags* can be a bitwise-or of the LOAD_XXX constants;\n"
@@ -583,7 +583,7 @@ static PyObject *PyFT2Font_set_text(PyFT2Font *self, PyObject *args, PyObject *k
583583
}
584584

585585
const char *PyFT2Font_get_num_glyphs__doc__ =
586-
"get_num_glyphs()\n"
586+
"get_num_glyphs(self)\n"
587587
"--\n\n"
588588
"Return the number of loaded glyphs.\n";
589589

@@ -593,7 +593,7 @@ static PyObject *PyFT2Font_get_num_glyphs(PyFT2Font *self, PyObject *args)
593593
}
594594

595595
const char *PyFT2Font_load_char__doc__ =
596-
"load_char(charcode, flags=32)\n"
596+
"load_char(self, charcode, flags=32)\n"
597597
"--\n\n"
598598
"Load character with *charcode* in current fontfile and set glyph.\n"
599599
"*flags* can be a bitwise-or of the LOAD_XXX constants;\n"
@@ -632,7 +632,7 @@ static PyObject *PyFT2Font_load_char(PyFT2Font *self, PyObject *args, PyObject *
632632
}
633633

634634
const char *PyFT2Font_load_glyph__doc__ =
635-
"load_glyph(glyphindex, flags=32)\n"
635+
"load_glyph(self, glyphindex, flags=32)\n"
636636
"--\n\n"
637637
"Load character with *glyphindex* in current fontfile and set glyph.\n"
638638
"*flags* can be a bitwise-or of the LOAD_XXX constants;\n"
@@ -671,7 +671,7 @@ static PyObject *PyFT2Font_load_glyph(PyFT2Font *self, PyObject *args, PyObject
671671
}
672672

673673
const char *PyFT2Font_get_width_height__doc__ =
674-
"get_width_height()\n"
674+
"get_width_height(self)\n"
675675
"--\n\n"
676676
"Get the width and height in 26.6 subpixels of the current string set by `.set_text`.\n"
677677
"The rotation of the string is accounted for. To get width and height\n"
@@ -687,7 +687,7 @@ static PyObject *PyFT2Font_get_width_height(PyFT2Font *self, PyObject *args)
687687
}
688688

689689
const char *PyFT2Font_get_bitmap_offset__doc__ =
690-
"get_bitmap_offset()\n"
690+
"get_bitmap_offset(self)\n"
691691
"--\n\n"
692692
"Get the (x, y) offset in 26.6 subpixels for the bitmap if ink hangs left or below (0, 0).\n"
693693
"Since Matplotlib only supports left-to-right text, y is always 0.\n";
@@ -702,7 +702,7 @@ static PyObject *PyFT2Font_get_bitmap_offset(PyFT2Font *self, PyObject *args)
702702
}
703703

704704
const char *PyFT2Font_get_descent__doc__ =
705-
"get_descent()\n"
705+
"get_descent(self)\n"
706706
"--\n\n"
707707
"Get the descent in 26.6 subpixels of the current string set by `.set_text`.\n"
708708
"The rotation of the string is accounted for. To get the descent\n"
@@ -718,7 +718,7 @@ static PyObject *PyFT2Font_get_descent(PyFT2Font *self, PyObject *args)
718718
}
719719

720720
const char *PyFT2Font_draw_glyphs_to_bitmap__doc__ =
721-
"draw_glyphs_to_bitmap()\n"
721+
"draw_glyphs_to_bitmap(self, antialiased=True)\n"
722722
"--\n\n"
723723
"Draw the glyphs that were loaded by `.set_text` to the bitmap.\n"
724724
"The bitmap size will be automatically set to include the glyphs.\n";
@@ -739,7 +739,7 @@ static PyObject *PyFT2Font_draw_glyphs_to_bitmap(PyFT2Font *self, PyObject *args
739739
}
740740

741741
const char *PyFT2Font_get_xys__doc__ =
742-
"get_xys()\n"
742+
"get_xys(self, antialiased=True)\n"
743743
"--\n\n"
744744
"Get the xy locations of the current glyphs.\n";
745745

@@ -760,7 +760,7 @@ static PyObject *PyFT2Font_get_xys(PyFT2Font *self, PyObject *args, PyObject *kw
760760
}
761761

762762
const char *PyFT2Font_draw_glyph_to_bitmap__doc__ =
763-
"draw_glyph_to_bitmap(bitmap, x, y, glyph)\n"
763+
"draw_glyph_to_bitmap(self, image, x, y, glyph, antialiased=True)\n"
764764
"--\n\n"
765765
"Draw a single glyph to the bitmap at pixel locations x, y\n"
766766
"Note it is your responsibility to set up the bitmap manually\n"
@@ -801,7 +801,7 @@ static PyObject *PyFT2Font_draw_glyph_to_bitmap(PyFT2Font *self, PyObject *args,
801801
}
802802

803803
const char *PyFT2Font_get_glyph_name__doc__ =
804-
"get_glyph_name(index)\n"
804+
"get_glyph_name(self, index)\n"
805805
"--\n\n"
806806
"Retrieve the ASCII name of a given glyph *index* in a face.\n"
807807
"\n"
@@ -821,7 +821,7 @@ static PyObject *PyFT2Font_get_glyph_name(PyFT2Font *self, PyObject *args)
821821
}
822822

823823
const char *PyFT2Font_get_charmap__doc__ =
824-
"get_charmap()\n"
824+
"get_charmap(self)\n"
825825
"--\n\n"
826826
"Return a dict that maps the character codes of the selected charmap\n"
827827
"(Unicode by default) to their corresponding glyph indices.\n";
@@ -852,7 +852,7 @@ static PyObject *PyFT2Font_get_charmap(PyFT2Font *self, PyObject *args)
852852

853853

854854
const char *PyFT2Font_get_char_index__doc__ =
855-
"get_char_index(codepoint)\n"
855+
"get_char_index(self, codepoint)\n"
856856
"--\n\n"
857857
"Return the glyph index corresponding to a character *codepoint*.\n";
858858

@@ -872,7 +872,7 @@ static PyObject *PyFT2Font_get_char_index(PyFT2Font *self, PyObject *args)
872872

873873

874874
const char *PyFT2Font_get_sfnt__doc__ =
875-
"get_sfnt()\n"
875+
"get_sfnt(self)\n"
876876
"--\n\n"
877877
"Load the entire SFNT names table, as a dict whose keys are\n"
878878
"(platform-ID, ISO-encoding-scheme, language-code, and description)\n"
@@ -933,7 +933,7 @@ static PyObject *PyFT2Font_get_sfnt(PyFT2Font *self, PyObject *args)
933933
}
934934

935935
const char *PyFT2Font_get_name_index__doc__ =
936-
"get_name_index(name)\n"
936+
"get_name_index(self, name)\n"
937937
"--\n\n"
938938
"Return the glyph index of a given glyph *name*.\n"
939939
"The glyph index 0 means 'undefined character code'.\n";
@@ -950,7 +950,7 @@ static PyObject *PyFT2Font_get_name_index(PyFT2Font *self, PyObject *args)
950950
}
951951

952952
const char *PyFT2Font_get_ps_font_info__doc__ =
953-
"get_ps_font_info()\n"
953+
"get_ps_font_info(self)\n"
954954
"--\n\n"
955955
"Return the information in the PS Font Info structure.\n";
956956

@@ -977,7 +977,7 @@ static PyObject *PyFT2Font_get_ps_font_info(PyFT2Font *self, PyObject *args)
977977
}
978978

979979
const char *PyFT2Font_get_sfnt_table__doc__ =
980-
"get_sfnt_table(name)\n"
980+
"get_sfnt_table(self, name)\n"
981981
"--\n\n"
982982
"Return one of the following SFNT tables: head, maxp, OS/2, hhea, "
983983
"vhea, post, or pclt.\n";
@@ -1279,7 +1279,7 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args)
12791279
}
12801280

12811281
const char *PyFT2Font_get_path__doc__ =
1282-
"get_path()\n"
1282+
"get_path(self)\n"
12831283
"--\n\n"
12841284
"Get the path data from the currently loaded glyph as a tuple of vertices, "
12851285
"codes.\n";
@@ -1290,7 +1290,7 @@ static PyObject *PyFT2Font_get_path(PyFT2Font *self, PyObject *args)
12901290
}
12911291

12921292
const char *PyFT2Font_get_image__doc__ =
1293-
"get_image()\n"
1293+
"get_image(self)\n"
12941294
"--\n\n"
12951295
"Return the underlying image buffer for this font object.\n";
12961296

0 commit comments

Comments
 (0)