@Model.LineNumber | - } - else - { - var lineNumberClass = RemoveMultipleSpaces($"line-number"); - if (Model.CodeLine.IsDocumentation) - { -+@using ApiView +@using APIView.Model +@using APIView.DIff +@using System.Text.RegularExpressions +@using APIViewWeb.Models; +@using System.Text +@using APIViewWeb.Helpers +@using Microsoft.AspNetCore.Mvc.TagHelpers +@model APIViewWeb.Models.CodeLineModel +@functions +{ + public static string RemoveMultipleSpaces(string str) + { + return String.Join(" ", str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); + } +} +@{ + bool isRemoved = Model.Kind == DiffLineKind.Removed; + string lineClass = Model.Kind switch + { + DiffLineKind.Removed => "code-removed", + DiffLineKind.Added => "code-added", + _ => "" + }; + + bool isSectionHeading = false; + bool isSubSectionHeading = false; + bool isHeadingWithDelta = false; + string headingClass = String.Empty; + string documentationRow = String.Empty; + string hiddenApiRow = String.Empty; + string codeLineDisplay = String.Empty; + string codeLineClass = (!String.IsNullOrWhiteSpace(Model.CodeLine.LineClass)) ? Model.CodeLine.LineClass.Trim() : String.Empty; + int? sectionKey = Model.DiffSectionId ?? Model.CodeLine.SectionKey; + + if (sectionKey != null) + { + isSectionHeading = true; + headingClass = $"code-line-section-heading-{sectionKey}"; + if (Model.IsDiffView) + { + switch (Model.Kind) + { + case DiffLineKind.Added: + headingClass += $" rev-a-heading-{Model.CodeLine.SectionKey}"; + break; + case DiffLineKind.Removed: + headingClass += $" rev-b-heading-{Model.CodeLine.SectionKey}"; + break; + case DiffLineKind.Unchanged: + headingClass += $" rev-a-heading-{Model.CodeLine.SectionKey}"; + headingClass += $" rev-b-heading-{Model.OtherLineSectionKey}"; + break; + } + } + } + + if(Model.CodeLine.IsDocumentation) + { + documentationRow = "code-line-documentation"; + codeLineDisplay = "hidden-row"; + } + + var userPreference = TempData["UserPreference"] as UserPreferenceModel ?? new UserPreferenceModel(); + + // Always show hidden APIs if we are in Diff mode and there are changes. + if (Model.CodeLine.IsHiddenApi && Model.Kind == DiffLineKind.Unchanged) + { + hiddenApiRow += PageModelHelpers.GetHiddenApiClass(userPreference); + } + + if (Regex.IsMatch(codeLineClass, @".*lvl_[0-9]+_parent.*")) + { + isSubSectionHeading = true; + } + + if (Model.Kind == DiffLineKind.Unchanged && + ((isSubSectionHeading && Model.IsSubHeadingWithDiffInSection) || (isSectionHeading && Model.HeadingsOfSectionsWithDiff.Contains(Model.LineNumber)))) + { + lineClass += " code-delta"; + isHeadingWithDelta = true; + } + var rowClass = RemoveMultipleSpaces($"code-line {headingClass} {codeLineClass} {lineClass} {codeLineDisplay} {documentationRow} {hiddenApiRow}"); + var cellContent = String.Empty; + for (int i = 0; i < Model.CodeLine.Indent; i++) + { + if ((isSectionHeading || isSubSectionHeading) && (i == Model.CodeLine.Indent - 1)) + { + cellContent += @""; + }else + { + cellContent += @""; + } + } + cellContent += Model.CodeLine.DisplayString; +} + + | ||||||||||||||||||||
+
|
-
- @{
- string collapseMenu = (isSectionHeading || isSubSectionHeading) ? "" : "";
- }
- @if (Model.Kind == DiffLineKind.Removed)
- {
- var codeRemovedSign = @"";
- @Html.Raw(codeRemovedSign)@Html.Raw(cellContent)@Html.Raw(collapseMenu)
- }
- else if(Model.Kind == DiffLineKind.Added)
- {
- var codeAddedSign = @"";
- @Html.Raw(codeAddedSign)@Html.Raw(cellContent)@Html.Raw(collapseMenu)
- }
- else
- {
- var indentOrDelta = String.Empty;
- if (isHeadingWithDelta)
- {
- indentOrDelta = @"";
- }
- else
- {
- indentOrDelta = "";
- }
- @Html.Raw(indentOrDelta)@Html.Raw(cellContent)@Html.Raw(collapseMenu)
- }
- |
-||||||||||||||||||||
+ @if(Model.DocumentedByLines?.Length > 0) + { + + + + } + | + + } + @if (Model.CodeLine.IsDocumentation) + { ++ @if (isSectionHeading || isSubSectionHeading) + { + + } + | + +