X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib-python/blobdiff_plain/a19eaede18c9176b382df01e4f6c6e5c04a87d0f..addc0c3760b565ead630bd67cc038b31954b9284:/codec.pyx.in diff --git a/codec.pyx.in b/codec.pyx.in index 2ea5255..3da1b83 100644 --- a/codec.pyx.in +++ b/codec.pyx.in @@ -34,6 +34,11 @@ cdef extern from 'mLib/%PREFIX%.h': void *p, size_t sz, dstr *d) cdef class %CLASS%Encode: + """ + %CLASS%([indent = '\\n'], [maxline = 72]) + + Obsolete %CLASS% encoder. + """ cdef %PREFIX%_ctx ctx def __cinit__(me, *hunoz, **hukairz): _%PREFIX%_init(&me.ctx) @@ -47,6 +52,7 @@ cdef class %CLASS%Encode: if me.ctx.indent: xfree(me.ctx.indent) property indent: + """E.indent -> INT: indent level for new lines""" def __get__(me): return me.ctx.indent def __set__(me, indent): @@ -54,11 +60,13 @@ cdef class %CLASS%Encode: xfree(me.ctx.indent) me.ctx.indent = xstrdup(indent) property maxline: + """E.maxline -> INT: maximum length of line, or 0 to prevent splitting""" def __get__(me): return me.ctx.maxline def __set__(me, maxline): me.ctx.maxline = maxline def encode(me, text): + """E.encode(IN) -> OUT: continue encoding""" cdef void *p cdef Py_ssize_t len cdef dstr d @@ -71,6 +79,7 @@ cdef class %CLASS%Encode: dstr_destroy(&d) return rc def done(me): + """E.done() -> OUT: finish encoding, returning final output""" cdef dstr d DCREATE(&d) try: @@ -81,15 +90,22 @@ cdef class %CLASS%Encode: return rc def %PREFIX%_encode(text, *arg, **kw): + """%PREFIX%_encode(IN, [ARGS...]) -> OUT: %CLASS%-encode the string IN""" e = %CLASS%Encode(*arg, **kw) return e.encode(text) + e.done() cdef class %CLASS%Decode: + """ + %CLASS%() + + Obsolete %CLASS% decoder. + """ cdef %PREFIX%_ctx ctx def __cinit__(me, *hunoz, **hukairz): _%PREFIX%_init(&me.ctx) me.ctx.indent = NULL def decode(me, text): + """D.encode(IN) -> OUT: continue decoding""" cdef void *p cdef Py_ssize_t len cdef dstr d @@ -102,6 +118,7 @@ cdef class %CLASS%Decode: dstr_destroy(&d) return rc def done(me): + """D.done() -> OUT: finish decoding, returning final output""" cdef dstr d DCREATE(&d) try: @@ -112,6 +129,7 @@ cdef class %CLASS%Decode: return rc def %PREFIX%_decode(text, *arg, **kw): + """%PREFIX%_decode(IN) -> OUT: %CLASS%-decode the string IN""" d = %CLASS%Decode(*arg, **kw) return d.decode(text) + d.done()