javadoc에서 메소드 매개 변수에 대한 참조를 추가하는 방법은 무엇입니까?


313

메소드 문서 본문에서 하나 이상의 메소드 매개 변수에 대한 참조를 추가하는 방법이 있습니까? 다음과 같은 것 :

/**
 * 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)
{...}

답변:


367

javadoc에 대한 문서를 읽은 후에 알 수있는 한 그러한 기능은 없습니다.

<code>foo</code>다른 답변에서 권장 하는 대로 사용하지 마십시오 . 사용할 수 있습니다 {@code foo}. 이것은 {@code Iterator<String>}다음 과 같은 일반 유형을 참조 할 때 특히 유용 <code>Iterator&lt;String&gt;</code>합니다.


@code태그는 Javadoc- 태그 설명에 설명되어 있습니다. JDK8 코드의 샘플 사용법을 참조하십시오 .
— pba

59

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 사용법의 좋은 예라고 생각합니다).


5
<code> </ code> 태그가 특정 매개 변수를 참조하지 않습니다. "String"이라는 단어를 "code looking"텍스트로 형식화합니다.
— Naxos84

46

메소드 매개 변수를 참조하는 올바른 방법은 다음과 같습니다.

여기에 이미지 설명을 입력하십시오


2
이것은 기존 답변에 아무것도 추가하지 않습니다. 삭제하십시오.
— suriv

27
그것은 질문에 대답 할뿐만 아니라 Intellij와 같은 IDE를 사용하여 매개 변수로 Javadoc을 수정하는 방법을 시각적으로 설명합니다. 답변을 찾고있는 검색 자에게 유용합니다.
— Eurig Jones

1
이클립스에서는 작동하지 않습니다. 그럼에도 불구하고 그것은 좋은 대답입니다
— Henrique de Sousa

2
삭제해야합니다. 더 이상 존재하지 않는다고 상상하십시오.
— user4504267

2
@ user4504267 적어도 지금은 이미지가 잘 보입니다.
— ErikE

당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.