mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Alternative docstring pattern and added note to documentation.
This commit is contained in:
parent
09a7dd36bb
commit
c9c5c66eb6
@ -88,6 +88,14 @@ public @interface Callback {
|
|||||||
* more importantly you should document the expected parameters and return
|
* more importantly you should document the expected parameters and return
|
||||||
* type here.
|
* type here.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
* <em>Important</em>: the recommended format is either<br/>
|
||||||
|
* <tt>function(arg:type[, optionArg:type]):resultType -- Description.</tt><br/>
|
||||||
|
* or<br/>
|
||||||
|
* <tt>function(arg:type[, optionArg:type]):resultType; Description.</tt><br/>
|
||||||
|
* where the argument list can be of any format (as long as it doesn't contain
|
||||||
|
* further braces), and the return type is optional. These two formats are
|
||||||
|
* recognized by OC's NEI component documentation plugin. If you use a
|
||||||
|
* different format, the doc string will be used as-is.
|
||||||
*/
|
*/
|
||||||
String doc() default "";
|
String doc() default "";
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ class DocumentationHandler(val pages: Option[Array[String]]) extends IUsageHandl
|
|||||||
|
|
||||||
private val DocPattern = """^function(\([^)]*\)[^-]*) -- (.*)$""".r
|
private val DocPattern = """^function(\([^)]*\)[^-]*) -- (.*)$""".r
|
||||||
|
|
||||||
|
private val VexPattern = """^function(\([^)]*\)[^-]*); (.*)$""".r
|
||||||
|
|
||||||
private def wrap(line: String, width: Int) = GuiDraw.fontRenderer.listFormattedStringToWidth(line, width)
|
private def wrap(line: String, width: Int) = GuiDraw.fontRenderer.listFormattedStringToWidth(line, width)
|
||||||
|
|
||||||
override def getUsageHandler(input: String, ingredients: AnyRef*): IUsageHandler = {
|
override def getUsageHandler(input: String, ingredients: AnyRef*): IUsageHandler = {
|
||||||
@ -67,8 +69,9 @@ class DocumentationHandler(val pages: Option[Array[String]]) extends IUsageHandl
|
|||||||
val doc = callback.annotation.doc
|
val doc = callback.annotation.doc
|
||||||
if (Strings.isNullOrEmpty(doc)) name
|
if (Strings.isNullOrEmpty(doc)) name
|
||||||
else {
|
else {
|
||||||
val (signature, documentation) = DocPattern findFirstIn doc match {
|
val (signature, documentation) = doc match {
|
||||||
case Some(DocPattern(head, tail)) => (name + head, tail)
|
case DocPattern(head, tail) => (name + head, tail)
|
||||||
|
case VexPattern(head, tail) => (name + head, tail)
|
||||||
case _ => (name, doc)
|
case _ => (name, doc)
|
||||||
}
|
}
|
||||||
wrap(signature, 160).map(EnumChatFormatting.BLACK.toString + _).mkString("\n") +
|
wrap(signature, 160).map(EnumChatFormatting.BLACK.toString + _).mkString("\n") +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user