Skip to content

Commit

Permalink
[Mono.Android] Improve generated API docs diff (#7427)
Browse files Browse the repository at this point in the history
Updates the `<UpdateExternalDocumentation/>` target to run the mdoc
`export-msxdoc` command for validation, and to include new files in the
diff that it produces.
  • Loading branch information
pjcollins authored Sep 30, 2022
1 parent 82d6fdb commit ca8f561
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Mono.Android/Mono.Android.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.Git" />
<UsingTask AssemblyFile="$(BootstrapTasksAssembly)" TaskName="Xamarin.Android.Tools.BootstrapTasks.CheckApiCompatibility" />
<Import Project="..\..\build-tools\scripts\XAVersionInfo.targets" />
<Import Project="..\..\bin\Build$(Configuration)\Mono.Android.Apis.projitems" Condition="Exists('..\..\bin\Build$(Configuration)\Mono.Android.Apis.projitems')"/>
Expand Down Expand Up @@ -292,7 +293,7 @@
<DocsApiLevel Condition=" '$(DocsApiLevel)' == '' ">31</DocsApiLevel>
<DocsPlatformId Condition=" '$(DocsPlatformId)' == '' ">31</DocsPlatformId>
<DocsFxVersion Condition=" '$(DocsFxVersion)' == '' ">v12.0</DocsFxVersion>
<_Binlog>$(MSBuildThisFileDirectory)../../bin/Build$(Configuration)/UpdateApiDocs-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss")).binlog</_Binlog>
<_LogPrefix>$(MSBuildThisFileDirectory)../../bin/Build$(Configuration)/UpdateApiDocs-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss"))</_LogPrefix>
</PropertyGroup>

<!-- Generate documentation using MDoc -->
Expand All @@ -312,7 +313,7 @@
<_BuildProps Include="-p:AndroidFrameworkVersion=$(DocsFxVersion)" />
</ItemGroup>
<Exec
Command="&quot;$(DotNetPreviewTool)&quot; build -v:n -c $(Configuration) -bl:$(_Binlog) @(_BuildProps, ' ')"
Command="&quot;$(DotNetPreviewTool)&quot; build -v:n -c $(Configuration) -bl:$(_LogPrefix).binlog @(_BuildProps, ' ')"
IgnoreStandardErrorWarningFormat="True"
WorkingDirectory="$(MSBuildThisFileDirectory)"
/>
Expand Down Expand Up @@ -365,15 +366,25 @@
Command="$(ManagedRuntime) $(ManagedRuntimeArgs) $(_Mdoc) --debug update --use-docid --delete $(_Libdir) $(_ImportXml) $(_Output) $(_DocTypeArgs) $(_FxConfig) $(_Lang)"
WorkingDirectory="$(MSBuildThisFileDirectory)"
/>
<!-- Ensure updated docs can also be exported to msxdoc format -->
<Exec
Command="$(ManagedRuntime) $(ManagedRuntimeArgs) $(_Mdoc) --debug export-msxdoc -o &quot;$(_LogPrefix)-Export.xml&quot; &quot;$(XamarinAndroidSourcePath)external/android-api-docs/docs/Mono.Android/en/&quot;"
WorkingDirectory="$(MSBuildThisFileDirectory)"
/>
</Target>

<Target Name="_GenerateApiDocsDiff">
<PropertyGroup>
<_DiffFile>$(XamarinAndroidSourcePath)bin/Build$(Configuration)/UpdateApiDocs$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss")).diff</_DiffFile>
</PropertyGroup>
<Exec
Command="git diff --output=&quot;$(_DiffFile)&quot;"
<Git
Arguments="add ."
WorkingDirectory="$(XamarinAndroidSourcePath)external/android-api-docs"
ToolPath="$(GitToolPath)"
ToolExe="$(GitToolExe)"
/>
<Git
Arguments="diff --cached --output=&quot;$(_LogPrefix).diff&quot;"
WorkingDirectory="$(XamarinAndroidSourcePath)external/android-api-docs"
ToolPath="$(GitToolPath)"
ToolExe="$(GitToolExe)"
/>
</Target>

Expand Down

0 comments on commit ca8f561

Please sign in to comment.