In Scaladoc, how to link to a method in the same class?
Asked Answered
T

2

17

What is the correct way to create link to a method in the same class? Scaladoc documentation doesn't have examples of this.

Consider a class such as:

package controllers

// import ...

class AccountController extends Controller with Secured {

  def current = Authenticated() { request =>
    // ...
  }

  /**
   * See [[current]] for an endpoint that...
   */
  def findAll = Authenticated() { request =>
     // ... 
  }

}

In IntelliJ IDEA's "quick documentation" pop up, all these show up as red:

  • [[current]]
  • [[#current]]
  • [[AccountController.current]]
  • [[AccountController#current]]
  • [[controllers.AccountController.current]]

enter image description here

This does show up as blue:

[[controllers.AccountController#current]]

So I suppose this is correct, but is there there no simpler yet correct way?

Thicken answered 28/12, 2015 at 10:1 Comment(1)
While the Scaladoc HTML rendering gets a beautification, I'm afraid the tool itself is still in a rather unsatisfying state. This issue suggests that still only fully qualified names are supported...Gaga
S
7

The correct way for your example would be:

[[controllers.AccountController#current()]]

The empty parenthesis are necessary here for functions without parameters, despite you shouldn't add these in the code. You also have to use fully-qualified names everywhere, this means it should contain the package, class name, a hashtag and the method name.

Sachi answered 23/3, 2020 at 9:45 Comment(0)
S
2

I am not sure when was it fixed, but I am using IntelliJ IDEA version 2020.3, and it works for me:

/**
 * See [[current]] for an endpoint that...
 */

enter image description here

Shelve answered 17/1, 2021 at 15:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.