2009-11-03 9 views
247

メソッドドキュメンテーション本体から1つまたは複数のメソッドのパラメータへの参照を追加する方法はありますか? のような何か:javadocのメソッドパラメータへの参照を追加するには?

/** 
* When {@paramref a} is null, we rely on b for the discombobulation. 
* 
* @param a this is one of the parameters 
* @param b another param 
*/ 
void foo(String a, int b) 
{...} 

答えて

290

私が読むことができる限り、the docs for javadocにはそのような特徴はありません。

<code>foo</code>を他の回答で推奨されているように使用しないでください。 {@code foo}を使用できます。これは、{@code Iterator<String>}のようなジェネリックタイプを参照する際には特に便利です。確かに<code>Iterator&lt;String&gt;</code>よりもよさそうですね。

8

私はあなたがこの動作をサポートする独自のドックレットやタグレットを記述することができると思います。

Taglet Overview

Doclet Overview

+13

とJavadocにプルリクエストを作る:) –

53

あなたはjava.lang.StringクラスのJavaソースで見ることができるように:ということ

/** 
* Allocates a new <code>String</code> that contains characters from 
* a subarray of the character array argument. The <code>offset</code> 
* argument is the index of the first character of the subarray and 
* the <code>count</code> argument specifies the length of the 
* subarray. The contents of the subarray are copied; subsequent 
* modification of the character array does not affect the newly 
* created string. 
* 
* @param  value array that is the source of characters. 
* @param  offset the initial offset. 
* @param  count the length. 
* @exception IndexOutOfBoundsException if the <code>offset</code> 
*    and <code>count</code> arguments index characters outside 
*    the bounds of the <code>value</code> array. 
*/ 
public String(char value[], int offset, int count) { 
    if (offset < 0) { 
     throw new StringIndexOutOfBoundsException(offset); 
    } 
    if (count < 0) { 
     throw new StringIndexOutOfBoundsException(count); 
    } 
    // Note: offset or count might be near -1>>>1. 
    if (offset > value.length - count) { 
     throw new StringIndexOutOfBoundsException(offset + count); 
    } 

    this.value = new char[count]; 
    this.count = count; 
    System.arraycopy(value, offset, this.value, 0, count); 
} 

パラメータ参照は<code></code>タグで囲まれています、 Javadoc構文は、そのようなことを行う方法を提供していません。 (私はString.classはjavadocの使い方の良い例だと思う)。

+22

これは古いです。文字列は{@code foo} –

+2

で文書化されていますタグは特定のパラメータを参照していません。 「文字列」という単語を「コードを探している」テキストにフォーマットしています。 – Naxos84

10

メソッドのパラメータを参照する正しい方法は、このようなものです:

enter image description here

+0

これは既存の回答に何も追加しません。削除してください。 – suriv

+7

これは質問に答えるだけでなく、IntellijなどのIDEを使用してパラメータを使用してJavadocを修正する方法を視覚的に説明しています。これは、回答を探している検索者に役立ちます。 –

+0

Eclipseでは動作しません。しかしそれは良い答えですが、 –

関連する問題