Skip to content

Commit 846ed4d

Browse files
committed
[Mono.Android] Add UpdateExternalDocumentation target
Fixes: #5200 Context: a7413a2 Context: xamarin/android-api-docs#23 Context: https://review.docs.microsoft.com/en-us/engineering/projects/reference/dotnet/mdoc Add a new `UpdateExternalDocumentation` target which: 1. *Rebuilds* `src/Mono.Android` with `$(IncludeAndroidJavadoc)`=True. This produces a `Mono.Anroid.xml` file containing imported API-30 Javadoc. This *also* produces the log file `src/Mono.Android/UpdateExternalDocumentation-{TIME}.binlog`, which contains the build output for the rebuild. 2. Runs `mdoc update --import Mono.Android.xml --use-docid`, updating the [**mdoc**(5) documentation][0] within `external/android-api-docs/docs/Mono.Android/en` The `--use-docid` flag is needed for integration with the documentation infrastructure. Usage: msbuild /t:UpdateExternalDocumentation src/Mono.Android/Mono.Android.csproj This process takes ~60 minutes on my machine. Note: This uses the [mdoc NuGet package][1]. [0]: http://docs.go-mono.com/?link=man%3amdoc(5) [1]: https://www.nuget.org/packages/mdoc/
1 parent 16e0aa2 commit 846ed4d

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/Mono.Android/Mono.Android.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<PropertyGroup>
2727
<IncludeAndroidJavadoc Condition=" '$(IncludeAndroidJavadoc)' == '' And '$(CONVERT_JAVADOC_TO_XMLDOC)' == 'true' And '$(AndroidFrameworkVersion)' == '$(AndroidLatestStableFrameworkVersion)'">True</IncludeAndroidJavadoc>
28-
<AndroidJavadocVerbosity Condition=" '$(AndroidJavadocVerbosity)' == '' ">intellisense</AndroidJavadocVerbosity>
28+
<AndroidJavadocVerbosity Condition=" '$(AndroidJavadocVerbosity)' == '' ">intellisense+extraremarks</AndroidJavadocVerbosity>
2929
</PropertyGroup>
3030

3131
<PropertyGroup Condition=" '$(IncludeAndroidJavadoc)' == 'True' ">

src/Mono.Android/Mono.Android.targets

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
<ItemGroup>
88
<Compile Include="$(IntermediateOutputPath)AssemblyInfo.cs" />
99
</ItemGroup>
10+
<ItemGroup>
11+
<PackageReference Include="mdoc"
12+
PackageVersion="5.8.0"
13+
GeneratePathProperty="True"
14+
ReferenceOutputAssembly="False"
15+
SkipGetTargetFrameworkProperties="True"
16+
/>
17+
</ItemGroup>
1018
<Target Name="_BuildJavaInterop"
1119
BeforeTargets="BeforeResolveReferences"
1220
Condition=" '$(TargetFramework)' == 'monoandroid10' "
@@ -157,7 +165,7 @@
157165
<_TypeMap>--type-map-report=$(IntermediateOutputPath)mcw\type-mapping.txt</_TypeMap>
158166
<_Api>$(IntermediateOutputPath)mcw\api.xml</_Api>
159167
<_Dirs>--enumdir=$(IntermediateOutputPath)mcw</_Dirs>
160-
<_WithJavadocXml Condition=" '$(IncludeAndroidJavadoc)' == 'True' ">--doc-comment-verbosity=$(AndroidJavadocVerbosity) "--with-javadoc-xml=$(_AndroidJavadocXml)"</_WithJavadocXml>
168+
<_WithJavadocXml Condition=" '$(IncludeAndroidJavadoc)' == 'True' ">"--doc-comment-verbosity=$(AndroidJavadocVerbosity)" "--with-javadoc-xml=$(_AndroidJavadocXml)"</_WithJavadocXml>
161169
<_FullIntermediateOutputPath>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)'))</_FullIntermediateOutputPath>
162170
<_LangFeatures>--lang-features=nullable-reference-types</_LangFeatures>
163171
<_LangFeatures Condition="$(AndroidApiLevel) &gt;= 30">$(_LangFeatures),default-interface-methods,nested-interface-types,interface-constants</_LangFeatures>
@@ -260,4 +268,29 @@
260268
<FileWrites Include="$(IntermediateOutputPath)CheckApiCompatibility.stamp" />
261269
</ItemGroup>
262270
</Target>
271+
272+
<Target Name="UpdateExternalDocumentation">
273+
<Exec Command="git clean -xdf obj" WorkingDirectory="$(MSBuildThisFileDirectory)" />
274+
<PropertyGroup>
275+
<_Binlog>UpdateExternalDocumentation-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss")).binlog</_Binlog>
276+
</PropertyGroup>
277+
<Exec
278+
Command="msbuild /restore /p:IncludeAndroidJavadoc=True /bl:$(_Binlog)"
279+
IgnoreStandardErrorWarningFormat="True"
280+
WorkingDirectory="$(MSBuildThisFileDirectory)"
281+
/>
282+
<PropertyGroup>
283+
<_Mdoc Condition=" '$(Pkgmdoc)' != '' ">"$(Pkgmdoc)/tools/mdoc.exe"</_Mdoc>
284+
<_Mdoc Condition=" '$(_Mdoc)' == '' ">"$(MSBuildThisFileDirectory)../../packages/mdoc/5.0.0.25/tools/mdoc.exe"</_Mdoc>
285+
<_Libdir>-L "$(XAInstallPrefix)/xbuild-frameworks/MonoAndroid/v1.0"</_Libdir>
286+
<_AssemblyBasename>$(XAInstallPrefix)/xbuild-frameworks/MonoAndroid/$(AndroidFrameworkVersion)/Mono.Android</_AssemblyBasename>
287+
<_ImportXml>-i "$(_AssemblyBasename).xml"</_ImportXml>
288+
<_Assembly>"$(_AssemblyBasename).dll"</_Assembly>
289+
<_Output>-o "$(MSBuildThisFileDirectory)../../external/android-api-docs/docs/Mono.Android/en"</_Output>
290+
</PropertyGroup>
291+
<Exec
292+
Command="$(ManagedRuntime) $(ManagedRuntimeArgs) $(_Mdoc) --debug update --use-docid --delete $(_Libdir) $(_ImportXml) $(_Output) $(_Assembly)"
293+
WorkingDirectory="$(MSBuildThisFileDirectory)"
294+
/>
295+
</Target>
263296
</Project>

0 commit comments

Comments
 (0)