-
Notifications
You must be signed in to change notification settings - Fork 344
[specs] add documentation test #8929
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@typespec/http-specs" | ||
| --- | ||
|
|
||
| add test for documentation generation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| import "@typespec/http"; | ||
| import "@typespec/spector"; | ||
|
|
||
| using Http; | ||
| using Spector; | ||
|
|
||
| @scenarioService("/documentation") | ||
| @doc("Illustrates documentation generation and formatting features") | ||
| namespace Documentation; | ||
|
|
||
| @route("/lists") | ||
| namespace Lists { | ||
| /** | ||
| * This tests: | ||
| * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines. | ||
| * - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation. | ||
| * - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output. | ||
| * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases. | ||
| * - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines. | ||
| * - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines. | ||
| */ | ||
| @scenario | ||
| @scenarioDoc(""" | ||
| Test simple bullet points in documentation. | ||
| Expected behavior: Should render properly formatted bullet lists. | ||
| """) | ||
| @get | ||
| @route("/bullet-points/op") | ||
| op bulletPointsOp(): NoContentResponse; | ||
|
|
||
| /** | ||
| * This tests: | ||
| * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines. | ||
| * - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation. | ||
| * - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output. | ||
| * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases. | ||
| * - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines. | ||
| * - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines. | ||
| */ | ||
| model BulletPointsModel { | ||
| /** | ||
| * This property uses an enum with bullet point documentation. The enum documentation includes various formatting styles to test rendering. The styles are: | ||
| * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines. | ||
| * - Bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple | ||
| * - Bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output. | ||
| * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases. | ||
| * - **Bold bullet point** | ||
| * - *Italic bullet point* | ||
| */ | ||
| prop: BulletPointsEnum; | ||
| } | ||
|
|
||
| /** | ||
| * This tests really long bullet points in enum documentation to see how wrapping and formatting are handled. This should wrap around correctly and maintain proper indentation for each line. | ||
| * - Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines. | ||
| * - Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation. | ||
| * - Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output. | ||
| * - Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases. | ||
| * - **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines. | ||
| * - *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines. | ||
| */ | ||
| enum BulletPointsEnum { | ||
| /** | ||
| * Simple bullet point. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| * - One: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| * - Two: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| */ | ||
| Simple: "Simple", | ||
|
|
||
| /** | ||
| * Bullet point with **bold text**. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| * - **One**: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| * - **Two**: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| */ | ||
| Bold: "Bold", | ||
|
|
||
| /** | ||
| * Bullet point with *italic text*. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| * - *One*: one. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| * - *Two*: two. This line is intentionally long to test text wrapping in bullet points within enum documentation comments. It should properly indent the wrapped lines. | ||
| */ | ||
| Italic: "Italic", | ||
| } | ||
|
|
||
| @scenarioDoc(""" | ||
| Test bullet points in model and enum documentation. | ||
| Expected input: | ||
| ```json | ||
| { | ||
| "prop": "Simple" | ||
| } | ||
| ``` | ||
| """) | ||
| @post | ||
| @route("/bullet-points/model") | ||
| op bulletPointsModel(input: BulletPointsModel): NoContentResponse; | ||
iscai-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Steps to follow: | ||
| * 1. First step with **important** note | ||
| * 2. Second step with *emphasis* | ||
| * 3. Third step combining **bold** and *italic* | ||
| * 4. **Final step**: Review all steps for *accuracy*. | ||
| */ | ||
| @scenario | ||
| @scenarioDoc(""" | ||
| Test numbered lists. | ||
| Expected behavior: Should render numbered list properly. | ||
| """) | ||
| @route("/numbered") | ||
| @get | ||
| op numbered(): NoContentResponse; | ||
| } | ||
|
|
||
| @route("/text-formatting") | ||
| namespace TextFormatting { | ||
| /** | ||
| * This is **bold text** in the middle of a sentence. | ||
| * This is a sentence with **multiple bold** sections and **another bold** section. | ||
| * **This entire sentence is bold.** | ||
| */ | ||
| @scenario | ||
| @scenarioDoc(""" | ||
| Expected behavior: Text between ** should render as bold. | ||
| """) | ||
| @route("/bold") | ||
| @get | ||
| op boldText(): NoContentResponse; | ||
|
|
||
| /** | ||
| * This is *italic text* in the middle of a sentence. | ||
| * This is a sentence with *multiple italic* sections and *another italic* section. | ||
| * *This entire sentence is italic.* | ||
| * */ | ||
| @scenario | ||
| @scenarioDoc(""" | ||
| Test italic text formatting using *single asterisks*. | ||
| Expected behavior: Text between * should render as italic. | ||
| """) | ||
| @route("/italic") | ||
| @get | ||
| op italicText(): NoContentResponse; | ||
|
|
||
| /** | ||
| * This sentence has **bold**, *italic*, and ***bold italic*** text. | ||
| * You can also combine them like **bold with *italic inside* bold**. | ||
| * Or *italic with **bold inside** italic*. | ||
| * This is a sentence with **bold**, *italic*, and ***bold italic*** text. | ||
| */ | ||
| @scenario | ||
| @scenarioDoc(""" | ||
| Test combined bold and italic formatting. | ||
| Expected behavior: Should handle nested and combined formatting. | ||
| """) | ||
| @route("/combined") | ||
| @get | ||
| op combinedFormatting(): NoContentResponse; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; | ||
|
|
||
| export const Scenarios: Record<string, ScenarioMockApi> = {}; | ||
|
|
||
| function createGetServerTests(uri: string) { | ||
| return passOnSuccess({ | ||
| uri, | ||
| method: "get", | ||
| request: {}, | ||
| response: { | ||
| status: 204, | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }); | ||
| } | ||
|
|
||
| function createPostServerTests(uri: string, requestBody: unknown, responseBody?: unknown) { | ||
| return passOnSuccess({ | ||
| uri, | ||
| method: "post", | ||
| request: { | ||
| body: json(requestBody), | ||
| }, | ||
| response: { | ||
| status: 200, | ||
| body: responseBody ? json(responseBody) : undefined, | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }); | ||
| } | ||
|
|
||
| // Lists namespace tests | ||
| Scenarios.Documentation_Lists_bulletPointsOp = createGetServerTests( | ||
| "/documentation/lists/bullet-points/op", | ||
| ); | ||
|
|
||
| Scenarios.Documentation_Lists_bulletPointsModel = createPostServerTests( | ||
| "/documentation/lists/bullet-points/model", | ||
| { | ||
| prop: "Simple", | ||
| }, | ||
| ); | ||
|
|
||
| Scenarios.Documentation_Lists_numbered = createGetServerTests("/documentation/lists/numbered"); | ||
|
|
||
| // TextFormatting namespace tests | ||
| Scenarios.Documentation_TextFormatting_boldText = createGetServerTests( | ||
| "/documentation/text-formatting/bold", | ||
| ); | ||
|
|
||
| Scenarios.Documentation_TextFormatting_italicText = createGetServerTests( | ||
| "/documentation/text-formatting/italic", | ||
| ); | ||
|
|
||
| Scenarios.Documentation_TextFormatting_combinedFormatting = createGetServerTests( | ||
| "/documentation/text-formatting/combined", | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.