From 2ea7eae7c5c7a8db75be8a5c51fba9ef66861eea Mon Sep 17 00:00:00 2001 From: EWSoftware Date: Sun, 30 Apr 2023 18:25:34 -0700 Subject: [PATCH] Minor fixes - Fixed handling of list items with a term element but no description. Fixes #989. - Fixed odd case with an implicit operator that had no parameters. Fixes #985. --- .editorconfig | 10 +++++++++ IgnoredWords.dic | 2 ++ .../BuildEngine/BuildProcess.HelpFileUtils.cs | 16 +++++++------- .../CommandLine/BooleanOption.cs | 2 +- .../CommandLine/ParseArgumentsResult.cs | 2 +- .../SandcastleCore/CommandLine/ParseResult.cs | 2 +- .../CommandLine/StringOption.cs | 2 +- .../CommandLine/SwitchOption.cs | 2 +- .../Elements/Html/ListElement.cs | 14 +++++++++--- .../Elements/OpenXml/ListElement.cs | 14 +++++++++--- .../Transformation/TopicTransformationCore.cs | 22 +++++++++---------- TestCaseProject/TestClass.cs | 20 +++++++++++++++++ 12 files changed, 78 insertions(+), 30 deletions(-) diff --git a/.editorconfig b/.editorconfig index a4bf4a39..60a900a0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,17 @@ indent_style = space end_of_line = crlf guidelines = 80 dotted, 114 dotted # (Please don't specify an indent_size here; that has too many unintended consequences.) + +# VSSPELL: Spell checker settings for all files vsspell_section_id = 4ab9fbff07c9470c9a57edd4ce8100fb +vsspell_code_analyzer_ignore_identifier_if_private = true +vsspell_code_analyzer_ignore_identifier_if_internal = true +vsspell_code_analyzer_ignore_identifier_if_all_uppercase = true +vsspell_code_analyzer_ignore_identifiers_within_member_bodies = true +vsspell_code_analyzer_ignore_if_compiler_generated = true +vsspell_code_analyzer_ignore_delimited_comments = true +vsspell_code_analyzer_ignore_quadruple_slash_comments = true +vsspell_code_analyzer_apply_to_all_c_style_languages = true vsspell_ignored_words_4ab9fbff07c9470c9a57edd4ce8100fb = File:IgnoredWords.dic [*de-DE.xml] diff --git a/IgnoredWords.dic b/IgnoredWords.dic index bc82f601..4f88e91c 100644 --- a/IgnoredWords.dic +++ b/IgnoredWords.dic @@ -76,6 +76,7 @@ Grande guid Halleux hashtable +hhc hljs hoverable hralign @@ -201,6 +202,7 @@ url username ushort utf +utils varargs vbnet vbnetusage diff --git a/SHFB/Source/SandcastleBuilderUtils/BuildEngine/BuildProcess.HelpFileUtils.cs b/SHFB/Source/SandcastleBuilderUtils/BuildEngine/BuildProcess.HelpFileUtils.cs index 14b3a2a1..1458fe77 100644 --- a/SHFB/Source/SandcastleBuilderUtils/BuildEngine/BuildProcess.HelpFileUtils.cs +++ b/SHFB/Source/SandcastleBuilderUtils/BuildEngine/BuildProcess.HelpFileUtils.cs @@ -507,15 +507,15 @@ private void CopyStandardHelpContent() /// copied recursively. /// /// The source path from which to copy - /// The destination path to which to copy + /// The destination path to which to copy /// A reference to the file count variable - private void RecursiveCopy(string sourcePath, string destPath, ref int fileCount) + private void RecursiveCopy(string sourcePath, string destinationPath, ref int fileCount) { if(sourcePath == null) throw new ArgumentNullException(nameof(sourcePath)); - if(destPath == null) - throw new ArgumentNullException(nameof(destPath)); + if(destinationPath == null) + throw new ArgumentNullException(nameof(destinationPath)); int idx = sourcePath.LastIndexOf('\\'); @@ -523,10 +523,10 @@ private void RecursiveCopy(string sourcePath, string destPath, ref int fileCount foreach(string name in Directory.EnumerateFiles(dirName, fileSpec)) { - filename = destPath + Path.GetFileName(name); + filename = destinationPath + Path.GetFileName(name); - if(!Directory.Exists(destPath)) - Directory.CreateDirectory(destPath); + if(!Directory.Exists(destinationPath)) + Directory.CreateDirectory(destinationPath); // All attributes are turned off so that we can delete it later File.Copy(name, filename, true); @@ -544,7 +544,7 @@ private void RecursiveCopy(string sourcePath, string destPath, ref int fileCount // Ignore hidden folders as they may be under source control and are not wanted foreach(string folder in Directory.EnumerateDirectories(dirName)) if((File.GetAttributes(folder) & FileAttributes.Hidden) != FileAttributes.Hidden) - this.RecursiveCopy(folder + @"\*.*", destPath + folder.Substring(dirName.Length + 1) + @"\", + this.RecursiveCopy(folder + @"\*.*", destinationPath + folder.Substring(dirName.Length + 1) + @"\", ref fileCount); } } diff --git a/SHFB/Source/SandcastleCore/CommandLine/BooleanOption.cs b/SHFB/Source/SandcastleCore/CommandLine/BooleanOption.cs index 59e6bcdf..c7ea9f03 100644 --- a/SHFB/Source/SandcastleCore/CommandLine/BooleanOption.cs +++ b/SHFB/Source/SandcastleCore/CommandLine/BooleanOption.cs @@ -40,7 +40,7 @@ internal override ParseResult ParseArgument(string argument) return ParseResult.MalformedArgument; if(this.IsPresent) - return ParseResult.MultipleOccurence; + return ParseResult.MultipleOccurrence; this.Value = (argument == "+"); diff --git a/SHFB/Source/SandcastleCore/CommandLine/ParseArgumentsResult.cs b/SHFB/Source/SandcastleCore/CommandLine/ParseArgumentsResult.cs index b2abf238..e01726ad 100644 --- a/SHFB/Source/SandcastleCore/CommandLine/ParseArgumentsResult.cs +++ b/SHFB/Source/SandcastleCore/CommandLine/ParseArgumentsResult.cs @@ -113,7 +113,7 @@ public void WriteParseErrors(TextWriter writer) message = this.Options[error.Key].RequiredMessage; break; - case ParseResult.MultipleOccurence: + case ParseResult.MultipleOccurrence: message = "The option cannot occur more than once"; break; diff --git a/SHFB/Source/SandcastleCore/CommandLine/ParseResult.cs b/SHFB/Source/SandcastleCore/CommandLine/ParseResult.cs index cff98c74..87617a30 100644 --- a/SHFB/Source/SandcastleCore/CommandLine/ParseResult.cs +++ b/SHFB/Source/SandcastleCore/CommandLine/ParseResult.cs @@ -24,6 +24,6 @@ internal enum ParseResult /// Unrecognized option UnrecognizedOption, /// A single-use option appeared multiple times - MultipleOccurence + MultipleOccurrence } } diff --git a/SHFB/Source/SandcastleCore/CommandLine/StringOption.cs b/SHFB/Source/SandcastleCore/CommandLine/StringOption.cs index 551f9260..7e95aafa 100644 --- a/SHFB/Source/SandcastleCore/CommandLine/StringOption.cs +++ b/SHFB/Source/SandcastleCore/CommandLine/StringOption.cs @@ -83,7 +83,7 @@ internal override ParseResult ParseArgument(string argument) return ParseResult.MalformedArgument; if(this.IsPresent) - return ParseResult.MultipleOccurence; + return ParseResult.MultipleOccurrence; this.Value = argument.Substring(1); diff --git a/SHFB/Source/SandcastleCore/CommandLine/SwitchOption.cs b/SHFB/Source/SandcastleCore/CommandLine/SwitchOption.cs index d9bd09df..cb14265f 100644 --- a/SHFB/Source/SandcastleCore/CommandLine/SwitchOption.cs +++ b/SHFB/Source/SandcastleCore/CommandLine/SwitchOption.cs @@ -40,7 +40,7 @@ internal override ParseResult ParseArgument(string argument) return ParseResult.MalformedArgument; if(this.IsPresent) - return ParseResult.MultipleOccurence; + return ParseResult.MultipleOccurrence; this.Value = this.Name; diff --git a/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/Html/ListElement.cs b/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/Html/ListElement.cs index 7e73f88a..87e25d70 100644 --- a/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/Html/ListElement.cs +++ b/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/Html/ListElement.cs @@ -2,8 +2,8 @@ // System : Sandcastle Tools - Sandcastle Tools Core Class Library // File : ListElement.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 07/24/2022 -// Note : Copyright 2022, Eric Woodruff, All rights reserved +// Updated : 04/29/2023 +// Note : Copyright 2022-2023, Eric Woodruff, All rights reserved // // This file contains the class used to handle list elements based on the topic type // @@ -217,6 +217,13 @@ private void RenderXmlCommentsList(TopicTransformationCore transformation, XElem if(term != null || description != null) { + // If there's a term but no description, render the term as the description + if(term != null && description == null) + { + description = term; + term = null; + } + if(term != null) { var strong = new XElement("strong"); @@ -224,7 +231,8 @@ private void RenderXmlCommentsList(TopicTransformationCore transformation, XElem transformation.RenderChildElements(strong, term.Nodes()); } - transformation.RenderChildElements(li, description.Nodes()); + if(description != null) + transformation.RenderChildElements(li, description.Nodes()); } else transformation.RenderChildElements(li, item.Nodes()); diff --git a/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/OpenXml/ListElement.cs b/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/OpenXml/ListElement.cs index 15e2593a..51c243d6 100644 --- a/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/OpenXml/ListElement.cs +++ b/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/Elements/OpenXml/ListElement.cs @@ -2,8 +2,8 @@ // System : Sandcastle Tools - Sandcastle Tools Core Class Library // File : ListElement.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 05/29/2022 -// Note : Copyright 2022, Eric Woodruff, All rights reserved +// Updated : 04/29/2023 +// Note : Copyright 2022-2023, Eric Woodruff, All rights reserved // // This file contains the class used to handle list elements based on the topic type // @@ -187,6 +187,13 @@ private static void RenderXmlCommentsList(TopicTransformationCore transformation container = new XElement(OpenXmlElement.WordProcessingML + "p"); li.Add(container); + // If there's a term but no description, render the term as the description + if(term != null && description == null) + { + description = term; + term = null; + } + if(term != null) { bold = new XElement("span", new XAttribute("class", "Bold")); @@ -195,7 +202,8 @@ private static void RenderXmlCommentsList(TopicTransformationCore transformation transformation.RenderChildElements(bold, term.Nodes()); } - transformation.RenderChildElements(container, description.Nodes()); + if(description != null) + transformation.RenderChildElements(container, description.Nodes()); } else transformation.RenderChildElements(li, item.Nodes()); diff --git a/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/TopicTransformationCore.cs b/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/TopicTransformationCore.cs index 735afcf4..5d8e14ef 100644 --- a/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/TopicTransformationCore.cs +++ b/SHFB/Source/SandcastleCore/PresentationStyle/Transformation/TopicTransformationCore.cs @@ -2,8 +2,8 @@ // System : Sandcastle Tools - Sandcastle Tools Core Class Library // File : TopicTransformationCore.cs // Author : Eric Woodruff (Eric@EWoodruff.us) -// Updated : 10/11/2022 -// Note : Copyright 2022, Eric Woodruff, All rights reserved +// Updated : 04/29/2023 +// Note : Copyright 2022-2023, Eric Woodruff, All rights reserved // // This file contains the abstract base class that is used to define the settings and common functionality for a // specific presentation style topic transformation. @@ -1612,26 +1612,26 @@ protected virtual XNode ApiTopicTocTitleSimple() /// An enumerable list of one or more XML nodes representing the parameter and return types protected virtual IEnumerable ApiTopicOperatorTypes(bool plainText) { - var parameters = this.ReferenceNode.Element("parameters").Elements(); + var parameters = this.ReferenceNode.Element("parameters")?.Elements(); var returns = this.ReferenceNode.Element("returns").Elements(); if(plainText) { var sb = new StringBuilder(1024); - if(parameters.Count() == 1 || returns.Count() == 1) + if((parameters != null && parameters.Count() == 1) || returns.Count() == 1) sb.Append('('); - if(parameters.Count() == 1) + if(parameters != null && parameters.Count() == 1) this.ApiTypeNamePlainText(sb, parameters.First().Elements().First()); - if(parameters.Count() == 1 || returns.Count() == 1) + if(parameters != null && parameters.Count() == 1 && returns.Count() == 1) sb.Append(" to "); if(returns.Count() == 1) this.ApiTypeNamePlainText(sb, returns.First()); - if(parameters.Count() == 1 || returns.Count() == 1) + if((parameters != null && parameters.Count() == 1) || returns.Count() == 1) sb.Append(')'); return new[] { new XText(sb.ToString()) }; @@ -1640,19 +1640,19 @@ protected virtual IEnumerable ApiTopicOperatorTypes(bool plainText) // This isn't returned, just its content var opsElement = new XElement("parameters"); - if(parameters.Count() == 1 || returns.Count() == 1) + if((parameters != null && parameters.Count() == 1) || returns.Count() == 1) opsElement.Add("("); - if(parameters.Count() == 1) + if(parameters != null && parameters.Count() == 1) this.ApiTypeNameDecorated(opsElement, parameters.First().Elements().First()); - if(parameters.Count() == 1 || returns.Count() == 1) + if(parameters != null && parameters.Count() == 1 && returns.Count() == 1) opsElement.Add(" to "); if(returns.Count() == 1) this.ApiTypeNameDecorated(opsElement, returns.First()); - if(parameters.Count() == 1 || returns.Count() == 1) + if((parameters != null && parameters.Count() == 1) || returns.Count() == 1) opsElement.Add(")"); return opsElement.Nodes(); diff --git a/TestCaseProject/TestClass.cs b/TestCaseProject/TestClass.cs index 90ddddac..93b94ea9 100644 --- a/TestCaseProject/TestClass.cs +++ b/TestCaseProject/TestClass.cs @@ -547,6 +547,26 @@ private string PrivateMethod() /// /// /// + /// + /// List with term element only + /// + /// apartment + /// free + /// both + /// neutral + /// single + /// rental + /// + /// + /// List with description element only + /// + /// apartment + /// free + /// both + /// neutral + /// single + /// rental + /// /// public static double Sum(double[] values) {