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
Docs unification 1 #19630
Merged
maliming
merged 23 commits into
abpframework:docs-unification-1
from
EnesDONER:docs-unification-1
Apr 29, 2024
Merged
Docs unification 1 #19630
maliming
merged 23 commits into
abpframework:docs-unification-1
from
EnesDONER:docs-unification-1
Apr 29, 2024
Conversation
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
Merged
hi @EnesDONER I wrote a link checker. here are source code and results: // See https://aka.ms/new-console-template for more information
using System.Text.RegularExpressions;
var baseDir = "/Users/maliming/Github/abp/docs/en/";
var mdFiles = Directory.GetFiles(baseDir, "*.md", SearchOption.AllDirectories);
var count = 0;
foreach (var file in mdFiles.Where(x => !x.Contains("_deleted") && !x.Contains("Blog-Posts")))
{
var regex = new Regex(@"\[[^\[\]]*\]\(((?!http)[^\(\)]*)\)");
var content = File.ReadAllText(file);
var matches = regex.Matches(content);
foreach (Match match in matches)
{
var url = match.Groups[1].Value;
if (!string.IsNullOrWhiteSpace(url) && !url.StartsWith("#"))
{
var newUrl = url;
var parent = file;
if (newUrl.StartsWith("./"))
{
parent = Path.GetDirectoryName(parent);
newUrl = Path.Combine(parent, url.Replace("./", ""));
}
else if (newUrl.StartsWith("../"))
{
var count2 = Regex.Count(newUrl, @"\.\./");
for (var i = 0; i <= count2; i++)
{
parent = Path.GetDirectoryName(parent);
}
newUrl = Path.Combine(parent, url.Replace("../", ""));
}
else
{
newUrl = Path.Combine(Path.GetDirectoryName(parent), url);
}
if (newUrl.Contains("?"))
{
newUrl = newUrl.Substring(0, newUrl.IndexOf("?"));
}
if (!File.Exists(newUrl) && !File.Exists(Path.Combine(newUrl, "index.md")) && !File.Exists(newUrl + ".md"))
{
Console.WriteLine($"File : {file.Replace(baseDir, "")}");
Console.WriteLine($"Url : {url}");
//Console.WriteLine($"New Url : {newUrl}");
Console.WriteLine($"File not exists: {newUrl.Replace(baseDir, "")}");
Console.WriteLine("----------------------------------");
count++;
}
}
}
}
Console.WriteLine("Wrong Count: " + count);
|
maliming
approved these changes
Apr 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TODO: Abp docs broken links fixed