-
Notifications
You must be signed in to change notification settings - Fork 635
TypeSpec: new parser #4243
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
base: master
Are you sure you want to change the base?
TypeSpec: new parser #4243
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Name.Space input.tsp /^namespace Name.Space;$/;" n | ||
Versions input.tsp /^enum Versions {$/;" g | ||
OpA input.tsp /^op OpA<T extends TypeSpec.Reflection.Model> is OpB<$/;" o | ||
InterfaceA input.tsp /^interface InterfaceA extends InterfaceB {$/;" i | ||
opA input.tsp /^ opA is OpA<{$/;" p interface:InterfaceA | ||
opB input.tsp /^ opB: url;$/;" p interface:InterfaceA | ||
UnionA input.tsp /^union UnionA {$/;" u | ||
ModelA input.tsp /^model ModelA {$/;" m | ||
contentA input.tsp /^ contentA: ModelB;$/;" p model:ModelA | ||
contentB input.tsp /^ contentB?: boolean;$/;" p model:ModelA | ||
AliasA input.tsp /^alias AliasA<$/;" a |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import "@typespec/http"; | ||
import "./common.tsp"; | ||
|
||
using TypeSpec; | ||
using TypeSpec.Rest; | ||
|
||
@armProviderNamespace | ||
@service(#{ title: "Name.Space" }) | ||
@versioned(Versions) | ||
@armCommonTypesVersion(CommonTypes.Versions.v3) | ||
namespace Name.Space; | ||
|
||
@doc("API Versions") | ||
enum Versions { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we fill the scope: field of
If you're interested in implementing it in this pull request, talk to me. I have some hints. Let's call the above three items NYY-choice. |
||
@doc("May 01, 2024 Preview API Version") | ||
v2024_05_01_preview: "2024-05-01-preview", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we extract NYY-choice. |
||
} | ||
|
||
@summary("Example operation summary for demonstration purposes.") | ||
@doc(""" | ||
Example | ||
multi-line | ||
documentation. | ||
""") | ||
@returnsDoc("Example return documentation") | ||
@post | ||
op OpA<T extends TypeSpec.Reflection.Model> is OpB< | ||
T & ModelA, | ||
ModelB<ModelA[]> | ||
>; | ||
|
||
interface InterfaceA extends InterfaceB { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can fill Filling such a field makes your work applicable to broader use cases. Here is an example of C++. $ cat /tmp/foo.cc
class A: B {
int x;
};
$ ./ctags -o - /tmp/foo.cc
A /tmp/foo.cc /^class A: B {$/;" c file:
x /tmp/foo.cc /^ int x;$/;" m class:A typeref:typename:int file:
$ ./ctags --fields=+i -o - /tmp/foo.cc
A /tmp/foo.cc /^class A: B {$/;" c file: inherits:B
x /tmp/foo.cc /^ int x;$/;" m class:A typeref:typename:int file:
$ ./ctags --fields=+i -o foo.tags /tmp/foo.cc
$ ~/bin/querytags --tag-file foo.tags class-hierarchy A
A
B |
||
opA is OpA<{ | ||
@doc("The format of the HTTP payload.") | ||
@header | ||
contentType: "application/json"; | ||
|
||
@clientName("uri", "csharp") | ||
@doc("Example URL parameter.") | ||
opB: url; | ||
}>; | ||
|
||
/** | ||
* Example operation description | ||
*/ | ||
opB is OpB< | ||
ModelA, | ||
{ | ||
...ModelB | ||
} | ||
>; | ||
} | ||
|
||
@doc("Example union type description.") | ||
union UnionA { | ||
string, | ||
|
||
@doc("Example option A description with some technical details that would be typical for this kind of documentation.") | ||
"unionA", | ||
|
||
@doc("Example option B description with additional technical context that would be common in API documentation.") | ||
"unionB", | ||
} | ||
|
||
@doc("Example model description.") | ||
model ModelA { | ||
@doc("Example property description.") | ||
contentA: ModelB; | ||
|
||
@removed(Versions.v1_2) | ||
@doc("Example boolean property with typical documentation about its purpose and default behavior.") | ||
contentB?: boolean; | ||
|
||
...ModelX; | ||
} | ||
|
||
|
||
alias AliasA< | ||
TParamA extends ModelX, | ||
TParamB, | ||
TParamC extends ModelX = {}, | ||
TError = Error | ||
> = ModelB<TParamA, TParamB, TParamC, TError>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's increase the testing coverage, though. We don't have a target percentage. E.g., the code skipping
is not tested at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. String literal including |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested in extracting
import
ed items andusing
ed items.I will work on them after merging this pull request.
#3906
#2428