Skip to content

Commit ffb3d0a

Browse files
committed
[Java.Interop.Tools.JavaSource] Remove block and inline @cref values
Context: dotnet#843 Context: xamarin/android-api-docs#23 A handful of "broken" Javadoc to C# Doc conversions have been disabled for now. This will hopefully help reduce the number of new warnings introduced by xamarin/android-api-docs#23, and allow us to get an initial major documentation update landed in the short term. Longer term, we will revisit and fix these Javadoc conversion issues. Additionally, `Javadoc.cs` has been removed from tools/generator as it appeared to be an unused partial duplicate of `JavadocInfo.cs`.
1 parent 412e974 commit ffb3d0a

File tree

6 files changed

+29
-100
lines changed

6 files changed

+29
-100
lines changed

src/Java.Interop.Tools.JavaSource/Java.Interop.Tools.JavaSource/SourceJavadocToXmldocGrammar.BlockTagsBnfTerms.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)
8989
if (!grammar.ShouldImport (ImportJavadoc.ExceptionTag)) {
9090
return;
9191
}
92-
// TODO: convert `nonSpaceTerm` into a proper CREF
92+
/* TODO: convert `nonSpaceTerm` into a proper CREF
9393
var e = new XElement ("exception",
9494
new XAttribute ("cref", string.Join ("", AstNodeToXmlContent (parseNode.ChildNodes [1]))),
9595
AstNodeToXmlContent (parseNode.ChildNodes [2]));
9696
FinishParse (context, parseNode).Exceptions.Add (e);
9797
parseNode.AstNode = e;
98+
*/
99+
FinishParse (context, parseNode);
98100
};
99101

100102
ParamDeclaration.Rule = "@param" + nonSpaceTerm + BlockValues;
@@ -135,11 +137,15 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)
135137
if (!grammar.ShouldImport (ImportJavadoc.SeeTag)) {
136138
return;
137139
}
138-
// TODO: @see supports multiple forms; see: https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#see
140+
/* TODO: @see supports multiple forms; see: https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#see
141+
// Also need to convert to appropriate CREF value, ignore for now
139142
var e = new XElement ("seealso",
140143
new XAttribute ("cref", string.Join ("", AstNodeToXmlContent (parseNode.ChildNodes [1]))));
141144
FinishParse (context, parseNode).Extra.Add (e);
142145
parseNode.AstNode = e;
146+
*/
147+
FinishParse (context, parseNode);
148+
143149
};
144150

145151
SinceDeclaration.Rule = "@since" + BlockValues;
@@ -157,12 +163,14 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)
157163
if (!grammar.ShouldImport (ImportJavadoc.ExceptionTag)) {
158164
return;
159165
}
160-
// TODO: convert `nonSpaceTerm` into a proper CREF
166+
/* TODO: convert `nonSpaceTerm` into a proper CREF
161167
var e = new XElement ("exception",
162168
new XAttribute ("cref", string.Join ("", AstNodeToXmlContent (parseNode.ChildNodes [1]))),
163169
AstNodeToXmlContent (parseNode.ChildNodes [2]));
164170
FinishParse (context, parseNode).Exceptions.Add (e);
165171
parseNode.AstNode = e;
172+
*/
173+
FinishParse (context, parseNode);
166174
};
167175

168176
// Ignore serialization informatino

src/Java.Interop.Tools.JavaSource/Java.Interop.Tools.JavaSource/SourceJavadocToXmldocGrammar.InlineTagsBnfTerms.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)
4747
LinkDeclaration.Rule = grammar.ToTerm ("{@link") + InlineValue + "}";
4848
LinkDeclaration.AstConfig.NodeCreator = (context, parseNode) => {
4949
// TODO: *everything*; {@link target label}, but target can contain spaces!
50-
// Also need to convert to appropriate CREF value
50+
// Also need to convert to appropriate CREF value, use code text for now.
5151
var target = parseNode.ChildNodes [1].AstNode;
52-
var x = new XElement ("c");
53-
parseNode.AstNode = new XElement ("c", new XElement ("see", new XAttribute ("cref", target)));
52+
parseNode.AstNode = new XElement ("c", target);
5453
};
5554

5655
LinkplainDeclaration.Rule = grammar.ToTerm ("{@linkplain") + InlineValue + "}";
5756
LinkplainDeclaration.AstConfig.NodeCreator = (context, parseNode) => {
5857
// TODO: *everything*; {@link target label}, but target can contain spaces!
59-
// Also need to convert to appropriate CREF value
60-
var target = parseNode.ChildNodes [1].AstNode;
61-
parseNode.AstNode = new XElement ("see", new XAttribute ("cref", target));
58+
// Also need to convert to appropriate CREF value, use text for now.
59+
var target = parseNode.ChildNodes [1].AstNode.ToString ();
60+
parseNode.AstNode = new XText (target);
6261
};
6362

6463
LiteralDeclaration.Rule = grammar.ToTerm ("{@literal") + InlineValue + "}";

tests/Java.Interop.Tools.JavaSource-Tests/SourceJavadocToXmldocGrammar.BlockTagsBnfTermsTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public void ExceptionDeclaration ()
5151

5252
var r = p.Parse ("@exception Throwable Just Because.\n");
5353
Assert.IsFalse (r.HasErrors (), "@exception: " + DumpMessages (r, p));
54-
Assert.AreEqual ("<exception cref=\"Throwable\">Just Because.</exception>", r.Root.AstNode.ToString ());
54+
Assert.IsNull (r.Root.AstNode, "@exception should be ignored, but node was not null.");
55+
//Assert.AreEqual ("<exception cref=\"Throwable\">Just Because.</exception>", r.Root.AstNode.ToString ());
5556
}
5657

5758
[Test]
@@ -97,7 +98,8 @@ public void SeeDeclaration ()
9798

9899
var r = p.Parse ("@see \"Insert Book Name Here\"");
99100
Assert.IsFalse (r.HasErrors (), "@see: " + DumpMessages (r, p));
100-
Assert.AreEqual ("<seealso cref=\"&quot;Insert Book Name Here&quot;\" />", r.Root.AstNode.ToString ());
101+
Assert.IsNull (r.Root.AstNode, "@see should be ignored, but node was not null.");
102+
//Assert.AreEqual ("<seealso cref=\"&quot;Insert Book Name Here&quot;\" />", r.Root.AstNode.ToString ());
101103
}
102104

103105
[Test]
@@ -117,11 +119,13 @@ public void ThrowsDeclaration ()
117119

118120
var r = p.Parse ("@throws Throwable the {@code Exception} raised by this method");
119121
Assert.IsFalse (r.HasErrors (), "@throws: " + DumpMessages (r, p));
120-
Assert.AreEqual ("<exception cref=\"Throwable\">the <c>Exception</c> raised by this method</exception>", r.Root.AstNode.ToString ());
122+
Assert.IsNull (r.Root.AstNode, "@throws should be ignored, but node with code block was not null.");
123+
//Assert.AreEqual ("<exception cref=\"Throwable\">the <c>Exception</c> raised by this method</exception>", r.Root.AstNode.ToString ());
121124

122125
r = p.Parse ("@throws Throwable something <i>or other</i>!");
123126
Assert.IsFalse (r.HasErrors (), "@throws: " + DumpMessages (r, p));
124-
Assert.AreEqual ("<exception cref=\"Throwable\">something <i>or other</i>!</exception>", r.Root.AstNode.ToString ());
127+
Assert.IsNull (r.Root.AstNode, "@throws should be ignored, but node was not null.");
128+
//Assert.AreEqual ("<exception cref=\"Throwable\">something <i>or other</i>!</exception>", r.Root.AstNode.ToString ());
125129
}
126130

127131
[Test]

tests/Java.Interop.Tools.JavaSource-Tests/SourceJavadocToXmldocGrammar.InlineTagsBnfTermsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void LinkDeclaration ()
5252
var r = p.Parse ("{@link #ctor}");
5353
Assert.IsFalse (r.HasErrors (), DumpMessages (r, p));
5454
var c = (XElement) r.Root.AstNode;
55-
Assert.AreEqual ("<c><see cref=\"#ctor\" /></c>", c.ToString (SaveOptions.DisableFormatting));
55+
Assert.AreEqual ("<c>#ctor</c>", c.ToString (SaveOptions.DisableFormatting));
5656
}
5757

5858
[Test]
@@ -62,7 +62,7 @@ public void LinkplainDeclaration ()
6262

6363
var r = p.Parse ("{@linkplain #ctor}");
6464
Assert.IsFalse (r.HasErrors (), DumpMessages (r, p));
65-
Assert.AreEqual ("<see cref=\"#ctor\" />", r.Root.AstNode.ToString ());
65+
Assert.AreEqual ("#ctor", r.Root.AstNode.ToString ());
6666
}
6767

6868
[Test]

tests/Java.Interop.Tools.JavaSource-Tests/SourceJavadocToXmldocParserTests.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ more description here.</para>
111111
<para>What about <i>hard</i> paragraphs?</para>
112112
<para>Added in API level 1.</para>
113113
</remarks>
114-
<seealso cref=""#method()"" />
115114
</member>",
116115
IntelliSenseXml = @"<member>
117116
<param name=""a"">something</param>
@@ -135,14 +134,14 @@ more description here.</para>
135134
new ParseResult {
136135
Javadoc = "Something {@link #method}: description, \"<code>declaration</code>\" or \"<code>another declaration</code>\".\n\n@apiSince 1\n",
137136
FullXml = @"<member>
138-
<summary>Something <c><see cref=""#method"" /></c>: description, ""&lt;code&gt;declaration&lt;/code&gt;"" or ""&lt;code&gt;another declaration&lt;/code&gt;"".</summary>
137+
<summary>Something <c>#method</c>: description, ""&lt;code&gt;declaration&lt;/code&gt;"" or ""&lt;code&gt;another declaration&lt;/code&gt;"".</summary>
139138
<remarks>
140-
<para>Something <c><see cref=""#method"" /></c>: description, ""&lt;code&gt;declaration&lt;/code&gt;"" or ""&lt;code&gt;another declaration&lt;/code&gt;"".</para>
139+
<para>Something <c>#method</c>: description, ""&lt;code&gt;declaration&lt;/code&gt;"" or ""&lt;code&gt;another declaration&lt;/code&gt;"".</para>
141140
<para>Added in API level 1.</para>
142141
</remarks>
143142
</member>",
144143
IntelliSenseXml = @"<member>
145-
<summary>Something <c><see cref=""#method"" /></c>: description, ""&lt;code&gt;declaration&lt;/code&gt;"" or ""&lt;code&gt;another declaration&lt;/code&gt;"".</summary>
144+
<summary>Something <c>#method</c>: description, ""&lt;code&gt;declaration&lt;/code&gt;"" or ""&lt;code&gt;another declaration&lt;/code&gt;"".</summary>
146145
</member>",
147146
},
148147
new ParseResult {
@@ -166,11 +165,9 @@ more description here.</para>
166165
<remarks>
167166
<para>Summary.</para>
168167
</remarks>
169-
<exception cref=""Throwable"">insert <i>description</i> here.</exception>
170168
</member>",
171169
IntelliSenseXml = @"<member>
172170
<summary>Summary.</summary>
173-
<exception cref=""Throwable"">insert <i>description</i> here.</exception>
174171
</member>",
175172
},
176173
};

tools/generator/Java.Interop.Tools.Generator.ObjectModel/Javadoc.cs

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)