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

[js-apiview-parser] update CodeFile models from schemas #9256

Merged
merged 4 commits into from
Nov 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
/tools/apiview/emitters/typespec-apiview @tjprescott
/tools/apiview/parsers/cpp-api-parser @LarryOsterman
/tools/apiview/parsers/csharp-api-parser @christothes
/tools/apiview/parsers/js-api-parser @maorleger
/tools/apiview/parsers/js-api-parser @jeremymeng @maorleger
/src/swift @tjprescott
/src/java/apiview-java-processor @JonathanGiles
/src/go @jhendrixMSFT @chlowell @RickWinter
Expand Down
4 changes: 4 additions & 0 deletions tools/apiview/parsers/js-api-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.4

- update models from latest CodeFile schemas

# 2.0.3

- add `SkipDiff: true` for dependency header line
Expand Down
2 changes: 1 addition & 1 deletion tools/apiview/parsers/js-api-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/ts-genapi",
"version": "2.0.3",
"version": "2.0.4",
"description": "",
"main": "index.js",
"publishConfig": {
Expand Down
7 changes: 6 additions & 1 deletion tools/apiview/parsers/js-api-parser/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,19 @@ function buildDependencies(reviewLines: ReviewLine[], dependencies: Record<strin
const nameToken: ReviewToken = buildToken({
Kind: TokenKind.StringLiteral,
Value: dependency,
SkipDiff: true,
});
const versionToken: ReviewToken = buildToken({
Kind: TokenKind.StringLiteral,
Value: ` ${dependencies[dependency]}`,
SkipDiff: true,
});
const dependencyLine: ReviewLine = {
Tokens: [nameToken, buildToken({ Kind: TokenKind.Punctuation, Value: ":" }), versionToken],
Tokens: [
nameToken,
buildToken({ Kind: TokenKind.Punctuation, Value: ":", SkipDiff: true }),
versionToken,
],
};
dependencyLines.push(dependencyLine);
}
Expand Down
22 changes: 18 additions & 4 deletions tools/apiview/parsers/js-api-parser/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ export interface CodeFile {
/** Language variant is applicable only for java variants */
LanguageVariant?: "None" | "Spring" | "Android";
CrossLanguagePackageId?: string;
ReviewLines: ReviewLine[];
ReviewLines: Array<ReviewLine>;
/** Add any system generated comments. Each comment is linked to review line ID */
Diagnostics?: CodeDiagnostic[];
Diagnostics?: Array<CodeDiagnostic>;
/**
* Navigation items are used to create a tree view in the navigation panel. Each navigation item is linked to a review line ID. This is optional.
* If navigation items are not provided then navigation panel will be automatically generated using the review lines. Navigation items should be provided only if you want to customize the navigation panel.
*/
Navigation?: Array<NavigationItem>;
}

/** ReviewLine object corresponds to each line displayed on API review. If an empty line is required then add a code line object without any token. */
Expand All @@ -40,12 +45,12 @@ export interface ReviewLine {
LineId?: string;
CrossLanguageId?: string;
/** list of tokens that constructs a line in API review */
Tokens: ReviewToken[];
Tokens: Array<ReviewToken>;
/**
* Add any child lines as children. For e.g. all classes and namespace level methods are added as a children of namespace(module) level code line.
* Similarly all method level code lines are added as children of it's class code line.
*/
Children?: ReviewLine[];
Children?: Array<ReviewLine>;
/** Set current line as hidden code line by default. .NET has hidden APIs and architects don't want to see them by default. */
IsHidden?: boolean;
/** Set current line as context end line. For e.g. line with token } or empty line after the class to mark end of context. */
Expand Down Expand Up @@ -77,6 +82,8 @@ export interface ReviewToken {
IsDeprecated?: boolean;
/** Set this to false if there is no suffix space required before next token. For e.g, punctuation right after method name */
HasSuffixSpace?: boolean;
/** Set this to true if there is a prefix space required before current token. For e.g, space before token for = */
HasPrefixSpace?: boolean;
/** Set isDocumentation to true if current token is part of documentation */
IsDocumentation?: boolean;
/** Language specific style css class names */
Expand All @@ -95,6 +102,13 @@ export interface CodeDiagnostic {
HelpLinkUri?: string;
}

export interface NavigationItem {
Text: string;
NavigationId: string;
ChildItems: Array<NavigationItem>;
Tags: Record<string, string>;
}

export enum TokenKind {
Text = 0,
Punctuation = 1,
Expand Down