Skip to content

Commit 6f29106

Browse files
authored
Add doc comments to all stdlib C# modules - types, methods, properties, constructors
1 parent 6d300e0 commit 6f29106

60 files changed

Lines changed: 888 additions & 15 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Sharpy.Stdlib/Argparse/__Init__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Sharpy
22
{
3-
/// <summary>Module exports for the argparse module.</summary>
3+
/// <summary>Command-line argument parsing.</summary>
44
[SharpyModule("argparse")]
55
public static partial class ArgparseModule
66
{ }

src/Sharpy.Stdlib/Base64/Base64Module.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
namespace Sharpy
55
{
6+
/// <summary>Provides base-N encoders and decoders similar to Python's base64 module.</summary>
67
public static partial class Base64Module
78
{
89
// ─── Base64 ──────────────────────────────────────────────────────────
910

11+
/// <summary>Encode bytes using Base64.</summary>
1012
public static Bytes B64encode(Bytes s, Bytes? altchars = null)
1113
{
1214
byte[] data = s.ToArray();
@@ -26,11 +28,13 @@ public static Bytes B64encode(Bytes s, Bytes? altchars = null)
2628
return new Bytes(Encoding.ASCII.GetBytes(encoded));
2729
}
2830

31+
/// <summary>Decode Base64-encoded bytes.</summary>
2932
public static Bytes B64decode(Bytes s, Bytes? altchars = null, bool validate = false)
3033
{
3134
return B64decodeString(Encoding.ASCII.GetString(s.ToArray()), altchars, validate);
3235
}
3336

37+
/// <summary>Decode a Base64-encoded string.</summary>
3438
public static Bytes B64decode(string s, Bytes? altchars = null, bool validate = false)
3539
{
3640
return B64decodeString(s, altchars, validate);
@@ -86,6 +90,7 @@ private static Bytes B64decodeString(string encoded, Bytes? altchars, bool valid
8690

8791
// ─── URL-safe Base64 ─────────────────────────────────────────────────
8892

93+
/// <summary>Encode bytes using URL-safe Base64.</summary>
8994
public static Bytes UrlsafeB64encode(Bytes s)
9095
{
9196
byte[] data = s.ToArray();
@@ -94,11 +99,13 @@ public static Bytes UrlsafeB64encode(Bytes s)
9499
return new Bytes(Encoding.ASCII.GetBytes(encoded));
95100
}
96101

102+
/// <summary>Decode URL-safe Base64-encoded bytes.</summary>
97103
public static Bytes UrlsafeB64decode(Bytes s)
98104
{
99105
return UrlsafeB64decodeString(Encoding.ASCII.GetString(s.ToArray()));
100106
}
101107

108+
/// <summary>Decode a URL-safe Base64-encoded string.</summary>
102109
public static Bytes UrlsafeB64decode(string s)
103110
{
104111
return UrlsafeB64decodeString(s);
@@ -122,6 +129,7 @@ private static Bytes UrlsafeB64decodeString(string encoded)
122129

123130
private static readonly char[] Base32Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".ToCharArray();
124131

132+
/// <summary>Encode bytes using Base32.</summary>
125133
public static Bytes B32encode(Bytes s)
126134
{
127135
byte[] data = s.ToArray();
@@ -158,6 +166,7 @@ public static Bytes B32encode(Bytes s)
158166
return new Bytes(Encoding.ASCII.GetBytes(sb.ToString()));
159167
}
160168

169+
/// <summary>Decode Base32-encoded bytes.</summary>
161170
public static Bytes B32decode(Bytes s, bool casefold = false)
162171
{
163172
string encoded = Encoding.ASCII.GetString(s.ToArray()).TrimEnd('=');
@@ -225,6 +234,7 @@ private static int Base32CharToValue(char c, bool casefold)
225234

226235
// ─── Base16 ──────────────────────────────────────────────────────────
227236

237+
/// <summary>Encode bytes using Base16.</summary>
228238
public static Bytes B16encode(Bytes s)
229239
{
230240
byte[] data = s.ToArray();
@@ -237,6 +247,7 @@ public static Bytes B16encode(Bytes s)
237247
return new Bytes(Encoding.ASCII.GetBytes(sb.ToString()));
238248
}
239249

250+
/// <summary>Decode Base16-encoded bytes.</summary>
240251
public static Bytes B16decode(Bytes s, bool casefold = false)
241252
{
242253
string hex = Encoding.ASCII.GetString(s.ToArray());
@@ -309,6 +320,7 @@ private static int[] BuildB85Lookup()
309320
return lookup;
310321
}
311322

323+
/// <summary>Encode bytes using RFC 1924 Base85.</summary>
312324
public static Bytes B85encode(Bytes s)
313325
{
314326
byte[] data = s.ToArray();
@@ -342,6 +354,7 @@ public static Bytes B85encode(Bytes s)
342354
return new Bytes(Encoding.ASCII.GetBytes(sb.ToString(0, resultLen)));
343355
}
344356

357+
/// <summary>Decode RFC 1924 Base85-encoded bytes.</summary>
345358
public static Bytes B85decode(Bytes s)
346359
{
347360
byte[] data = s.ToArray();
@@ -399,6 +412,7 @@ private static int B85CharToValue(char c)
399412

400413
// ─── Ascii85 (Adobe variant) ─────────────────────────────────────────
401414

415+
/// <summary>Encode bytes using Adobe-style Ascii85.</summary>
402416
public static Bytes A85encode(Bytes s)
403417
{
404418
byte[] data = s.ToArray();
@@ -439,6 +453,7 @@ public static Bytes A85encode(Bytes s)
439453
return new Bytes(Encoding.ASCII.GetBytes(sb.ToString(0, resultLen)));
440454
}
441455

456+
/// <summary>Decode Adobe-style Ascii85-encoded bytes.</summary>
442457
public static Bytes A85decode(Bytes s)
443458
{
444459
byte[] data = s.ToArray();

src/Sharpy.Stdlib/Base64/__Init__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Sharpy
22
{
3-
/// <summary>Module exports for the base64 module.</summary>
3+
/// <summary>RFC 4648 base16, base32, base64, and base85 data encodings.</summary>
44
[SharpyModule("base64")]
55
public static partial class Base64Module
66
{ }

src/Sharpy.Stdlib/Configparser/ConfigParser.IO.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace Sharpy
66
{
7+
/// <summary>Provides I/O helpers for the config parser.</summary>
78
public sealed partial class ConfigParser
89
{
10+
/// <summary>Reads configuration data from a string.</summary>
911
public void ReadString(string content, string source = "<string>")
1012
{
1113
using (var reader = new StringReader(content))
@@ -14,6 +16,7 @@ public void ReadString(string content, string source = "<string>")
1416
}
1517
}
1618

19+
/// <summary>Reads configuration data from a file if it exists.</summary>
1720
public void Read(string filename)
1821
{
1922
if (!File.Exists(filename))
@@ -24,6 +27,7 @@ public void Read(string filename)
2427
ReadString(content, filename);
2528
}
2629

30+
/// <summary>Loads configuration values from nested dictionaries.</summary>
2731
public void ReadDict(SCG.Dictionary<string, SCG.Dictionary<string, string>> dictionary)
2832
{
2933
foreach (var section in dictionary)
@@ -43,6 +47,7 @@ public void ReadDict(SCG.Dictionary<string, SCG.Dictionary<string, string>> dict
4347
}
4448
}
4549

50+
/// <summary>Writes the current configuration to a text writer.</summary>
4651
public void Write(TextWriter writer, bool spaceAroundDelimiters = true)
4752
{
4853
string delimiter = spaceAroundDelimiters ? " = " : "=";
@@ -82,6 +87,7 @@ public void Write(TextWriter writer, bool spaceAroundDelimiters = true)
8287
}
8388
}
8489

90+
/// <summary>Writes the current configuration to a file.</summary>
8591
public void WriteToFile(string filename, bool spaceAroundDelimiters = true)
8692
{
8793
using (var writer = new StreamWriter(filename))

src/Sharpy.Stdlib/Configparser/ConfigParser.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Sharpy
55
{
6+
/// <summary>Parses and stores INI-style configuration data.</summary>
67
[SharpyModuleType("configparser")]
78
public sealed partial class ConfigParser
89
{
@@ -17,12 +18,14 @@ public sealed partial class ConfigParser
1718
private readonly IInterpolation _interpolation;
1819
private readonly bool _allowNoValue;
1920

21+
/// <summary>Initializes a new config parser.</summary>
2022
public ConfigParser(IInterpolation? interpolation = null, bool allowNoValue = false)
2123
{
2224
_interpolation = interpolation ?? new BasicInterpolation();
2325
_allowNoValue = allowNoValue;
2426
}
2527

28+
/// <summary>Gets a proxy for the named section.</summary>
2629
public SectionProxy this[string section]
2730
{
2831
get
@@ -36,11 +39,13 @@ public SectionProxy this[string section]
3639
}
3740
}
3841

42+
/// <summary>Returns the non-default section names.</summary>
3943
public SCG.List<string> Sections()
4044
{
4145
return new SCG.List<string>(_sections.Keys);
4246
}
4347

48+
/// <summary>Adds a new section.</summary>
4449
public void AddSection(string section)
4550
{
4651
if (string.Equals(section, DefaultSectionName, StringComparison.OrdinalIgnoreCase))
@@ -54,6 +59,7 @@ public void AddSection(string section)
5459
_sections[section] = new SCG.Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
5560
}
5661

62+
/// <summary>Determines whether a non-default section exists.</summary>
5763
public bool HasSection(string section)
5864
{
5965
if (string.Equals(section, DefaultSectionName, StringComparison.OrdinalIgnoreCase))
@@ -63,6 +69,7 @@ public bool HasSection(string section)
6369
return _sections.ContainsKey(section);
6470
}
6571

72+
/// <summary>Removes a non-default section.</summary>
6673
public bool RemoveSection(string section)
6774
{
6875
if (string.Equals(section, DefaultSectionName, StringComparison.OrdinalIgnoreCase))
@@ -72,6 +79,7 @@ public bool RemoveSection(string section)
7279
return _sections.Remove(section);
7380
}
7481

82+
/// <summary>Gets an option value, optionally applying interpolation.</summary>
7583
public string? Get(string section, string option, string? fallback = null, bool raw = false)
7684
{
7785
string normalizedOption = option.ToLowerInvariant();
@@ -112,6 +120,7 @@ public bool RemoveSection(string section)
112120
return _interpolation.BeforeGet(this, section, normalizedOption, rawValue);
113121
}
114122

123+
/// <summary>Gets an option as an integer.</summary>
115124
public int GetInt(string section, string option, int? fallback = null)
116125
{
117126
string? value = null;
@@ -131,6 +140,7 @@ public int GetInt(string section, string option, int? fallback = null)
131140
return result;
132141
}
133142

143+
/// <summary>Gets an option as a floating-point number.</summary>
134144
public double GetFloat(string section, string option, double? fallback = null)
135145
{
136146
string? value = null;
@@ -151,6 +161,7 @@ public double GetFloat(string section, string option, double? fallback = null)
151161
return result;
152162
}
153163

164+
/// <summary>Gets an option as a boolean using configparser truth values.</summary>
154165
public bool GetBoolean(string section, string option, bool? fallback = null)
155166
{
156167
string? value = null;
@@ -185,6 +196,7 @@ public bool GetBoolean(string section, string option, bool? fallback = null)
185196
}
186197
}
187198

199+
/// <summary>Sets an option value in a section.</summary>
188200
public void Set(string section, string option, string value)
189201
{
190202
string normalizedOption = option.ToLowerInvariant();
@@ -201,6 +213,7 @@ public void Set(string section, string option, string value)
201213
_sections[section][normalizedOption] = value;
202214
}
203215

216+
/// <summary>Determines whether a section or defaults contain an option.</summary>
204217
public bool HasOption(string section, string option)
205218
{
206219
string normalizedOption = option.ToLowerInvariant();
@@ -216,6 +229,7 @@ public bool HasOption(string section, string option)
216229
return _sections[section].ContainsKey(normalizedOption) || _defaults.ContainsKey(normalizedOption);
217230
}
218231

232+
/// <summary>Removes an option from a section or from defaults.</summary>
219233
public bool RemoveOption(string section, string option)
220234
{
221235
string normalizedOption = option.ToLowerInvariant();
@@ -231,6 +245,7 @@ public bool RemoveOption(string section, string option)
231245
return _sections[section].Remove(normalizedOption);
232246
}
233247

248+
/// <summary>Returns the option names available in a section.</summary>
234249
public SCG.List<string> Options(string section)
235250
{
236251
if (string.Equals(section, DefaultSectionName, StringComparison.OrdinalIgnoreCase))
@@ -254,6 +269,7 @@ public SCG.List<string> Options(string section)
254269
return new SCG.List<string>(result);
255270
}
256271

272+
/// <summary>Returns the section items with defaults applied.</summary>
257273
public SCG.Dictionary<string, string> Items(string section)
258274
{
259275
if (!string.Equals(section, DefaultSectionName, StringComparison.OrdinalIgnoreCase)
@@ -287,6 +303,7 @@ public SCG.Dictionary<string, string> Items(string section)
287303
return result;
288304
}
289305

306+
/// <summary>Returns the default section values.</summary>
290307
public SCG.Dictionary<string, string> Defaults()
291308
{
292309
var result = new SCG.Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

0 commit comments

Comments
 (0)