Commit 0e01fb5
authored
Context: dotnet/android#5485
In an attempt to generate updated documentation for API-30 I noticed
a minor issue in generator Javadoc import (7574f16): when a
`<javadoc/>` element contains multiple `@return` values:
<class name="Example" …>
<method name="getP" …>
<javadoc>
<![CDATA[
…
@return some docs
@return additional docs
]]>
</javadoc>
</method>
</class>
We would generate multiple `<returns/>` elements, one for each
`@return`:
partial class Example {
/// <returns>some docs</returns>
/// <returns>additional docs</returns>
public int P {
[Register("getP", …)] get => …
}
}
This is "fine", as far as the C# compiler is concerned, which results
in a Documentation XML file containing both `<returns/>`:
<doc>
<members>
<member name="P:Example.P">
<returns>some docs</returns>
<returns>additional docs</returns>
</member>
</members>
</doc>
The problem is when we later try to *import* this documentation via
`mdoc update --import`, as dotnet/android#5485 does;
if it's a *method* which contains multiple `<returns/>` elements and
mdoc 5.7.4.9 is used (included with macOS Mono 6.12):
$ mdoc update -o docs assembly.dll --import assembly.xml
Then the resulting imported [**mdoc**(5)][0] documentation only
contains the *first* element:
<Docs>
<summary>To be added.</summary>
<returns>some docs</returns>
<remarks>To be added.</remarks>
</Docs>
Using [mdoc 5.8.0][1] will preserve both `<returns/>` elements, but
"higher level" tooling such as HTML rendering or IntelliSense may not
properly support multiple `<returns/>` elements.
*However*, if it's a *property* which contains multiple `<returns/>`
elements, then `mdoc update` will convert each `<returns/>` element
into a `<value/>` element:
$ mdoc update -o docs assembly.dll --import assembly.xml
…
<Docs>
<summary>To be added.</summary>
<value>some docs</value>
<value>additional docs</value>
<remarks>To be added.</remarks>
</Docs>
This is "odd", but it gets worse: on subsequent `mdoc update`
invocations, *additional* `<value/>` elements are created!
$ mdoc update -o docs assembly.dll --import assembly.xml
…
<Docs>
<summary>To be added.</summary>
<value>additional docs</value>
<value>some docs</value>
<value>additional docs</value>
<remarks>To be added.</remarks>
</Docs>
$ mdoc update -o docs assembly.dll --import assembly.xml
…
<Docs>
<summary>To be added.</summary>
<value>some docs</value>
<value>additional docs</value>
<value>some docs</value>
<value>additional docs</value>
<remarks>To be added.</remarks>
</Docs>
While an `mdoc` bug, we can prevent this from happening by updating
the Javadoc importer so that multiple `@returns` blocks are *merged*
into a single `<returns/>` element:
partial class Example {
/// <returns>some docs additional docs</returns>
public int P {…}
}
[0]: http://docs.go-mono.com/?link=man%3amdoc(5)
[1]: https://www.nuget.org/packages/mdoc/5.8.0
1 parent 12e670a commit 0e01fb5
File tree
2 files changed
+37
-18
lines changed- src/Java.Interop.Tools.JavaSource/Java.Interop.Tools.JavaSource
- tests/Java.Interop.Tools.JavaSource-Tests
2 files changed
+37
-18
lines changedLines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
118 | 121 | | |
119 | | - | |
120 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
121 | 131 | | |
122 | 132 | | |
123 | 133 | | |
| |||
Lines changed: 24 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
29 | 28 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
| |||
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
43 | | - | |
| 41 | + | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
| |||
78 | 76 | | |
79 | 77 | | |
80 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
81 | 90 | | |
82 | 91 | | |
83 | 92 | | |
| |||
166 | 175 | | |
167 | 176 | | |
168 | 177 | | |
169 | | - | |
| 178 | + | |
170 | 179 | | |
171 | 180 | | |
172 | 181 | | |
| |||
0 commit comments