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

Feature/cross language API revision context #7849

Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 8 additions & 5 deletions src/dotnet/APIView/APIView/CodeFileRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private void Render(List<CodeLine> list, IEnumerable<CodeFileToken> node, bool s
{
var stringBuilder = new StringBuilder();
string currentId = null;
string currentCrossLangId = null;
string currentTableId = null;
bool isDocumentationRange = false;
bool isHiddenApiToken = false;
Expand All @@ -57,7 +58,7 @@ private void Render(List<CodeLine> list, IEnumerable<CodeFileToken> node, bool s
switch (token.Kind)
{
case CodeFileTokenKind.Newline:
CaptureCodeLine(list, sections, nodesInProcess, ref section, stringBuilder, ref lineNumber, ref leafSectionPlaceHolderNumber, ref currentId, isDocumentationRange, isHiddenApiToken);
CaptureCodeLine(list, sections, nodesInProcess, ref section, stringBuilder, ref lineNumber, ref leafSectionPlaceHolderNumber, ref currentId, ref currentCrossLangId, isDocumentationRange, isHiddenApiToken);
break;

case CodeFileTokenKind.DocumentRangeStart:
Expand Down Expand Up @@ -97,6 +98,7 @@ private void Render(List<CodeLine> list, IEnumerable<CodeFileToken> node, bool s
case CodeFileTokenKind.FoldableSectionHeading:
nodesInProcess.Push(SectionType.Heading);
currentId = (token.DefinitionId != null) ? token.DefinitionId : currentId;
currentCrossLangId = (token.CrossLanguageDefinitionId != null) ? token.CrossLanguageDefinitionId : currentCrossLangId;
RenderToken(token, stringBuilder, isDeprecatedToken, isHiddenApiToken);
break;

Expand Down Expand Up @@ -149,7 +151,7 @@ private void Render(List<CodeLine> list, IEnumerable<CodeFileToken> node, bool s
stringBuilder.Append("</strong></li>");
stringBuilder.Append("</ul>");
tableColumnCount.Curr = 0;
CaptureCodeLine(list, sections, nodesInProcess, ref section, stringBuilder, ref lineNumber, ref leafSectionPlaceHolderNumber, ref currentId, isDocumentationRange, isHiddenApiToken);
CaptureCodeLine(list, sections, nodesInProcess, ref section, stringBuilder, ref lineNumber, ref leafSectionPlaceHolderNumber, ref currentId, ref currentCrossLangId, isDocumentationRange, isHiddenApiToken);
}
else
{
Expand Down Expand Up @@ -186,7 +188,7 @@ private void Render(List<CodeLine> list, IEnumerable<CodeFileToken> node, bool s
if (tableColumnCount.Curr == 0)
{
stringBuilder.Append("</ul>");
CaptureCodeLine(list, sections, nodesInProcess, ref section, stringBuilder, ref lineNumber, ref leafSectionPlaceHolderNumber, ref currentId, isDocumentationRange, isHiddenApiToken);
CaptureCodeLine(list, sections, nodesInProcess, ref section, stringBuilder, ref lineNumber, ref leafSectionPlaceHolderNumber, ref currentId, ref currentCrossLangId, isDocumentationRange, isHiddenApiToken);
}
break;

Expand All @@ -208,6 +210,7 @@ private void Render(List<CodeLine> list, IEnumerable<CodeFileToken> node, bool s

default:
currentId = (token.DefinitionId != null) ? token.DefinitionId : currentId;
currentCrossLangId = (token.CrossLanguageDefinitionId != null) ? token.CrossLanguageDefinitionId : currentCrossLangId;
RenderToken(token, stringBuilder, isDeprecatedToken, isHiddenApiToken);
break;
}
Expand All @@ -228,11 +231,11 @@ protected virtual void StartDocumentationRange(StringBuilder stringBuilder) { }
protected virtual void CloseDocumentationRange(StringBuilder stringBuilder) { }

private void CaptureCodeLine(List<CodeLine> list, Dictionary<int, TreeNode<CodeLine>> sections, Stack<SectionType> nodesInProcess,
ref TreeNode<CodeLine> section, StringBuilder stringBuilder, ref int lineNumber, ref int leafSectionPlaceHolderNumber, ref string currentId,
ref TreeNode<CodeLine> section, StringBuilder stringBuilder, ref int lineNumber, ref int leafSectionPlaceHolderNumber, ref string currentId, ref string currentCrossLangId,
bool isDocumentationRange = false, bool isHiddenApiToken = false)
{
int? sectionKey = (nodesInProcess.Count > 0 && section == null) ? sections.Count : null;
CodeLine codeLine = new CodeLine(stringBuilder.ToString(), currentId, String.Empty, ++lineNumber, sectionKey, isDocumentation: isDocumentationRange, isHiddenApi: isHiddenApiToken);
CodeLine codeLine = new CodeLine(stringBuilder.ToString(), currentId, currentCrossLangId, String.Empty, ++lineNumber, sectionKey, isDocumentation: isDocumentationRange, isHiddenApi: isHiddenApiToken);
if (leafSectionPlaceHolderNumber != 0)
{
lineNumber += leafSectionPlaceHolderNumber - 1;
Expand Down
7 changes: 5 additions & 2 deletions src/dotnet/APIView/APIView/CodeLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace ApiView
{
public string DisplayString { get; }
public string ElementId { get; }
public string CrossLanguageDefinitionId { get; }
public string LineClass { get; }
public int? LineNumber { get; }
public int? SectionKey { get; }
Expand All @@ -15,10 +16,11 @@ namespace ApiView
public TreeNode<CodeLine> NodeRef { get; }
public bool IsHiddenApi { get; }

public CodeLine(string html, string id, string lineClass, int? lineNumber = null, int? sectionKey = null, int indent = 0, bool isDocumentation = false, TreeNode<CodeLine> nodeRef = null, bool isHiddenApi = false)
public CodeLine(string html, string id, string crossLangId, string lineClass, int? lineNumber = null, int? sectionKey = null, int indent = 0, bool isDocumentation = false, TreeNode<CodeLine> nodeRef = null, bool isHiddenApi = false)
{
this.DisplayString = html;
this.ElementId = id;
this.CrossLanguageDefinitionId = crossLangId;
this.LineClass = lineClass;
this.LineNumber = lineNumber;
this.SectionKey = sectionKey;
Expand All @@ -28,10 +30,11 @@ public CodeLine(string html, string id, string lineClass, int? lineNumber = null
this.IsHiddenApi = isHiddenApi;
}

public CodeLine(CodeLine codeLine, string html = null, string id = null, string lineClass = null, int? lineNumber = null, int? sectionKey = null, int indent = 0, bool isDocumentation = false, TreeNode<CodeLine> nodeRef = null, bool isHiddenApi = false)
public CodeLine(CodeLine codeLine, string html = null, string id = null, string crossLangId = null, string lineClass = null, int? lineNumber = null, int? sectionKey = null, int indent = 0, bool isDocumentation = false, TreeNode<CodeLine> nodeRef = null, bool isHiddenApi = false)
{
this.DisplayString = html ?? codeLine.DisplayString;
this.ElementId = id ?? codeLine.ElementId;
this.CrossLanguageDefinitionId = crossLangId ?? codeLine.CrossLanguageDefinitionId;
this.LineClass = lineClass ?? codeLine.LineClass;
this.LineNumber = lineNumber ?? codeLine.LineNumber;
this.SectionKey = sectionKey ?? codeLine.SectionKey;
Expand Down
4 changes: 2 additions & 2 deletions src/dotnet/APIView/APIView/Model/CodeFileToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public CodeFileToken(string value, CodeFileTokenKind kind, int? numberOfLinesinL
NavigateToId = null;
Kind = kind;
DefinitionId = null;
CrossLanguageDefId = null;
CrossLanguageDefinitionId = null;
NumberOfLinesinLeafSection = numberOfLinesinLeafSection;
}

Expand All @@ -20,7 +20,7 @@ public CodeFileToken(string value, CodeFileTokenKind kind, int? numberOfLinesinL

public CodeFileTokenKind Kind { get; set; }

public string CrossLanguageDefId { get; set; }
public string CrossLanguageDefinitionId { get; set; }

public int? NumberOfLinesinLeafSection { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/APIView/APIViewWeb/Client/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@import "./shared/sumo-select.scss";
@import "./shared/bootstraps-overrides.scss";
@import "./shared/off-canvas.scss";
@import "./shared/icons.scss";
@import "./shared/language-customizations.scss";
@import "./shared/codeline-navigation.scss";
@import "./shared/codeline.scss";
@import "./shared/comments.scss";
Expand Down
46 changes: 46 additions & 0 deletions src/dotnet/APIView/APIViewWeb/Client/css/shared/codeline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
animation: glow normal 1.5s ease-in-out;
}

.code-line.cl-active, .code-line tr.cl-active {
background: rgba(239,155,15, 0.22);
}

.code {
padding: 0px;
position: relative;
Expand Down Expand Up @@ -133,6 +137,48 @@
width: auto;
}

.cl-line-no {
color: goldenrod;
}

.cross-language-panel {
.nav-link {
color: var(--link-color);
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
background-color: transparent;
box-shadow: var(--box-shadow-left);
}

.nav-pills .nav-link {
border-radius: 0;
}

.badge {
background-color: var(--link-color);
border-color: var(--link-color);
color: var(--primary-btn-color);
}
}


.cross-language-pills-tab-content {
width: 55dvw;
margin-right: 5px;
max-height: 35dvh;
overflow: auto;
}

.cl-custom-popover {
--bs-popover-max-width: 200px;
--bs-popover-border-color: var(--bd-violet-bg);
--bs-popover-header-bg: var(--bd-violet-bg);
--bs-popover-header-color: var(--bs-white);
--bs-popover-body-padding-x: 1rem;
--bs-popover-body-padding-y: .5rem;
}

.line-comment-button:hover {
transform: scale(1);
text-decoration: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@
background: url(/icons/swagger-original.svg) center/contain no-repeat;
}

.icon-typespec {
@extend .icon-language;
background: url(/icons/typespec-original.svg) center center no-repeat;
}

.icon-comments {
cursor: pointer;
position: absolute;
Expand Down
Loading
Loading