Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds strong tag to namespace and Parent Module labels #329

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions misc/templates/reference/module.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
var byCategory = members
.GroupBy(m => m.Category)
.OrderBy(g => String.IsNullOrEmpty(g.Key) ? "ZZZ" : g.Key)
.Select((g, n) => new {
Index = n,
GroupKey = g.Key,
Members = g.OrderBy(m => m.Name),
.Select((g, n) => new {
Index = n,
GroupKey = g.Key,
Members = g.OrderBy(m => m.Name),
Name = String.IsNullOrEmpty(g.Key) ? "Other module members" : g.Key
});

Expand All @@ -33,23 +33,23 @@

<h1>@Model.Module.Name</h1>
<p>
<span>Namespace: @Model.Namespace.Name</span><br />
<span><strong>Namespace:</strong> @Model.Namespace.Name</span><br />
@if(Model.ParentModule.Exists())
{
<span>Parent Module: <a href="@(Model.ParentModule.Value.UrlName).html">@Model.ParentModule.Value.Name</a></span>
<span><strong>Parent Module:</strong> <a href="@(Model.ParentModule.Value.UrlName).html">@Model.ParentModule.Value.Name</a></span>
}
</p>
<div class="xmldoc">
@foreach (var sec in comment.Sections) {
// XML comment for the type has multiple sections that can be labelled
// with categories (to give comment for an individual category). Here,
// with categories (to give comment for an individual category). Here,
// we print only those that belong to the <default> section.
if (!byCategory.Any(g => g.GroupKey == sec.Key))
{
if (sec.Key != "<default>") {
<h2>@sec.Key</h2>
}
@sec.Value
@sec.Value
}
}
</div>
Expand All @@ -60,7 +60,7 @@
<ul>
@foreach (var g in byCategory)
{
<li><a href="@("#section" + g.Index.ToString())">@g.Name</a></li>
<li><a href="@("#section" + g.Index.ToString())">@g.Name</a></li>
}
</ul>
}
Expand All @@ -84,7 +84,7 @@
// that is related to this specific category.
if (byCategory.Count() > 1)
{
<h2>@g.Name<a name="@("section" + g.Index.ToString())">&#160;</a></h2>
<h2>@g.Name<a name="@("section" + g.Index.ToString())">&#160;</a></h2>
var info = comment.Sections.FirstOrDefault(kvp => kvp.Key == g.GroupKey);
if (info.Key != null)
{
Expand All @@ -94,21 +94,21 @@
}
}

@RenderPart("part-members", new {
@RenderPart("part-members", new {
Header = "Functions and values",
TableHeader = "Function or value",
Members = g.Members.Where(m => m.Kind == MemberKind.ValueOrFunction)
})

@RenderPart("part-members", new {
@RenderPart("part-members", new {
Header = "Type extensions",
TableHeader = "Type extension",
Members = g.Members.Where(m => m.Kind == MemberKind.TypeExtension)
})

@RenderPart("part-members", new {
@RenderPart("part-members", new {
Header = "Active patterns",
TableHeader = "Active pattern",
Members = g.Members.Where(m => m.Kind == MemberKind.ActivePattern)
})
}
}
20 changes: 10 additions & 10 deletions misc/templates/reference/type.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Get all the members & comment for the type
var members = (IEnumerable<Member>)Model.Type.AllMembers;
var comment = (Comment)Model.Type.Comment;

// Group all members by their category which is an inline annotation
// that can be added to members using special XML comment:
//
Expand All @@ -19,26 +19,26 @@
var byCategory = members
.GroupBy(m => m.Category)
.OrderBy(g => String.IsNullOrEmpty(g.Key) ? "ZZZ" : g.Key)
.Select((g, n) => new {
Index = n,
GroupKey = g.Key,
Members = g.OrderBy(m => m.Kind == MemberKind.StaticParameter ? "" : m.Name),
Name = String.IsNullOrEmpty(g.Key) ? "Other type members" : g.Key
.Select((g, n) => new {
Index = n,
GroupKey = g.Key,
Members = g.OrderBy(m => m.Kind == MemberKind.StaticParameter ? "" : m.Name),
Name = String.IsNullOrEmpty(g.Key) ? "Other type members" : g.Key
});
}

<h1>@Model.Type.Name</h1>
<p>
<span>Namespace: @Model.Namespace.Name</span><br />
<span><strong>Namespace:</strong> @Model.Namespace.Name</span><br />
@if(Model.HasParentModule)
{
<span>Parent Module: <a href="@(Model.ParentModule.Value.UrlName).html">@Model.ParentModule.Value.Name</a></span>
<span><strong>Parent Module:</strong> <a href="@(Model.ParentModule.Value.UrlName).html">@Model.ParentModule.Value.Name</a></span>
}
</p>
<div class="xmldoc">
@foreach (var sec in comment.Sections) {
// XML comment for the type has multiple sections that can be labelled
// with categories (to give comment for an individual category). Here,
// with categories (to give comment for an individual category). Here,
// we print only those that belong to the <default> section.
if (!byCategory.Any(g => g.GroupKey == sec.Key)) {
if (sec.Key != "<default>") {
Expand Down Expand Up @@ -84,7 +84,7 @@
TableHeader = "Record Field",
Members = g.Members.Where(m => m.Kind == MemberKind.RecordField)
})

@RenderPart("part-members", new {
Header = "Static parameters",
TableHeader = "Static parameters",
Expand Down
10 changes: 5 additions & 5 deletions tests/FSharp.MetadataFormat.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ let ``MetadataFormat generates module link in nested types``() =
let files = dict [ for f in fileNames -> Path.GetFileName(f), File.ReadAllText(f) ]

// Check that the modules and type files have namespace information
files.["fslib-class.html"] |> should contain "Namespace: FsLib"
files.["fslib-nested.html"] |> should contain "Namespace: FsLib"
files.["fslib-nested-nestedtype.html"] |> should contain "Namespace: FsLib"
files.["fslib-nested-submodule.html"] |> should contain "Namespace: FsLib"
files.["fslib-nested-submodule-verynestedtype.html"] |> should contain "Namespace: FsLib"
files.["fslib-class.html"] |> should contain "<strong>Namespace:</strong> FsLib"
files.["fslib-nested.html"] |> should contain "<strong>Namespace:</strong> FsLib"
files.["fslib-nested-nestedtype.html"] |> should contain "<strong>Namespace:</strong> FsLib"
files.["fslib-nested-submodule.html"] |> should contain "<strong>Namespace:</strong> FsLib"
files.["fslib-nested-submodule-verynestedtype.html"] |> should contain "<strong>Namespace:</strong> FsLib"

// Check that the link to the module is correctly generated
files.["fslib-nested-nestedtype.html"] |> should contain "Parent Module:"
Expand Down