Source

IronPython.Zlib / src / ZlibModule.cs

Diff from to

src/ZlibModule.cs

 using IronPython.Runtime.Exceptions;
 using IronPython.Runtime.Operations;
 using IronPython.Runtime.Types;
+using Microsoft.Scripting.Runtime;
 
 [assembly: PythonModule("zlib", typeof(IronPython.Zlib.ZlibModule))]
 
 {
     public static class ZlibModule
     {
+        public const string __doc__ = @"The functions in this module allow compression and decompression using the
+zlib library, which is based on GNU zip.
+
+adler32(string[, start]) -- Compute an Adler-32 checksum.
+compress(string[, level]) -- Compress string, with compression level in 1-9.
+compressobj([level]) -- Return a compressor object.
+crc32(string[, start]) -- Compute a CRC-32 checksum.
+decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.
+decompressobj([wbits]) -- Return a decompressor object.
+
+'wbits' is window buffer size.
+Compressor objects support compress() and flush() methods; decompressor
+objects support decompress() and flush().";
+
         public const string ZLIB_VERSION = "1.2.3";     // just match the zlib version in Python 2.6
 
         internal const int Z_OK = (int)ZLibResultCode.Z_OK;
 
         internal const int DEFAULTALLOC = 16 * 1024;
 
-        #region adler32
+        [Documentation(@"adler32(string[, start]) -- Compute an Adler-32 checksum of string.
 
+An optional starting value can be specified.  The returned checksum is
+a signed integer.")]
         public static int adler32(string data, [DefaultParameterValue(1L)] long baseValue)
         {
             return adler32(Latin1.GetBytes(data), baseValue);
             return (int)Adler32.GetAdler32Checksum(baseValue, data, 0, data.Length);
         }
 
-        #endregion
+        [Documentation(@"crc32(string[, start]) -- Compute a CRC-32 checksum of string.
 
-        #region crc32
-
+An optional starting value can be specified.  The returned checksum is
+a signed integer.")]
         public static int crc32(string data, [DefaultParameterValue(0L)] long baseValue)
         {
             if(baseValue < int.MinValue || baseValue > uint.MaxValue)
                 return IronPython.Modules.PythonBinaryAscii.crc32(data, (int)baseValue);
         }
 
-        #endregion
 
         public static string compress(PythonBuffer data, 
             [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level)
             return compress(data.ToString(), level);
         }
 
+        [Documentation(@"compress(string[, level]) -- Returned compressed string.
+
+Optional arg level is the compression level, in 1-9.")]
         public static string compress(string data,
             [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level)
         {
                 throw zlib_error(zst, err, "while finishing compression");
         }
 
+        [Documentation(@"compressobj([level]) -- Return a compressor object.
+
+Optional arg level is the compression level, in 1-9.")]
         public static Compress compressobj(
             [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level,
             [DefaultParameterValue(DEFLATED)]int method,
             return new Compress(level, method, wbits, memlevel, strategy);
         }
 
+        [Documentation(@"decompress(string[, wbits[, bufsize]]) -- Return decompressed string.
+
+Optional arg wbits is the window buffer size.  Optional arg bufsize is
+the initial output buffer size.")]
         public static string decompress(string data,
             [DefaultParameterValue(MAX_WBITS)]int wbits,
             [DefaultParameterValue(DEFAULTALLOC)]int bufsize)
             return Latin1.GetString(output, 0, outputOffset);
         }
 
+        [Documentation(@"decompressobj([wbits]) -- Return a decompressor object.
+
+Optional arg wbits is the window buffer size.")]
         public static Decompress decompressobj([DefaultParameterValue(MAX_WBITS)]int wbits)
         {
             return new Decompress(wbits);