Skip to content

Commit aaf4aa3

Browse files
committed
Added more docstring documentation.
1 parent a8db677 commit aaf4aa3

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

mapcodemodule.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020

2121
static char version_doc[] =
22-
"version()\n\
22+
"version() -> string\n\
2323
\n\
24-
Returns the version of the Mapcode C library used by this Python module.\n";
24+
Returns the version of the Mapcode C library used by this module.\n";
2525

2626
static PyObject *version(PyObject *self, PyObject *args)
2727
{
@@ -30,7 +30,7 @@ static PyObject *version(PyObject *self, PyObject *args)
3030

3131

3232
static char isvalid_doc[] =
33-
"isvalid()\n\
33+
"isvalid(mapcode) -> bool\n\
3434
\n\
3535
Verify if the provided mapcode has the correct syntax.\n";
3636

@@ -51,10 +51,12 @@ static PyObject *isvalid(PyObject *self, PyObject *args)
5151

5252

5353
static char decode_doc[] =
54-
"decode(mapcode, (territoryname))\n\
54+
"decode(mapcode, (territoryname)) -> (float, float)\n\
5555
\n\
5656
Decodes the provided string to latitude and longitude. Optionally\n\
57-
a territoryname can be provided to disambiguate the mapcode.\n";
57+
a territoryname can be provided to disambiguate the mapcode.\n\
58+
\n\
59+
Returns (999,999) when decoding failed.\n";
5860

5961
static PyObject *decode(PyObject *self, PyObject *args)
6062
{
@@ -83,12 +85,13 @@ static PyObject *decode(PyObject *self, PyObject *args)
8385

8486

8587
static char encode_doc[] =
86-
"encode(latitude, longitude, (territoryname, extra_digits))\n\
88+
"encode(latitude, longitude, (territoryname, (extra_digits))) -> [(string, string)] \n\
8789
\n\
8890
Encodes the given latitude, longitude to one or more mapcodes.\n\
89-
Returns a list with one or more pairs of mapcode and territoryname.\n\
91+
Returns a list of tuples that contain mapcode and territoryname.\n\
9092
\n\
91-
Optionally a territoryname can be provided to generate a mapcode in partiucular territory.\n";
93+
Optionally a territoryname can be provided to generate a mapcode in\n\
94+
a particular territory.\n";
9295

9396
static PyObject *encode(PyObject *self, PyObject *args)
9497
{
@@ -117,7 +120,8 @@ static PyObject *encode(PyObject *self, PyObject *args)
117120
result = PyList_New(n);
118121
while (n--) {
119122
// printf("debug: %d: %s - %s\n", n, mapcode_results[n * 2], mapcode_results[(n * 2) + 1]);
120-
PyList_SetItem(result, n, Py_BuildValue("(ss)", (mapcode_results[n * 2]), mapcode_results[(n * 2) + 1]));
123+
PyList_SetItem(result, n, Py_BuildValue("(ss)",
124+
(mapcode_results[n * 2]), mapcode_results[(n * 2) + 1]));
121125
}
122126
return result;
123127
}
@@ -126,10 +130,12 @@ static PyObject *encode(PyObject *self, PyObject *args)
126130

127131

128132
static char encode_single_doc[] =
129-
"encode_single(latitude, longitude, (territoryname, extra_digits))\n\
133+
"encode_single(latitude, longitude, (territoryname, (extra_digits))) -> string\n\
134+
\n\
135+
Encodes the given latitude, longitude to the shortest mapcode possible.\n\
130136
\n\
131-
Encodes the given latitude, longitude to a mapcode. Optionally a territoryname\n\
132-
can be provided to generate a mapcode in partiucular territory.\n";
137+
Optionally a territoryname can be provided to generate a mapcode in\n\
138+
a particular territory.\n";
133139

134140
static PyObject *encode_single(PyObject *self, PyObject *args)
135141
{

0 commit comments

Comments
 (0)