Skip to content

Commit d1661a7

Browse files
johnpiersonclaude
andauthored
DYN-9663 fix missing parameter DataType in NodeDocumentationMarkdownGenerator (#17141)
Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 5b9fc9b commit d1661a7

6 files changed

Lines changed: 54 additions & 11 deletions

File tree

src/DocumentationBrowserViewExtension/NodeDocumentationHtmlGenerator.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private static string CreateInputsAndOutputs(OpenNodeAnnotationEventArgs e)
268268
{
269269
sb.AppendLine("<tr class=\"table--border\">");
270270
sb.AppendLine($"<td class=\"table--border\">{e.InputNames.ElementAt(i)}</td>");
271-
sb.AppendLine($"<td class=\"table--border\">{GetTypeFromDescription(e.InputDescriptions.ElementAt(i))}</td>");
271+
sb.AppendLine($"<td class=\"table--border\">{e.InputTypes.ElementAt(i)}</td>");
272272
sb.AppendLine($"<td class=\"table--border\">{GetNthRowFromStringSplit(e.InputDescriptions.ElementAt(i), 0)}</td>");
273273
sb.AppendLine($"<td class=\"table--border broken\">{GetDefaultValueFromDescription(e.InputDescriptions.ElementAt(i))}</td>");
274274
sb.AppendLine(@"</tr>");
@@ -292,6 +292,7 @@ private static string CreateInputsAndOutputs(OpenNodeAnnotationEventArgs e)
292292
sb.AppendLine(" <tr class=\"table--border\">");
293293
sb.AppendLine($"<td class=\"table--border\">{e.OutputNames.ElementAt(i)}</td>");
294294
sb.AppendLine($"<td class=\"table--border\">{GetNthRowFromStringSplit(e.OutputDescriptions.ElementAt(i), 0)}</td>");
295+
sb.AppendLine($"<td class=\"table--border\">{e.OutputTypes.ElementAt(i)}</td>");
295296
sb.AppendLine(@"</tr>");
296297
}
297298

@@ -302,13 +303,6 @@ private static string CreateInputsAndOutputs(OpenNodeAnnotationEventArgs e)
302303
return sb.ToString();
303304
}
304305

305-
private static string GetTypeFromDescription(string element)
306-
{
307-
var stringArr = element.Split(new string[] {"\r\n", "\r", "\n"}, StringSplitOptions.None);
308-
if(stringArr.Length > 2) return stringArr[2];
309-
return string.Empty;
310-
}
311-
312306
private static string GetDefaultValueFromDescription(string element)
313307
{
314308
var stringArr = element.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);

src/DynamoCore/Graph/Nodes/PortModel.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,23 @@ internal string GetInputPortType()
515515

516516
try
517517
{
518-
return inPortAttribute?.PortTypes.ElementAt(Index);
518+
var attrType = inPortAttribute?.PortTypes.ElementAt(Index);
519+
if (attrType != null) return attrType;
519520
}
520521
catch (Exception e)
521522
{
522523
Log(e.Message);
523524
}
525+
526+
// Fallback: infer from the port's default value node type.
527+
return DefaultValue switch
528+
{
529+
IntNode _ => "int",
530+
DoubleNode _ => "double",
531+
BooleanNode _ => "bool",
532+
StringNode _ => "string",
533+
_ => null
534+
};
524535
}
525536
return null;
526537
}

src/DynamoCoreWpf/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Dynamo.ViewModels.DynamoViewModel.PythonEngineUpgradeToastRequested -> System.Ac
2626
Dynamo.ViewModels.DynamoViewModel.ToastManager.get -> Dynamo.Wpf.UI.ToastManager
2727
Dynamo.ViewModels.DynamoViewModel.ToastManager.set -> void
2828
Dynamo.ViewModels.DynamoViewModel.ShowPythonEngineUpgradeCanvasToast(string message, bool stayOpen = true, string filePath = null) -> void
29+
Dynamo.ViewModels.OpenNodeAnnotationEventArgs.InputTypes.get -> System.Collections.Generic.IEnumerable<string>
30+
Dynamo.ViewModels.OpenNodeAnnotationEventArgs.OutputTypes.get -> System.Collections.Generic.IEnumerable<string>
2931
Dynamo.ViewModels.PreferencesViewModel.AutoSyncDocumentBrowserIsChecked.get -> bool
3032
Dynamo.ViewModels.PreferencesViewModel.AutoSyncDocumentBrowserIsChecked.set -> void
3133
Dynamo.ViewModels.PreferencesViewModel.ShowPythonAutoMigrationNotificationIsChecked.get -> bool

src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelEventArgs.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ public class OpenNodeAnnotationEventArgs : OpenDocumentationLinkEventArgs
217217
/// </summary>
218218
public IEnumerable<string> OutputDescriptions { get; private set; }
219219
/// <summary>
220+
/// Collection of the nodes input port types.
221+
/// </summary>
222+
public IEnumerable<string> InputTypes { get; private set; }
223+
/// <summary>
224+
/// Collection of the nodes output port types.
225+
/// </summary>
226+
public IEnumerable<string> OutputTypes { get; private set; }
227+
/// <summary>
220228
/// Collection of the nodes collection of warnings/errors/infos.
221229
/// </summary>
222230
public IEnumerable<Info> NodeInfos { get; private set; }
@@ -247,33 +255,38 @@ private void SetOutputs(NodeModel nodeModel)
247255
{
248256
var outputNames = new List<string>();
249257
var outputDescriptions = new List<string>();
258+
var outputTypes = new List<string>();
250259

251260
var outputs = nodeModel.OutPorts;
252261
foreach (var output in outputs)
253262
{
254263
outputNames.Add(output.Name);
255264
outputDescriptions.Add(output.ToolTip);
265+
outputTypes.Add(output.GetOutPortType() ?? string.Empty);
256266
}
257267

258268
OutputNames = outputNames;
259269
OutputDescriptions = outputDescriptions;
270+
OutputTypes = outputTypes;
260271
}
261272

262273
private void SetInputs(NodeModel nodeModel)
263274
{
264275
var inputNames = new List<string>();
265276
var inputDescriptions = new List<string>();
277+
var inputTypes = new List<string>();
266278

267279
var inputs = nodeModel.InPorts;
268280
foreach (var input in inputs)
269281
{
270282
inputNames.Add(input.Name);
271283
inputDescriptions.Add(input.ToolTip);
284+
inputTypes.Add(input.GetInputPortType() ?? string.Empty);
272285
}
273286

274287
InputNames = inputNames;
275288
InputDescriptions = inputDescriptions;
276-
289+
InputTypes = inputTypes;
277290
}
278291
}
279292

src/Tools/NodeDocumentationMarkdownGenerator/AssemblyHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ private static List<TypedParameter> BuildParameters(ArgumentSignatureNode signat
422422
}
423423
}
424424

425-
typeParams.Add(new TypedParameter(name));
425+
typeParams.Add(new TypedParameter(name, arg.ArgumentType));
426426
}
427427

428428
return typeParams;

test/DynamoCoreWpf3Tests/NodeViewTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,32 @@
99
using System.Windows.Media;
1010
using Dynamo.Controls;
1111
using Dynamo.Graph;
12+
using Dynamo.Graph.Nodes;
1213
using Dynamo.Graph.Workspaces;
1314
using Dynamo.Models;
1415
using Dynamo.Selection;
1516
using Dynamo.UI.Prompts;
1617
using Dynamo.ViewModels;
1718
using DynamoCoreWpfTests.Utility;
1819
using NUnit.Framework;
20+
using ProtoCore.AST.AssociativeAST;
1921

2022
namespace DynamoCoreWpfTests
2123
{
2224
public class NodeViewTests : DynamoTestUIBase
2325
{
2426
// adapted from: http://stackoverflow.com/questions/9336165/correct-method-for-using-the-wpf-dispatcher-in-unit-tests
27+
private class DefaultValueInputTypeNode : NodeModel
28+
{
29+
internal DefaultValueInputTypeNode()
30+
{
31+
InPorts.Add(new PortModel(PortType.Input, this, new PortData("integer", "integer", AstFactory.BuildIntNode(1))));
32+
InPorts.Add(new PortModel(PortType.Input, this, new PortData("number", "number", AstFactory.BuildDoubleNode(1.0))));
33+
InPorts.Add(new PortModel(PortType.Input, this, new PortData("boolean", "boolean", AstFactory.BuildBooleanNode(true))));
34+
InPorts.Add(new PortModel(PortType.Input, this, new PortData("text", "text", AstFactory.BuildStringNode("value"))));
35+
RegisterAllPorts();
36+
}
37+
}
2538

2639
protected override void GetLibrariesToPreload(List<string> libraries)
2740
{
@@ -361,6 +374,16 @@ public void InputPortType_NodeModelNode_AreCorrect()
361374
Assert.AreEqual("System.Drawing.Bitmap", type);
362375
}
363376

377+
[Test]
378+
public void InputPortType_NodeModelNodeWithoutInPortTypes_FallsBackToDefaultValueType()
379+
{
380+
var node = new DefaultValueInputTypeNode();
381+
382+
CollectionAssert.AreEqual(
383+
new[] { "int", "double", "bool", "string" },
384+
node.InPorts.Select(port => port.GetInputPortType()));
385+
}
386+
364387
[Test]
365388
[Category("RegressionTests")]
366389
public void GettingNodeNameDoesNotTriggerPropertyChangeCycle()

0 commit comments

Comments
 (0)