Skip to content

Commit 5292ffb

Browse files
author
Gauvain Pocentek
committed
[docs] Rework the examples pages
* Get rid of the .py files and bring all the python examples in the RST files * Fix a few things
1 parent 2c34237 commit 5292ffb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+697
-2319
lines changed

docs/gl_objects/access_requests.py

-26
This file was deleted.

docs/gl_objects/access_requests.rst

+14-33
Original file line numberDiff line numberDiff line change
@@ -25,48 +25,29 @@ References
2525
+ :class:`gitlab.v4.objects.GroupAccessRequestManager`
2626
+ :attr:`gitlab.v4.objects.Group.accessrequests`
2727

28-
* v3 API:
29-
30-
+ :class:`gitlab.v3.objects.ProjectAccessRequest`
31-
+ :class:`gitlab.v3.objects.ProjectAccessRequestManager`
32-
+ :attr:`gitlab.v3.objects.Project.accessrequests`
33-
+ :attr:`gitlab.Gitlab.project_accessrequests`
34-
+ :class:`gitlab.v3.objects.GroupAccessRequest`
35-
+ :class:`gitlab.v3.objects.GroupAccessRequestManager`
36-
+ :attr:`gitlab.v3.objects.Group.accessrequests`
37-
+ :attr:`gitlab.Gitlab.group_accessrequests`
38-
3928
* GitLab API: https://docs.gitlab.com/ce/api/access_requests.html
4029

4130
Examples
4231
--------
4332

44-
List access requests from projects and groups:
45-
46-
.. literalinclude:: access_requests.py
47-
:start-after: # list
48-
:end-before: # end list
49-
50-
Get a single request:
33+
List access requests from projects and groups::
5134

52-
.. literalinclude:: access_requests.py
53-
:start-after: # get
54-
:end-before: # end get
35+
p_ars = project.accessrequests.list()
36+
g_ars = group.accessrequests.list()
5537

56-
Create an access request:
38+
Create an access request::
5739

58-
.. literalinclude:: access_requests.py
59-
:start-after: # create
60-
:end-before: # end create
40+
p_ar = project.accessrequests.create({})
41+
g_ar = group.accessrequests.create({})
6142

62-
Approve an access request:
43+
Approve an access request::
6344

64-
.. literalinclude:: access_requests.py
65-
:start-after: # approve
66-
:end-before: # end approve
45+
ar.approve() # defaults to DEVELOPER level
46+
ar.approve(access_level=gitlab.MASTER_ACCESS) # explicitly set access level
6747

68-
Deny (delete) an access request:
48+
Deny (delete) an access request::
6949

70-
.. literalinclude:: access_requests.py
71-
:start-after: # delete
72-
:end-before: # end delete
50+
project.accessrequests.delete(user_id)
51+
group.accessrequests.delete(user_id)
52+
# or
53+
ar.delete()

docs/gl_objects/branches.py

-46
This file was deleted.

docs/gl_objects/branches.rst

+14-26
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,34 @@ References
1111
+ :class:`gitlab.v4.objects.ProjectBranchManager`
1212
+ :attr:`gitlab.v4.objects.Project.branches`
1313

14-
* v3 API:
15-
16-
+ :class:`gitlab.v3.objects.ProjectBranch`
17-
+ :class:`gitlab.v3.objects.ProjectBranchManager`
18-
+ :attr:`gitlab.v3.objects.Project.branches`
19-
2014
* GitLab API: https://docs.gitlab.com/ce/api/branches.html
2115

2216
Examples
2317
--------
2418

25-
Get the list of branches for a repository:
19+
Get the list of branches for a repository::
2620

27-
.. literalinclude:: branches.py
28-
:start-after: # list
29-
:end-before: # end list
21+
branches = project.branches.list()
3022

31-
Get a single repository branch:
23+
Get a single repository branch::
3224

33-
.. literalinclude:: branches.py
34-
:start-after: # get
35-
:end-before: # end get
25+
branch = project.branches.get('master')
3626

37-
Create a repository branch:
27+
Create a repository branch::
3828

39-
.. literalinclude:: branches.py
40-
:start-after: # create
41-
:end-before: # end create
29+
branch = project.branches.create({'branch': 'feature1',
30+
'ref': 'master'})
4231

43-
Delete a repository branch:
32+
Delete a repository branch::
4433

45-
.. literalinclude:: branches.py
46-
:start-after: # delete
47-
:end-before: # end delete
34+
project.branches.delete('feature1')
35+
# or
36+
branch.delete()
4837

49-
Protect/unprotect a repository branch:
38+
Protect/unprotect a repository branch::
5039

51-
.. literalinclude:: branches.py
52-
:start-after: # protect
53-
:end-before: # end protect
40+
branch.protect()
41+
branch.unprotect()
5442

5543
.. note::
5644

docs/gl_objects/builds.rst

+11-54
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
##########################
2-
Pipelines, Builds and Jobs
3-
##########################
4-
5-
Build and job are two classes representing the same object. Builds are used in
6-
v3 API, jobs in v4 API.
1+
##################
2+
Pipelines and Jobs
3+
##################
74

85
Project pipelines
96
=================
@@ -19,13 +16,6 @@ Reference
1916
+ :class:`gitlab.v4.objects.ProjectPipelineManager`
2017
+ :attr:`gitlab.v4.objects.Project.pipelines`
2118

22-
* v3 API:
23-
24-
+ :class:`gitlab.v3.objects.ProjectPipeline`
25-
+ :class:`gitlab.v3.objects.ProjectPipelineManager`
26-
+ :attr:`gitlab.v3.objects.Project.pipelines`
27-
+ :attr:`gitlab.Gitlab.project_pipelines`
28-
2919
* GitLab API: https://docs.gitlab.com/ce/api/pipelines.html
3020

3121
Examples
@@ -66,13 +56,6 @@ Reference
6656
+ :class:`gitlab.v4.objects.ProjectTriggerManager`
6757
+ :attr:`gitlab.v4.objects.Project.triggers`
6858

69-
* v3 API:
70-
71-
+ :class:`gitlab.v3.objects.ProjectTrigger`
72-
+ :class:`gitlab.v3.objects.ProjectTriggerManager`
73-
+ :attr:`gitlab.v3.objects.Project.triggers`
74-
+ :attr:`gitlab.Gitlab.project_triggers`
75-
7659
* GitLab API: https://docs.gitlab.com/ce/api/pipeline_triggers.html
7760

7861
Examples
@@ -88,8 +71,7 @@ Get a trigger::
8871

8972
Create a trigger::
9073

91-
trigger = project.triggers.create({}) # v3
92-
trigger = project.triggers.create({'description': 'mytrigger'}) # v4
74+
trigger = project.triggers.create({'description': 'mytrigger'})
9375

9476
Remove a trigger::
9577

@@ -190,13 +172,6 @@ Reference
190172
+ :class:`gitlab.v4.objects.GroupVariableManager`
191173
+ :attr:`gitlab.v4.objects.Group.variables`
192174

193-
* v3 API
194-
195-
+ :class:`gitlab.v3.objects.ProjectVariable`
196-
+ :class:`gitlab.v3.objects.ProjectVariableManager`
197-
+ :attr:`gitlab.v3.objects.Project.variables`
198-
+ :attr:`gitlab.Gitlab.project_variables`
199-
200175
* GitLab API
201176

202177
+ https://docs.gitlab.com/ce/api/project_level_variables.html
@@ -232,11 +207,11 @@ Remove a variable::
232207
# or
233208
var.delete()
234209

235-
Builds/Jobs
236-
===========
210+
Jobs
211+
====
237212

238-
Builds/Jobs are associated to projects, pipelines and commits. They provide
239-
information on the builds/jobs that have been run, and methods to manipulate
213+
Jobs are associated to projects, pipelines and commits. They provide
214+
information on the jobs that have been run, and methods to manipulate
240215
them.
241216

242217
Reference
@@ -248,13 +223,6 @@ Reference
248223
+ :class:`gitlab.v4.objects.ProjectJobManager`
249224
+ :attr:`gitlab.v4.objects.Project.jobs`
250225

251-
* v3 API
252-
253-
+ :class:`gitlab.v3.objects.ProjectJob`
254-
+ :class:`gitlab.v3.objects.ProjectJobManager`
255-
+ :attr:`gitlab.v3.objects.Project.jobs`
256-
+ :attr:`gitlab.Gitlab.project_jobs`
257-
258226
* GitLab API: https://docs.gitlab.com/ce/api/jobs.html
259227

260228
Examples
@@ -268,32 +236,21 @@ job::
268236

269237
List jobs for the project::
270238

271-
builds = project.builds.list() # v3
272-
jobs = project.jobs.list() # v4
273-
274-
To list builds for a specific commit, create a
275-
:class:`~gitlab.v3.objects.ProjectCommit` object and use its
276-
:attr:`~gitlab.v3.objects.ProjectCommit.builds` method (v3 only)::
277-
278-
# v3 only
279-
commit = gl.project_commits.get(commit_sha, project_id=1)
280-
builds = commit.builds()
239+
jobs = project.jobs.list()
281240

282241
To list builds for a specific pipeline or get a single job within a specific
283242
pipeline, create a
284243
:class:`~gitlab.v4.objects.ProjectPipeline` object and use its
285-
:attr:`~gitlab.v4.objects.ProjectPipeline.jobs` method (v4 only)::
244+
:attr:`~gitlab.v4.objects.ProjectPipeline.jobs` method::
286245

287-
# v4 only
288246
project = gl.projects.get(project_id)
289247
pipeline = project.pipelines.get(pipeline_id)
290248
jobs = pipeline.jobs.list() # gets all jobs in pipeline
291249
job = pipeline.jobs.get(job_id) # gets one job from pipeline
292250

293251
Get a job::
294252

295-
project.builds.get(build_id) # v3
296-
project.jobs.get(job_id) # v4
253+
project.jobs.get(job_id)
297254

298255
Get the artifacts of a job::
299256

docs/gl_objects/commits.py

-68
This file was deleted.

0 commit comments

Comments
 (0)