2009-11-03 4 views
247

विधि प्रलेखन निकाय से एक या अधिक विधि के पैरामीटर में संदर्भ जोड़ने का कोई तरीका है? कुछ की तरह: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

मुझे लगता है कि आप अपने खुद के doclet या taglet इस व्यवहार का समर्थन करने के लिख सकते हैं।

Taglet Overview

Doclet Overview

+13

और जावाडोक :) –

53

आप java.lang.String वर्ग के जावा स्रोत में देख सकते हैं:

/** 
* 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> टैग से घिरे रहे हैं, जिसका मतलब है जावाडोक सिंटैक्स ऐसी चीज करने का कोई तरीका नहीं प्रदान करता है। (मुझे लगता है कि स्ट्रिंग.क्लास जैवाडोक उपयोग का एक अच्छा उदाहरण है)।

+22

के लिए एक पुल अनुरोध यह पुरानी है या नहीं। स्ट्रिंग को {@code foo} –

+2

के साथ दस्तावेज किया गया है टैग एक विशिष्ट पैरामीटर का संदर्भ नहीं दे रहा है। यह "कोडिंग" शब्द में "स्ट्रिंग" शब्द को स्वरूपित कर रहा है। – Naxos84

10

एक विधि पैरामीटर की चर्चा करते हुए का सही तरीका इस तरह है:

enter image description here

+0

यह मौजूदा उत्तरों में कुछ भी नहीं जोड़ता है। कृपया इसे हटा दें। – suriv

+7

न केवल यह प्रश्न का उत्तर देता है, बल्कि यह स्पष्ट रूप से बताता है कि कैसे इंटेलिज जैसे आईडीई का उपयोग करके पैरामीटर के साथ जावाडोक में संशोधन करना है। यह उन खोजकर्ताओं के लिए उपयोगी होगा जो उत्तर की तलाश में हैं। –

+0

ग्रहण पर यह काम नहीं करता है। लेकिन यह एक अच्छा जवाब है फिर भी –