Skip to content

Commit

Permalink
[monodoc] Fix ecma traversal with unattached tree.
Browse files Browse the repository at this point in the history
Previously the code expected to stop at upper level node using the fact that their element starts with `root:/'. This element is attributed by RootNode when loading a complete tree. However tool like mdoc also loads tree unattached which doesn't create a standard `root:/` top-level root node hence causing the issue.
  • Loading branch information
garuma committed Jun 5, 2013
1 parent a84dee6 commit ff81791
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mcs/class/monodoc/Monodoc/providers/EcmaDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,11 @@ public static char GetNodeMemberTypeChar (Node node)
public static int GetNodeLevel (Node node)
{
int i = 0;
for (; !node.Element.StartsWith ("root:/", StringComparison.OrdinalIgnoreCase); i++)
for (; !node.Element.StartsWith ("root:/", StringComparison.OrdinalIgnoreCase); i++) {
node = node.Parent;
if (node == null)
return i - 1;
}
return i - 1;
}

Expand Down
14 changes: 14 additions & 0 deletions mcs/class/monodoc/Test/Monodoc/HelpSourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using Monodoc;
using Monodoc.Generators;
using Monodoc.Providers;

// Used by ReachabilityWithCrefsTest
// using HtmlAgilityPack;
Expand Down Expand Up @@ -153,6 +154,19 @@ public void AspNetStyleUrlReachabilityTest ()
Assert.IsTrue (rootTree.RenderUrl ("T:System.IComparable{T}", generator, out result), "#6");
}

[Test]
public void PublicUrlOnUnattachedHelpSourceRoot ()
{
// Unattached help source have no root:/ URL attributed
var hs = new EcmaHelpSource (Path.Combine (BaseDir, "sources", "netdocs"), false);
var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false);
hs.RootTree = rootTree;
Assert.IsNull (hs.Tree.RootNode.PublicUrl);
var nsChildUrl = hs.Tree.RootNode.ChildNodes.First ().PublicUrl;
Assert.IsNotNull (nsChildUrl);
StringAssert.StartsWith ("N:", nsChildUrl);
}

/*
[Test, Ignore ("Mono documentation is full of syntax errors so we can't use it reliably for this test")]
public void ReachabilityWithCrefsTest ()
Expand Down

0 comments on commit ff81791

Please sign in to comment.