Skip to content

Commit f08f172

Browse files
committed
Move glob into a standalone project and cleanup code
1 parent 6c02915 commit f08f172

33 files changed

+538
-1052
lines changed

All.sln

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.24730.1
4+
VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "docfx", "src\docfx\docfx.csproj", "{AB97BEDF-D207-42E9-A56F-C9DD395BFCDD}"
77
EndProject
@@ -367,6 +367,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DocAsCode.YamlSer
367367
EndProject
368368
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DocAsCode.MarkdownLite.Tests", "test\Microsoft.DocAsCode.MarkdownLite.Tests\Microsoft.DocAsCode.MarkdownLite.Tests.csproj", "{F94BB644-A042-4364-AD2D-BF9D5BBD44AC}"
369369
EndProject
370+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DocAsCode.Glob", "src\Microsoft.DocAsCode.Glob\Microsoft.DocAsCode.Glob.csproj", "{629EC13D-8939-4F23-B7DC-7A98964BB9A4}"
371+
EndProject
372+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DocAsCode.Glob", "src\Microsoft.DocAsCode.Glob\Microsoft.DocAsCode.Glob.xproj", "{C2459EBE-8013-4111-8685-16D47C341F35}"
373+
EndProject
374+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DocAsCode.Glob.Tests", "test\Microsoft.DocAsCode.Glob.Tests\Microsoft.DocAsCode.Glob.Tests.csproj", "{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}"
375+
EndProject
370376
Global
371377
GlobalSection(SolutionConfigurationPlatforms) = preSolution
372378
Debug|Any CPU = Debug|Any CPU
@@ -566,6 +572,30 @@ Global
566572
{F94BB644-A042-4364-AD2D-BF9D5BBD44AC}.Release|Any CPU.Build.0 = Release|Any CPU
567573
{F94BB644-A042-4364-AD2D-BF9D5BBD44AC}.Release|x86.ActiveCfg = Release|Any CPU
568574
{F94BB644-A042-4364-AD2D-BF9D5BBD44AC}.Release|x86.Build.0 = Release|Any CPU
575+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
576+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
577+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Debug|x86.ActiveCfg = Debug|Any CPU
578+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Debug|x86.Build.0 = Debug|Any CPU
579+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
580+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Release|Any CPU.Build.0 = Release|Any CPU
581+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Release|x86.ActiveCfg = Release|Any CPU
582+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4}.Release|x86.Build.0 = Release|Any CPU
583+
{C2459EBE-8013-4111-8685-16D47C341F35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
584+
{C2459EBE-8013-4111-8685-16D47C341F35}.Debug|Any CPU.Build.0 = Debug|Any CPU
585+
{C2459EBE-8013-4111-8685-16D47C341F35}.Debug|x86.ActiveCfg = Debug|Any CPU
586+
{C2459EBE-8013-4111-8685-16D47C341F35}.Debug|x86.Build.0 = Debug|Any CPU
587+
{C2459EBE-8013-4111-8685-16D47C341F35}.Release|Any CPU.ActiveCfg = Release|Any CPU
588+
{C2459EBE-8013-4111-8685-16D47C341F35}.Release|Any CPU.Build.0 = Release|Any CPU
589+
{C2459EBE-8013-4111-8685-16D47C341F35}.Release|x86.ActiveCfg = Release|Any CPU
590+
{C2459EBE-8013-4111-8685-16D47C341F35}.Release|x86.Build.0 = Release|Any CPU
591+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
592+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
593+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Debug|x86.ActiveCfg = Debug|Any CPU
594+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Debug|x86.Build.0 = Debug|Any CPU
595+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
596+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Release|Any CPU.Build.0 = Release|Any CPU
597+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Release|x86.ActiveCfg = Release|Any CPU
598+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC}.Release|x86.Build.0 = Release|Any CPU
569599
EndGlobalSection
570600
GlobalSection(SolutionProperties) = preSolution
571601
HideSolutionNode = FALSE
@@ -613,5 +643,8 @@ Global
613643
{87EFC656-3081-442E-902B-822714514768} = {2DAAC304-36F6-4E4A-A0EA-5821B4B9842A}
614644
{EA319525-1EE9-43E0-8D0E-817EE4C72EFE} = {38490932-E9E7-4C31-81DD-B4B06BACD1BB}
615645
{F94BB644-A042-4364-AD2D-BF9D5BBD44AC} = {E872B0D7-6331-4E40-8264-0015330DA5D3}
646+
{629EC13D-8939-4F23-B7DC-7A98964BB9A4} = {2DAAC304-36F6-4E4A-A0EA-5821B4B9842A}
647+
{C2459EBE-8013-4111-8685-16D47C341F35} = {38490932-E9E7-4C31-81DD-B4B06BACD1BB}
648+
{957B06B4-FD5B-473F-A118-D1EA5EBF64BC} = {E872B0D7-6331-4E40-8264-0015330DA5D3}
616649
EndGlobalSection
617650
EndGlobal

src/Microsoft.DocAsCode.EntityModel/Microsoft.DocAsCode.EntityModel.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@
207207
<None Include="packages.config" />
208208
</ItemGroup>
209209
<ItemGroup>
210+
<ProjectReference Include="..\Microsoft.DocAsCode.Glob\Microsoft.DocAsCode.Glob.csproj">
211+
<Project>{629ec13d-8939-4f23-b7dc-7a98964bb9a4}</Project>
212+
<Name>Microsoft.DocAsCode.Glob</Name>
213+
</ProjectReference>
210214
<ProjectReference Include="..\Microsoft.DocAsCode.Plugins\Microsoft.DocAsCode.Plugins.csproj">
211215
<Project>{42f7a3b4-464b-403c-8352-5fbf40c696ff}</Project>
212216
<Name>Microsoft.DocAsCode.Plugins</Name>

src/Microsoft.DocAsCode.EntityModel/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Microsoft.DocAsCode.MarkdownLite": "1.0.0",
55
"Microsoft.DocAsCode.Plugins": "1.0.0",
66
"Microsoft.DocAsCode.Utility": "1.0.0",
7+
"Microsoft.DocAsCode.Glob": "1.0.0",
78
"Microsoft.DocAsCode.YamlSerialization": "1.0.0",
89
"Microsoft.CodeAnalysis.Workspaces.Dnx": "1.0.0",
910
"Microsoft.CodeAnalysis.Common": "1.1.0-*",

src/Microsoft.DocAsCode.Utility/Glob/FileGlob.cs renamed to src/Microsoft.DocAsCode.Glob/FileGlob.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Microsoft.DocAsCode.Glob
77
using System.Collections.Generic;
88
using System.IO;
99
using System.Linq;
10-
using Utility;
1110

1211
public class FileGlob
1312
{
@@ -29,15 +28,15 @@ private static IEnumerable<string> GetFilesCore(string cwd, IEnumerable<GlobMatc
2928
if (!Directory.Exists(cwd)) yield break;
3029
foreach (var file in GetFilesFromSubfolder(cwd, cwd, globs, excludeGlobs))
3130
{
32-
yield return file.ToNormalizedFullPath();
31+
yield return NormalizePath(file);
3332
}
3433
}
3534

3635
private static IEnumerable<string> GetFilesFromSubfolder(string baseDirectory, string cwd, IEnumerable<GlobMatcher> globs, IEnumerable<GlobMatcher> excludeGlobs)
3736
{
3837
foreach (var file in Directory.GetFiles(baseDirectory, "*", SearchOption.TopDirectoryOnly))
3938
{
40-
var relativePath = PathUtility.MakeRelativePath(cwd, file);
39+
var relativePath = GetRelativeFilePath(cwd, file);
4140
if (IsFileMatch(relativePath, globs, excludeGlobs))
4241
{
4342
yield return file;
@@ -46,7 +45,7 @@ private static IEnumerable<string> GetFilesFromSubfolder(string baseDirectory, s
4645

4746
foreach (var dir in Directory.GetDirectories(baseDirectory, "*", SearchOption.TopDirectoryOnly))
4847
{
49-
var relativePath = PathUtility.MakeRelativePath(cwd, dir) + "/";
48+
var relativePath = GetRelativeDirectoryPath(cwd, dir);
5049

5150
// For folder, exclude glob matches folder means nothing, e.g. **/a matches b/a folder, however, **/a does not match b/a/c file
5251
foreach (var glob in globs)
@@ -64,6 +63,22 @@ private static IEnumerable<string> GetFilesFromSubfolder(string baseDirectory, s
6463
}
6564
}
6665

66+
private static string GetRelativeFilePath(string directory, string file)
67+
{
68+
return file.Substring(directory.Length + 1);
69+
}
70+
71+
private static string GetRelativeDirectoryPath(string parentDirectory, string directory)
72+
{
73+
var relativeDirectory = GetRelativeFilePath(parentDirectory, directory);
74+
return relativeDirectory.TrimEnd('\\', '/') + "/";
75+
}
76+
77+
private static string NormalizePath(string path)
78+
{
79+
return path.Replace('\\', '/');
80+
}
81+
6782
private static bool IsFileMatch(string path, IEnumerable<GlobMatcher> globs, IEnumerable<GlobMatcher> excludeGlobs)
6883
{
6984
foreach (var exclude in excludeGlobs)

src/Microsoft.DocAsCode.Utility/Glob/GlobMatcher.cs renamed to src/Microsoft.DocAsCode.Glob/GlobMatcher.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace Microsoft.DocAsCode.Glob
88
using System.Text;
99
using System.Text.RegularExpressions;
1010
using System.Linq;
11-
using Utility;
1211

1312
public class GlobMatcher
1413
{
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\Shared\base.props" />
4+
<PropertyGroup>
5+
<ProjectGuid>{629EC13D-8939-4F23-B7DC-7A98964BB9A4}</ProjectGuid>
6+
<OutputType>Library</OutputType>
7+
<RootNamespace>Microsoft.DocAsCode.Glob</RootNamespace>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Compile Include="FileGlob.cs" />
11+
<Compile Include="GlobMatcher.cs" />
12+
<Compile Include="Properties\AssemblyInfo.cs" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<Reference Include="System" />
16+
</ItemGroup>
17+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
18+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
19+
Other similar extension points exist, see Microsoft.Common.targets.
20+
<Target Name="BeforeBuild">
21+
</Target>
22+
<Target Name="AfterBuild">
23+
</Target>
24+
-->
25+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="__ToolsVersion__" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\Shared\xproj.base.props" />
4+
<PropertyGroup Label="Globals">
5+
<ProjectGuid>c2459ebe-8013-4111-8685-16d47c341f35</ProjectGuid>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'" Label="Configuration">
8+
</PropertyGroup>
9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" Label="Configuration">
10+
</PropertyGroup>
11+
<PropertyGroup>
12+
<SchemaVersion>2.0</SchemaVersion>
13+
</PropertyGroup>
14+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
15+
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
16+
</PropertyGroup>
17+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
18+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Runtime.CompilerServices;
5+
6+
[assembly: InternalsVisibleTo("Microsoft.DocAsCode.Glob.Tests")]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "1.0.0",
3+
"dependencies": {
4+
},
5+
"frameworks": {
6+
"dnx451": {
7+
"frameworkAssemblies": {
8+
"System": ""
9+
}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)