~pauli-virtanen/scipy/numpy-refguide

« back to all changes in this revision

Viewing changes to ext/autosummary.py

  • Committer: Pauli Virtanen
  • Date: 2008-09-29 20:22:52 UTC
  • Revision ID: pauli.virtanen@iki.fi-20080929202252-be7puu4opjowa3t4
autosummary: preserve the order of items in the toctree

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
    names = []
132
132
    names += [x for x in content if x.strip()]
133
133
 
134
 
    result, warnings, titles = get_autosummary(names, state.document,
135
 
                                               'nosignatures' in options)
 
134
    result, warnings, real_names = get_autosummary(names, state.document,
 
135
                                                   'nosignatures' in options)
136
136
 
137
137
    node = nodes.paragraph()
138
138
    state.nested_parse(result, 0, node)
145
145
    if 'toctree' in options:
146
146
        tree_prefix = options['toctree'].strip()
147
147
        docnames = []
148
 
        for name in titles.keys():
 
148
        for name in names:
 
149
            name = real_names.get(name, name)
 
150
 
149
151
            docname = tree_prefix + name
150
152
            if docname.endswith(suffix):
151
153
                docname = docname[:-len(suffix)]
179
181
    
180
182
    """
181
183
    result = ViewList()
 
184
    real_names = {}
182
185
    warnings = []
183
 
    titles = {}
184
186
 
185
187
    prefixes = ['']
186
188
    prefixes.insert(0, document.settings.env.currmodule)
196
198
            rows.append((":obj:`%s`" % name, ""))
197
199
            continue
198
200
 
 
201
        real_names[name] = real_name
 
202
 
199
203
        doc = get_doc_object(obj)
200
204
 
201
205
        if doc['Summary']:
202
 
            titles[real_name] = " ".join(doc['Summary'])
 
206
            title = " ".join(doc['Summary'])
203
207
        else:
204
 
            titles[real_name] = ""
 
208
            title = ""
205
209
        
206
210
        col1 = ":obj:`%s <%s>`" % (name, real_name)
207
211
        if doc['Signature']:
218
222
            else:
219
223
                sig = re.sub(r'(\(.{16,16}[^,)]*?),.*?\)', r'\1, ...)', sig)
220
224
            col1 += " " + sig
221
 
        col2 = titles[real_name]
 
225
        col2 = title
222
226
        
223
227
        rows.append((col1, col2))
224
228
 
225
229
    if not rows:
226
 
        return result, warnings, titles
 
230
        return result, warnings, real_names
227
231
    
228
232
    max_name_len = max([len(x[0]) for x in rows])
229
233
    row_fmt = "%%-%ds  %%s" % max_name_len
235
239
    result.append(table_banner, '<autosummary>')
236
240
    result.append('', '<autosummary>')
237
241
 
238
 
    return result, warnings, titles
 
242
    return result, warnings, real_names
239
243
 
240
244
def import_by_name(name, prefixes=[None]):
241
245
    """