Browse Source

Fixes #84

tags/v0.16.4
Frans Bouma 6 years ago
parent
commit
a81e067589
10 changed files with 50 additions and 34 deletions
  1. +1
    -1
      src/DocNet/Program.cs
  2. +1
    -1
      src/DocNet/Properties/AssemblyInfo.cs
  3. +18
    -9
      src/DocNet/SimpleNavigationElement.cs
  4. +6
    -1
      src/MarkdownDeep/Extensions.cs
  5. +2
    -0
      src/MarkdownDeepTests/DocNetMode.cs
  6. +9
    -9
      src/MarkdownDeepTests/ExtensionsTests.cs
  7. +10
    -8
      src/MarkdownDeepTests/MarkdownDeepTests.csproj
  8. +0
    -2
      src/MarkdownDeepTests/Properties/AssemblyInfo.cs
  9. +1
    -1
      src/MarkdownDeepTests/packages.config
  10. +2
    -2
      src/MarkdownDeepTests/testfiles/docnetmode/Snippet(DocNetMode).txt

+ 1
- 1
src/DocNet/Program.cs View File

@@ -88,7 +88,7 @@ namespace Docnet

private static void DisplayHeader()
{
Console.WriteLine("Docnet v{0}. (c)2017 Frans Bouma and contributors", FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location).FileVersion);
Console.WriteLine("Docnet v{0}. (c){1} Frans Bouma and contributors", FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location).FileVersion, DateTime.UtcNow.Year);
Console.WriteLine("Get your copy at: https://github.com/FransBouma/Docnet \n");
}



+ 1
- 1
src/DocNet/Properties/AssemblyInfo.cs View File

@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Docnet")]
[assembly: AssemblyCopyright("Copyright ©2018 Frans Bouma")]
[assembly: AssemblyCopyright("Copyright ©2019 Frans Bouma")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]



+ 18
- 9
src/DocNet/SimpleNavigationElement.cs View File

@@ -194,21 +194,30 @@ namespace Docnet
relativePathToRoot,
this.GetFinalTargetUrl(navigationContext),
this.Name));
if (isCurrent && _relativeLinksOnPage.SelectMany(x => x.Children).Any(x => x.Level > 1))
if (isCurrent && _relativeLinksOnPage.Count>0)
{
// generate relative links
fragments.Add("<ul class=\"currentrelative\">");
bool renderHeadings = _relativeLinksOnPage.SelectMany(x => x.Children).Any(x => x.Level > 1);
if(!renderHeadings)
{
// check if there are headings of a higher level than 1 present. If so, continue and render as usual
renderHeadings = _relativeLinksOnPage.Any(x => x.Level > 1);
}

foreach (var heading in _relativeLinksOnPage)
if(renderHeadings)
{
var content = GenerateToCFragmentForHeading(heading, navigationContext);
if (!string.IsNullOrWhiteSpace(content))
// generate relative links
fragments.Add("<ul class=\"currentrelative\">");

foreach(var heading in _relativeLinksOnPage)
{
fragments.Add(content);
var content = GenerateToCFragmentForHeading(heading, navigationContext);
if(!string.IsNullOrWhiteSpace(content))
{
fragments.Add(content);
}
}
fragments.Add("</ul>");
}

fragments.Add("</ul>");
}
else
{


+ 6
- 1
src/MarkdownDeep/Extensions.cs View File

@@ -4,6 +4,12 @@ namespace MarkdownDeep
{
public static class Extensions
{
/// <summary>
/// Converts the set of headings in a hierarchy, where a heading of level n contains the headings of leven n+1 etc.
/// </summary>
/// <param name="headings"></param>
/// <returns></returns>
/// <remarks>If there's no root found, the returning set will be the same as the one passed in.</remarks>
public static List<Heading> ConvertToHierarchy(this List<Heading> headings)
{
var hierarchy = new List<Heading>();
@@ -32,7 +38,6 @@ namespace MarkdownDeep
hierarchy.Add(headings[i]);
}
}

return hierarchy;
}



+ 2
- 0
src/MarkdownDeepTests/DocNetMode.cs View File

@@ -17,6 +17,8 @@ namespace MarkdownDeepTests
}


// Make sure you copy the AutoHeaderIDTests.cs file to c:\temp, as it's used in one of the tests, which uses an absolute path for the snippet feature
// a relative path would have been preferable but the tests are run in a temp folder so they don't know the path of the source.
[Test, TestCaseSource("GetTests")]
public void Test(string resourceName)
{


+ 9
- 9
src/MarkdownDeepTests/ExtensionsTests.cs View File

@@ -11,15 +11,15 @@ namespace MarkdownDeepTests
public void ConvertsHeadingsHierarchy()
{
var headings = new List<Heading>();
headings.Add(new Heading { Level = 1, Name = "1" });
headings.Add(new Heading { Level = 2, Name = "1.1" });
headings.Add(new Heading { Level = 3, Name = "1.1.1" });
headings.Add(new Heading { Level = 2, Name = "1.2" });
headings.Add(new Heading { Level = 4, Name = "1.2.1.1" });
headings.Add(new Heading { Level = 2, Name = "1.3" });
headings.Add(new Heading { Level = 1, Name = "2" });
headings.Add(new Heading { Level = 3, Name = "2.1.1" });
headings.Add(new Heading { Level = 2, Name = "2.2" });
headings.Add(new Heading {Level = 1, Name = "1"});
headings.Add(new Heading {Level = 2, Name = "1.1"});
headings.Add(new Heading {Level = 3, Name = "1.1.1"});
headings.Add(new Heading {Level = 2, Name = "1.2"});
headings.Add(new Heading {Level = 4, Name = "1.2.1.1"});
headings.Add(new Heading {Level = 2, Name = "1.3"});
headings.Add(new Heading {Level = 1, Name = "2"});
headings.Add(new Heading {Level = 3, Name = "2.1.1"});
headings.Add(new Heading {Level = 2, Name = "2.2"});

var hierarchy = headings.ConvertToHierarchy();



+ 10
- 8
src/MarkdownDeepTests/MarkdownDeepTests.csproj View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\..\packages\NUnit.3.11.0\build\NUnit.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -41,14 +42,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunit.mocks">
<HintPath>..\..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
<Reference Include="pnunit.framework">
<HintPath>..\..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
<HintPath>..\..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -529,4 +525,10 @@
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit.3.11.0\build\NUnit.props'))" />
</Target>
</Project>

+ 0
- 2
src/MarkdownDeepTests/Properties/AssemblyInfo.cs View File

@@ -35,5 +35,3 @@ using NUnit.Framework;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: RequiresSTA]

+ 1
- 1
src/MarkdownDeepTests/packages.config View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.5.10.11092" />
<package id="NUnit" version="3.11.0" targetFramework="net461" />
<package id="System.Collections.Immutable" version="1.3.0" targetFramework="net461" />
</packages>

+ 2
- 2
src/MarkdownDeepTests/testfiles/docnetmode/Snippet(DocNetMode).txt View File

@@ -2,8 +2,8 @@

This is some text with a snippet.

@snippet cs [..\..\AutoHeaderIDTests.cs] SetUp
@snippet cs [c:\temp\AutoHeaderIDTests.cs] SetUp

@snippet cs [..\..\AutoHeaderIDTests.cs] =WithPunctuation
@snippet cs [c:\temp\AutoHeaderIDTests.cs] =WithPunctuation
post

Loading…
Cancel
Save