Skip to content

Commit dbf19ce

Browse files
committed
v2.0.2
1 parent e270548 commit dbf19ce

11 files changed

Lines changed: 156 additions & 7 deletions

MarkupDoc/AddOns/SourceOnlyPackages/SourceOnlyPackagesAddOn.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ await markup.WriteParaAsync(
168168
.AddIf(markup.LineBreak(), !string.IsNullOrEmpty(nuProps.PackageTags))
169169
.Add($"Includes: {nuProps.IncludesType}")
170170
.Add(markup.LineBreak())
171-
.Add($"Declaring file: {nuProps.DeclaringFile.Substring(root.ProjectRootDir.Length + 1)}")
171+
.Add($"Declaring file: { PathUtils.GetRelativeSourceFile(nuProps.DeclaringFile,root.ProjectRootDir)}")
172172
));
173173

174174
await markup.WriteParaAsync(nuProps.PackageDescription);
@@ -209,7 +209,7 @@ await markup.WriteParaAsync(new Txt()
209209
await markup.WriteParaAsync(new Txt()
210210
.Add(markup.Bold("Sources"))
211211
.Add(markup.DescriptionList(
212-
f => $"{f.Substring(root.ProjectRootDir.Length + 1)}",
212+
f => $"{PathUtils.GetRelativeSourceFile(f,root.ProjectRootDir)}",
213213
f => string.Empty,
214214
nuProps.PackageFiles)));
215215

MarkupDoc/Markup/MarkdownMarkupProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class MarkdownMarkupProvider : IMarkupProvider
1616
/// <summary>
1717
/// Gets the extension of file generated by markup provider
1818
/// </summary>
19-
public string Extension => OutputOptions.HtmlExtension;
19+
public string Extension => OutputOptions.MarkdownExtension;
2020

2121
/// <summary>
2222
/// Output configuration

MarkupDoc/Markup/MarkupGenerator.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Runtime.CompilerServices;
56
using System.Threading.Tasks;
67
using net.adamec.dev.markupdoc.CodeModel;
78
using net.adamec.dev.markupdoc.MsApiDoc;
@@ -711,7 +712,7 @@ await Markup.WriteParaAsync(
711712
.Add(Markup.LineBreak())
712713
.Add($"Type: {Markup.Link(member.Type.Name, member.Type)}")
713714
.AddIf(Markup.LineBreak(), member.SourceFiles != null && member.SourceFiles.Count > 0)
714-
.AddIf(() => "Sources: " + string.Join(", ", member.SourceFiles.Select(s => s.Substring(member.Root.ProjectRootDir.Length + 1))),
715+
.AddIf(() => "Sources: " + string.Join(", ", member.SourceFiles.Select(s => PathUtils.GetRelativeSourceFile(s,member.Root.ProjectRootDir))),
715716
member.SourceFiles != null && member.SourceFiles.Count > 0)
716717
.AddEachIf(a => a.WritePageHeader(member, Markup), addOns, addOns.Count > 0)));
717718
}
@@ -734,11 +735,13 @@ await Markup.WriteParaAsync(
734735
.Add(Markup.LineBreak())
735736
.Add($"Assembly: {type.Assembly.Name}")
736737
.AddIf(Markup.LineBreak(), type.SourceFiles != null && type.SourceFiles.Count > 0)
737-
.AddIf(() => "Sources: " + string.Join(", ", type.SourceFiles.Select(s => s.Substring(type.Root.ProjectRootDir.Length + 1))),
738+
.AddIf(() => "Sources: " + string.Join(", ", type.SourceFiles.Select(s => PathUtils.GetRelativeSourceFile(s,type.Root.ProjectRootDir))),
738739
type.SourceFiles != null && type.SourceFiles.Count > 0)
739740
.AddEachIf(a => a.WritePageHeader(type, Markup), addOns, addOns.Count > 0)));
740741
}
741742

743+
744+
742745
/// <summary>
743746
/// Writes the Example documentation section for given <paramref name="member"/> if available
744747
/// </summary>

MarkupDoc/MarkupDoc.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
<Compile Include="Utils\Extensions\StringExtensions.cs" />
100100
<Compile Include="Utils\Extensions\TypeKindExtensions.cs" />
101101
<Compile Include="Utils\IsNewUtils.cs" />
102+
<Compile Include="Utils\PathUtils.cs" />
102103
<Compile Include="Utils\Txt.cs" />
103104
<Compile Include="XmlDocumentation\C.cs" />
104105
<Compile Include="XmlDocumentation\Code.cs" />

MarkupDoc/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.1.0")]
36-
[assembly: AssemblyFileVersion("2.0.1.0")]
35+
[assembly: AssemblyVersion("2.0.2.0")]
36+
[assembly: AssemblyFileVersion("2.0.2.0")]

MarkupDoc/Utils/PathUtils.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.IO;
3+
4+
namespace net.adamec.dev.markupdoc.Utils
5+
{
6+
/// <summary>
7+
/// File path utilities
8+
/// </summary>
9+
public class PathUtils
10+
{
11+
/// <summary>
12+
/// Gets the relative path of the source file with the project root as a base
13+
/// </summary>
14+
/// <remarks>
15+
/// Returns substring of the <paramref name="sourceFile"/> with removed starting part of <paramref name="projectRoot"/> for standard source files within the project.
16+
/// When a source-only package is consumed, the source file is physically in .nuget package dir and in <c>App_Packages</c> virtual dir in project.
17+
/// It looks for the "signature" <c>contentFiles\\cs\\any\\App_Packages\\</c> of the source-only package, get's the path relative to package and prefixes it with <c>App_Packages</c>.
18+
/// For any other files (not really have a case for it), just the file name is returned.
19+
/// </remarks>
20+
/// <param name="sourceFile">Full path to the source file</param>
21+
/// <param name="projectRoot">Full path to the project root directory</param>
22+
/// <returns>Relative path of the source file with the project root as a base</returns>
23+
public static string GetRelativeSourceFile(string sourceFile, string projectRoot)
24+
{
25+
//standard file within project
26+
if (sourceFile.StartsWith(projectRoot))
27+
{
28+
return sourceFile.Substring(projectRoot.Length + 1);
29+
}
30+
31+
//source only package - do it "App_Packages\....."
32+
const string sourceOnlyPackageLocation = "contentFiles\\cs\\any\\App_Packages\\";
33+
// ReSharper disable once InvertIf
34+
if (sourceFile.Contains(sourceOnlyPackageLocation))
35+
{
36+
var idx = sourceFile.IndexOf(sourceOnlyPackageLocation, StringComparison.InvariantCulture);
37+
idx += sourceOnlyPackageLocation.Length;
38+
return "App_Packages\\" + sourceFile.Substring(idx);
39+
}
40+
41+
//another file (maybe link) - return just file name
42+
return new FileInfo(sourceFile).Name;
43+
}
44+
}
45+
}

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## [2.0.2] - 2018-12-30 ##
7+
### Fixed ###
8+
- Relative paths to source files from source-only packages corrected in output
9+
- Fixed Extension returned by MarkdownMarkupProvider
10+
611
## [2.0.1] - 2018-12-29 ##
712
### Changed ###
813
- Output generator add-on instances are created automatically.
@@ -39,6 +44,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
3944
### Added ###
4045
- Initial release
4146

47+
[2.0.2]: https://github.com/adamecr/MarkupDoc/compare/v2.0.1...v2.0.2
4248
[2.0.1]: https://github.com/adamecr/MarkupDoc/compare/v2.0.0...v2.0.1
4349
[2.0.0]: https://github.com/adamecr/MarkupDoc/compare/v1.0.0...v2.0.0
4450
[1.0.0]: https://github.com/adamecr/MarkupDoc/releases/tag/v1.0.0

doc/MarkupDoc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ <h2> <a id="type-list" ></a> Types </h2>
102102
<tr><td><a href="net.adamec.dev.markupdoc.XmlDocumentation__1ter1y6.html#t-net.adamec.dev.markupdoc.xmldocumentation.para__1no80es" >Para</a></td><td>public</td><td>Class</td><td>Class representing &lt;para&gt; element of XML Documentation Comments</td></tr>
103103
<tr><td><a href="net.adamec.dev.markupdoc.XmlDocumentation__1ter1y6.html#t-net.adamec.dev.markupdoc.xmldocumentation.param__7q99qf" >Param</a></td><td>public</td><td>Class</td><td>Class representing &lt;param&gt; element of XML Documentation Comments</td></tr>
104104
<tr><td><a href="net.adamec.dev.markupdoc.XmlDocumentation__1ter1y6.html#t-net.adamec.dev.markupdoc.xmldocumentation.paramref__1goure8" >ParamRef</a></td><td>public</td><td>Class</td><td>Class representing &lt;paramref&gt; element of XML Documentation Comments</td></tr>
105+
<tr><td><a href="net.adamec.dev.markupdoc.Utils__m327rs.html#t-net.adamec.dev.markupdoc.utils.pathutils__ueq8cw" >PathUtils</a></td><td>public</td><td>Class</td><td>File path utilities</td></tr>
105106
<tr><td><a href="net.adamec.dev.markupdoc__1d9f9qh.html#t-net.adamec.dev.markupdoc.program__cagybt" >Program</a></td><td>internal</td><td>Class</td><td>Main program entry class</td></tr>
106107
<tr><td><a href="net.adamec.dev.markupdoc.CodeModel__1f8sg55.html#t-net.adamec.dev.markupdoc.codemodel.propertymember__m06mbu" >PropertyMember</a></td><td>public</td><td>Class</td><td>Represents a property within the code model</td></tr>
107108
<tr><td><a href="net.adamec.dev.markupdoc.CodeModel.Builder__w36mxa.html#t-net.adamec.dev.markupdoc.codemodel.builder.propertymemberbuilder__k8fr6c" >PropertyMemberBuilder</a></td><td>public</td><td>Class</td><td>Builder for <a href="net.adamec.dev.markupdoc.CodeModel__1f8sg55.html#t-net.adamec.dev.markupdoc.codemodel.propertymember__m06mbu" >PropertyMember</a></td></tr>

doc/MarkupDoc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
| [Para](net.adamec.dev.markupdoc.XmlDocumentation__1ter1y6.md#t-net.adamec.dev.markupdoc.xmldocumentation.para__1no80es) | public | Class | Class representing &lt;para&gt; element of XML Documentation Comments |
7171
| [Param](net.adamec.dev.markupdoc.XmlDocumentation__1ter1y6.md#t-net.adamec.dev.markupdoc.xmldocumentation.param__7q99qf) | public | Class | Class representing &lt;param&gt; element of XML Documentation Comments |
7272
| [ParamRef](net.adamec.dev.markupdoc.XmlDocumentation__1ter1y6.md#t-net.adamec.dev.markupdoc.xmldocumentation.paramref__1goure8) | public | Class | Class representing &lt;paramref&gt; element of XML Documentation Comments |
73+
| [PathUtils](net.adamec.dev.markupdoc.Utils__m327rs.md#t-net.adamec.dev.markupdoc.utils.pathutils__ueq8cw) | public | Class | File path utilities |
7374
| [Program](net.adamec.dev.markupdoc__1d9f9qh.md#t-net.adamec.dev.markupdoc.program__cagybt) | internal | Class | Main program entry class |
7475
| [PropertyMember](net.adamec.dev.markupdoc.CodeModel__1f8sg55.md#t-net.adamec.dev.markupdoc.codemodel.propertymember__m06mbu) | public | Class | Represents a property within the code model |
7576
| [PropertyMemberBuilder](net.adamec.dev.markupdoc.CodeModel.Builder__w36mxa.md#t-net.adamec.dev.markupdoc.codemodel.builder.propertymemberbuilder__k8fr6c) | public | Class | Builder for [PropertyMember](net.adamec.dev.markupdoc.CodeModel__1f8sg55.md#t-net.adamec.dev.markupdoc.codemodel.propertymember__m06mbu) |

doc/net.adamec.dev.markupdoc.Utils__m327rs.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ <h3> Classes </h3>
4242
<tr><td><a href="net.adamec.dev.markupdoc.Utils__m327rs.html#t-net.adamec.dev.markupdoc.utils.basedisposable__1niv1i9" >BaseDisposable</a></td><td>public abstract</td><td>Helper class for implementation of <a href="https://docs.microsoft.com/en-us/dotnet/api/system.idisposable" class="link-external" target="_blank" >System.IDisposable</a> types</td></tr>
4343
<tr><td><a href="net.adamec.dev.markupdoc.Utils__m327rs.html#t-net.adamec.dev.markupdoc.utils.consoleutils__xyngj2" >ConsoleUtils</a></td><td>public static</td><td>Console output helpers</td></tr>
4444
<tr><td><a href="net.adamec.dev.markupdoc.Utils__m327rs.html#t-net.adamec.dev.markupdoc.utils.isnewutils__slf3x" >IsNewUtils</a></td><td>public static</td><td>Helpers to get the access to internal ISymbol.IsNew property</td></tr>
45+
<tr><td><a href="net.adamec.dev.markupdoc.Utils__m327rs.html#t-net.adamec.dev.markupdoc.utils.pathutils__ueq8cw" >PathUtils</a></td><td>public</td><td>File path utilities</td></tr>
4546
<tr><td><a href="net.adamec.dev.markupdoc.Utils__m327rs.html#t-net.adamec.dev.markupdoc.utils.txt__ptyt6s" >Txt</a></td><td>public</td><td>Text builder</td></tr>
4647
</table>
4748
<p> </p>
@@ -312,6 +313,34 @@ <h3> Remarks </h3>
312313
<p>Uses the reflection to get the access to the internal property IsNew. The retrieved <a href="https://docs.microsoft.com/en-us/dotnet/api/system.reflection.propertyinfo" class="link-external" target="_blank" >System.Reflection.PropertyInfo</a> is cached in <a href="net.adamec.dev.markupdoc.Utils__m327rs.html#f-net.adamec.dev.markupdoc.utils.isnewutils.isnewpropertycache__fi6gva" >IsNewPropertyCache</a> to minimize the performance impacts.</p>
313314
<p>Go to <a href="MarkupDoc.html#namespace-list" >namespaces</a> or <a href="MarkupDoc.html#type-list" >types</a></p>
314315
<p> </p>
316+
<h2> <a id="t-net.adamec.dev.markupdoc.utils.pathutils__ueq8cw" ></a> PathUtils Class </h2>
317+
<p><small>Namespace: <a href="net.adamec.dev.markupdoc.Utils__m327rs.html#n-net.adamec.dev.markupdoc.utils__m327rs" >net.adamec.dev.markupdoc.Utils</a><br />
318+
Assembly: MarkupDoc<br />
319+
Sources: Utils\PathUtils.cs</small></p>
320+
<p>File path utilities</p>
321+
<pre><code class="csharp">public class PathUtils</code></pre>
322+
<p>Inheritance: <a href="https://docs.microsoft.com/en-us/dotnet/api/system.object" class="link-external" target="_blank" >object</a><br />
323+
</p>
324+
<h3> Methods </h3>
325+
<table><tr><th>Name</th><th>Modifier</th><th>Summary</th></tr>
326+
<tr><td><a href="net.adamec.dev.markupdoc.Utils__m327rs.html#m-net.adamec.dev.markupdoc.utils.pathutils.getrelativesourcefile_system.string-system.string___1t61qb1" >GetRelativeSourceFile(string, string)</a></td><td>public static</td><td>Gets the relative path of the source file with the project root as a base</td></tr>
327+
</table>
328+
<p> </p>
329+
<p>Go to <a href="MarkupDoc.html#namespace-list" >namespaces</a> or <a href="MarkupDoc.html#type-list" >types</a></p>
330+
<p> </p>
331+
<h2> <a id="m-net.adamec.dev.markupdoc.utils.pathutils.getrelativesourcefile_system.string-system.string___1t61qb1" ></a> PathUtils.GetRelativeSourceFile(string, string) Method </h2>
332+
<p><small>Namespace: <a href="net.adamec.dev.markupdoc.Utils__m327rs.html#n-net.adamec.dev.markupdoc.utils__m327rs" >net.adamec.dev.markupdoc.Utils</a><br />
333+
Assembly: MarkupDoc<br />
334+
Type: <a href="net.adamec.dev.markupdoc.Utils__m327rs.html#t-net.adamec.dev.markupdoc.utils.pathutils__ueq8cw" >PathUtils</a><br />
335+
Sources: Utils\PathUtils.cs</small></p>
336+
<p>Gets the relative path of the source file with the project root as a base</p>
337+
<pre><code class="csharp">public static string GetRelativeSourceFile(string sourceFile, string projectRoot)</code></pre>
338+
<strong>Method parameters</strong><dl><dt><a href="https://docs.microsoft.com/en-us/dotnet/api/system.string" class="link-external" target="_blank" >string</a> <strong>sourceFile</strong></dt><dd>Full path to the source file</dd><dt><a href="https://docs.microsoft.com/en-us/dotnet/api/system.string" class="link-external" target="_blank" >string</a> <strong>projectRoot</strong></dt><dd>Full path to the project root directory</dd></dl>
339+
<p><strong>Return value</strong><dl><dt><a href="https://docs.microsoft.com/en-us/dotnet/api/system.string" class="link-external" target="_blank" >string</a></dt><dd>Relative path of the source file with the project root as a base</dd></dl></p>
340+
<h3> Remarks </h3>
341+
<p>Returns substring of the <strong>sourceFile</strong> with removed starting part of <strong>projectRoot</strong> for standard source files within the project. When a source-only package is consumed, the source file is physically in .nuget package dir and in <code class="csharp">App_Packages</code> virtual dir in project. It looks for the &quot;signature&quot; <code class="csharp">contentFiles\\cs\\any\\App_Packages\\</code> of the source-only package, get&#39;s the path relative to package and prefixes it with <code class="csharp">App_Packages</code> . For any other files (not really have a case for it), just the file name is returned.</p>
342+
<p>Go to <a href="MarkupDoc.html#namespace-list" >namespaces</a> or <a href="MarkupDoc.html#type-list" >types</a></p>
343+
<p> </p>
315344
<h2> <a id="t-net.adamec.dev.markupdoc.utils.txt__ptyt6s" ></a> Txt Class </h2>
316345
<p><small>Namespace: <a href="net.adamec.dev.markupdoc.Utils__m327rs.html#n-net.adamec.dev.markupdoc.utils__m327rs" >net.adamec.dev.markupdoc.Utils</a><br />
317346
Assembly: MarkupDoc<br />

0 commit comments

Comments
 (0)