From 81e1c13e05172d86b613f13ddacc896db5ffd250 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 5 Nov 2016 18:43:19 +0100 Subject: Make the manager objects create mor dynamic For the gitlab.Gitlab object make the detection of "submanagers" more dynamic. This will avoid duplication of definitions. Update the sphinx extension to add these managers in the list of attributes. --- docs/ext/docstrings.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'docs/ext/docstrings.py') diff --git a/docs/ext/docstrings.py b/docs/ext/docstrings.py index b380b64..5e5f82f 100644 --- a/docs/ext/docstrings.py +++ b/docs/ext/docstrings.py @@ -45,9 +45,17 @@ class GitlabDocstring(GoogleDocstring): def __init__(self, *args, **kwargs): super(GitlabDocstring, self).__init__(*args, **kwargs) - if hasattr(self._obj, 'obj_cls') and self._obj.obj_cls is not None: - self._parsed_lines = self._build_doc('manager_tmpl.j2', - cls=self._obj.obj_cls) + if getattr(self._obj, '__name__', None) == 'Gitlab': + mgrs = [] + gl = self._obj('http://dummy', private_token='dummy') + for item in vars(gl).items(): + if hasattr(item[1], 'obj_cls'): + mgrs.append(item) + self._parsed_lines.extend(self._build_doc('gl_tmpl.j2', + mgrs=sorted(mgrs))) + elif hasattr(self._obj, 'obj_cls') and self._obj.obj_cls is not None: + self._parsed_lines.extend(self._build_doc('manager_tmpl.j2', + cls=self._obj.obj_cls)) elif hasattr(self._obj, 'canUpdate') and self._obj.canUpdate: - self._parsed_lines = self._build_doc('object_tmpl.j2', - obj=self._obj) + self._parsed_lines.extend(self._build_doc('object_tmpl.j2', + obj=self._obj)) -- cgit v1.2.1