Skip to content

Fix inherit doc warnings #13199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scaladoc-testcases/src/tests/inheritDoc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package tests
package inheritDoc

class Test {
/** {@inheritDoc} */
def f: Unit = { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CommentExpander {
case None =>
// SI-8210 - The warning would be false negative when this symbol is a setter
if (ownComment.indexOf("@inheritdoc") != -1 && ! sym.isSetter)
println(s"${sym.span}: the comment for ${sym} contains @inheritdoc, but no parent comment is available to inherit from.")
report.warning(s"The comment for ${sym} contains @inheritdoc, but no parent comment is available to inherit from.", sym.srcPos)
ownComment.replace("@inheritdoc", "<invalid inheritdoc annotation>")
case Some(sc) =>
if (ownComment == "") sc
Expand Down Expand Up @@ -159,7 +159,7 @@ class CommentExpander {
* @param sym The child symbol
* @return The child comment with the inheritdoc sections expanded
*/
def expandInheritdoc(parent: String, child: String, sym: Symbol): String =
def expandInheritdoc(parent: String, child: String, sym: Symbol)(using Context): String =
if (child.indexOf("@inheritdoc") == -1)
child
else {
Expand Down Expand Up @@ -193,8 +193,8 @@ class CommentExpander {
val sectionTextBounds = extractSectionText(parent, section)
cleanupSectionText(parent.substring(sectionTextBounds._1, sectionTextBounds._2))
case None =>
println(s"""${sym.span}: the """" + getSectionHeader + "\" annotation of the " + sym +
" comment contains @inheritdoc, but the corresponding section in the parent is not defined.")
report.warning(s"""The """" + getSectionHeader + "\" annotation of the " + sym +
" comment contains @inheritdoc, but the corresponding section in the parent is not defined.", sym.srcPos)
"<invalid inheritdoc annotation>"
}

Expand Down