Skip to content

Commit

Permalink
Use correct relative path in the README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
citizenmatt committed Sep 26, 2017
1 parent cedb126 commit 2605833
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/resharper-template-compiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static void DoCompile(CompileOptions compileOptions)

var markdown = File.ReadAllText(inputFile);
var template = parser.Parse(markdown);
template.InputFile = inputFile;
template.InputFile = Path.Combine(Directory.GetCurrentDirectory(), inputFile);
store.AddTemplate(template);
// TODO: Concatenate markdown to a readme.md
}
Expand All @@ -70,7 +70,7 @@ private static void DoCompile(CompileOptions compileOptions)
stream = File.Open(compileOptions.ReadMeFile, FileMode.Create, FileAccess.Write);
using (var streamWriter = new StreamWriter(stream))
{
var readme = new ReadmeFormatter(streamWriter);
var readme = new ReadmeFormatter(streamWriter, Path.GetDirectoryName(Path.GetFullPath(compileOptions.ReadMeFile)));
readme.FormatTemplates(store);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/resharper-template-compiler/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
16 changes: 13 additions & 3 deletions src/resharper-template-compiler/ReadmeFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ namespace CitizenMatt.ReSharper.TemplateCompiler
public class ReadmeFormatter
{
private readonly TextWriter writer;
private readonly Uri baseUri;

public ReadmeFormatter(TextWriter writer)
public ReadmeFormatter(TextWriter writer, string basePath)
{
this.writer = writer;
if (!basePath.EndsWith(@"\")) basePath += @"\";
baseUri = new Uri(basePath);
}

public void FormatTemplates(TemplateStore templates)
Expand Down Expand Up @@ -78,7 +81,7 @@ private void FormatLiveTemplates(IEnumerable<Template> templates)
writer.WriteLine("Shortcut | Description");
writer.WriteLine("---------|------------");
foreach (var template in templates.OrderBy(t => t.Shortcut))
writer.WriteLine("[{0}]({1}) | {2}", template.Shortcut, template.InputFile, template.Description);
writer.WriteLine("[{0}]({1}) | {2}", template.Shortcut, GetRelativePath(template.InputFile), template.Description);

writer.WriteLine();
}
Expand All @@ -96,9 +99,16 @@ private void FormatFileTemplates(IEnumerable<Template> templates)
writer.WriteLine("Description |");
writer.WriteLine("------------|");
foreach (var template in templates.OrderBy(t => t.Description))
writer.WriteLine("[{0}]({1}) |", template.Description, template.InputFile);
writer.WriteLine("[{0}]({1}) |", template.Description, GetRelativePath(template.InputFile));

writer.WriteLine();
}

private string GetRelativePath(string fullPath)
{
var fullUri = new Uri(fullPath, UriKind.Absolute);
var relativeUri = baseUri.MakeRelativeUri(fullUri);
return relativeUri.ToString();
}
}
}

0 comments on commit 2605833

Please sign in to comment.