-
Notifications
You must be signed in to change notification settings - Fork 670
DYN-10109 - add debug mode for node docs #16881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
caa38db
a4bf717
5d05aa3
a94a1ba
6dc871a
0a315ec
4cf7d8f
c0f6c48
cd83c1d
9f96179
bd16dd7
db85bed
f5bede1
a1d0ba5
b7c9ed1
6c46a3d
6cf3570
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |||||||||||||||||||||||||||||||||
| using System.IO; | ||||||||||||||||||||||||||||||||||
| using System.Linq; | ||||||||||||||||||||||||||||||||||
| using System.Security.Permissions; | ||||||||||||||||||||||||||||||||||
| using System.Text; | ||||||||||||||||||||||||||||||||||
| using System.Threading; | ||||||||||||||||||||||||||||||||||
| using System.Windows; | ||||||||||||||||||||||||||||||||||
| using System.Windows.Threading; | ||||||||||||||||||||||||||||||||||
|
|
@@ -15,12 +16,14 @@ | |||||||||||||||||||||||||||||||||
| using Dynamo.Logging; | ||||||||||||||||||||||||||||||||||
| using Dynamo.Models; | ||||||||||||||||||||||||||||||||||
| using Dynamo.PackageManager; | ||||||||||||||||||||||||||||||||||
| using Dynamo.Search.SearchElements; | ||||||||||||||||||||||||||||||||||
| using Dynamo.Selection; | ||||||||||||||||||||||||||||||||||
| using Dynamo.ViewModels; | ||||||||||||||||||||||||||||||||||
| using Dynamo.Wpf.Extensions; | ||||||||||||||||||||||||||||||||||
| using Dynamo.Wpf.Interfaces; | ||||||||||||||||||||||||||||||||||
| using DynamoProperties = Dynamo.Properties; | ||||||||||||||||||||||||||||||||||
| using MenuItem = System.Windows.Controls.MenuItem; | ||||||||||||||||||||||||||||||||||
| using Microsoft.Win32; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| namespace Dynamo.DocumentationBrowser | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
|
@@ -408,6 +411,271 @@ private void OnPackageLoaded(Package pkg) | |||||||||||||||||||||||||||||||||
| PackageDocumentationManager.Instance.AddPackageDocumentation(pkg.NodeDocumentaionDirectory, pkg.Name); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| internal void RunNodeHelpAudit() | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| if (DynamoViewModel == null || ViewModel == null) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| OnMessageLogged(LogMessage.Warning(Resources.NodeHelpAuditNotReady, WarningLevel.Mild)); | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var docManager = PackageDocumentationManager.Instance; | ||||||||||||||||||||||||||||||||||
| if (docManager == null) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| OnMessageLogged(LogMessage.Warning(Resources.NodeHelpAuditManagerMissing, WarningLevel.Mild)); | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var saveDialog = new SaveFileDialog | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| Filter = Resources.NodeHelpAuditSaveDialogFilter, | ||||||||||||||||||||||||||||||||||
| DefaultExt = ".csv", | ||||||||||||||||||||||||||||||||||
| AddExtension = true, | ||||||||||||||||||||||||||||||||||
| FileName = $"NodeHelpAudit_{DateTime.Now:yyyyMMdd_HHmmss}.csv", | ||||||||||||||||||||||||||||||||||
| Title = Resources.NodeHelpAuditSaveDialogTitle | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var owner = viewLoadedParamsReference?.DynamoWindow; | ||||||||||||||||||||||||||||||||||
| var dialogResult = owner == null ? saveDialog.ShowDialog() : saveDialog.ShowDialog(owner); | ||||||||||||||||||||||||||||||||||
| if (dialogResult != true) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var targetPath = saveDialog.FileName; | ||||||||||||||||||||||||||||||||||
| try | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| var entries = DynamoViewModel.Model?.SearchModel?.Entries?.Where(entry => entry.IsVisibleInSearch).ToList(); | ||||||||||||||||||||||||||||||||||
| if (entries == null) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| OnMessageLogged(LogMessage.Warning(Resources.NodeHelpAuditNoEntries, WarningLevel.Mild)); | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var packages = pmExtension?.PackageLoader?.LocalPackages?.ToList() ?? new List<Package>(); | ||||||||||||||||||||||||||||||||||
| var packageRoots = BuildPackageRootIndex(packages); | ||||||||||||||||||||||||||||||||||
| var packageAssemblies = BuildPackageAssemblyLookup(packages); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var csv = new StringBuilder(); | ||||||||||||||||||||||||||||||||||
| var csvHeader = Resources.NodeHelpAuditCsvHeader; | ||||||||||||||||||||||||||||||||||
| if (string.IsNullOrWhiteSpace(csvHeader)) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| csvHeader = "Library,Category,Name,FullName,MissingMd,MissingDyn,MarkdownPath,SampleGraphPath"; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| csv.AppendLine(csvHeader); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| foreach (var entry in entries) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| try | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| var node = entry.CreateNode(); | ||||||||||||||||||||||||||||||||||
| var minimumQualifiedName = DynamoViewModel.GetMinimumQualifiedName(node); | ||||||||||||||||||||||||||||||||||
| var packageName = ResolvePackageName(entry, packageRoots, packageAssemblies); | ||||||||||||||||||||||||||||||||||
|
johnpierson marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var mdPath = docManager.GetAnnotationDoc(minimumQualifiedName, packageName) ?? string.Empty; | ||||||||||||||||||||||||||||||||||
| var isBuiltInByPath = !string.IsNullOrEmpty(packageName) && ViewModel.IsBuiltInDocPath(mdPath); | ||||||||||||||||||||||||||||||||||
| var isOwnedByPackage = !string.IsNullOrEmpty(packageName) && !isBuiltInByPath; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var sampleGraphPath = string.IsNullOrWhiteSpace(mdPath) | ||||||||||||||||||||||||||||||||||
| ? string.Empty | ||||||||||||||||||||||||||||||||||
| : ViewModel.DynamoGraphFromMDFilePath(mdPath, isOwnedByPackage); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var missingMd = string.IsNullOrWhiteSpace(mdPath) || !File.Exists(mdPath); | ||||||||||||||||||||||||||||||||||
| var missingDyn = string.IsNullOrWhiteSpace(sampleGraphPath) || !File.Exists(sampleGraphPath); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var category = entry.FullCategoryName ?? string.Empty; | ||||||||||||||||||||||||||||||||||
| var library = GetLibraryName(category); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| csv.AppendLine(string.Join(",", | ||||||||||||||||||||||||||||||||||
| EscapeCsv(library), | ||||||||||||||||||||||||||||||||||
| EscapeCsv(category), | ||||||||||||||||||||||||||||||||||
| EscapeCsv(entry.Name), | ||||||||||||||||||||||||||||||||||
| EscapeCsv(entry.FullName), | ||||||||||||||||||||||||||||||||||
| missingMd, | ||||||||||||||||||||||||||||||||||
| missingDyn, | ||||||||||||||||||||||||||||||||||
| EscapeCsv(mdPath), | ||||||||||||||||||||||||||||||||||
| EscapeCsv(sampleGraphPath))); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| catch (Exception ex) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| OnMessageLogged(LogMessage.Warning(string.Format(Resources.NodeHelpAuditEntryFailed, entry.FullName, ex.Message), WarningLevel.Mild)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| File.WriteAllText(targetPath, csv.ToString(), new UTF8Encoding(false)); | ||||||||||||||||||||||||||||||||||
| DynamoViewModel.ToastManager.CreateRealTimeInfoWindow(string.Format(Resources.NodeHelpAuditCompleted, targetPath), true); | ||||||||||||||||||||||||||||||||||
|
johnpierson marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| catch (Exception ex) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+545
to
+551
|
||||||||||||||||||||||||||||||||||
| catch (Exception) | |
| { | |
| } | |
| }); | |
| } | |
| catch (Exception) | |
| { | |
| catch (Exception ex) | |
| { | |
| OnMessageLogged(LogMessage.Warning(Resources.NodeHelpAuditEntryFailed + " " + ex.ToString(), WarningLevel.Mild)); | |
| } | |
| }); | |
| } | |
| catch (Exception ex) | |
| { | |
| OnMessageLogged(LogMessage.Warning(Resources.NodeHelpAuditFailed + " " + ex.ToString(), WarningLevel.Mild)); |
Uh oh!
There was an error while loading. Please reload this page.