Skip to content

Commit 027d003

Browse files
davidfowlCopilotsebastienros
authored
Update polyglot spec for ATS docs (#17167)
* Update polyglot spec for ATS docs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify ATS docs fallback behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update docs/specs/polyglot-apphost.md Co-authored-by: Sébastien Ros <sebastienros@gmail.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Sébastien Ros <sebastienros@gmail.com>
1 parent 2786a91 commit 027d003

1 file changed

Lines changed: 75 additions & 4 deletions

File tree

docs/specs/polyglot-apphost.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ You run `aspire run`, and the CLI starts both the .NET AppHost server and your g
3939
- **DTO** - A serializable data transfer object (marked with `[AspireDto]`)
4040
- **Enum** - A .NET enum type that serializes as its string name
4141
- **Exported Value** - An immutable predefined value (marked with `[AspireValue]`) emitted into guest SDK catalogs
42+
- **Documentation** - Structured XML documentation captured during ATS scanning and emitted by guest SDK generators
4243

4344
---
4445

@@ -47,7 +48,7 @@ You run `aspire run`, and the CLI starts both the .NET AppHost server and your g
4748
ATS leverages .NET's rich type system rather than replacing it. The `[AspireExport]`, `[AspireDto]`, and `[AspireValue]` attributes mark what should be exposed—the rest is inferred from the C# signatures. This means:
4849

4950
- Integration authors write **normal C# extension methods**
50-
- The scanner **extracts types, parameters, and relationships** at build time
51+
- The scanner **extracts types, parameters, relationships, and documentation** at build time
5152
- Code generators produce **idiomatic APIs** in each target language
5253

5354
ATS then flattens .NET's polymorphism into a simple, portable model that any language can work with:
@@ -959,7 +960,67 @@ The CLI generates language-specific SDKs from ATS capabilities.
959960
1. Load assemblies from AppHost server build
960961
2. Scan for `[AspireExport]`, `[AspireDto]`, and `[AspireValue]` metadata using `AtsCapabilityScanner`
961962
3. Expand interface targets to concrete implementations
962-
4. Generate language-specific SDK, including predefined value catalogs
963+
4. Capture XML documentation for generated public SDK surfaces
964+
5. Generate language-specific SDK, including predefined value catalogs and documentation comments
965+
966+
### Documentation Model
967+
968+
ATS treats C# XML documentation as part of the code-generation model, not as export-shaping metadata. The scanner captures documentation into `AtsDocumentationInfo` so every language generator can choose how to render it.
969+
970+
Documentation is captured for:
971+
972+
- Exported handle and resource types
973+
- Capabilities, including summaries, remarks, returns, and parameters
974+
- Callback parameters
975+
- DTO types and DTO properties
976+
- Enum types and enum values
977+
- Exported value catalogs and exported values
978+
979+
`[AspireExport(Description = "...")]` remains compatibility metadata and is only used as a fallback summary when XML summary documentation is unavailable (either because the member has no XML documentation or because its `<summary>`/`<ats-summary>` text is missing). New API documentation should prefer XML docs so C# and generated guest SDK documentation stay tied together.
980+
981+
First-level `ats-*` tags override the matching standard XML documentation when generated SDKs need language-neutral or polyglot-specific text:
982+
983+
| Standard tag | ATS override |
984+
|--------------|--------------|
985+
| `<summary>` | `<ats-summary>` |
986+
| `<param name="...">` | `<ats-param name="...">` |
987+
| `<returns>` | `<ats-returns>` |
988+
| `<remarks>` | `<ats-remarks>` |
989+
990+
An empty `ats-*` override intentionally suppresses the matching standard documentation. This is useful when C# documentation is correct for .NET callers but misleading for generated guest language APIs.
991+
992+
```csharp
993+
/// <summary>
994+
/// Adds a PostgreSQL resource to the application model.
995+
/// </summary>
996+
/// <ats-summary>
997+
/// Adds a PostgreSQL server resource to the application model.
998+
/// </ats-summary>
999+
/// <param name="builder">The distributed application builder.</param>
1000+
/// <param name="name">The resource name.</param>
1001+
/// <ats-param name="name">The name used when referencing this resource from other resources.</ats-param>
1002+
/// <returns>The PostgreSQL resource builder.</returns>
1003+
[AspireExport("addPostgres")]
1004+
public static IResourceBuilder<PostgresServerResource> AddPostgres(
1005+
this IDistributedApplicationBuilder builder,
1006+
string name)
1007+
```
1008+
1009+
Language-neutral links use `ats-see` and `ats-seealso` with generated SDK identifiers instead of C# `cref` syntax:
1010+
1011+
```csharp
1012+
/// <summary>
1013+
/// Configures <ats-see cref="type:RedisResource" />.
1014+
/// </summary>
1015+
/// <remarks>
1016+
/// See <ats-see cref="method:RedisResource.withPersistence" /> and
1017+
/// <ats-see cref="field:RedisDefaults.Port" />.
1018+
/// </remarks>
1019+
```
1020+
1021+
The supported reference kinds are `type`, `method`, and `field`. The target uses dot notation over generated polyglot-visible identifiers and must not use C# generic type syntax. TypeScript currently renders these references as JSDoc `{@link ...}` tags.
1022+
1023+
TypeScript renders captured documentation as JSDoc on generated classes, interfaces, enums, enum values, exported values, methods, method parameters, callback option parameters, and return values. Other language generators should consume the same `AtsDocumentationInfo` model and render documentation in the idiomatic format for that language.
9631024

9641025
### Capability Expansion
9651026

@@ -1487,18 +1548,28 @@ public sealed class AtsContext
14871548
- `ExpandedTargetTypeIds` - Concrete types for interface targets
14881549
- `ReturnType` - Return type reference with category
14891550
- `Parameters` - List of parameter info
1490-
- `Description` - Documentation
1551+
- `Description` - Compatibility/fallback summary metadata
1552+
- `Documentation` - Structured XML documentation for generated SDKs
14911553

14921554
**AtsEnumTypeInfo** contains:
14931555
- `TypeId` - Enum type ID
14941556
- `Name` - Simple enum name (e.g., `ContainerLifetime`)
14951557
- `Values` - List of enum member names
1558+
- `ValueInfos` - Enum member names with documentation
1559+
- `Documentation` - Structured XML documentation for the enum type
14961560

14971561
**AtsExportedValueInfo** contains:
14981562
- `PathSegments` - Guest SDK catalog path segments (for example, `["FoundryModels", "OpenAI", "Gpt41Mini"]`)
14991563
- `Type` - ATS type metadata for the snapped value
15001564
- `Value` - Snapped JSON payload emitted into guest SDKs
1501-
- `Description` - Optional XML documentation summary
1565+
- `Description` - Optional compatibility/fallback summary metadata
1566+
- `Documentation` - Structured XML documentation for the exported value
1567+
1568+
**AtsDocumentationInfo** contains:
1569+
- `Summary` - Summary text
1570+
- `Remarks` - Longer remarks text
1571+
- `Returns` - Return value documentation
1572+
- `Parameters` - List of parameter documentation entries, each with the C# parameter name and description
15021573

15031574
**Generation steps:**
15041575

0 commit comments

Comments
 (0)