Skip to content

Commit

Permalink
Merge branch 'develop' into runMonitoring_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mesmith75 authored May 23, 2024
2 parents 2f377f3 + 5596a5e commit 5b8c477
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions doc/fill_gpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def indent(s, depth=''):
"""
Adds `indent` to the beginning of every line
"""
return '\n'.join(depth+l for l in s.splitlines())
return '\n'.join(depth + _l for _l in s.splitlines())


def reindent(docstring, depth=''):
Expand All @@ -66,7 +66,7 @@ def signature(func, name=None):
Returns: a string representing its signature as would be written in code
"""
args, varargs, varkw, defaults = inspect.getargspec(func)
args, varargs, varkw, defaults, *_ = inspect.getfullargspec(func)
defaults = defaults or [] # If there are no defaults, set it to an empty list
defaults = [repr(d) for d in defaults] # Type to get a useful string representing the default

Expand All @@ -81,23 +81,26 @@ def signature(func, name=None):
for arg, default in arg_pairs:
full_arg = arg
if default is not None:
full_arg += '='+default
full_arg += '=' + default
arg_strings.append(full_arg)
# and append args and kwargs if necessary to get
# arg_strings=['a', 'b', 'a=None', 'd=4', '*args', '**kwargs']
if varargs is not None:
arg_strings.append('*'+varargs)
arg_strings.append('*' + varargs)
if varkw is not None:
arg_strings.append('**'+varkw)
arg_strings.append('**' + varkw)

# Signature is then 'foo(a, b, c=None, d=4, *args, **kwargs)'
return '{name}({args})'.format(name=name or func.__name__, args=', '.join(arg_strings))


# First we get all objects that are in Ganga.GPI and filter out any non-GangaObjects
gpi_classes = [stripProxy(o) for name, o in GangaCore.GPI.__dict__.items() if isinstance(o, type) and issubclass(o, GPIProxyObject)]
gpi_classes = [
stripProxy(o) for name, o in GangaCore.GPI.__dict__.items()
if isinstance(o, type) and issubclass(o, GPIProxyObject)
]

with open(doc_dir+'/GPI/classes.rst', 'w') as cf:
with open(doc_dir + '/GPI/classes.rst', 'w') as cf:

print('GPI classes', file=cf)
print('===========', file=cf)
Expand Down Expand Up @@ -151,7 +154,7 @@ def signature(func, name=None):

# Looking through the plugin list helps categorise the GPI objects

with open(doc_dir+'/GPI/plugins.rst', 'w') as pf:
with open(doc_dir + '/GPI/plugins.rst', 'w') as pf:
from GangaCore.Utility.Plugin.GangaPlugin import allPlugins

print('Plugins', file=pf)
Expand All @@ -160,7 +163,7 @@ def signature(func, name=None):

for c, ps in allPlugins.allCategories().items():
print(c, file=pf)
print('-'*len(c), file=pf)
print('-' * len(c), file=pf)
print('', file=pf)

for name, c in ps.items():
Expand All @@ -172,7 +175,8 @@ def signature(func, name=None):
print('')

# All objects that are not proxied GangaObjects
gpi_objects = dict((name, stripProxy(o)) for name, o in GangaCore.GPI.__dict__.items() if stripProxy(o) not in gpi_classes and not name.startswith('__'))
gpi_objects = dict((name, stripProxy(o)) for name, o in GangaCore.GPI.__dict__.items()
if stripProxy(o) not in gpi_classes and not name.startswith('__'))

# Any objects which are not exposed as proxies (mostly exceptions)
non_proxy_classes = dict((k, v) for k, v in gpi_objects.items() if inspect.isclass(v))
Expand All @@ -183,7 +187,7 @@ def signature(func, name=None):
# Things which were declared as actual functions
functions = dict((k, v) for k, v in callables.items() if inspect.isfunction(v) or inspect.ismethod(v))

with open(doc_dir+'/GPI/functions.rst', 'w') as ff:
with open(doc_dir + '/GPI/functions.rst', 'w') as ff:

print('Functions', file=ff)
print('=========', file=ff)
Expand Down

0 comments on commit 5b8c477

Please sign in to comment.