Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
- Fixed handling of list items with a term element but no description.  Fixes EWSoftware#989.
- Fixed odd case with an implicit operator that had no parameters.  Fixes EWSoftware#985.
  • Loading branch information
EWSoftware committed May 1, 2023
1 parent f2e3d57 commit 2ea7eae
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 30 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions IgnoredWords.dic
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Grande
guid
Halleux
hashtable
hhc
hljs
hoverable
hralign
Expand Down Expand Up @@ -201,6 +202,7 @@ url
username
ushort
utf
utils
varargs
vbnet
vbnetusage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,26 +507,26 @@ private void CopyStandardHelpContent()
/// copied recursively.
/// </summary>
/// <param name="sourcePath">The source path from which to copy</param>
/// <param name="destPath">The destination path to which to copy</param>
/// <param name="destinationPath">The destination path to which to copy</param>
/// <param name="fileCount">A reference to the file count variable</param>
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('\\');

string dirName = sourcePath.Substring(0, idx), fileSpec = sourcePath.Substring(idx + 1), filename;

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);
Expand All @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion SHFB/Source/SandcastleCore/CommandLine/BooleanOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "+");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion SHFB/Source/SandcastleCore/CommandLine/ParseResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ internal enum ParseResult
/// <summary>Unrecognized option</summary>
UnrecognizedOption,
/// <summary>A single-use option appeared multiple times</summary>
MultipleOccurence
MultipleOccurrence
}
}
2 changes: 1 addition & 1 deletion SHFB/Source/SandcastleCore/CommandLine/StringOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion SHFB/Source/SandcastleCore/CommandLine/SwitchOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// System : Sandcastle Tools - Sandcastle Tools Core Class Library
// File : ListElement.cs
// Author : Eric Woodruff ([email protected])
// 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
//
Expand Down Expand Up @@ -217,14 +217,22 @@ 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");
li.Add(strong, " \u2013 ");
transformation.RenderChildElements(strong, term.Nodes());
}

transformation.RenderChildElements(li, description.Nodes());
if(description != null)
transformation.RenderChildElements(li, description.Nodes());
}
else
transformation.RenderChildElements(li, item.Nodes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// System : Sandcastle Tools - Sandcastle Tools Core Class Library
// File : ListElement.cs
// Author : Eric Woodruff ([email protected])
// 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
//
Expand Down Expand Up @@ -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"));
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// System : Sandcastle Tools - Sandcastle Tools Core Class Library
// File : TopicTransformationCore.cs
// Author : Eric Woodruff ([email protected])
// 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.
Expand Down Expand Up @@ -1612,26 +1612,26 @@ protected virtual XNode ApiTopicTocTitleSimple()
/// <returns>An enumerable list of one or more XML nodes representing the parameter and return types</returns>
protected virtual IEnumerable<XNode> 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()) };
Expand All @@ -1640,19 +1640,19 @@ protected virtual IEnumerable<XNode> 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();
Expand Down
20 changes: 20 additions & 0 deletions TestCaseProject/TestClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,26 @@ private string PrivateMethod()
/// </description>
/// </item>
/// </list>
///
/// <para>List with term element only</para>
/// <list type="bullet">
/// <item><term>apartment</term></item>
/// <item><term>free </term></item>
/// <item><term>both </term></item>
/// <item><term>neutral </term></item>
/// <item><term>single </term></item>
/// <item><term>rental </term></item>
/// </list>
///
/// <para>List with description element only</para>
/// <list type="bullet">
/// <item><description>apartment</description></item>
/// <item><description>free </description></item>
/// <item><description>both </description></item>
/// <item><description>neutral </description></item>
/// <item><description>single </description></item>
/// <item><description>rental </description></item>
/// </list>
/// </remarks>
public static double Sum(double[] values)
{
Expand Down

0 comments on commit 2ea7eae

Please sign in to comment.