|
19 | 19 | import os |
20 | 20 | import sys |
21 | 21 |
|
| 22 | +import attr |
22 | 23 | from sphinx.ext.autodoc import ModuleLevelDocumenter, DataDocumenter |
23 | 24 |
|
24 | 25 | sys.path.insert(0, os.path.abspath('../')) |
|
335 | 336 | # texinfo_no_detailmenu = False |
336 | 337 |
|
337 | 338 |
|
| 339 | +autodoc_member_order = 'bysource' |
| 340 | + |
| 341 | + |
| 342 | +def process_signature(app, what, name, obj, options, signature, annotation): |
| 343 | + if isinstance(obj, attr._make.Attribute): |
| 344 | + obj.__class__.__repr__ = lambda *a, **k: None |
| 345 | + |
338 | 346 | def maybe_skip_member(app, what, name, obj, skip, options): |
339 | | - # print (what, name, obj, skip) |
340 | 347 | if type(obj) == property: |
341 | 348 | skip = False |
342 | 349 | whitelisted_names = [] |
343 | 350 | if name in whitelisted_names: |
344 | 351 | return False |
345 | 352 | whitelisted_init_classes = ["GogsApi", "Token", "UsernamePassword", "Builder"] |
346 | 353 | if name == "__init__": |
347 | | - return obj.im_class.__name__ not in whitelisted_init_classes |
| 354 | + if hasattr(obj, 'im_class'): |
| 355 | + return obj.im_class.__name__ not in whitelisted_init_classes |
348 | 356 | blacklisted_names = ["update_kwargs"] |
349 | 357 | return skip or (name in blacklisted_names) |
350 | 358 |
|
351 | 359 | def setup(app): |
352 | 360 | app.connect('autodoc-skip-member', maybe_skip_member) |
| 361 | + app.connect('autodoc-process-signature', process_signature) |
353 | 362 |
|
354 | 363 | def add_directive_header(self, sig): |
355 | 364 | ModuleLevelDocumenter.add_directive_header(self, sig) |
|
0 commit comments