-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3309 from 2sic/develop
V17.02
- Loading branch information
Showing
132 changed files
with
2,496 additions
and
797 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,95 @@ | ||
using System; | ||
using System.IO; | ||
using System.Text.RegularExpressions; | ||
using System.Xml.Linq; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
namespace ToSic.Sxc.BuildTasks | ||
{ | ||
public class ModifyXmlDocumentation : Task | ||
{ | ||
[Required] | ||
public string XmlDocumentationPath { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
// Launches a dialog asking if you want to attach a debugger | ||
//System.Diagnostics.Debugger.Launch(); | ||
|
||
try | ||
{ | ||
var content = File.ReadAllText(XmlDocumentationPath); | ||
|
||
var modifiedContent = ReplaceXrefsWithLinks(content); | ||
|
||
modifiedContent = AddDocsLinkToTypesAndProperties(modifiedContent); | ||
|
||
File.WriteAllText(XmlDocumentationPath, modifiedContent); | ||
Log.LogMessage(MessageImportance.High, $"XML documentation modified successfully at: {XmlDocumentationPath}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.LogErrorFromException(ex); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private static string ReplaceXrefsWithLinks(string content) | ||
{ | ||
// regex pattern to handle method signatures with parentheses | ||
var pattern = @"\[(.*?)\]\(xref:((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)"; | ||
|
||
// Replacement method defined as a local function | ||
string Replacement(Match m) | ||
{ | ||
var label = m.Groups[1].Value; | ||
var reference = m.Groups[2].Value; | ||
// Use label if provided, otherwise use reference as label | ||
var linkText = !string.IsNullOrEmpty(label) ? label : reference; | ||
return $@"<a href=""https://go.2sxc.org/xref17?xref={reference}"">{linkText}</a>"; | ||
} | ||
|
||
var modifiedContent = Regex.Replace(content, pattern, new MatchEvaluator(Replacement)); | ||
return modifiedContent; | ||
} | ||
|
||
private string AddDocsLinkToTypesAndProperties(string content) | ||
{ | ||
var xdoc = XDocument.Parse(content); | ||
foreach (var member in xdoc.Descendants("member")) | ||
{ | ||
try | ||
{ | ||
var memberName = member.Attribute("name")?.Value; | ||
|
||
if (memberName == null | ||
|| !(memberName.StartsWith("T:") || memberName.StartsWith("P:")) | ||
|| memberName.Contains(".Internal.") | ||
|| memberName.Contains(".Integration.")) continue; | ||
|
||
var summary = member.Element("summary"); | ||
if (summary == null) continue; | ||
|
||
var summaryContent = summary.Value; | ||
if (summaryContent.Contains("📖")) continue; | ||
|
||
var reference = memberName.Substring(2); | ||
// if it's a generic type, we need to remove the generic part and append * | ||
//if (reference.Contains("`")) reference = reference.Substring(0,reference.LastIndexOf('`')) + "*"; | ||
|
||
var label = reference.Substring(reference.LastIndexOf('.') + 1); | ||
|
||
summary.Add(new XElement("para", new XElement("a", new XAttribute("href", $"https://go.2sxc.org/xref17?xref={reference}"), "📖 " + label))); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.LogErrorFromException(ex); | ||
} | ||
} | ||
return xdoc.ToString(); | ||
} | ||
} | ||
} |
Binary file modified
BIN
+2.5 KB
(120%)
Src/Build/ToSic.Sxc.BuildTasks/bin/Debug/net472/ToSic.Sxc.BuildTasks.dll
Binary file not shown.
Binary file modified
BIN
+1.1 KB
(120%)
Src/Build/ToSic.Sxc.BuildTasks/bin/Debug/net472/ToSic.Sxc.BuildTasks.pdb
Binary file not shown.
Binary file modified
BIN
+2.5 KB
(120%)
Src/Build/ToSic.Sxc.BuildTasks/bin/Debug/net7.0/ToSic.Sxc.BuildTasks.dll
Binary file not shown.
Binary file modified
BIN
+5.09 KB
(140%)
Src/Build/ToSic.Sxc.BuildTasks/bin/Debug/net7.0/ToSic.Sxc.BuildTasks.pdb
Binary file not shown.
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
Binary file not shown.
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,20 @@ | ||
[ | ||
{ | ||
"id": 0, | ||
"name": "Completely Empty App", | ||
"teaser": "Completely empty app, without any code or content", | ||
"internalNotes": "should create an app using the previous mechanism", | ||
"zip": null, | ||
"appName": null, | ||
"folder": null | ||
}, | ||
{ | ||
"id": 1, | ||
"name": "App Template Basic", | ||
"teaser": "A basic app template with simple instructions and a first razor template", | ||
"internalNotes": "should import the zip, reset the GUID, rename the App and folder", | ||
"zip": "2sxcApp_AppTemplateBasic_0.17.0.zip", | ||
"appName": "AppTemplateBasic", | ||
"folder": "app-template-basic" | ||
} | ||
] |
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
Oops, something went wrong.