Skip to content

Commit f980707

Browse files
author
Gauvain Pocentek
committed
[docs] Move notes examples in their own file
Fixes python-gitlab#472
1 parent f09089b commit f980707

File tree

4 files changed

+92
-120
lines changed

4 files changed

+92
-120
lines changed

docs/api-objects.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ API examples
2222
gl_objects/labels
2323
gl_objects/notifications
2424
gl_objects/mrs
25-
gl_objects/namespaces
2625
gl_objects/milestones
26+
gl_objects/namespaces
27+
gl_objects/notes
2728
gl_objects/pagesdomains
2829
gl_objects/projects
2930
gl_objects/runners

docs/gl_objects/notes.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
.. _project-notes:
2+
3+
#####
4+
Notes
5+
#####
6+
7+
You can manipulate notes (comments) on project issues, merge requests and
8+
snippets.
9+
10+
Reference
11+
---------
12+
13+
* v4 API:
14+
15+
Issues:
16+
17+
+ :class:`gitlab.v4.objects.ProjectIssueNote`
18+
+ :class:`gitlab.v4.objects.ProjectIssueNoteManager`
19+
+ :attr:`gitlab.v4.objects.ProjectIssue.notes`
20+
21+
MergeRequests:
22+
23+
+ :class:`gitlab.v4.objects.ProjectMergeRequestNote`
24+
+ :class:`gitlab.v4.objects.ProjectMergeRequestNoteManager`
25+
+ :attr:`gitlab.v4.objects.ProjectMergeRequest.notes`
26+
27+
Snippets:
28+
29+
+ :class:`gitlab.v4.objects.ProjectSnippetNote`
30+
+ :class:`gitlab.v4.objects.ProjectSnippetNoteManager`
31+
+ :attr:`gitlab.v4.objects.ProjectSnippet.notes`
32+
33+
* v3 API:
34+
35+
Issues:
36+
37+
+ :class:`gitlab.v3.objects.ProjectIssueNote`
38+
+ :class:`gitlab.v3.objects.ProjectIssueNoteManager`
39+
+ :attr:`gitlab.v3.objects.ProjectIssue.notes`
40+
+ :attr:`gitlab.v3.objects.Project.issue_notes`
41+
+ :attr:`gitlab.Gitlab.project_issue_notes`
42+
43+
MergeRequests:
44+
45+
+ :class:`gitlab.v3.objects.ProjectMergeRequestNote`
46+
+ :class:`gitlab.v3.objects.ProjectMergeRequestNoteManager`
47+
+ :attr:`gitlab.v3.objects.ProjectMergeRequest.notes`
48+
+ :attr:`gitlab.v3.objects.Project.mergerequest_notes`
49+
+ :attr:`gitlab.Gitlab.project_mergerequest_notes`
50+
51+
Snippets:
52+
53+
+ :class:`gitlab.v3.objects.ProjectSnippetNote`
54+
+ :class:`gitlab.v3.objects.ProjectSnippetNoteManager`
55+
+ :attr:`gitlab.v3.objects.ProjectSnippet.notes`
56+
+ :attr:`gitlab.v3.objects.Project.snippet_notes`
57+
+ :attr:`gitlab.Gitlab.project_snippet_notes`
58+
59+
* GitLab API: https://docs.gitlab.com/ce/api/notes.html
60+
61+
Examples
62+
--------
63+
64+
List the notes for a resource::
65+
66+
i_notes = issue.notes.list()
67+
mr_notes = mr.notes.list()
68+
s_notes = snippet.notes.list()
69+
70+
Get a note for a resource::
71+
72+
i_note = issue.notes.get(note_id)
73+
mr_note = mr.notes.get(note_id)
74+
s_note = snippet.notes.get(note_id)
75+
76+
Create a note for a resource::
77+
78+
i_note = issue.notes.create({'body': 'note content'})
79+
mr_note = mr.notes.create({'body': 'note content'})
80+
s_note = snippet.notes.create({'body': 'note content'})
81+
82+
Update a note for a resource::
83+
84+
note.body = 'updated note content'
85+
note.save()
86+
87+
Delete a note for a resource::
88+
89+
note.delete()

docs/gl_objects/projects.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -276,33 +276,6 @@
276276
snippet.delete()
277277
# end snippets delete
278278

279-
# notes list
280-
i_notes = issue.notes.list()
281-
mr_notes = mr.notes.list()
282-
s_notes = snippet.notes.list()
283-
# end notes list
284-
285-
# notes get
286-
i_note = issue.notes.get(note_id)
287-
mr_note = mr.notes.get(note_id)
288-
s_note = snippet.notes.get(note_id)
289-
# end notes get
290-
291-
# notes create
292-
i_note = issue.notes.create({'body': 'note content'})
293-
mr_note = mr.notes.create({'body': 'note content'})
294-
s_note = snippet.notes.create({'body': 'note content'})
295-
# end notes create
296-
297-
# notes update
298-
note.body = 'updated note content'
299-
note.save()
300-
# end notes update
301-
302-
# notes delete
303-
note.delete()
304-
# end notes delete
305-
306279
# service get
307280
# For v3
308281
service = project.services.get(service_name='asana', project_id=1)

docs/gl_objects/projects.rst

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -391,98 +391,7 @@ Delete a snippet:
391391
Notes
392392
=====
393393

394-
You can manipulate notes (comments) on the issues, merge requests and snippets.
395-
396-
* :class:`~gitlab.objects.ProjectIssue` with
397-
:class:`~gitlab.objects.ProjectIssueNote`
398-
* :class:`~gitlab.objects.ProjectMergeRequest` with
399-
:class:`~gitlab.objects.ProjectMergeRequestNote`
400-
* :class:`~gitlab.objects.ProjectSnippet` with
401-
:class:`~gitlab.objects.ProjectSnippetNote`
402-
403-
Reference
404-
---------
405-
406-
* v4 API:
407-
408-
Issues:
409-
410-
+ :class:`gitlab.v4.objects.ProjectIssueNote`
411-
+ :class:`gitlab.v4.objects.ProjectIssueNoteManager`
412-
+ :attr:`gitlab.v4.objects.ProjectIssue.notes`
413-
414-
MergeRequests:
415-
416-
+ :class:`gitlab.v4.objects.ProjectMergeRequestNote`
417-
+ :class:`gitlab.v4.objects.ProjectMergeRequestNoteManager`
418-
+ :attr:`gitlab.v4.objects.ProjectMergeRequest.notes`
419-
420-
Snippets:
421-
422-
+ :class:`gitlab.v4.objects.ProjectSnippetNote`
423-
+ :class:`gitlab.v4.objects.ProjectSnippetNoteManager`
424-
+ :attr:`gitlab.v4.objects.ProjectSnippet.notes`
425-
426-
* v3 API:
427-
428-
Issues:
429-
430-
+ :class:`gitlab.v3.objects.ProjectIssueNote`
431-
+ :class:`gitlab.v3.objects.ProjectIssueNoteManager`
432-
+ :attr:`gitlab.v3.objects.ProjectIssue.notes`
433-
+ :attr:`gitlab.v3.objects.Project.issue_notes`
434-
+ :attr:`gitlab.Gitlab.project_issue_notes`
435-
436-
MergeRequests:
437-
438-
+ :class:`gitlab.v3.objects.ProjectMergeRequestNote`
439-
+ :class:`gitlab.v3.objects.ProjectMergeRequestNoteManager`
440-
+ :attr:`gitlab.v3.objects.ProjectMergeRequest.notes`
441-
+ :attr:`gitlab.v3.objects.Project.mergerequest_notes`
442-
+ :attr:`gitlab.Gitlab.project_mergerequest_notes`
443-
444-
Snippets:
445-
446-
+ :class:`gitlab.v3.objects.ProjectSnippetNote`
447-
+ :class:`gitlab.v3.objects.ProjectSnippetNoteManager`
448-
+ :attr:`gitlab.v3.objects.ProjectSnippet.notes`
449-
+ :attr:`gitlab.v3.objects.Project.snippet_notes`
450-
+ :attr:`gitlab.Gitlab.project_snippet_notes`
451-
452-
* GitLab API: https://docs.gitlab.com/ce/api/notes.html
453-
454-
Examples
455-
--------
456-
457-
List the notes for a resource:
458-
459-
.. literalinclude:: projects.py
460-
:start-after: # notes list
461-
:end-before: # end notes list
462-
463-
Get a note for a resource:
464-
465-
.. literalinclude:: projects.py
466-
:start-after: # notes get
467-
:end-before: # end notes get
468-
469-
Create a note for a resource:
470-
471-
.. literalinclude:: projects.py
472-
:start-after: # notes create
473-
:end-before: # end notes create
474-
475-
Update a note for a resource:
476-
477-
.. literalinclude:: projects.py
478-
:start-after: # notes update
479-
:end-before: # end notes update
480-
481-
Delete a note for a resource:
482-
483-
.. literalinclude:: projects.py
484-
:start-after: # notes delete
485-
:end-before: # end notes delete
394+
See :ref:`project-notes`.
486395

487396
Project members
488397
===============

0 commit comments

Comments
 (0)