*.c: Consistently show keyword arguments as optional in docstrings.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 9 Oct 2019 10:45:45 +0000 (11:45 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 22 Nov 2019 22:18:09 +0000 (22:18 +0000)
buffer.c
ec.c
field.c
group.c
key.c
mp.c
pgen.c
pubkey.c
rand.c

index 7360d0b..b15a245 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -269,7 +269,7 @@ static PyMethodDef rbuf_pymethods[] = {
   BUF_DOSUFFIXES(RBMETH_DECL_GETBUF_)
   METH (getmp,                 "RBUF.getmp() -> X")
   METH (getgf,                 "RBUF.getgf() -> X")
-  KWMETH(getecpt,              "RBUF.getecpt(curve = None) -> P")
+  KWMETH(getecpt,              "RBUF.getecpt([curve = None]) -> P")
   METH (getecptraw,            "RBUF.getecptraw(CURVE) -> P")
   METH (getge,                 "RBUF.getge(GROUP) -> X")
   METH (getgeraw,              "RBUF.getgeraw(GROUP) -> X")
diff --git a/ec.c b/ec.c
index c006926..e18cbb8 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -1063,7 +1063,7 @@ static PyMethodDef eccurve_pymethods[] = {
   METH (mmul,          "\
 E.mmul([(P0, N0), (P1, N1), ...]) = N0 P0 + N1 P1 + ...")
   METH (find,          "E.find(X) -> P")
-  KWMETH(rand,         "E.rand(rng = rand) ->P")
+  KWMETH(rand,         "E.rand([rng = rand]) -> P")
 #undef METHNAME
   { 0 }
 };
diff --git a/field.c b/field.c
index 1f316f3..d35f1b8 100644 (file)
--- a/field.c
+++ b/field.c
@@ -525,7 +525,7 @@ static PyGetSetDef field_pygetset[] = {
 static PyMethodDef field_pymethods[] = {
 #define METHNAME(name) fmeth_##name
   METH (_adopt,        "F._adopt(X) -> FE")
-  KWMETH(rand,         "F.rand(rng = rand) -> FE, uniformly distributed")
+  KWMETH(rand,         "F.rand([rng = rand]) -> FE, uniformly distributed")
 #undef METHNAME
   { 0 }
 };
diff --git a/group.c b/group.c
index 83608d3..9f7bbcd 100644 (file)
--- a/group.c
+++ b/group.c
@@ -964,7 +964,7 @@ static PyMethodDef ge_pymethods[] = {
   METH (check,         "X.check() -> check X really belongs to its group")
   METH (toint,         "X.toint() -> X converted to an integer")
   KWMETH(toec,         "\
-X.toec(curve = ECPt) -> X converted to elliptic curve point")
+X.toec([curve = ECPt]) -> X converted to elliptic curve point")
   METH (tobuf,         "X.tobuf() -> X in buffer representation")
   METH (toraw,         "X.toraw() -> X in raw representation")
 #undef METHNAME
@@ -1079,7 +1079,7 @@ static PyMethodDef group_pymethods[] = {
 #define METHNAME(name) gmeth_##name
   METH (mexp,          "\
 G.mexp([(X0, N0), (X1, N1), ...]) -> X0^N0 X1^N1 ...")
-  KWMETH(checkgroup,   "G.checkgroup(rng = rand): check group is good")
+  KWMETH(checkgroup,   "G.checkgroup([rng = rand]): check group is good")
 #undef METHNAME
   { 0 }
 };
@@ -1377,16 +1377,16 @@ static PyMethodDef methods[] = {
   METH (_DHInfo__groupn,       0)
   METH (_BinDHInfo__groupn,    0)
   KWMETH(_DHInfo_generate,     "\
-generate(PBITS, [qbits = 0, event = pgen_nullev,\n\
-        rng = rand, nsteps = 0]) -> D")
+generate(PBITS, [qbits = 0], [event = pgen_nullev],\n\
+        [rng = rand], [nsteps = 0]) -> D")
   KWMETH(_DHInfo_genlimlee,    "\
-genlimlee(PBITS, QBITS, [event = pgen_nullev, ievent = pgen_nullev,\n\
-         rng = rand, nsteps = 0, subgroupp = True]) -> (D, [Q, ...])")
+genlimlee(PBITS, QBITS, [event = pgen_nullev], [ievent = pgen_nullev],\n\
+         [rng = rand], [nsteps = 0], [subgroupp = True]) -> (D, [Q, ...])")
   KWMETH(_DHInfo_gendsa,       "\
-gendsa(PBITS, QBITS, SEED, [event = pgen_nullevnsteps = 0])\n\
+gendsa(PBITS, QBITS, SEED, [event = pgen_nullev], [nsteps = 0])\n\
   -> (D, SEED, COUNT)")
   KWMETH(_DHInfo_genkcdsa,     "\
-gendsa(PBITS, QBITS, [event = pgen_nullev, rng = rand, nsteps = 0])\n\
+gendsa(PBITS, QBITS, [event = pgen_nullev], [rng = rand], [nsteps = 0])\n\
   -> (D, V)")
 #undef METHNAME
   { 0 }
diff --git a/key.c b/key.c
index cb0ac72..5511699 100644 (file)
--- a/key.c
+++ b/key.c
@@ -465,9 +465,9 @@ static PyMethodDef keydata_pymethods[] = {
 #define METHNAME(func) kdmeth_##func
   METH (matchp,                "KD.matchp(FILTER) -> BOOL")
   METH (split,                 "KD.split()")
-  KWMETH(write,                        "KD.write(filter = <any>) -> STRING")
-  KWMETH(encode,               "KD.encode(filter = <any>) -> BYTES")
-  KWMETH(copy,                 "KD.copy(filter = <any>) -> KD")
+  KWMETH(write,                        "KD.write([filter = <any>]) -> STRING")
+  KWMETH(encode,               "KD.encode([filter = <any>]) -> BYTES")
+  KWMETH(copy,                 "KD.copy([filter = <any>]) -> KD")
   METH (plock,                 "KD.plock(TAG) -> ENCRYPTED-KD")
   METH (lock,                  "KD.lock(KEY) -> ENCRYPTED-KD")
 #undef METHNAME
@@ -1599,8 +1599,8 @@ static PyMethodDef key_pymethods[] = {
   METH (delete,        "KEY.delete()")
   METH (expire,        "KEY.expire()")
   METH (used,          "KEY.used(TIME)")
-  KWMETH(extract,      "KEY.extract(FILE, filter = '')")
-  KWMETH(fingerprint,  "KEY.fingerprint(HASH, filtr = '-secret')")
+  KWMETH(extract,      "KEY.extract(FILE, [filter = <any>])")
+  KWMETH(fingerprint,  "KEY.fingerprint(HASH, [filter = '-secret'])")
 #undef METHNAME
   { 0 }
 };
@@ -1990,12 +1990,13 @@ static PyObject *kfget_filep(PyObject *me, void *hunoz)
 static PyMethodDef keyfile_pymethods[] = {
 #define METHNAME(func) kfmeth_##func
   METH (save,          "KF.save()")
-  KWMETH(merge,                "KF.merge(FILE, report = <built-in-reporter>)")
-  KWMETH(newkey,       "KF.newkey(ID, TYPE, exptime = KEXP_FOREVER) -> KEY")
+  KWMETH(merge,                "KF.merge(FILE, [report = <built-in-reporter>])")
+  KWMETH(newkey,       "KF.newkey(ID, TYPE, "
+                               "[exptime = KEXP_FOREVER]) -> KEY")
   METH (byid,          "KF.byid(KEYID) -> KEY|None")
   METH (bytype,        "KF.bytype(TYPE) -> KEY|None")
   METH (bytag,         "KF.bytag(TAG) -> KEY|None")
-  KWMETH(qtag,         "KF.qtag(TAG, new = KD) -> FULLTAG, KEY, OLDKD")
+  KWMETH(qtag,         "KF.qtag(TAG, [new = KD]) -> FULLTAG, KEY, OLDKD")
   GMAP_ROMETHODS
 #undef METHNAME
   { 0 }
diff --git a/mp.c b/mp.c
index 2aa4cab..a234c6d 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -809,14 +809,14 @@ static PyMethodDef mp_pymethods[] = {
   METH (modsqrt,       "X.modsqrt(Y) -> square root of Y mod X, if X prime")
   METH (leastcongruent,
         "X.leastcongruent(B, M) -> smallest Z >= B with Z == X (mod M)")
-  KWMETH(primep,       "X.primep(rng = rand) -> true/false if X is prime")
-  KWMETH(tostring,     "X.tostring(radix = 10) -> STR")
-  KWMETH(storel,       "X.storel(len = -1) -> little-endian bytes")
-  KWMETH(storeb,       "X.storeb(len = -1) -> big-endian bytes")
+  KWMETH(primep,       "X.primep([rng = rand]) -> true/false if X is prime")
+  KWMETH(tostring,     "X.tostring([radix = 10]) -> STR")
+  KWMETH(storel,       "X.storel([len = -1]) -> little-endian bytes")
+  KWMETH(storeb,       "X.storeb([len = -1]) -> big-endian bytes")
   KWMETH(storel2c,
-        "X.storel2c(len = -1) -> little-endian bytes, two's complement")
+        "X.storel2c([len = -1]) -> little-endian bytes, two's complement")
   KWMETH(storeb2c,
-        "X.storeb2c(len = -1) -> big-endian bytes, two's complement")
+        "X.storeb2c([len = -1]) -> big-endian bytes, two's complement")
   METH (tobuf,         "X.tobuf() -> buffer format")
 #undef METHNAME
   { 0 }
@@ -896,7 +896,7 @@ versatile.  Support all the standard arithmetic operations, with\n\
 implicit conversions from `PrimeFilter', and other objects which\n\
 convert to `long'.\n\
 \n\
-Constructor MP(X, radix = R) attempts to convert X to an `MP'.  If\n\
+Constructor MP(X, [radix = R]) attempts to convert X to an `MP'.  If\n\
 X is a string, it's read in radix-R form, or we look for a prefix\n\
 if R = 0.  Other acceptable things are field elements, elliptic curve\n\
 points, group elements, Python `int' and `long' objects, and anything\n\
@@ -2003,13 +2003,13 @@ static PyMethodDef gf_pymethods[] = {
   METH (irreduciblep,  "X.irreduciblep() -> true/false")
 #undef METHNAME
 #define METHNAME(func) mpmeth_##func
-  KWMETH(tostring,     "X.tostring(radix = 10) -> STR")
-  KWMETH(storel,       "X.storel(len = -1) -> little-endian bytes")
-  KWMETH(storeb,       "X.storeb(len = -1) -> big-endian bytes")
+  KWMETH(tostring,     "X.tostring([radix = 10]) -> STR")
+  KWMETH(storel,       "X.storel([len = -1]) -> little-endian bytes")
+  KWMETH(storeb,       "X.storeb([len = -1]) -> big-endian bytes")
   KWMETH(storel2c,
-        "X.storel2c(len = -1) -> little-endian bytes, two's complement")
+        "X.storel2c([len = -1]) -> little-endian bytes, two's complement")
   KWMETH(storeb2c,
-        "X.storeb2c(len = -1) -> big-endian bytes, two's complement")
+        "X.storeb2c([len = -1]) -> big-endian bytes, two's complement")
   METH (tobuf,         "X.tobuf() -> buffer format")
 #undef METHNAME
   { 0 }
@@ -2087,7 +2087,7 @@ static PyTypeObject gf_pytype_skel = {
 "Binary polynomials.  Support almost all the standard arithmetic\n\
 operations.\n\
 \n\
-Constructor GF(X, radix = R) attempts to convert X to a `GF'.  If\n\
+Constructor GF(X, [radix = R]) attempts to convert X to a `GF'.  If\n\
 X is a string, it's read in radix-R form, or we look for a prefix\n\
 if R = 0.  Other acceptable things are field elements, elliptic curve\n\
 points, group elements, Python `int' and `long' objects, and anything\n\
@@ -2472,13 +2472,13 @@ and normal basis representations.",
 static PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   KWMETH(_MP_fromstring,       "\
-fromstring(STR, radix = 0) -> (X, REST)\n\
+fromstring(STR, [radix = 0]) -> (X, REST)\n\
 \n\
 Parse STR as a large integer, according to radix.  If radix is zero,\n\
 read a prefix from STR to decide radix: allow `0' for octal, `0x' for hex\n\
 or `R_' for other radix R.")
   KWMETH(_GF_fromstring,       "\
-fromstring(STR, radix = 0) -> (X, REST)\n\
+fromstring(STR, [radix = 0]) -> (X, REST)\n\
 \n\
 Parse STR as a binary polynomial, according to radix.  If radix is zero,\n\
 read a prefix from STR to decide radix: allow `0' for octal, `0x' for hex\n\
diff --git a/pgen.c b/pgen.c
index 081d8e5..a77c88b 100644 (file)
--- a/pgen.c
+++ b/pgen.c
@@ -1028,18 +1028,18 @@ static PyMethodDef methods[] = {
   METH (_PrimeFilter_smallfactor,      "smallfactor(X) -> PGRC")
   METH (_RabinMiller_iters,            "iters(NBITS) -> NITERS")
   KWMETH(pgen,                         "\
-pgen(START, [name = 'p', stepper = PrimeGenStepper(2),\n\
-     tester = PrimeGenTester(), event = pgen_nullev,\n\
-     nsteps = 0, ntests = RabinMiller.iters(START.nbits)]) -> P")
+pgen(START, [name = 'p'[, [stepper = PrimeGenStepper(2)],\n\
+     [tester = PrimeGenTester()], [event = pgen_nullev],\n\
+     [nsteps = 0], [ntests = RabinMiller.iters(START.nbits)]) -> P")
   KWMETH(strongprime_setup,            "\
-strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
-                 rng = rand, nsteps = 0]) -> (START, JUMP)")
+strongprime_setup(NBITS, [name = 'p'], [event = pgen_nullev],\n\
+                 [rng = rand], [nsteps = 0]) -> (START, JUMP)")
   KWMETH(strongprime,                  "\
-strongprime(NBITS, [name = 'p', event = pgen_nullev,\n\
-           rng = rand, nsteps = 0]) -> P")
+strongprime(NBITS, [name = 'p'], [event = pgen_nullev],\n\
+           [rng = rand], [nsteps = 0]) -> P")
   KWMETH(limlee,                       "\
-limlee(PBITS, QBITS, [name = 'p', event = pgen_nullev,\n\
-       ievent = pgen_nullev, rng = rand, nsteps = 0]) -> (P, [Q, ...])")
+limlee(PBITS, QBITS, [name = 'p'], [event = pgen_nullev],\n\
+       [ievent = pgen_nullev], [rng = rand], [nsteps = 0]) -> (P, [Q, ...])")
 #undef METHNAME
   { 0 }
 };
index 5167a97..44454df 100644 (file)
--- a/pubkey.c
+++ b/pubkey.c
@@ -200,7 +200,7 @@ static PyMethodDef dsapub_pymethods[] = {
 
 static PyMethodDef dsapriv_pymethods[] = {
 #define METHNAME(name) dsameth_##name
-  KWMETH(sign,                 "D.sign(MSG, k = K) -> R, S")
+  KWMETH(sign,                 "D.sign(MSG, [k = K]) -> R, S")
 #undef METHNAME
   { 0 }
 };
@@ -437,7 +437,7 @@ static PyMethodDef kcdsapub_pymethods[] = {
 
 static PyMethodDef kcdsapriv_pymethods[] = {
 #define METHNAME(name) kcdsameth_##name
-  KWMETH(sign,                 "D.sign(MSG, k = K) -> R, S")
+  KWMETH(sign,                 "D.sign(MSG, [k = K]) -> R, S")
 #undef METHNAME
   { 0 }
 };
@@ -783,7 +783,7 @@ static PyGetSetDef rsapriv_pygetset[] = {
 
 static PyMethodDef rsapriv_pymethods[] = {
 #define METHNAME(name) rsameth_##name
-  KWMETH(privop,               "R.privop(X, rng = None) -> X^D (mod N)")
+  KWMETH(privop,               "R.privop(X, [rng = None]) -> X^D (mod N)")
 #undef METHNAME
   { 0 }
 };
@@ -1261,7 +1261,7 @@ static PyMethodDef methods[] = {
   KWMETH(_pss_encode,                  0)
   KWMETH(_pss_decode,                  0)
   KWMETH(_RSAPriv_generate,            "\
-generate(NBITS, [event = pgen_nullev, rng = rand, nsteps = 0]) -> R")
+generate(NBITS, [event = pgen_nullev], [rng = rand], [nsteps = 0]) -> R")
 #define DEFMETH(X, x)                                                  \
   METH  (x,                            "\
 " #x "(KEY, PUBLIC) -> SHARED")
@@ -1271,11 +1271,11 @@ generate(NBITS, [event = pgen_nullev, rng = rand, nsteps = 0]) -> R")
   METH  (ed##_pubkey,                  "\
 " #ed "_pubkey(KEY) -> PUBLIC")                                                \
   KWMETH(ed##_sign,                    "\
-" #ed "_sign(KEY, MSG, [pub = PUBLIC, "                                        \
-        "perso = STRING, phflag = BOOL]) -> SIG")                      \
+" #ed "_sign(KEY, MSG, [pub = PUBLIC], "                               \
+        "[perso = STRING], [phflag = BOOL]) -> SIG")                   \
   KWMETH(ed##_verify,                  "\
 " #ed "_verify(PUBLIC, MSG, SIG, "                                     \
-        "[perso = STRINGphflag = BOOL]) -> BOOL")
+        "[perso = STRING], [phflag = BOOL]) -> BOOL")
   EDDSAS(DEFMETH)
 #undef DEFMETH
 #undef METHNAME
diff --git a/rand.c b/rand.c
index 6fe78bc..3b5b5c3 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -1489,7 +1489,8 @@ static PyTypeObject bbspriv_pytype_skel = {
 static PyMethodDef methods[] = {
 #define METHNAME(name) meth_##name
   KWMETH(_BBSPriv_generate,            "\
-generate(NBITS, [event = pgen_nullev, rng = rand, nsteps = 0, seed = 2])")
+generate(NBITS, [event = pgen_nullev], [rng = rand],\n\
+        [nsteps = 0], [seed = 2])")
 #undef METHNAME
   { 0 }
 };