Skip to content

Commit cee5e72

Browse files
authored
[Mono.Android] Add UpdateExternalDocumentation target (#5485)
Context: a7413a2 Context: #5200 Context: xamarin/android-api-docs#23 Context: https://review.docs.microsoft.com/en-us/engineering/projects/reference/dotnet/mdoc Add a new `UpdateExternalDocumentation` target to `src/Mono.Android/Mono.Android.csproj` which: 1. *Rebuilds* `src/Mono.Android` with `$(IncludeAndroidJavadoc)`=True. This produces a `Mono.Anroid.xml` file containing imported API-30 Javadoc. On macOS, 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. Additionally, add a new `RunMdoc` target, which just runs the `mdoc update --import…` command. This is useful for one-off testing. The `UpdateExternalDocumentation` and `RunMdoc` targets also takes an optional `$(DocTypeName)` MSBuild property, which is used to restrict the types that `mdoc update` will update: msbuild /p:DocTypeName=Java.Lang.Object /t:UpdateExternalDocumentation src/Mono.Android/Mono.Android.csproj # -or- msbuild /p:DocTypeName=Java.Lang.Object /t:RunMdoc src/Mono.Android/Mono.Android.csproj 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/5.8.0
1 parent 1bb7602 commit cee5e72

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

src/Mono.Android/Mono.Android.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
<OutputPath>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\$(TargetFramework)\</OutputPath>
4747
</PropertyGroup>
4848

49+
<PropertyGroup>
50+
<IncludeAndroidJavadoc Condition=" '$(IncludeAndroidJavadoc)' == '' And '$(CONVERT_JAVADOC_TO_XMLDOC)' == 'true' And '$(AndroidFrameworkVersion)' == '$(AndroidLatestStableFrameworkVersion)'">True</IncludeAndroidJavadoc>
51+
<AndroidJavadocVerbosity Condition=" '$(AndroidJavadocVerbosity)' == '' ">intellisense+extraremarks</AndroidJavadocVerbosity>
52+
</PropertyGroup>
53+
54+
<PropertyGroup Condition=" '$(IncludeAndroidJavadoc)' == 'True' ">
55+
<DocumentationFile>$(OutputPath)Mono.Android.xml</DocumentationFile>
56+
<NoWarn>$(NoWarn);CS1572;CS1573;CS1574;CS1584;CS1587;CS1591;CS1658;</NoWarn>
57+
</PropertyGroup>
58+
4959
<PropertyGroup>
5060
<JavaCallableWrapperAbsAssembly>$([System.IO.Path]::GetFullPath ('$(OutputPath)$(AssemblyName).dll'))</JavaCallableWrapperAbsAssembly>
5161
</PropertyGroup>

src/Mono.Android/Mono.Android.targets

Lines changed: 57 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,52 @@
260268
<FileWrites Include="$(IntermediateOutputPath)CheckApiCompatibility.stamp" />
261269
</ItemGroup>
262270
</Target>
271+
272+
<Target Name="UpdateExternalDocumentation">
273+
<MSBuild Projects="$(MSBuildThisFileDirectory)Mono.Android.csproj"
274+
Properties="TargetFramework=monoandroid10"
275+
Targets="_UpdateExternalDocumentation;_RunMdoc"
276+
/>
277+
</Target>
278+
<Target Name="_UpdateExternalDocumentation">
279+
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
280+
<PropertyGroup>
281+
<_Binlog>UpdateExternalDocumentation-$([System.DateTime]::Now.ToString ("yyyyMMddTHHmmss")).binlog</_Binlog>
282+
</PropertyGroup>
283+
<Exec
284+
Condition=" '$(HostOS)' != 'Windows' "
285+
Command="msbuild /restore /p:Configuration=$(Configuration) /p:IncludeAndroidJavadoc=True /bl:$(_Binlog)"
286+
IgnoreStandardErrorWarningFormat="True"
287+
WorkingDirectory="$(MSBuildThisFileDirectory)"
288+
/>
289+
<MSBuild
290+
Condition=" '$(HostOS)' == 'Windows' "
291+
Projects="$(MSBuildThisFileDirectory)Mono.Android.csproj"
292+
Properties="IncludeAndroidJavadoc=True"
293+
Targets="Restore;Build"
294+
/>
295+
</Target>
296+
297+
<Target Name="RunMdoc">
298+
<MSBuild Projects="$(MSBuildThisFileDirectory)Mono.Android.csproj"
299+
Properties="TargetFramework=monoandroid10"
300+
Targets="_RunMdoc"
301+
/>
302+
</Target>
303+
<Target Name="_RunMdoc">
304+
<PropertyGroup>
305+
<_Mdoc Condition=" '$(Pkgmdoc)' != '' ">"$(Pkgmdoc)/tools/mdoc.exe"</_Mdoc>
306+
<_Libdir>-L "$(OutputPath)../v1.0"</_Libdir>
307+
<_AssemblyBasename>$(OutputPath)Mono.Android</_AssemblyBasename>
308+
<_ImportXml>-i "$(_AssemblyBasename).xml"</_ImportXml>
309+
<_Assembly>"$(_AssemblyBasename).dll"</_Assembly>
310+
<_Output>-o "$(MSBuildThisFileDirectory)../../external/android-api-docs/docs/Mono.Android/en"</_Output>
311+
<_DocTypeArgs Condition=" '$(DocTypeName)' != '' ">--type=$(DocTypeName)</_DocTypeArgs>
312+
</PropertyGroup>
313+
<Exec
314+
Command="$(ManagedRuntime) $(ManagedRuntimeArgs) $(_Mdoc) --debug update --use-docid --delete $(_Libdir) $(_ImportXml) $(_Output) $(_DocTypeArgs) $(_Assembly) "
315+
WorkingDirectory="$(MSBuildThisFileDirectory)"
316+
/>
317+
</Target>
318+
263319
</Project>

0 commit comments

Comments
 (0)