Skip to content

Commit

Permalink
feat: Generate more useful descriptions for REST packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jskeet committed Apr 9, 2024
1 parent 89f4a14 commit e95ae48
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions Google.Api.Generator.Rest/Models/PackageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,35 @@ int GetRevision()

string GetApiDescription()
{
// Unhelpful documentation links found by browsing Discovery docs.
string[] nonProductDocLinks =
{
"https://cloud.google.com/",
"https://cloud.google.com/learnmoreurl",
"https://cloud.google.com/support/docs/apis",
"https://www.google.com"
};

string upperCamelApiName = ApiName.ToUpperCamelCase(upperAfterDigit: false);
var prefix = _features.CloudPackageMap.TryGetValue(PackageName, out var cloudPackage)
? $@"
This is not the recommended package for working with {upperCamelApiName}, please use the {cloudPackage} package.
This Google APIs Client Library for working with {upperCamelApiName} {ApiVersion} uses older code generation, and is harder to use."
: $"\n Google APIs Client Library for working with {upperCamelApiName} {ApiVersion}.";
// Some packages have useful product documentation, but not all.
string productDocSection = _discoveryDoc.DocumentationLink is string productLink && !nonProductDocLinks.Contains(productLink) ? $@"
Product documentation is available at:
{productLink}" : "";
// The part of the package description that's the same for all packages - but can't be a constant due to the ApiName/ApiVersion part of the link.
string suffix = @$"
API reference documentation for this package is available at:
https://googleapis.dev/dotnet/{PackageName}/latest/api/{PackageName}.html
The source code for this package is available at:
https://github.com/google/google-api-dotnet-client/tree/master/Src/Generated/{PackageName}
Supported Platforms:
- .NET Framework 4.6.2+
- .NET Standard 2.0
Expand All @@ -406,15 +426,9 @@ string GetApiDescription()
- Windows 8 Apps
- Windows Phone 8.1
- Windows Phone Silverlight 8.0
More documentation on the API is available at:
https://developers.google.com/api-client-library/dotnet/apis/{ApiName}/{ApiVersion}
The package source code is available at:
https://github.com/google/google-api-dotnet-client/tree/master/Src/Generated
";

return prefix + suffix;
return prefix + productDocSection + suffix;
}

XElement PackageReference(string name, string version, params XAttribute[] extraAttributes) =>
Expand Down

0 comments on commit e95ae48

Please sign in to comment.