diff --git a/csdown/csdown/Program.cs b/csdown/csdown/Program.cs index 13978049..19b1726e 100644 --- a/csdown/csdown/Program.cs +++ b/csdown/csdown/Program.cs @@ -50,12 +50,9 @@ namespace csdown { Console.WriteLine("Generating C# documentation."); - sb.AppendLine(""); - sb.AppendLine("## Functions"); - sb.AppendLine(); - sb.AppendLine("---"); - sb.AppendLine(); + // All the member functions in the Astronomy class go in the "functions" section. + AppendSectionHeader(sb, "Functions"); Type astro = asm.GetType("CosineKitty.Astronomy"); MethodInfo[] funcs = astro.GetMethods() .Where(m => m.IsPublic && m.IsStatic) @@ -64,6 +61,51 @@ namespace csdown foreach (MethodInfo f in funcs) AppendFunctionMarkdown(sb, cinfo, f); + + // The classes other than "Astronomy" are listed one by one in the "classes" section. + sb.AppendLine("---"); + sb.AppendLine(); + AppendSectionHeader(sb, "Classes"); + Type[] otherClassList = asm.GetExportedTypes() + .Where(c => c.Name != "Astronomy" && c.IsClass) + .OrderBy(c => c.Name.ToUpperInvariant()) + .ToArray(); + + foreach (Type c in otherClassList) + AppendClassMarkdown(sb, cinfo, c); + } + + private static void AppendClassMarkdown(StringBuilder sb, CodeInfo cinfo, Type c) + { + sb.AppendLine(""); + sb.AppendLine("## `class " + c.Name + "`"); + sb.AppendLine(); + + MethodInfo[] funcs = c.GetMethods() + .Where(m => m.IsPublic && m.DeclaringType == c) + .OrderBy(m => m.Name.ToUpperInvariant()) + .ToArray(); + + if (funcs.Length > 0) + { + sb.AppendLine("### member functions"); + sb.AppendLine(); + + foreach (MethodInfo f in funcs) + AppendFunctionMarkdown(sb, cinfo, f); + } + + sb.AppendLine("---"); + sb.AppendLine(); + } + + private static void AppendSectionHeader(StringBuilder sb, string name) + { + sb.AppendLine(""); + sb.AppendLine("## " + name); + sb.AppendLine(); + sb.AppendLine("---"); + sb.AppendLine(); } private static void AppendFunctionMarkdown(StringBuilder sb, CodeInfo cinfo, MethodInfo f) @@ -140,6 +182,9 @@ namespace csdown case "System.Int32": return "`int`"; + case "System.DateTime": + return "`DateTime`"; + default: throw new NotImplementedException("Unhandled type " + t.FullName); } diff --git a/csdown/csharp_prefix.md b/csdown/csharp_prefix.md index c89d84fa..5ad1b8be 100644 --- a/csdown/csharp_prefix.md +++ b/csdown/csharp_prefix.md @@ -15,32 +15,14 @@ To get started quickly, here are some [examples](../../demo/csharp/). - [Topic Index](#topics) - [Functions](#functions) +- [Classes](#classes) - [Enumerated Types](#enums) -- [Structures](#structs) -- [Type Definitions](#typedefs) --- ## Topic Index -### Dates and times - -| Function | Description | -| -------- | ----------- | -| [CurrentTime](#Astronomy.CurrentTime) | Obtains the current date and time of the computer's clock in the form of an [`astro_time_t`](#astro_time_t) that can be used for astronomy calculations. | -| [MakeTime](#Astronomy.MakeTime) | Converts a UTC calendar date and time given as separate numeric parameters into an [`astro_time_t`](#astro_time_t) that can be used for astronomy calculations. | -| [AddDays](#Astronomy.AddDays) | Adds or subtracts an amount of time to an [`astro_time_t`](#astro_time_t) to get another [`astro_time_t`](#astro_time_t). | -| [TimeFromUtc](#Astronomy.TimeFromUtc) | Converts UTC calendar date and time from an [`astro_utc_t`](#astro_utc_t) structure to an [`astro_time_t`](#astro_time_t) structure that can be used for astronomy calculations. | -| [UtcFromTime](#Astronomy.UtcFromTime) | Converts an astronomical [`astro_time_t`](#astro_time_t) time value to an [`astro_utc_t`](#astro_utc_t) structure that can be used for displaying a UTC calendar date and time. | - -### Celestial bodies - -| Function | Description | -| -------- | ----------- | -| [BodyCode](#Astronomy.BodyCode) | Converts the English name of a celestial body to its equivalent [`astro_body_t`](#astro_body_t) enumeration value. | -| [BodyName](#Astronomy.BodyName) | Converts an [`astro_body_t`](#astro_body_t) enumeration value to its equivalent English name as a string. | - ### Position of Sun, Moon, and planets | Function | Description | diff --git a/source/csharp/README.md b/source/csharp/README.md index 6de47921..bda18980 100644 --- a/source/csharp/README.md +++ b/source/csharp/README.md @@ -15,32 +15,14 @@ To get started quickly, here are some [examples](../../demo/csharp/). - [Topic Index](#topics) - [Functions](#functions) +- [Classes](#classes) - [Enumerated Types](#enums) -- [Structures](#structs) -- [Type Definitions](#typedefs) --- ## Topic Index -### Dates and times - -| Function | Description | -| -------- | ----------- | -| [CurrentTime](#Astronomy.CurrentTime) | Obtains the current date and time of the computer's clock in the form of an [`astro_time_t`](#astro_time_t) that can be used for astronomy calculations. | -| [MakeTime](#Astronomy.MakeTime) | Converts a UTC calendar date and time given as separate numeric parameters into an [`astro_time_t`](#astro_time_t) that can be used for astronomy calculations. | -| [AddDays](#Astronomy.AddDays) | Adds or subtracts an amount of time to an [`astro_time_t`](#astro_time_t) to get another [`astro_time_t`](#astro_time_t). | -| [TimeFromUtc](#Astronomy.TimeFromUtc) | Converts UTC calendar date and time from an [`astro_utc_t`](#astro_utc_t) structure to an [`astro_time_t`](#astro_time_t) structure that can be used for astronomy calculations. | -| [UtcFromTime](#Astronomy.UtcFromTime) | Converts an astronomical [`astro_time_t`](#astro_time_t) time value to an [`astro_utc_t`](#astro_utc_t) structure that can be used for displaying a UTC calendar date and time. | - -### Celestial bodies - -| Function | Description | -| -------- | ----------- | -| [BodyCode](#Astronomy.BodyCode) | Converts the English name of a celestial body to its equivalent [`astro_body_t`](#astro_body_t) enumeration value. | -| [BodyName](#Astronomy.BodyName) | Converts an [`astro_body_t`](#astro_body_t) enumeration value to its equivalent English name as a string. | - ### Position of Sun, Moon, and planets | Function | Description | @@ -807,3 +789,88 @@ In fact, the function #Seasons does use this function for that purpose. **Returns:** The ecliptic coordinates of the Sun using the Earth's true equator of date. +--- + + +## Classes + +--- + + +## `class AstroTime` + +### member functions + + +### AstroTime.AddDays(days) ⇒ [`AstroTime`](#AstroTime) + +**Calculates the sum or difference of an #AstroTime with a specified floating point number of days.** + +Sometimes we need to adjust a given #astro_time_t value by a certain amount of time. +This function adds the given real number of days in `days` to the date and time in this object. + +More precisely, the result's Universal Time field `ut` is exactly adjusted by `days` and +the Terrestrial Time field `tt` is adjusted correctly for the resulting UTC date and time, +according to the historical and predictive Delta-T model provided by the +[United States Naval Observatory](http://maia.usno.navy.mil/ser7/). + +| Type | Parameter | Description | +| --- | --- | --- | +| `double` | `days` | A floating point number of days by which to adjust `time`. May be negative, 0, or positive. | + +**Returns:** A date and time that is conceptually equal to `time + days`. + + +### AstroTime.ToString() ⇒ `string` + +**Converts this `AstroTime` to ISO 8601 format, expressed in UTC with millisecond resolution.** + +**Returns:** Example: "2019-08-30T17:45:22.763". + + +### AstroTime.ToUtcDateTime() ⇒ `DateTime` + +**Converts this object to .NET `DateTime` format.** + +**Returns:** a UTC `DateTime` object for this `AstroTime` value. + +--- + + +## `class EarthNotAllowedException` + +--- + + +## `class Ecliptic` + +--- + + +## `class Equatorial` + +--- + + +## `class Observer` + +--- + + +## `class SearchContext` + +### member functions + + +### SearchContext.Eval(time) ⇒ `double` + +**Evaluates the function at a given time** + +| Type | Parameter | Description | +| --- | --- | --- | +| [`AstroTime`](#AstroTime) | `time` | The time at which to evaluate the function. | + +**Returns:** The floating point value of the function at the specified time. + +--- +