Skip to content

Commit 2aec2e9

Browse files
committed
fix docs
1 parent 766def8 commit 2aec2e9

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/cs/Bootsharp.Publish.Test/GenerateJS/DeclarationTest.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ public enum Kind
14341434
}
14351435
14361436
/// <summary>
1437-
/// A payload sent across interop.
1437+
/// A payload sent across interop, keyed by <c>Kind</c>.
14381438
/// </summary>
14391439
/// <remarks>Visible in generated TypeScript.</remarks>
14401440
public record Payload<T>
@@ -1461,7 +1461,7 @@ public interface IExportedInstanced
14611461
/// <summary>Current state.</summary>
14621462
int State { get; }
14631463
1464-
/// <summary>Invokes instance.</summary>
1464+
/// <summary>Invokes instance with <paramref name="value"/>.</summary>
14651465
/// <param name="value">Value to pass.</param>
14661466
void Inv (string value);
14671467
}
@@ -1485,7 +1485,10 @@ public partial class Class
14851485
/// <summary>Runs foo.</summary>
14861486
/// <param name="function">Function value.</param>
14871487
/// <param name="names">Names to run.</param>
1488-
/// <returns>Computed value.</returns>
1488+
/// <returns>
1489+
/// Computed value to be used with <see cref="Get"/> and <see cref="OnFoo"/>,
1490+
/// or <see langword="null"/> when invalid.
1491+
/// </returns>
14891492
[Export] public static int Foo (List<int?> function, string[] names) => 0;
14901493
14911494
/// <summary>Gets payload.</summary>
@@ -1522,7 +1525,7 @@ export enum Kind {
15221525
Contains(
15231526
"""
15241527
/**
1525-
* A payload sent across interop.
1528+
* A payload sent across interop, keyed by Kind.
15261529
*/
15271530
export type Payload<T> = Readonly<{
15281531
/**
@@ -1542,7 +1545,7 @@ export interface IExportedInstanced {
15421545
*/
15431546
readonly state: number;
15441547
/**
1545-
* Invokes instance.
1548+
* Invokes instance with value.
15461549
* @param value Value to pass.
15471550
*/
15481551
inv(value: string): void;
@@ -1578,7 +1581,7 @@ export namespace Class {
15781581
* Runs foo.
15791582
* @param fn Function value.
15801583
* @param names Names to run.
1581-
* @returns Computed value.
1584+
* @returns Computed value to be used with Get and OnFoo, or null when invalid.
15821585
*/
15831586
export function foo(fn: Array<number | null>, names: Array<string>): number;
15841587
/**

src/cs/Bootsharp.Publish/GenerateJS/Declarations/DocumentationBuilder.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Text.RegularExpressions;
23
using System.Xml.Linq;
34

45
namespace Bootsharp.Publish;
@@ -34,7 +35,7 @@ public void Event (EventMeta evt)
3435
var sum = GetSummary(xml);
3536
foreach (var arg in evt.Args)
3637
if ((GetArgXml(xml, arg) ?? GetDelegateArgXml(arg)) is { } x)
37-
sum.Add($"@param {arg.JSName} {x.Value}");
38+
sum.Add($"@param {arg.JSName} {RenderXml(x)}");
3839
Append(sum);
3940

4041
XElement? GetDelegateArgXml (ArgumentMeta arg)
@@ -61,9 +62,9 @@ public void Method (MethodMeta method)
6162
var sum = GetSummary(xml);
6263
foreach (var arg in method.Args)
6364
if (GetArgXml(xml, arg) is { } x)
64-
sum.Add($"@param {arg.JSName} {x.Value}");
65+
sum.Add($"@param {arg.JSName} {RenderXml(x)}");
6566
if (xml.Element("returns") is { } returns)
66-
sum.Add($"@returns {returns.Value}");
67+
sum.Add($"@returns {RenderXml(returns)}");
6768
Append(sum);
6869

6970
static string GetMethodKey (MethodMeta method)
@@ -113,6 +114,15 @@ private static string GetXmlKey (Type type)
113114

114115
private static List<string> GetSummary (XElement xml)
115116
{
116-
return xml.Elements("summary").Select(e => e.Value.Trim()).ToList();
117+
return xml.Elements("summary").Select(RenderXml).ToList();
117118
}
119+
120+
private static string RenderXml (XElement xml) =>
121+
Regex.Replace(string.Concat(xml.DescendantNodes().Select(node => node switch {
122+
XText xt => xt.Value,
123+
XElement xe when xe.Attribute("cref")?.Value is { } cref =>
124+
Regex.Replace(Regex.Replace(cref, "[`(].*$", ""), "^.*[.:]", ""),
125+
XElement xe when (xe.Attribute("langword") ?? xe.Attribute("name"))?.Value is { } v => v,
126+
_ => ""
127+
})), @"\s+", " ").Trim();
118128
}

0 commit comments

Comments
 (0)