[Epydoc-commits] SF.net SVN: epydoc: [1529] trunk/epydoc
Brought to you by:
edloper
|
From: <dva...@us...> - 2007-02-18 12:34:10
|
Revision: 1529
http://svn.sourceforge.net/epydoc/?rev=1529&view=rev
Author: dvarrazzo
Date: 2007-02-18 04:34:08 -0800 (Sun, 18 Feb 2007)
Log Message:
-----------
- If there is no other info for a metadata variable, drop it as variable
- @newfield also add a metadata variable
- dropped __revision__ as alias for __version__. A new field can now be
defined.
Modified Paths:
--------------
trunk/epydoc/doc/fields.html
trunk/epydoc/src/epydoc/docstringparser.py
Modified: trunk/epydoc/doc/fields.html
===================================================================
--- trunk/epydoc/doc/fields.html 2007-02-18 11:20:10 UTC (rev 1528)
+++ trunk/epydoc/doc/fields.html 2007-02-18 12:34:08 UTC (rev 1529)
@@ -530,19 +530,20 @@
<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. </p>
+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%">Variable</th><th width="50%">Tag</th></tr>
+ <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><br/>
- <code>__revision__</code></td></tr>
+ <td><code>__version__</code></td></tr>
<tr><td align="left" valign="top">
<b><code>@date</code></b></td>
@@ -584,7 +585,12 @@
<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. The following
+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%">
Modified: trunk/epydoc/src/epydoc/docstringparser.py
===================================================================
--- trunk/epydoc/src/epydoc/docstringparser.py 2007-02-18 11:20:10 UTC (rev 1528)
+++ trunk/epydoc/src/epydoc/docstringparser.py 2007-02-18 12:34:08 UTC (rev 1529)
@@ -72,7 +72,7 @@
"""
def __init__(self, tags, label, plural=None,
short=0, multivalue=1, takes_arg=0,
- varnames=[]):
+ varnames=None):
if type(tags) in (list, tuple):
self.tags = tuple(tags)
elif type(tags) is str:
@@ -84,7 +84,7 @@
self.multivalue = multivalue
self.short = short
self.takes_arg = takes_arg
- self.varnames = varnames
+ self.varnames = varnames or []
def __cmp__(self, other):
if not isinstance(other, DocstringField): return -1
@@ -109,7 +109,7 @@
# Status info
DocstringField(['version'], 'Version', multivalue=0,
- varnames=['__version__', '__revision__']),
+ varnames=['__version__']),
DocstringField(['date'], 'Date', multivalue=0,
varnames=['__date__']),
DocstringField(['status'], 'Status', multivalue=0),
@@ -274,8 +274,9 @@
for varname in field.varnames:
# Check if api_doc has a variable w/ the given name.
if varname not in api_doc.variables: continue
- if api_doc.variables[varname].value is UNKNOWN: continue
- val_doc = api_doc.variables[varname].value
+ var_doc = api_doc.variables[varname]
+ if var_doc.value is UNKNOWN: continue
+ val_doc = var_doc.value
value = []
# Try extracting the value from the pyval.
@@ -308,7 +309,11 @@
elt = unicode(elt)
elt = epytext.ParsedEpytextDocstring(
epytext.parse_as_para(elt))
+
+ # Add in the metadata and remove from the variables
api_doc.metadata.append( (field, varname, elt) )
+ if var_doc.docstring in (None, UNKNOWN):
+ del api_doc.variables[varname]
def initialize_api_doc(api_doc):
"""A helper function for L{parse_docstring()} that initializes
@@ -664,6 +669,7 @@
api_doc.extra_docstring_fields = []
try:
docstring_field = _descr_to_docstring_field(arg, descr)
+ docstring_field.varnames.append("__%s__" % arg)
api_doc.extra_docstring_fields.append(docstring_field)
except ValueError, e:
raise ValueError('Bad %s: %s' % (tag, e))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|