CommentExpander

dotty.tools.dotc.core.Comments.CommentExpander

Port of DocComment.scala from nsc

Attributes

Authors:

Martin Odersky

Felix Mulder

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Classlikes

Attributes

Supertypes
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def cookedDocComment(sym: Symbol, docStr: String)(using Context): String

The raw doc comment of symbol sym, minus usecase and define sections, augmented by missing sections of an inherited doc comment. If a symbol does not have a doc comment but some overridden version of it does, the doc comment of the overridden version is copied instead.

The raw doc comment of symbol sym, minus usecase and define sections, augmented by missing sections of an inherited doc comment. If a symbol does not have a doc comment but some overridden version of it does, the doc comment of the overridden version is copied instead.

Attributes

def defineVariables(sym: Symbol)(using Context): Unit
def docCommentPos(sym: Symbol)(using Context): Span

The position of the raw doc comment of symbol sym, or NoPosition if missing If a symbol does not have a doc comment but some overridden version of it does, the position of the doc comment of the overridden version is returned instead.

The position of the raw doc comment of symbol sym, or NoPosition if missing If a symbol does not have a doc comment but some overridden version of it does, the position of the doc comment of the overridden version is returned instead.

Attributes

def expand(sym: Symbol, site: Symbol)(using Context): String
def expandInheritdoc(parent: String, child: String, sym: Symbol): String

Expand inheritdoc tags

Expand inheritdoc tags

  • for the main comment we transform the inheritdoc into the super variable, and the variable expansion can expand it further
  • for the param, tparam and throws sections we must replace comments on the spot

This is done separately, for two reasons:

  1. It takes longer to run compared to merge
  2. The inheritdoc annotation should not be used very often, as building the comment from pieces severely impacts performance

Value parameters

child

The child (overriding member or usecase) comment

parent

The source (or parent) comment

sym

The child symbol

Attributes

Returns

The child comment with the inheritdoc sections expanded

def expandedDocComment(sym: Symbol, site: Symbol, docStr: String)(using Context): String

The cooked doc comment of symbol sym after variable expansion, or "" if missing.

The cooked doc comment of symbol sym after variable expansion, or "" if missing.

Value parameters

site

The class for which doc comments are generated

sym

The symbol for which doc comment is returned

Attributes

Throws
ExpansionLimitExceeded

when more than 10 successive expansions of the same string are done, which is interpreted as a recursive variable definition.

def lookupVariable(vble: String, site: Symbol)(using Context): Option[String]

Lookup definition of variable.

Lookup definition of variable.

Value parameters

site

The class for which doc comments are generated

vble

The variable for which a definition is searched

Attributes

def merge(src: String, dst: String, sym: Symbol, copyFirstPara: Boolean): String