diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2017-01-10 13:20:23 -0500 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2017-01-10 13:20:23 -0500 |
| commit | ffdcc904ea16467c51e3d36773be132b7aa4cb3f (patch) | |
| tree | db07a54c603ecb1543fdf3c7e26886f47c460a38 /api-docs | |
| parent | 1230404d0b7cd7a00fd3da7ad2aebb66d663fd08 (diff) | |
update documentation to be dynamically generated based on module and class hierarchy
Diffstat (limited to 'api-docs')
| -rw-r--r-- | api-docs/source/conf.py | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/api-docs/source/conf.py b/api-docs/source/conf.py index 15e06045..379d6d7e 100644 --- a/api-docs/source/conf.py +++ b/api-docs/source/conf.py @@ -19,15 +19,68 @@ import os import sys import platform +import inspect if (platform.system() == "Darwin"): - bnpath=os.path.join(os.path.abspath('.'), "..", "..", "..", "ui", "binaryninja.app", "Contents", "Resources", "python") + bnpath=os.path.join(os.path.abspath('.'), "..", "..", "..", "ui", "binaryninja.app", "Contents", "Resources", "python") else: - bnpath=os.path.join(os.path.abspath('.'), "..", "..", "..", "ui", "python") + bnpath=os.path.join(os.path.abspath('.'), "..", "..", "..", "ui", "python") sys.path.insert(0, bnpath) import binaryninja +def modulelist(modulename): + modules = inspect.getmembers(modulename, inspect.ismodule) + return filter(lambda x: x[0] not in ("abc", "ctypes", "core", "struct", "sys", "_binaryninjacore", "traceback", "code", "enum", "json", "threading"), modules) + + +def classlist(module): + members = inspect.getmembers(module, inspect.isclass) + if module.__name__ != "binaryninja.enums": + members = filter(lambda x: type(x[1]) != binaryninja.enum.EnumMeta, members) + members.extend(inspect.getmembers(module, inspect.isfunction)) + return map(lambda x: x[0], filter(lambda x: not x[0].startswith("_"), members)) + + +def generaterst(): + pythonrst = open("python.rst", "w") + pythonrst.write('''Binary Ninja Python API Documentation +===================================== + +.. toctree:: + :maxdepth: 2 + +''') + + for modulename, module in modulelist(binaryninja): + filename = 'binaryninja.{module}.rst'.format(module=modulename) + pythonrst.write(' {module} <{filename}>\n'.format(module=modulename, filename=filename)) + modulefile = open(filename, "w") + modulefile.write('''{module} module +===================== + +.. autosummary:: + :toctree: + +'''.format(module=modulename)) + + for classname in classlist(module): + modulefile.write(" binaryninja.{module}.{classname}\n".format(module=modulename, classname=classname)) + + modulefile.write('''\n.. toctree:: + :maxdepth: 2\n''') + modulefile.close() + + pythonrst.write('''.. automodule:: binaryninja + :members: + :undoc-members: + :show-inheritance: +''') + pythonrst.close() + + +generaterst() + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. @@ -50,7 +103,7 @@ extensions = [ ] autosummary_generate = True -autodoc_member_order = 'groupwise' +#autodoc_member_order = 'groupwise' breathe_projects = { "BinaryNinja": "../../xml/" } breathe_projects_source = { |
