Skip to content

Commit

Permalink
Merge pull request #14879 from unoplatform/mergify/bp/release/stable/…
Browse files Browse the repository at this point in the history
…5.0/pr-14833

Add link for Gallery and Playground on Docs Reference (backport #14833)
  • Loading branch information
jeromelaban authored Dec 19, 2023
2 parents d1e9315 + 8b5982d commit 95416d9
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 1 deletion.
175 changes: 175 additions & 0 deletions src/Uno.UWPSyncGenerator/DocGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ void BuildMemberLists()
_sb.AppendParagraph($"In addition, {formattedViewName} has Uno-specific documentation {Hyperlink("here", customDocLink)}.");
}

List<string> options = new List<string>();
void AddOption(string text, string linkText, string link)
{
if (link is not null)
{
options.Add($"{text} {Hyperlink(linkText, link)}");
}
}

var galleryLink = GetGalleryLink(viewName);
var playgroundLink = GetPlaygroundLink(viewName);

AddOption("use the", "Uno Gallery", galleryLink);
AddOption($"run your own tests on the", "Uno Playground", playgroundLink);

if (options.Count > 0)
{
_sb.AppendParagraph($"To better understand how {formattedViewName} works, you can {string.Join(" or ", options)}.");
}

var properties = view.UAPSymbol.GetMembers().OfType<IPropertySymbol>().Select(p => GetAllMatchingPropertyMember(view, p)).ToArray();
var methods = view.UAPSymbol
.GetMembers()
Expand Down Expand Up @@ -417,5 +437,160 @@ private static string GetCustomDocLink(string shortTypeName)
["controls/MenuFlyout.md"] = new[] { "MenuFlyout" },
["features/shapes-and-brushes.md"] = new[] { "Ellipse", "Line", "Path", "Polygon", "Polyline", "Rectangle", "ArbitraryShapeBase" },
};


private static string GetGalleryLink(string shortTypeName)
{
var galleryDocMapping = GalleryDocMapping.FirstOrDefault(kvp => kvp.Value.Contains(shortTypeName)).Key;
return galleryDocMapping != null ?
$"https://gallery.platform.uno/#{galleryDocMapping}" :
null;
}

private static readonly Dictionary<string, string[]> GalleryDocMapping = new Dictionary<string, string[]>
{
["ListView"] = new[] { "ListView", "ListViewItem" },
["InfoBadge"] = new[] { "InfoBadge" },
["Panel"] = new[] { "Panel" },
["Grid"] = new[] { "Grid" },
["GridView"] = new[] { "GridView" },
["StackPanel"] = new[] { "StackPanel" },
["RelativePanel"] = new[] { "RelativePanel" },
["RadioButton"] = new[] { "RadioButton" },
["PersonPicture"] = new[] { "PersonPicture" },
["ViewBox"] = new[] { "ViewBox" },
["TreeView"] = new[] { "TreeView", "TreeViewItem" },
["ColorPicker"] = new[] { "ColorPicker" },
["Button"] = new[] { "Button" },
["PasswordBox"] = new[] { "PasswordBox" },
["DatePicker"] = new[] { "DatePicker" },
["CalendarDatePicker"] = new[] { "CalendarDatePicker" },
["ToggleSwitch"] = new[] { "ToggleSwitch" },
["ComboBox"] = new[] { "ComboBox" },
["BreadcrumbBar"] = new[] { "BreadcrumbBar", "BreadcrumbBarItem" },
["Image"] = new[] { "Image" },
["CheckBox"] = new[] { "CheckBox" },
["MediaPlayerElement"] = new[] { "MediaPlayerElement" },
["ListView"] = new[] { "ListView", "ListViewItem" },
["Flyout"] = new[] { "MenuFlyout", "MenuFlyoutItem", "MenuFlyoutSubItem", "MenuFlyoutSeparator " },
["ContentDialog"] = new[] { "ContentDialog" },
["NumberBox"] = new[] { "NumberBox" },
["AutoSuggestBox"] = new[] { "AutoSuggestBox" },
["PipsPager"] = new[] { "PipsPager" },
["MenuBar"] = new[] { "MenuBar", "MenuBarItem" },
["Slider"] = new[] { "Slider" },
["HyperlinkButton"] = new[] { "HyperlinkButton" },
["CalendarView"] = new[] { "CalendarView" },
["RatingControl"] = new[] { "RatingControl" },
["CommandBar"] = new[] { "CommandBar" },
["TextBlock"] = new[] { "TextBlock" },
["Shape"] = new[] { "Shape" },
["TwoPaneView"] = new[] { "TwoPaneView" },
["TabBar"] = new[] { "TabBar" },
["DataGrid"] = new[] { "DataGrid" },
["SwipeControl"] = new[] { "SwipeControl" },
["RefreshContainer"] = new[] { "RefreshContainer" },
["Icon"] = new[] { "Icon" },
["Path"] = new[] { "Path" },
["Progress Ring/Bar"] = new[] { "ProgressBar", "ProgressRing" },
["TextBox"] = new[] { "TextBox" },
["VariableSizedWrapGrid"] = new[] { "VariableSizedWrapGrid" },

//Should we redirect NavigationView to NavigationBar?
//["NavigationView"] = new[] { "NavigationView" },
//["NavigationBar"] = new[] { "NavigationBar" },

//There is a gallery, but it is not on the list of references
//["Lottie"] = new[] { "Lottie" },
//["Chip"] = new[] { "Chip" },
//["Material Palette"] = new[] { "Material Palette" },
//["Animation"] = new[] { "Animation" },
//["ElevatedView"] = new[] { "ElevatedView" },
//["Launcher"] = new[] { "Launcher" },
//["Card"] = new[] { "Card" },
//["Cupertino Palette"] = new[] { "Cupertino Palette" },
//["PhoneCallManager"] = new[] { "PhoneCallManager" },
//["ShadowContainer"] = new[] { "ShadowContainer" },
//["SegmentedControl"] = new[] { "SegmentedControl" },
//["ChipGroup"] = new[] { "ChipGroup" },
//["Binding"] = new[] { "Binding" },
//["Simple Orientation"] = new[] { "Simple Orientation" },
//["Fluent Palette"] = new[] { "Fluent Palette" },
//["Divider"] = new[] { "Divider" },
//["Geolocator"] = new[] { "Geolocator" },
//["Sharing"] = new[] { "Sharing" },
//["Display Request"] = new[] { "Display Request" },
//["Light Sensor"] = new[] { "Light Sensor" },
//["Overview"] = new[] { "Overview" },
//["Clipboard"] = new[] { "Clipboard" },
//["Gyrometer"] = new[] { "Gyrometer" },
//["Acrylic"] = new[] { "Acrylic" },
//["Floating Action Button"] = new[] { "Floating Action Button" },
//["Typography"] = new[] { "Typography" },
//["Local Settings"] = new[] { "Local Settings" },
//["Email Manager"] = new[] { "Email Manager" },
//["Lightweight Styling"] = new[] { "Lightweight Styling" },
//["Network Information"] = new[] { "Network Information" },
//["Lamp"] = new[] { "Lamp" },
//["Pedometer"] = new[] { "Pedometer" },
//["Vibration"] = new[] { "Vibration" },
//["File and Folder Pickers"] = new[] { "File and Folder Pickers" },
//["Brush"] = new[] { "Brush" },
//["Magnetometer"] = new[] { "Magnetometer" },
//["Accelerometer"] = new[] { "Accelerometer" },
//["Gamepad"] = new[] { "Gamepad" },
//["Transforms"] = new[] { "Transforms" },

};

private static string GetPlaygroundLink(string shortTypeName)
{
var playgroundDocMapping = PlaygroundDocMapping.FirstOrDefault(kvp => kvp.Value.Contains(shortTypeName)).Key;
return playgroundDocMapping != null ?
$"https://playground.platform.uno/#{playgroundDocMapping}" :
null;
}

private static readonly Dictionary<string, string[]> PlaygroundDocMapping = new Dictionary<string, string[]>
{
//List of existing references in the Playground
["cards"] = new[] { "ListView", "ListViewItem" },
["combobox"] = new[] { "ComboBox" },
["animation-simple"] = new[] { "Animations" },
["borders"] = new[] { "Border" },
["button"] = new[] { "Button" },
["canvas"] = new[] { "Canvas" },
["checkbox"] = new[] { "CheckBox" },
["date-and-time"] = new[] { "DatePicker", "CalendarDatePicker", "CalendarView" },
["grid"] = new[] { "Grid" },
["hello-world"] = new[] { "TextBlock" },
["hyperlinkbutton"] = new[] { "HyperlinkButton" },
["image"] = new[] { "Image" },
["info-bar"] = new[] { "InfoBar" },
["menubar"] = new[] { "MenuBar", "MenuBarItem", "MenuFlyoutSubItem", "MenuFlyoutItem" },
["menuflyout"] = new[] { "Flyout", "MenuFlyoutItem", "MenuFlyoutSeparator" },
["numberbox"] = new[] { "NumberBox" },
["relativepanel"] = new[] { "RelativePanel" },
["panels"] = new[] { "Canvas", "Grid" },
["passwordbox"] = new[] { "PasswordBox" },
["path"] = new[] { "Path" },
["person-picture"] = new[] { "PersonPicture" },
["progressbar"] = new[] { "ProgressBar" },
["radiobutton"] = new[] { "RadioButton" },
["shapes"] = new[] { "Ellipse", "Rectangle", "Polygon" },
["slider"] = new[] { "Slider" },
["stackpanel"] = new[] { "StackPanel" },
["tabview"] = new[] { "TabView", "TabViewItem" },
["textblock"] = new[] { "TextBlock" },
["textbox"] = new[] { "TextBox" },
["toggle-button"] = new[] { "ToggleButton" },
["toggleswitch"] = new[] { "ToggleSwitch" },
["transforms"] = new[] { "FrameworkElement" },
["treeview"] = new[] { "TreeView", "TreeViewNode" },
["viewbox"] = new[] { "Viewbox" },

//New example creations
["fe7ad367"] = new[] { "Pivot" },
};
}
}
2 changes: 1 addition & 1 deletion src/Uno.UWPSyncGenerator/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"commandLineArgs": "sync"
}
}
}
}

0 comments on commit 95416d9

Please sign in to comment.