| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fbd2010 commit 9be50be
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -227,6 +227,33 @@ def version(self): | |||
| 227 | 227 | ||
| 228 | 228 | return self._server_version, self._server_revision | |
| 229 | 229 | ||
| 230 | + def markdown(self, text, gfm=False, project=None, **kwargs): | ||
| 231 | + """Render an arbitrary Markdown document. | ||
| 232 | + | ||
| 233 | + Args: | ||
| 234 | + text (str): The markdown text to render | ||
| 235 | + gfm (bool): Render text using GitLab Flavored Markdown. Default is | ||
| 236 | + False | ||
| 237 | + project (str): Full path of a project used a context when `gfm` is | ||
| 238 | + True | ||
| 239 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 240 | + | ||
| 241 | + Raises: | ||
| 242 | + GitlabAuthenticationError: If authentication is not correct | ||
| 243 | + GitlabMarkdownError: If the server cannot perform the request | ||
| 244 | + | ||
| 245 | + Returns: | ||
| 246 | + str: The HTML rendering of the markdown text. | ||
| 247 | + """ | ||
| 248 | + post_data = {'text': text, 'gfm': gfm} | ||
| 249 | + if project is not None: | ||
| 250 | + post_data['project'] = project | ||
| 251 | + try: | ||
| 252 | + data = self.http_post('/markdown', post_data=post_data, **kwargs) | ||
| 253 | + except Exception: | ||
| 254 | + raise GitlabMarkdownError | ||
| 255 | + return data['html'] | ||
| 256 | + | ||
| 230 | 257 | def _construct_url(self, id_, obj, parameters, action=None): | |
| 231 | 258 | if 'next_url' in parameters: | |
| 232 | 259 | return parameters['next_url'] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,6 +205,10 @@ class GitlabStopError(GitlabOperationError): | |||
| 205 | 205 | pass | |
| 206 | 206 | ||
| 207 | 207 | ||
| 208 | + class GitlabMarkdownError(GitlabOperationError): | ||
| 209 | + pass | ||
| 210 | + | ||
| 211 | + | ||
| 208 | 212 | def on_http_error(error): | |
| 209 | 213 | """Manage GitlabHttpError exceptions. | |
| 210 | 214 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1981,8 +1981,8 @@ def delete(self, name, **kwargs): | |||
| 1981 | 1981 | **kwargs: Extra options to send to the Gitlab server (e.g. sudo) | |
| 1982 | 1982 | ||
| 1983 | 1983 | Raises: | |
| 1984 | - GitlabAuthenticationError: If authentication is not correct. | ||
| 1985 | - GitlabDeleteError: If the server cannot perform the request. | ||
| 1984 | + GitlabAuthenticationError: If authentication is not correct | ||
| 1985 | + GitlabDeleteError: If the server cannot perform the request | ||
| 1986 | 1986 | """ | |
| 1987 | 1987 | self.gitlab.http_delete(self.path, query_data={'name': name}, **kwargs) | |
| 1988 | 1988 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,6 +60,10 @@ | |||
| 60 | 60 | gl.auth() | |
| 61 | 61 | assert(isinstance(gl.user, gitlab.v4.objects.CurrentUser)) | |
| 62 | 62 | ||
| 63 | + # markdown (need to wait for gitlab 11 to enable the test) | ||
| 64 | + # html = gl.markdown('foo') | ||
| 65 | + # assert('foo' in html) | ||
| 66 | + | ||
| 63 | 67 | # sidekiq | |
| 64 | 68 | out = gl.sidekiq.queue_metrics() | |
| 65 | 69 | assert(isinstance(out, dict)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments