-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Still Hsu
committed
Aug 10, 2018
1 parent
0cca485
commit c9c992b
Showing
3 changed files
with
60 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace DocFX.Plugin.DescriptionGenerator | ||
{ | ||
/// <summary> | ||
/// Defines the type of article. | ||
/// </summary> | ||
internal enum ArticleType | ||
{ | ||
Conceptual, | ||
Reference | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace DocFX.Plugin.DescriptionGenerator | ||
{ | ||
public static class StringHelper | ||
{ | ||
/// <summary> | ||
/// Truncates the specified string. | ||
/// </summary> | ||
/// <remarks> | ||
/// This method truncates the input string. | ||
/// | ||
/// This snippet is fetched from the Humanizer project, which is licensed under the MIT license. | ||
/// Copyright(c) .NET Foundation and Contributors | ||
/// </remarks> | ||
/// <seealso href="https://github.com/Humanizr/Humanizer/" /> | ||
/// <seealso href="https://github.com/Humanizr/Humanizer/blob/master/LICENSE" /> | ||
public static string Truncate(this string value, int length, string truncationString) | ||
{ | ||
if (value == null) | ||
return null; | ||
|
||
if (value.Length == 0) | ||
return value; | ||
|
||
if (truncationString == null || truncationString.Length > length) | ||
return value.Substring(0, length); | ||
|
||
return value.Length > length | ||
? value.Substring(0, length - truncationString.Length) + truncationString | ||
: value; | ||
} | ||
} | ||
} |