Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DOCFX_PREVIEW_BUILD)' == 'true'">net8.0;net10.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks Condition="'$(DOCFX_PREVIEW_BUILD)' == 'true'">net8.0</TargetFrameworks>
Comment on lines -4 to +5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we downgrading .NET

<LangVersion>Preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
Expand Down
25 changes: 21 additions & 4 deletions src/Docfx.Build/ApiPage/ApiPageMarkdownTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,27 @@ public static string Render(ApiPage page)

FormattableString Api(Api api) => api.Value switch
{
Api1 api1 => ToHeading(1, api1.api1, api1.id),
Api2 api2 => ToHeading(2, api2.api2, api2.id),
Api3 api3 => ToHeading(3, api3.api3, api3.id),
Api4 api4 => ToHeading(4, api4.api4, api4.id),
Api1 api1 => CombineFormattableStrings(ToHeading(1, api1.api1, api1.id), PreviewAlertNullable(api1.preview)),
Api2 api2 => CombineFormattableStrings(ToHeading(2, api2.api2, api2.id), PreviewAlertNullable(api2.preview)),
Api3 api3 => CombineFormattableStrings(ToHeading(3, api3.api3, api3.id), PreviewAlertNullable(api3.preview)),
Api4 api4 => CombineFormattableStrings(ToHeading(4, api4.api4, api4.id), PreviewAlertNullable(api4.preview)),
};

FormattableString CombineFormattableStrings(FormattableString first, FormattableString second) =>
$"{first}{second}";

FormattableString PreviewAlertNullable(OneOf.OneOf<bool, string>? preview)
{
if (preview == null) return $"";

if (preview.Value.IsT0 && preview.Value.AsT0)
return $"> [!NOTE]\n> This API is experimental.\n\n";

if (preview.Value.IsT1)
return $"> [!NOTE]\n> {preview.Value.AsT1}\n\n";

return $"";
}

FormattableString ToHeading(int level, string title, string? id = null) =>
$"{new string('#', level)}{(string.IsNullOrEmpty(id) ? null : $" <a id=\"{id}\"></a>")} {Escape(title)}\n\n";
Expand Down Expand Up @@ -76,6 +92,7 @@ FormattableString Parameters(Parameters parameters) =>
? $"`{parameter.name}`"
: $"`{parameter.name} = {parameter.@default}`")} {Inline(parameter.type)}

{(parameter.preview == null ? "" : (parameter.preview.Value.IsT0 ? $"> [!NOTE]\n> This parameter is experimental.\n\n" : $"> [!NOTE]\n> {parameter.preview.Value.AsT1}\n\n"))}
{(string.IsNullOrEmpty(parameter.description) ? null : $"{parameter.description}\n\n")}
""";

Expand Down