2009-11-03 17 views
247

Yöntem belgeleme biriminden bir veya daha fazla yöntem parametresine başvuru eklemenin bir yolu var mı? şey gibi:Javadoc'ta bir yöntem parametresine başvuru nasıl eklenir?

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

cevap

290

the docs for javadoc okuduktan sonra anlatabildiğim kadarıyla böyle bir özellik yoktur.

Diğer yanıtlarda önerildiği şekilde <code>foo</code> kullanmayın; {@code foo}'u kullanabilirsiniz. Bu, {@code Iterator<String>} gibi genel bir türe başvurduğunuzda bilmeniz açısından özellikle iyidir - kesinlikle <code>Iterator&lt;String&gt;</code>'dan daha güzel görünüyor, değil mi?

53

Eğer java.lang.String sınıfının Java Kaynak görebileceğiniz gibi: demektir

/** 
* 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> etiketleri ile çevrilidir, Javadoc sözdizimi böyle bir şey yapmanın hiçbir yolunu sağlamaz. (Ben String.class javadoc kullanımı için iyi bir örnek olduğunu düşünüyorum).

+22

bir çekme isteği yapmak. Dize, {@code foo} –

+2

ile belgelenmiştir. etiketi, belirli bir parametreye başvuruyor. "Dize" kelimesini "kod görünümlü" metne biçimlendiriyor. – Naxos84

10

bir yöntem parametresi atıfta doğru yolu şu şekildedir:

enter image description here

+0

Bu, mevcut cevaplara hiçbir şey eklemiyor. Lütfen sil. – suriv

+7

Sadece bu soruya cevap vermekle kalmıyor, aynı zamanda Javadoc'u Intellij gibi bir IDE kullanarak bir parametreyle nasıl değiştirebileceğinizi görsel olarak açıklıyor. Bu, bir cevap arayan arama yapanlar için yararlı olacaktır. –

+0

Eclipse üzerinde çalışmıyor. Ama yine de güzel bir cevap –

İlgili konular