|
14 | 14 |
|
15 | 15 | import sys |
16 | 16 | import os |
| 17 | +import sphinx |
| 18 | +import docutils |
17 | 19 |
|
18 | 20 | # If extensions (or modules to document with autodoc) are in another directory, |
19 | 21 | # add these directories to sys.path here. If the directory is relative to the |
|
45 | 47 | ] |
46 | 48 |
|
47 | 49 | autodoc_default_flags = ['inherited-members'] |
| 50 | +# autodoc_member_order = "groupwise" |
48 | 51 | todo_include_todos = True |
49 | 52 |
|
50 | 53 | # Add any paths that contain templates here, relative to this directory. |
@@ -375,5 +378,30 @@ def get_rst(app, what, name, obj, options, lines): |
375 | 378 | def get_rst2(app, what, name, obj, options, signature, return_annotation): |
376 | 379 | pass |
377 | 380 |
|
| 381 | + |
| 382 | +# Test code to handle :class:`gdef.STRUCTURE_NAME` |
| 383 | +# demo of custom xref for not-found structures |
| 384 | +# Test was for ref to 'SECURITY_DESCRIPTOR_CONTROL' in SecurityDescriptor.control |
| 385 | +def miss_ref(app, env, node, contnode): |
| 386 | + # import pdb;pdb.set_trace() |
| 387 | + if not node["reftype"] == "class": |
| 388 | + return |
| 389 | + print(node, node["reftype"], node["reftarget"], contnode) |
| 390 | + # import pdb;pdb.set_trace() |
| 391 | + |
| 392 | + if "SECURITY_DESCRIPTOR_CONTROL" not in node["reftarget"]: |
| 393 | + return |
| 394 | + |
| 395 | + res = docutils.nodes.reference("", "") |
| 396 | + py_domain = env.domains["py"] |
| 397 | + full_name = "windows.generated_def.winstructs.{0}".format(node["reftarget"].rsplit(".", 1)[-1]) |
| 398 | + t = [x for x in py_domain.get_objects() if full_name == x[0]][0] |
| 399 | + res["refdocname"] = node["refdoc"] |
| 400 | + res.append(contnode) |
| 401 | + uri = app.builder.get_relative_uri(node["refdoc"], t[3]) |
| 402 | + res['refuri'] = "{0}#{1}".format(uri, t[0]) |
| 403 | + return res |
| 404 | + |
378 | 405 | def setup(app): |
379 | 406 | app.add_stylesheet('css/mbasic.css') # may also be an URL |
| 407 | + # app.connect('missing-reference', miss_ref) |
0 commit comments