1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title>Epydoc Fields</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"/>
</head>
<!-- $Id: fields.html 1575 2007-03-08 21:28:07Z edloper $ -->
<body>
<div class="body">
<h1>Epydoc Fields</h1>
<p> Fields are used to describe specific properties of a documented
object. For example, fields can be used to define the parameters and
return value of a function; the instance variables of a class; and the
author of a module. Each field consists of a <i>tag</i>, an optional
<i>argument</i>, and a <i>body</i>. </p>
<ul>
<li> The <i>tag</i> is a case-insensitive word that indicates what
kind of documentaiton is given by the field. </li>
<li> The optional <i>argument</i> specifies what object, parameter,
or group is documented by the field. </li>
<li> The <i>body</i> contains the main contents of the field. </li>
</ul>
<h2> 1. Field Markup </h2>
<p> Each docstring markup langauge marks fields differently. The
following table shows the basic fields syntax for each markup
language. For more information, see the definition of field syntax
for each markup language. </p>
<center>
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th width="33%">Epytext</th>
<th width="33%">reStructuredText</th>
<th width="33%">Javadoc</th>
</tr>
<tr>
<td>
<code>@<i>tag</i>: <i>body</i></code>...<br/>
<code>@<i>tag</i> <i>arg</i>: <i>body</i></code>...<br/>
</td>
<td>
<code>:<i>tag</i>: <i>body</i></code>...<br/>
<code>:<i>tag</i> <i>arg</i>: <i>body</i></code>...<br/>
</td>
<td>
<code>@<i>tag</i> <i>body</i></code>...<br/>
<code>@<i>tag</i> <i>arg</i> <i>body</i></code>...<br/>
</td>
</tr>
<tr>
<td align="center"><a
href="epytext.html#fieldlist">Definition of<br/>epytext fields</a></td>
<td align="center"><a
href="http://docutils.sourceforge.net/spec/rst/reStructuredText.html#field-lists">Definition of<br/>reStructuredText fields</a></td>
<td align="center"><a
href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javadoc.html#javadoctags">Definition of<br/>Javadoc fields</a></td>
</tr>
</table>
</center>
<a name="fields"></a>
<h2> 2. Supported Fields</h2>
<p> The following table lists the fields that epydoc currently
recognizes. Field tags are written using epytext markup; if you are
using a different markup language, then you should adjust the markup
accordingly. </p>
<table border="1" cellspacing="0" cellpadding="3" width="95%">
<!-- ========== Functions & Methods ========== -->
<tr><th colspan="2" align="left">Functions and Methods
<i>(function or method docstrings)</i></th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>param</b> <i>p</i>:</code> ... </td><td>
A description of the parameter <code><i>p</i></code> for a
function or method. It may appear in the class docstring to describe
a costructor parameter: mostly useful for C extensions.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>type</b> <i>p</i>:</code> ... </td><td>
The expected type for the parameter.
<code><i>p</i></code>. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>return</b>:</code> ... </td><td>
The return value for a function or method. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>rtype</b>:</code> ... </td><td>
The type of the return value for a function or method. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>keyword</b> <i>p</i>:</code> ... </td><td>
A description of the keyword parameter <code><i>p</i></code>.
It may appear in the class docstring to describe
a costructor keyword parameter.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>raise</b> <i>e</i>:</code> ... </td><td>
A description of the circumstances under which a function or
method raises exception <code><i>e</i></code>.
It may appear in the class docstring to describe
an exception that can be raised by the costructor.</td></tr>
<!-- ========== Variables ========== -->
<tr><th colspan="2" align="left">Variables
<i>(module, class or <a href="#variable-docstring">variable</a> docstrings)</i></th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>ivar</b> <i>v</i>:</code> ... </td><td>
A description of the class instance variable
<code><i>v</i></code>. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>cvar</b> <i>v</i>:</code> ... </td><td>
A description of the static class variable
<code><i>v</i></code>. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>var</b> <i>v</i>:</code> ... </td><td>
A description of the module variable
<code><i>v</i></code>. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>type</b> <i>v</i>:</code> ... </td><td>
The type of the variable
<code><i>v</i></code>. </td></tr>
<!-- This does exist, but leave it out to avoid confusion: -->
<!--
<tr><td width="10%" align="left" valign="top">
<code>@<b>type</b> <i>p</i>:</code> ... </td><td>
The type of the property
<code><i>p</i></code>. </td></tr>
-->
<!-- ========== Properties ========== -->
<tr><th colspan="2" align="left">Properties
<i>(property docstrings)</i></th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>type</b>:</code> ... </td><td>
The type of the property. </td></tr>
<!-- ========== Grouping & Sorting ========== -->
<tr><th colspan="2" align="left">Grouping and Sorting
<i>(module, class, function, or method docstrings)</i></th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>group</b> <i>g</i>: <i>c<sub>1</sub
>,...,c<sub>n</sub></i></code> </td><td>
Organizes a set of related children of a module or class into a group.
<code><i>g</i></code> is the name of the group; and
<code><i>c<sub>1</sub>,...,c<sub>n</sub></i></code> are the names
of the children in the group. To define multiple groups, use
multiple <code>group</code> fields.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>sort</b>: <i>c<sub>1</sub
>,...,c<sub>n</sub></i></code> </td><td>
Specifies the sort order for the children of a module or class.
<code><i>c<sub>1</sub>,...,c<sub>n</sub></i></code> are the names
of the children, in the order in which they should appear. Any
children that are not included in this list will appear after
the children from this list, in alphabetical order.
</td></tr>
<!-- ========== Related Topics ========== -->
<tr><th colspan="2" align="left">Related Topics</th></tr>
<tr><td width="10%" align="left" valign="top"> <code>@<b>see</b>:</code> ... </td><td>
A description of a related topic. <code>see</code> fields
typically use documentation crossreference links or external
hyperlinks that link to the related topic. </td></tr>
<!-- ========== Notes & Warnings ========== -->
<tr><th colspan="2" align="left">Notes and Warnings</th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>note</b>:</code> ... </td><td>
A note about an object. Multiple
<code>note</code> fields may be used to list separate
notes.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>attention</b>:</code> ... </td><td>
An important note about an object. Multiple
<code>attention</code> fields may be used to list separate
notes.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>bug</b>:</code> ... </td><td>
A description of a bug in an object.
Multiple <code>bug</code> fields may be used to report separate
bugs.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>warning</b>:</code> ... </td><td>
A warning about an object. Multiple
<code>warning</code> fields may be used to report separate
warnings.</td></tr>
<!-- ========== Status ========== -->
<tr><th colspan="2" align="left">Status</th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>version</b>:</code> ... </td><td>
The current version of an object. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>todo</b> [<i>ver</i>]:</code> ... </td><td> A planned
change to an object. If the optional argument <code><i>ver</i></code>
is given, then it specifies the version for which the change will be
made. Multiple <code>todo</code> fields may be used if multiple
changes are planned. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>deprecated</b>:</code> ... </td><td>
Indicates that an object is
deprecated. The body of the field describe the reason why
the object is deprecated.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>since</b>:</code> ... </td><td>
The date or version when an object was
first introduced.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>status</b>:</code> ... </td><td>
The current status of an object.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>change</b>:</code> ... </td><td>
A change log entry for this object.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>permission</b>:</code> ... </td><td>
The object access permission, for systems such Zope/Plone supporting
this concept. It may be used more than once to specify multiple
permissions.</td></tr>
<!-- ========== Formal Conditions ========== -->
<tr><th colspan="2" align="left">Formal Conditions</th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>requires</b>:</code> ... </td><td>
A requirement for using an object. Multiple <code>requires</code>
fields may be used if an object has multiple
requirements.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>precondition</b>:</code> ... </td><td>
A condition that must be true before an object is used. Multiple
<code>precondition</code> fields may be used if an object has
multiple preconditions.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>postcondition</b>:</code> ... </td><td>
A condition that is guaranteed to be true after an object is used.
Multiple <code>postcondition</code> fields may be used if an
object has multiple postconditions.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>invariant</b>:</code> ... </td><td>
A condition which should always be true for an object. Multiple
<code>invariant</code> fields may be used if an object has
multiple invariants.</td></tr>
<!-- ========== Bibliographic Info ========== -->
<tr><th colspan="2" align="left">Bibliographic Information</th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>author</b>:</code> ... </td><td> The author(s) of an
object. Multiple <code>author</code>
fields may be used if an object has multiple authors.</td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>organization</b>:</code> ... </td><td> The
organization that created or maintains an
object. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>copyright</b>:</code> ... </td><td> The copyright
information for an object. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>license</b>:</code> ... </td><td> The licensing
information for an object. </td></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>contact</b>:</code> ... </td><td> Contact information
for the author or maintainer of a module, class, function, or
method. Multiple <code>contact</code> fields may be used if an
object has multiple contacts.</td></tr>
<!-- ========== Summarization ========== -->
<tr><th colspan="2" align="left">Summarization</th></tr>
<tr><td width="10%" align="left" valign="top">
<code>@<b>summary</b>:</code> ... </td><td> A summary
description for an object. This description overrides the default
summary (which is constructed from the first sentence of the
object's description). </td></tr>
</table>
<h3> 2.1. Notes on Supported Fields</h3>
<ul>
<li> <p> <code>@param</code> fields should be used to document any
explicit parameter (including the keyword parameter).
<code>@keyword</code> fields should only be used for non-explicit
keyword parameters: </p>
<div class="screen"><pre>
<code class="keyword">def</code> <code class="function">plant</code>(seed, *tools, **options):
<code class="string">"""</code>
<code class="field">@param seed:</code> The seed that should be planted.
<code class="field">@param tools:</code> Tools that should be used to plant the seed.
<code class="field">@param options:</code> Any extra options for the planting.
<code class="field">@keyword dig_deep:</code> Plant the seed deep under ground.
<code class="field">@keyword soak:</code> Soak the seed before planting it.
<code class="string">"""</code>
<i>[...]</i>
</pre></div>
</li>
<li> <p> For the <code>@group</code> and <code>@sort</code> tags,
asterisks (<code>*</code>) can be used to specify multiple children at
once. An asterisk in a child name will match any substring: </p>
<div class="screen"><pre>
<code class="keyword">class</code> <code class="function">widget</code>(size, weight, age):
<code class="string">"""</code>
<code class="field">@group Tools:</code> zip, zap, *_tool
<code class="field">@group Accessors:</code> get_*
<code class="field">@sort:</code> get_*, set_*, unpack_*, cut
<code class="string">"""</code>
<i>[...]</i>
</pre></div>
</li>
<li> <p> Since the <code>@type</code> field allows for arbitrary text,
it does not automatically create a crossreference link to the
specified type, and is not written in fixed-width font by default. If
you want to create a crossreference link to the type, or to write the
type in a fixed-width font, then you must use inline markup: </p>
<div class="screen"><pre>
<code class="keyword">def</code> <code class="function">ponder</code>(person, time):
<code class="string">"""</code>
<code class="field">@param person:</code> Who should think.
<code class="field">@type person:</code> L{Person} or L{Animal}
<code class="field">@param time:</code> How long they should think.
<code class="field">@type time:</code> C{int} or C{float}
<code class="string">"""</code>
<i>[...]</i>
</pre></div>
</li>
</ul>
<a name="locations"></a>
<h2> 3. Where to Write Fields</h2>
<p> Normally the fields are written in the docstring of the documented
objects: this allows you to add fields to modules, classes, function, properties.
Where a docstring is not allowed, usually alternative options do exist.
</p>
<a name="variable-docstring"></a>
<h3> 3.1. Variable docstrings </h3>
<p> Python variables don't support docstrings. The variable can be described
in the module or class where it is defined using the tags <code>@var</code>,
<code>@ivar</code>, <code>@cvar</code>; but this only allows for a textual
description: no further metadata can be added to the variable (except for the
type, using the <code>@type</code> tag. </p>
<p> Epydoc supports <i>variable docstrings</i>: if a variable
assignment statement is immediately followed by a bare string literal,
then that assignment is treated as a docstring for that variable. In
classes, variable assignments at the class definition level are
considered class variables; and assignments to instance variables in
the constructor (<code>__init__</code>) are considered instance variables:<p>
<div class="screen2"><pre>
<code class="prompt">>>></code> <code class="keyword">class</code> A:
<code class="prompt">...</code> x = 22
<code class="prompt">...</code> <code class="string">"""Docstring for class variable A.x"""</code>
<code class="prompt">...</code>
<code class="prompt">...</code> <code class="keyword">def</code> <code class="function">__init__</code>(self, a):
<code class="prompt">...</code> self.y = a
<code class="prompt">...</code> <code class="string">"""Docstring for instance variable A.y</code>
</pre></div>
<p> Variables may also be documented using <i>comment docstrings</i>.
If a variable assignment is immediately preceeded by a comment whose
lines begin with the special marker "<code><b>#:</b></code>", or is
followed on the same line by such a comment, then it is treated as a
docstring for that variable: </p>
<div class="screen2"><pre>
<code class="prompt">>>></code> <code class="comment">#: docstring for x</code>
<code class="prompt">...</code> x = 22
<code class="prompt">>>></code> x = 22 <code class="comment">#: docstring for x</code>
</pre></div>
<p> A common Python idiom is to create instance variables settings their
default value in the class instead of the constructor (hopefully if the default
is immutable...). To avoid Epydoc to interpret such variable as a class
variable, you can describe it using the tag <code>@ivar</code> in the
context of a variable docstring:</p>
<div class="screen2"><pre>
<code class="prompt">>>></code> <code class="keyword">class</code> B:
<code class="prompt">...</code> y = 42
<code class="prompt">...</code> <code class="string">"""@ivar: This is an instance variable."""</code>
</pre></div>
<p> Notice that variable docstrings are only available for documentation
when the source code is available for parsing: it is not possible to retrieve
variable docstrings from introspection informations only. </p>
<h3> 3.2. C Extensions </h3>
<p> In a C extension module, extension classes cannot have a docstring attached
to the <code>__init__</code> function; consequently it is not possible to
document parameters and exceptions raised by the class constructor. To overcome
this shortcoming, the tags <code>@param</code>, <code>@keyword</code>,
<code>@type</code>, <code>@exception</code> are allowed to appear in the class
docstring to refer to constructor parameters.
</p>
<h2>4. Field Synonyms</h2>
<p> Several fields have "synonyms," or alternate tags. The following
table lists all field synonyms. Field tags are written using epytext
markup; if you are using a different markup language, then you should
adjust the markup accordingly. </p>
<center>
<table class="transparent">
<tr valign="top"><td class="transparent">
<table border="1" cellspacing="0" cellpadding="3">
<tr><th width="50%">Name</th><th width="50%">Synonyms</th></tr>
<tr><td align="left" valign="top">
<b><code>@param <i>p</i>:</code> ...</b> </td>
<td><code>@parameter <i>p</i>:</code> ...<br/>
<code>@arg <i>p</i>:</code> ...<br/>
<code>@argument <i>p</i>:</code> ...</td></tr>
<tr><td align="left" valign="top">
<b><code>@return:</code> ...</b> </td><td>
<code>@returns:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@rtype:</code> ...</b> </td><td>
<code>@returntype:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@raise <i>e</i>:</code> ...</b> </td>
<td><code>@raises <i>e</i>:</code> ...<br/>
<code>@except <i>e</i>:</code> ...<br/>
<code>@exception <i>e</i>:</code> ...</td></tr>
<tr><td align="left" valign="top">
<b><code>@keyword <i>p</i>:</code> ...</b> </td><td>
<code>@kwarg <i>p</i>:</code> ... <br/>
<code>@kwparam <i>p</i>:</code> ... <br/></td></tr>
<tr><td align="left" valign="top">
<b><code>@ivar <i>v</i>:</code> ...</b> </td><td>
<code>@ivariable <i>v</i>:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@cvar <i>v</i>:</code> ...</b> </td><td>
<code>@cvariable <i>v</i>:</code> ... </td></tr>
</table></td>
<td width="20" class="transparent"></td>
<td class="transparent">
<table border="1" cellspacing="0" cellpadding="3">
<tr><th width="50%">Name</th><th width="50%">Synonyms</th></tr>
<tr><td align="left" valign="top">
<b><code>@var <i>v</i>:</code> ...</b> </td><td>
<code>@variable <i>v</i>:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@see:</code> ...</b> </td><td>
<code>@seealso:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@warning:</code> ...</b> </td><td>
<code>@warn:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@requires:</code> ...</b> </td><td>
<code>@require:</code> ... <br/>
<code>@requirement:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@precondition:</code> ...</b> </td><td>
<code>@precond:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@postcondition:</code> ...</b> </td><td>
<code>@postcod:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@organization:</code> ...</b> </td><td>
<code>@org:</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@copyright:</code> ...</b> </td><td>
<code>@(c):</code> ... </td></tr>
<tr><td align="left" valign="top">
<b><code>@change:</code> ...</b> </td><td>
<code>@changed:</code> ... </td></tr>
</table>
</td></tr></table>
</center>
<a name="metadata-variable"></a>
<h3> 4.1. Metadata variables </h3>
<p> Some module variables are commonly used as module metadata. Epydoc can
use the value provided by these variables as alternate form for tags. The
following table lists the recognized variables and the tag they replace.
Customized metadata variables can be added using the method described
in <a href="newfield">Adding New Fields</a>.</p>
<center>
<table border="1" cellspacing="0" cellpadding="3">
<tr><th width="50%">Tag</th><th width="50%">Variable</th></tr>
<tr><td align="left" valign="top">
<b><code>@deprecated</code></b></td>
<td><code>__deprecated__</code></td></tr>
<tr><td align="left" valign="top">
<b><code>@version</code></b></td>
<td><code>__version__</code></td></tr>
<tr><td align="left" valign="top">
<b><code>@date</code></b></td>
<td><code>__date__</code></td></tr>
<tr><td align="left" valign="top">
<b><code>@author</code></b><br/>
<b><code>@authors</code></b></td>
<td><code>__author__</code><br/>
<code>__authors__</code></td></tr>
<tr><td align="left" valign="top">
<b><code>@contact</code></b></td>
<td><code>__contact__</code></td></tr>
<tr><td align="left" valign="top">
<b><code>@copyright</code></b></td>
<td><code>__copyright__</code></td></tr>
<tr><td align="left" valign="top">
<b><code>@license</code></b></td>
<td><code>__license__</code></td></tr>
</table>
</center>
<a name="newfield"></a>
<h2> 5. Adding New Fields</h2>
<p> New fields can be defined for the docstrings in a module using the
special <code>@newfield</code> tag (or its synonym,
<code>@deffield</code>). This tag has the following syntax:</p>
<div class="screen"><pre>
<b>@newfield <i>tag</i>:</b> <i>label</i> [, <i>plural</i>]
</pre></div>
<p>Where <code><i>tag</i></code> is the new tag that's being defined;
<code><i>label</i></code> is a string that will be used to mark this
field in the generated output; and <code><i>plural</i></code> is the
plural form of <code><i>label</i></code>, if different.</p>
<p>It will also be possibile to use the module variable
<code>__<i>tag</i>__</code> to set the value for the newly defined tag.</p>
<p>The following
example illustrates how the <code>@newfield</code> can be used: </p>
<table border="1" cellspacing="0" cellpadding="3" width="95%">
<tr><th width="50%">Docstring Input</th><th width="50%">Rendered Output</th>
<tr valign="top"><td>
<pre>
"""
@newfield corpus: Corpus, Corpora
"""
<code class="keyword">def</code> <code class="function">example</code>():
<code class="string">"""</code>
<code class="field">@corpus:</code> Bob's wordlist.
<code class="field">@corpus:</code> The British National Corpus.
<code class="string">"""</code>
<i>[...]</i>
</pre>
</td><td>
<p><b>Corpora:</b>
<ul>
<li> Bob's wordlist. </li>
<li> The British National Corpus. </li>
</ul>
</p>
</td></tr>
</table>
<p><b>Note:</b> The module-level variable
<code>__extra_epydoc_fields__</code> is deprecated; use
<code>@newfield</code> instead.</p>
<h2> 6. Markup-Specific Notes </h2>
<p> For the most part, fields are treated identically, regardless of
what markup language is used to encode them. However, there are a few
minor differences, which are intended to accomodate existing standards
for each markup language. In particular: </p>
<ul>
<li> reStructuredText supports an extra group of fields, called
<i>consolidated fields</i>, which combine the documentation for
several objects into a single field. </li>
<li> Javadoc uses a special syntax for the body of the
<code>@see</code> fields. </li>
<li> Javadoc does not support multi-word arguments. </li>
</ul>
<p> For more information about these differences, read the subsections
below. </p>
<a name="rst"></a>
<h3> 6.1. reStructuredText Fields </h3>
<p> In reStructuredText, a single field can be used to encode the
documentation for a group of related items. For example, a single
<code>:Parameters:</code> field is often used to describe all of the
parameters for a function or method: </p>
<div class="screen"><pre>
<code class="keyword">def</code> <code class="function">fox_speed</code>(size, weight, age):
<code class="string">"""
Return the maximum speed for a fox.
<code class="field">:Parameters:</code>
- `size`: The size of the fox (in meters)
- `weight`: The weight of the fox (in stones)
- `age`: The age of the fox (in years)
"""</code>
<i>[...]</i>
</pre></div>
<p> Epydoc will automatically extract information about each parameter
from this list. These <i>consolidated fields</i> may be written using
either a bulleted list or a <a
href="http://docutils.sourceforge.net/docs/user/rst/quickref.html#definition-lists">definition
list</a>. If a consolidated field is written as a bulleted list, then
each list item must begin with the field's argument, marked as <a
href="http://docutils.sourceforge.net/docs/user/rst/quickref.html#inline-markup">interpreted
text</a>, and followed by a colon or dash. If a consolidated field is
written as a definition list, then each definition item's term should
contain the field's argument, (it is not mandatory for it being marked as interpreted text). The term
classifier, if present, is used to specify the associated type. The
following example shows the use of a definition list to define a
consolidated field. (Note that docutils requires a space before and
after the ":" used to mark classifiers.)
</p>
<div class="screen"><pre>
<code class="keyword">def</code> <code class="function">fox_speed</code>(size, weight, age):
<code class="string">"""
Return the maximum speed for a fox.
<code class="field">:Parameters:</code>
size
The size of the fox (in meters)
weight : float
The weight of the fox (in stones)
age : int
The age of the fox (in years)
"""</code>
<i>[...]</i>
</pre></div>
<p> The following consolidated
fields are currently supported by epydoc: </p>
<center>
<table class="transparent">
<tr valign="top"><td class="transparent">
<table border="1" cellspacing="0" cellpadding="3">
<tr><th>Consolidated<br />Field Tag</th>
<th>Corresponding<br />Base Field Tag</th></tr>
<tr><td><code>:Parameters:</code></td>
<td><code>:param:</code></td>
<tr><td><code>:Exceptions:</code></td>
<td><code>:except:</code></td>
<tr><td><code>:Groups:</code></td>
<td><code>:group:</code></td>
<tr><td><code>:Keywords:</code></td>
<td><code>:keyword:</code></td>
</table></td>
<td class="transparent" width="20"></td>
<td class="transparent">
<table border="1" cellspacing="0" cellpadding="3">
<tr><th>Consolidated<br />Field Tag</th>
<th>Corresponding<br />Base Field Tag</th></tr>
<tr><td><code>:Variables:</code></td>
<td><code>:var:</code></td>
<tr><td><code>:Ivariables:</code></td>
<td><code>:ivar:</code></td>
<tr><td><code>:Cvariables:</code></td>
<td><code>:cvar:</code></td>
<tr><td><code>:Types:</code></td>
<td><code>:type:</code></td>
</table>
</td></tr></table>
</center>
<h3> 6.2. Javadoc Fields </h3>
<p> For compatibility with Javadoc, every <code>@see</code> field is
assumed to contain a single crossreference link, unless its body
is quoted, or it starts with an HTML tag. See <a
href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javadoc.html#@see">the
Javadoc reference manual</a> for more information about how the
<code>@see</code> field is encoded in Javadoc. </p>
<p> Because Javadoc does not mark end of the optional argument, field
arguments must contain exactly one word. Thus, multi-word arguments
are not available in Javadoc. In particular, all group names must
be single words. </p>
</div>
<table width="100%" class="navbox" cellpadding="1" cellspacing="0">
<tr>
<a class="nav" href="index.html">
<td align="center" width="20%" class="nav">
<a class="nav" href="index.html">
Home</a></td></a>
<a class="nav" href="installing.html">
<td align="center" width="20%" class="nav">
<a class="nav" href="installing.html">
Installing Epydoc</a></td></a>
<a class="nav" href="using.html">
<td align="center" width="20%" class="nav">
<a class="nav" href="using.html">
Using Epydoc</a></td></a>
<a class="nav" href="epytext.html">
<td align="center" width="20%" class="nav">
<a class="nav" href="epytext.html">
Epytext</a></td></a>
<td align="center" width="20%" class="nav">
<A href="http://sourceforge.net/projects/epydoc">
<IMG src="sflogo.png"
width="88" height="26" border="0" alt="SourceForge"
align="top"/></A></td>
</tr>
</table>
</body>
</html>
|