| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6c0a3d9 commit 7cfbe87
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,34 +33,21 @@ def _process_docstring(app, what, name, obj, options, lines): | |||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | 35 | class GitlabDocstring(GoogleDocstring): | |
| 36 | - _j2_env = None | ||
| 37 | - | ||
| 38 | - def _build_j2_env(self): | ||
| 39 | - if self._j2_env is None: | ||
| 40 | - self._j2_env = jinja2.Environment(loader=jinja2.FileSystemLoader( | ||
| 41 | - os.path.dirname(__file__)), trim_blocks=False) | ||
| 42 | - self._j2_env.filters['classref'] = classref | ||
| 43 | - | ||
| 44 | - return self._j2_env | ||
| 45 | - | ||
| 46 | - def _build_manager_doc(self): | ||
| 47 | - env = self._build_j2_env() | ||
| 48 | - template = env.get_template('manager_tmpl.j2') | ||
| 49 | - output = template.render(cls=self._obj.obj_cls) | ||
| 50 | - | ||
| 51 | - return output.split('\n') | ||
| 52 | - | ||
| 53 | - def _build_object_doc(self): | ||
| 54 | - env = self._build_j2_env() | ||
| 55 | - template = env.get_template('object_tmpl.j2') | ||
| 56 | - output = template.render(obj=self._obj) | ||
| 36 | + def _build_doc(self, tmpl, **kwargs): | ||
| 37 | + env = jinja2.Environment(loader=jinja2.FileSystemLoader( | ||
| 38 | + os.path.dirname(__file__)), trim_blocks=False) | ||
| 39 | + env.filters['classref'] = classref | ||
| 40 | + template = env.get_template(tmpl) | ||
| 41 | + output = template.render(**kwargs) | ||
| 57 | 42 | ||
| 58 | 43 | return output.split('\n') | |
| 59 | 44 | ||
| 60 | 45 | def __init__(self, *args, **kwargs): | |
| 61 | 46 | super(GitlabDocstring, self).__init__(*args, **kwargs) | |
| 62 | 47 | ||
| 63 | 48 | if hasattr(self._obj, 'obj_cls') and self._obj.obj_cls is not None: | |
| 64 | - self._parsed_lines = self._build_manager_doc() | ||
| 49 | + self._parsed_lines = self._build_doc('manager_tmpl.j2', | ||
| 50 | + cls=self._obj.obj_cls) | ||
| 65 | 51 | elif hasattr(self._obj, 'canUpdate') and self._obj.canUpdate: | |
| 66 | - self._parsed_lines = self._build_object_doc() | ||
| 52 | + self._parsed_lines = self._build_doc('object_tmpl.j2', | ||
| 53 | + obj=self._obj) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments