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

feat(csharp): Generate README.md #4455

Merged
merged 8 commits into from
Aug 29, 2024
Merged

feat(csharp): Generate README.md #4455

merged 8 commits into from
Aug 29, 2024

Conversation

amckinney
Copy link
Contributor

@amckinney amckinney commented Aug 28, 2024

Overview

This adds support for generating C# README.md files by interfacing with the generator-cli (via the CsharpGeneratorAgent type).

The following sections are generated for all README.md files:

  • Installation
  • Usage
  • Exception Handling
  • Retries (Advanced)
  • Timeouts (Advanced)

Implementation

This updates the shared AbstractGeneratorAgent type so that it consolidates more of the shared logic required to produce README.md and reference.md files (e.g. reading the features.yml, producing the GitHub remote configuration, etc). The generator is expected to implement an interface that looks like the following:

export class CsharpGeneratorAgent extends AbstractGeneratorAgent<SdkGeneratorContext> {
    private readmeConfigBuilder: ReadmeConfigBuilder;

    public getReadmeConfig(
        args: AbstractGeneratorAgent.ReadmeConfigArgs<SdkGeneratorContext>
    ): FernGeneratorCli.ReadmeConfig {
        return this.readmeConfigBuilder.build({
            context: args.context,
            remote: args.remote,
            featureConfig: args.featureConfig,
            endpointSnippets: args.endpointSnippets
        });
    }

    public getLanguage(): FernGeneratorCli.Language {
        return FernGeneratorCli.Language.Csharp;
    }
}

The ReadmeConfigBuilder used here is scoped to each language, but it shares a similar structure between each implementation (i.e. it interacts with a ReadmeSnippetBuilder and produces the corresponding FernGeneratorCli.LanguageInfo).

Future improvements

There's additional functionality we can consolidate in the new AbstractReadmeSnippetBuilder.

For now, both of the language-specific implementations have their own representation of the IR's HttpEndpoint (which is extended to include a FernFilepath). Once the HttpEndpoint itself has the FernFilepath, we can easily refactor the AbstractReadmeSnippetBuilder as a generic type, and DRY up many of the helper functions (e.g. buildEndpoints, getEndpointsForFeature, etc).

@amckinney amckinney merged commit f01601c into main Aug 29, 2024
33 checks passed
@amckinney amckinney deleted the amckinney/csharp/readme branch August 29, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants