Javadoc'taki bir yöntem parametresine başvuru nasıl eklenir?


313

Yöntem dokümantasyon gövdesinden bir veya daha fazla yöntemin parametresine referans eklemenin bir yolu var mı? Gibi bir şey:

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

Yanıtlar:


367

Javadoc için belgeleri okuduktan sonra söyleyebildiğim kadarıyla böyle bir özellik yok.

<code>foo</code>Diğer yanıtlarda önerildiği gibi kullanmayın ; kullanabilirsiniz {@code foo}. Bu, genel bir türden bahsederken bilmek özellikle iyidir {@code Iterator<String>}- emin daha güzel görünüyor <code>Iterator&lt;String&gt;</code>, değil mi!



59

Java.lang.String sınıfının Java Kaynağında görebileceğiniz gibi:

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

Parametre referansları <code></code>etiketlerle çevrilidir , yani Javadoc sözdizimi böyle bir şey yapmak için herhangi bir yol sağlamaz. (Sanırım String.class javadoc kullanımının iyi bir örneğidir).


5
<code> </code> etiketi belirli bir parametreye başvurmuyor. "String" kelimesini "kod görünümlü" metne biçimlendiriyor.
— Naxos84

46

Bir yöntem parametresine başvurmanın doğru yolu şöyledir:

resim açıklamasını buraya girin


2
Bu mevcut cevaplara hiçbir şey katmaz. Lütfen silin.
— suriv

27
Sadece soruyu cevaplamakla kalmaz, aynı zamanda Intellij gibi bir IDE kullanarak bir parametrede Javadoc'un nasıl değiştirileceğini görsel olarak açıklar. Bu, cevap arayan arama kullanıcıları için faydalı olacaktır.
— Eurig Jones

1
Eclipse'de işe yaramıyor. Ama yine de güzel bir cevap
— Henrique de Sousa

2
bu silinmelidir. artık var olmadığını hayal et.
— user4504267

2
@ user4504267 Görüntü en azından şimdi iyi görünüyor.
— ErikE

Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.