From 4cd03e9a5faa9504cdc68be74cc3d663e44b20cd Mon Sep 17 00:00:00 2001 From: Don Cross Date: Tue, 24 May 2022 21:51:07 -0400 Subject: [PATCH] C# documentation generator fixes The C# markdown generator (csdown) was not generating documentation about constructors. This was especially needed for the new GravitySimulator class. Also added markdown for properties like GravitySimulator.NumSmallBodies GravitySimulator.Time Made several constructors internal so they don't need to be listed in the markdown docs. --- generate/csdown/csdown/CodeInfo.cs | 17 ++++ generate/csdown/csdown/Program.cs | 128 ++++++++++++++++++----- generate/template/astronomy.cs | 18 ++-- source/csharp/README.md | 158 +++++++++++++++++++++++++++++ source/csharp/astronomy.cs | 18 ++-- 5 files changed, 295 insertions(+), 44 deletions(-) diff --git a/generate/csdown/csdown/CodeInfo.cs b/generate/csdown/csdown/CodeInfo.cs index 65aaf2b1..d1e42328 100644 --- a/generate/csdown/csdown/CodeInfo.cs +++ b/generate/csdown/csdown/CodeInfo.cs @@ -129,6 +129,17 @@ namespace csdown return ""; } + public CodeItem FindConstructor(ConstructorInfo c) + { + string id = c.DeclaringType.FullName + ".#ctor"; + ParameterInfo[] parms = c.GetParameters(); + if (parms.Length > 0) + id += "(" + string.Join(",", parms.Select(p => p.ParameterType.FullName)) + ")"; + CodeItem item; + table.TryGetValue(id, out item); + return item; + } + public CodeItem FindMethod(MethodInfo f) { string id = f.DeclaringType.FullName + "." + f.Name; @@ -147,6 +158,12 @@ namespace csdown return table[id]; } + public CodeItem FindProperty(PropertyInfo p) + { + string id = p.DeclaringType.FullName + "." + p.Name; + return table[id]; + } + public CodeItem FindType(Type t) { return table[t.FullName]; diff --git a/generate/csdown/csdown/Program.cs b/generate/csdown/csdown/Program.cs index 04681dc5..a09cd33a 100644 --- a/generate/csdown/csdown/Program.cs +++ b/generate/csdown/csdown/Program.cs @@ -76,6 +76,8 @@ namespace csdown private static void AppendTypeMarkdown(StringBuilder sb, CodeInfo cinfo, Type type) { + var temp_sb = new StringBuilder(); + string kind; if (type.IsClass) kind = "class"; @@ -119,33 +121,63 @@ namespace csdown } else { - // Dump struct/class fields. - FieldInfo[] fields = type.GetFields(); - if (fields.Length > 0) + // Dump constructor(s). + temp_sb.Clear(); + ConstructorInfo[] ctors = type.GetConstructors(); + foreach (ConstructorInfo c in ctors) + AppendConstructorMarkdown(temp_sb, cinfo, c); + if (temp_sb.Length > 0) { - sb.AppendLine("| Type | Name | Description |"); - sb.AppendLine("| --- | --- | --- |"); - foreach (FieldInfo f in fields) - if (f.DeclaringType == type) - AppendMemberVariableMarkdown(sb, cinfo, f); + sb.AppendLine("### constructors"); + sb.AppendLine(); + sb.Append(temp_sb); sb.AppendLine(); } - } - // Member functions + // Dump struct/class fields. + temp_sb.Clear(); + FieldInfo[] fields = type.GetFields(); + foreach (FieldInfo f in fields) + if (f.DeclaringType == type) + AppendMemberVariableMarkdown(temp_sb, cinfo, f); + if (temp_sb.Length > 0) + { + sb.AppendLine("### member variables"); + sb.AppendLine(); + sb.AppendLine("| Type | Name | Description |"); + sb.AppendLine("| --- | --- | --- |"); + sb.Append(temp_sb); + sb.AppendLine(); + } - MethodInfo[] funcs = type.GetMethods() - .Where(m => m.IsPublic && m.DeclaringType == type) - .OrderBy(m => m.Name.ToUpperInvariant()) - .ToArray(); + temp_sb.Clear(); + PropertyInfo[] props = type.GetProperties(); + foreach (PropertyInfo p in props) + if (p.DeclaringType == type) + AppendPropertyMarkdown(temp_sb, cinfo, p); + if (temp_sb.Length > 0) + { + sb.AppendLine("### properties"); + sb.AppendLine(); + sb.AppendLine("| Type | Name | Description |"); + sb.AppendLine("| --- | --- | --- |"); + sb.Append(temp_sb); + sb.AppendLine(); + } - if (funcs.Length > 0) - { - sb.AppendLine("### member functions"); - sb.AppendLine(); + // Member functions + MethodInfo[] funcs = type.GetMethods() + .Where(m => m.IsPublic && m.DeclaringType == type) + .OrderBy(m => m.Name.ToUpperInvariant()) + .ToArray(); - foreach (MethodInfo f in funcs) - AppendFunctionMarkdown(sb, cinfo, f); + if (funcs.Length > 0) + { + sb.AppendLine("### member functions"); + sb.AppendLine(); + foreach (MethodInfo f in funcs) + AppendFunctionMarkdown(sb, cinfo, f); + } } sb.AppendLine("---"); @@ -164,6 +196,18 @@ namespace csdown sb.AppendLine(" |"); } + private static void AppendPropertyMarkdown(StringBuilder sb, CodeInfo cinfo, PropertyInfo p) + { + CodeItem item = cinfo.FindProperty(p); + sb.Append("| "); + sb.Append(TypeMarkdown(p.PropertyType)); + sb.Append(" | `"); + sb.Append(p.Name); + sb.Append("` | "); + sb.Append(CodeInfo.Linear(item.Summary)); + sb.AppendLine(" |"); + } + private static void AppendEnumValueMarkdown(StringBuilder sb, CodeInfo cinfo, FieldInfo f) { CodeItem item = cinfo.FindField(f); @@ -223,20 +267,48 @@ namespace csdown sb.AppendLine(); } + private static void AppendConstructorMarkdown(StringBuilder sb, CodeInfo cinfo, ConstructorInfo c) + { + CodeItem item = cinfo.FindConstructor(c); + if (item != null) + { + AppendCallableMarkdown( + sb, + item, + c.GetParameters(), + null, // not so easy to create an anchor for multiple constructors, and not yet needed + "new " + c.DeclaringType.Name, + null + ); + } + } + private static void AppendFunctionMarkdown(StringBuilder sb, CodeInfo cinfo, MethodInfo f) { CodeItem item = cinfo.FindMethod(f); - if (item == null) - return; + if (item != null) + { + string name = f.DeclaringType.Name + "." + f.Name; + AppendCallableMarkdown(sb, item, f.GetParameters(), name, name, f.ReturnType); + } + } - ParameterInfo[] parms = f.GetParameters(); - string parentClassName = f.DeclaringType.Name; - sb.AppendFormat("", parentClassName, f.Name); - sb.AppendLine(); - sb.AppendFormat("### {0}.{1}(", parentClassName, f.Name); + private static void AppendCallableMarkdown( + StringBuilder sb, + CodeItem item, + ParameterInfo[] parms, + string anchor, + string display, + Type returnType) + { + if (anchor != null) + sb.AppendLine($""); + sb.Append($"### {display}("); sb.Append(string.Join(", ", parms.Select(p => p.Name))); - sb.AppendFormat(") ⇒ {0}", TypeMarkdown(f.ReturnType)); + sb.Append(")"); + if (returnType != null) // constructors don't have return types (not even `void`) + sb.AppendFormat(" ⇒ {0}", TypeMarkdown(returnType)); sb.AppendLine(); sb.AppendLine(); if (!string.IsNullOrWhiteSpace(item.Summary)) diff --git a/generate/template/astronomy.cs b/generate/template/astronomy.cs index d70e07a1..649445bb 100644 --- a/generate/template/astronomy.cs +++ b/generate/template/astronomy.cs @@ -40,7 +40,7 @@ namespace CosineKitty public class EarthNotAllowedException: ArgumentException { /// Creates an exception indicating that the Earth is not allowed as a target body. - public EarthNotAllowedException(): + internal EarthNotAllowedException(): base("The Earth is not allowed as the body parameter.") {} } @@ -52,7 +52,8 @@ namespace CosineKitty public class InvalidBodyException: ArgumentException { /// Creates an exception indicating that the given body is not valid for this operation. - public InvalidBodyException(Body body): + /// The body that was invalid. + internal InvalidBodyException(Body body): base("Invalid body: " + body) {} } @@ -65,7 +66,8 @@ namespace CosineKitty public class InternalError: Exception { /// Creates an exception indicating that an unexpected error ocurred. - public InternalError(string message): + /// Diagnostic text about the internal error. + internal InternalError(string message): base("Internal error. Please report an issue at: https://github.com/cosinekitty/astronomy/issues. Diagnostic: " + message) {} } @@ -860,7 +862,7 @@ namespace CosineKitty /// Declination in degrees. /// Distance to the celestial body in AU. /// Equatorial coordinates in vector form. - public Equatorial(double ra, double dec, double dist, AstroVector vec) + internal Equatorial(double ra, double dec, double dist, AstroVector vec) { this.ra = ra; this.dec = dec; @@ -902,7 +904,7 @@ namespace CosineKitty /// ecliptic vector /// ecliptic latitude /// ecliptic longitude - public Ecliptic(AstroVector vec, double elat, double elon) + internal Ecliptic(AstroVector vec, double elat, double elon) { this.vec = vec; this.elat = elat; @@ -947,7 +949,7 @@ namespace CosineKitty /// Angle in degrees above (positive) or below (negative) the observer's horizon. /// Right ascension in sidereal hours. /// Declination in degrees. - public Topocentric(double azimuth, double altitude, double ra, double dec) + internal Topocentric(double azimuth, double altitude, double ra, double dec) { this.azimuth = azimuth; this.altitude = altitude; @@ -1057,7 +1059,7 @@ namespace CosineKitty /// /// The date and time when the body crosses the specified hour angle. /// Apparent coordinates of the body at the time it crosses the specified hour angle. - public HourAngleInfo(AstroTime time, Topocentric hor) + internal HourAngleInfo(AstroTime time, Topocentric hor) { this.time = time; this.hor = hor; @@ -1090,7 +1092,7 @@ namespace CosineKitty /// Whether the body is best seen in the morning or the evening. /// The angle in degrees between the body and the Sun, as seen from the Earth. /// The difference between the ecliptic longitudes of the body and the Sun, as seen from the Earth. - public ElongationInfo(AstroTime time, Visibility visibility, double elongation, double ecliptic_separation) + internal ElongationInfo(AstroTime time, Visibility visibility, double elongation, double ecliptic_separation) { this.time = time; this.visibility = visibility; diff --git a/source/csharp/README.md b/source/csharp/README.md index 293f62aa..e88bf79b 100644 --- a/source/csharp/README.md +++ b/source/csharp/README.md @@ -2254,6 +2254,8 @@ point is called *apogee*. The closest approach of a planet to the Sun is called This data structure is returned by [`Astronomy.SearchLunarApsis`](#Astronomy.SearchLunarApsis) and [`Astronomy.NextLunarApsis`](#Astronomy.NextLunarApsis) to iterate through consecutive alternating perigees and apogees. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `time` | The date and time of the apsis. | @@ -2280,6 +2282,40 @@ to iterate through consecutive alternating perigees and apogees. **A date and time used for astronomical calculations.** +### constructors + +### new AstroTime(ut) + +**Creates an `AstroTime` object from a Universal Time day value.** + +| Type | Parameter | Description | +| --- | --- | --- | +| `double` | `ut` | The number of days after the J2000 epoch. | + +### new AstroTime(d) + +**Creates an `AstroTime` object from a .NET `DateTime` object.** + +| Type | Parameter | Description | +| --- | --- | --- | +| `DateTime` | `d` | The date and time to be converted to AstroTime format. | + +### new AstroTime(year, month, day, hour, minute, second) + +**Creates an `AstroTime` object from a UTC year, month, day, hour, minute and second.** + +| Type | Parameter | Description | +| --- | --- | --- | +| `int` | `year` | The UTC year value. | +| `int` | `month` | The UTC month value 1..12. | +| `int` | `day` | The UTC day of the month 1..31. | +| `int` | `hour` | The UTC hour value 0..23. | +| `int` | `minute` | The UTC minute value 0..59. | +| `int` | `second` | The UTC second value 0..59. | + + +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `ut` | UT1/UTC number of days since noon on January 1, 2000. | @@ -2345,6 +2381,22 @@ an `AstroTime` value that can be passed to Astronomy Engine functions. **A 3D Cartesian vector whose components are expressed in Astronomical Units (AU).** +### constructors + +### new AstroVector(x, y, z, t) + +**Creates an AstroVector.** + +| Type | Parameter | Description | +| --- | --- | --- | +| `double` | `x` | A Cartesian x-coordinate expressed in AU. | +| `double` | `y` | A Cartesian y-coordinate expressed in AU. | +| `double` | `z` | A Cartesian z-coordinate expressed in AU. | +| [`AstroTime`](#AstroTime) | `t` | The date and time at which this vector is valid. | + + +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `x` | The Cartesian x-coordinate of the vector in AU. | @@ -2390,6 +2442,8 @@ The fields `ra`, `dec`, and `spin` correspond to the variables The field `north` is a unit vector pointing in the direction of the body's north pole. It is expressed in the equatorial J2000 system (EQJ). +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `ra` | The J2000 right ascension of the body's north pole direction, in sidereal hours. | @@ -2434,6 +2488,8 @@ Constellations are defined with respect to the B1875 equatorial system per IAU standard. Although `Astronomy.Constellation` requires J2000 equatorial coordinates, the struct contains converted B1875 coordinates for reference. +### member variables + | Type | Name | Description | | --- | --- | --- | | `string` | `Symbol` | 3-character mnemonic symbol for the constellation, e.g. "Ori". | @@ -2499,6 +2555,8 @@ visible if the Earth were transparent, but the observer cannot actually see it. If `altitude` is positive but less than a few degrees, visibility will be impaired by atmospheric interference (sunrise or sunset conditions). +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `time` | The date and time of the event. | @@ -2529,6 +2587,8 @@ atmospheric interference (sunrise or sunset conditions). Coordinates of a celestial body as seen from the center of the Sun (heliocentric), oriented with respect to the plane of the Earth's orbit around the Sun (the ecliptic). +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroVector`](#AstroVector) | `vec` | Cartesian ecliptic vector, with components as follows: x: the direction of the equinox along the ecliptic plane. y: in the ecliptic plane 90 degrees prograde from the equinox. z: perpendicular to the ecliptic plane. Positive is north. | @@ -2544,6 +2604,8 @@ oriented with respect to the plane of the Earth's orbit around the Sun (the ecli See [`Astronomy.Elongation`](#Astronomy.Elongation) for more detailed information about the members of this structure. See also [`Astronomy.SearchMaxElongation`](#Astronomy.SearchMaxElongation) for how to search for maximum elongation events.** +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `time` | The date and time of the observation. | @@ -2587,6 +2649,8 @@ Coordinates of a celestial body as seen from the Earth (geocentric or topocentric, depending on context), oriented with respect to the projection of the Earth's equator onto the sky. +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `ra` | Right ascension in sidereal hours. | @@ -2621,6 +2685,8 @@ onto the daytime side of the Earth at the instant of the eclipse's peak. If `kind` has any other value, `latitude` and `longitude` are undefined and should not be used. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`EclipseKind`](#EclipseKind) | `kind` | The type of solar eclipse: `EclipseKind.Partial`, `EclipseKind.Annular`, or `EclipseKind.Total`. | @@ -2644,10 +2710,19 @@ list of initial positions and velocities for the small bodies. Then the class can update the positions and velocities over small time steps. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`Body`](#Body) | `OriginBody` | The origin of the reference frame. See constructor for more info. | +### properties + +| Type | Name | Description | +| --- | --- | --- | +| `int` | `NumSmallBodies` | The number of small bodies that are included in this gravity simulation. | +| [`AstroTime`](#AstroTime) | `Time` | The time represented by the current step of the gravity simulation. | + ### member functions @@ -2724,6 +2799,8 @@ to the `originBody` that was used to construct this simulator. Returned by the function [`Astronomy.SearchHourAngle`](#Astronomy.SearchHourAngle) to report information about a celestial body crossing a certain hour angle as seen by a specified topocentric observer. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `time` | The date and time when the body crosses the specified hour angle. | @@ -2739,6 +2816,8 @@ a celestial body crossing a certain hour angle as seen by a specified topocentri Returned by the functions [`Astronomy.Illumination`](#Astronomy.Illumination) and [`Astronomy.SearchPeakMagnitude`](#Astronomy.SearchPeakMagnitude) to report the visual magnitude and illuminated fraction of a celestial body at a given date and time. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `time` | The date and time of the observation. | @@ -2780,6 +2859,8 @@ the EQJ system (that is, using Earth's equator at the J2000 epoch). The positions are expressed in astronomical units (AU), and the velocities in AU/day. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`StateVector`](#StateVector) | `io` | The position and velocity of Jupiter's moon Io. | @@ -2794,6 +2875,8 @@ and the velocities in AU/day. **Lunar libration angles, returned by [`Astronomy.Libration`](#Astronomy.Libration).** +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `elat` | Sub-Earth libration ecliptic latitude angle, in degrees. | @@ -2832,6 +2915,8 @@ When an event field is valid, the caller must also check its `altitude` field to see whether the Sun is above the horizon at the time indicated by the `time` field. See [`EclipseEvent`](#EclipseEvent) for more information. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`EclipseKind`](#EclipseKind) | `kind` | The type of solar eclipse: `EclipseKind.Partial`, `EclipseKind.Annular`, or `EclipseKind.Total`. | @@ -2867,6 +2952,8 @@ phase (expressed in minutes), or 0 if the eclipse never reaches that phase. By converting from minutes to days, and subtracting/adding with `peak`, the caller may determine the date and time of the beginning/end of each eclipse phase. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`EclipseKind`](#EclipseKind) | `kind` | The type of lunar eclipse found. | @@ -2882,6 +2969,8 @@ may determine the date and time of the beginning/end of each eclipse phase. **A lunar quarter event (new moon, first quarter, full moon, or third quarter) along with its date and time.** +### member variables + | Type | Name | Description | | --- | --- | --- | | `int` | `quarter` | 0=new moon, 1=first quarter, 2=full moon, 3=third quarter. | @@ -2897,6 +2986,8 @@ may determine the date and time of the beginning/end of each eclipse phase. This structure is returned by [`Astronomy.SearchMoonNode`](#Astronomy.SearchMoonNode) and [`Astronomy.NextMoonNode`](#Astronomy.NextMoonNode) to report information about the center of the Moon passing through the ecliptic plane. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `time` | The time when the body passes through the ecliptic plane. | @@ -2925,6 +3016,21 @@ to report information about the center of the Moon passing through the ecliptic This structure is passed to functions that calculate phenomena as observed from a particular place on the Earth. +### constructors + +### new Observer(latitude, longitude, height) + +**Creates an Observer object.** + +| Type | Parameter | Description | +| --- | --- | --- | +| `double` | `latitude` | Geographic latitude in degrees north (positive) or south (negative) of the equator. | +| `double` | `longitude` | Geographic longitude in degrees east (positive) or west (negative) of the prime meridian at Greenwich, England. | +| `double` | `height` | The height above (positive) or below (negative) sea level, expressed in meters. | + + +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `latitude` | Geographic latitude in degrees north (positive) or south (negative) of the equator. | @@ -2951,6 +3057,8 @@ from a particular place on the Earth. **A rotation matrix that can be used to transform one coordinate system to another.** +### member variables + | Type | Name | Description | | --- | --- | --- | | `double[3,3]` | `rot` | A normalized 3x3 rotation matrix. | @@ -2984,6 +3092,8 @@ See [`Astronomy.Search`](#Astronomy.Search).** **The dates and times of changes of season for a given calendar year. Call [`Astronomy.Seasons`](#Astronomy.Seasons) to calculate this data structure for a given year.** +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `mar_equinox` | The date and time of the March equinox for the specified year. | @@ -2998,6 +3108,21 @@ Call [`Astronomy.Seasons`](#Astronomy.Seasons) to calculate this data structure **Spherical coordinates: latitude, longitude, distance.** +### constructors + +### new Spherical(lat, lon, dist) + +**Creates a set of spherical coordinates.** + +| Type | Parameter | Description | +| --- | --- | --- | +| `double` | `lat` | The latitude angle: -90..+90 degrees. | +| `double` | `lon` | The longitude angle: 0..360 degrees. | +| `double` | `dist` | Distance in AU. | + + +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `lat` | The latitude angle: -90..+90 degrees. | @@ -3015,6 +3140,35 @@ A state vector represents the dynamic state of a point at a given moment. It includes the position vector of the point, expressed in Astronomical Units (AU) along with the velocity vector of the point, expressed in AU/day. +### constructors + +### new StateVector(x, y, z, vx, vy, vz, t) + +**Creates an AstroVector.** + +| Type | Parameter | Description | +| --- | --- | --- | +| `double` | `x` | A position x-coordinate expressed in AU. | +| `double` | `y` | A position y-coordinate expressed in AU. | +| `double` | `z` | A position z-coordinate expressed in AU. | +| `double` | `vx` | A velocity x-component expressed in AU/day. | +| `double` | `vy` | A velocity y-component expressed in AU/day. | +| `double` | `vz` | A velocity z-component expressed in AU/day. | +| [`AstroTime`](#AstroTime) | `t` | The date and time at which this state vector is valid. | + +### new StateVector(pos, vel, time) + +**Combines a position vector and a velocity vector into a single state vector.** + +| Type | Parameter | Description | +| --- | --- | --- | +| [`AstroVector`](#AstroVector) | `pos` | A position vector. | +| [`AstroVector`](#AstroVector) | `vel` | A velocity vector. | +| [`AstroTime`](#AstroTime) | `time` | The common time that represents the given position and velocity. | + + +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `x` | The position x-coordinate in AU. | @@ -3048,6 +3202,8 @@ Contains horizontal and equatorial coordinates seen by an observer on or near the surface of the Earth (a topocentric observer). Optionally corrected for atmospheric refraction. +### member variables + | Type | Name | Description | | --- | --- | --- | | `double` | `azimuth` | Compass direction around the horizon in degrees. 0=North, 90=East, 180=South, 270=West. | @@ -3076,6 +3232,8 @@ against the Sun in its background. The calculations are performed from the point of view of a geocentric observer. +### member variables + | Type | Name | Description | | --- | --- | --- | | [`AstroTime`](#AstroTime) | `start` | Date and time at the beginning of the transit. | diff --git a/source/csharp/astronomy.cs b/source/csharp/astronomy.cs index 803a651b..aacf1eee 100644 --- a/source/csharp/astronomy.cs +++ b/source/csharp/astronomy.cs @@ -40,7 +40,7 @@ namespace CosineKitty public class EarthNotAllowedException: ArgumentException { /// Creates an exception indicating that the Earth is not allowed as a target body. - public EarthNotAllowedException(): + internal EarthNotAllowedException(): base("The Earth is not allowed as the body parameter.") {} } @@ -52,7 +52,8 @@ namespace CosineKitty public class InvalidBodyException: ArgumentException { /// Creates an exception indicating that the given body is not valid for this operation. - public InvalidBodyException(Body body): + /// The body that was invalid. + internal InvalidBodyException(Body body): base("Invalid body: " + body) {} } @@ -65,7 +66,8 @@ namespace CosineKitty public class InternalError: Exception { /// Creates an exception indicating that an unexpected error ocurred. - public InternalError(string message): + /// Diagnostic text about the internal error. + internal InternalError(string message): base("Internal error. Please report an issue at: https://github.com/cosinekitty/astronomy/issues. Diagnostic: " + message) {} } @@ -860,7 +862,7 @@ namespace CosineKitty /// Declination in degrees. /// Distance to the celestial body in AU. /// Equatorial coordinates in vector form. - public Equatorial(double ra, double dec, double dist, AstroVector vec) + internal Equatorial(double ra, double dec, double dist, AstroVector vec) { this.ra = ra; this.dec = dec; @@ -902,7 +904,7 @@ namespace CosineKitty /// ecliptic vector /// ecliptic latitude /// ecliptic longitude - public Ecliptic(AstroVector vec, double elat, double elon) + internal Ecliptic(AstroVector vec, double elat, double elon) { this.vec = vec; this.elat = elat; @@ -947,7 +949,7 @@ namespace CosineKitty /// Angle in degrees above (positive) or below (negative) the observer's horizon. /// Right ascension in sidereal hours. /// Declination in degrees. - public Topocentric(double azimuth, double altitude, double ra, double dec) + internal Topocentric(double azimuth, double altitude, double ra, double dec) { this.azimuth = azimuth; this.altitude = altitude; @@ -1057,7 +1059,7 @@ namespace CosineKitty /// /// The date and time when the body crosses the specified hour angle. /// Apparent coordinates of the body at the time it crosses the specified hour angle. - public HourAngleInfo(AstroTime time, Topocentric hor) + internal HourAngleInfo(AstroTime time, Topocentric hor) { this.time = time; this.hor = hor; @@ -1090,7 +1092,7 @@ namespace CosineKitty /// Whether the body is best seen in the morning or the evening. /// The angle in degrees between the body and the Sun, as seen from the Earth. /// The difference between the ecliptic longitudes of the body and the Sun, as seen from the Earth. - public ElongationInfo(AstroTime time, Visibility visibility, double elongation, double ecliptic_separation) + internal ElongationInfo(AstroTime time, Visibility visibility, double elongation, double ecliptic_separation) { this.time = time; this.visibility = visibility;