Skip to content

Commit 9433ecd

Browse files
committed
Documentation updates and fixes
- Add new callbacks documentation page covering RemoteCallbacks, CheckoutCallbacks, StashApplyCallbacks, and Passthrough. - Add new enums documentation page covering all pygit2.enums classes. - Document missing classes: RemoteHead, PushUpdate, FilterList. - Document missing methods: Repository.load_filter_list, Repository.hashfile. - Fix create_tag docstring showing message as optional when it is required. - Fix Odb.read_header docstring return type. - Fix docstring reST formatting errors in callbacks.py and enums.py. - Update version examples in general.rst to libgit2 1.9.4. - Fix typo in branches.rst example. - Fix bytes/string example in objects.rst create_blob snippet. - Add callbacks.rst and enums.rst to the documentation toctree. - Add .docenv to .gitignore. Fixes: #1323 Fixes: #1289 Assisted-by: Kimi-k2.6
1 parent 926acaf commit 9433ecd

16 files changed

Lines changed: 305 additions & 17 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ pyrightconfig.json
239239
# custom ignore paths
240240
/.envrc
241241
/venv*
242+
/.docenv
242243
/ci/
243244
*.swp
244245
/pygit2/_libgit2.c

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
- Documentation and annotation fixes
1616
[#410](https://github.com/libgit2/pygit2/issues/410)
17+
[#1289](https://github.com/libgit2/pygit2/issues/1289)
18+
[#1323](https://github.com/libgit2/pygit2/issues/1323)
1719
[#1333](https://github.com/libgit2/pygit2/issues/1333)
1820
[#1458](https://github.com/libgit2/pygit2/issues/1458)
1921
[#1460](https://github.com/libgit2/pygit2/pull/1460)

docs/branches.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Example::
3535
>>> # Create a local branch, branching from master
3636
>>> new_branch = repo.branches.local.create('new-branch', repo[master_branch.target])
3737

38-
>>> And delete it
38+
>>> # And delete it
3939
>>> repo.branches.delete('new-branch')
4040

4141

docs/callbacks.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
**********************************************************************
2+
Callbacks
3+
**********************************************************************
4+
5+
Many pygit2 operations accept callback objects. The callbacks module provides
6+
base classes that you can subclass to customize behavior such as progress
7+
reporting, credential lookup, or checkout notifications.
8+
9+
.. contents:: Contents
10+
:local:
11+
12+
13+
Remote callbacks
14+
================
15+
16+
.. autoclass:: pygit2.RemoteCallbacks
17+
:members:
18+
19+
20+
Checkout callbacks
21+
==================
22+
23+
.. autoclass:: pygit2.CheckoutCallbacks
24+
:members:
25+
26+
27+
Stash apply callbacks
28+
=====================
29+
30+
.. autoclass:: pygit2.StashApplyCallbacks
31+
:members:
32+
33+
34+
Passthrough
35+
===========
36+
37+
Callbacks may raise :exc:`pygit2.Passthrough` to tell libgit2 to behave as if
38+
the callback had not been set. This is useful when a callback only wants to
39+
handle some cases and let libgit2 use its default behavior for the rest. See
40+
:doc:`general` for the exception reference.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# author = ''
2424

2525
# The full version, including alpha/beta/rc tags
26-
release = '1.19.2'
26+
release = '1.19.3'
2727

2828

2929
# -- General configuration ---------------------------------------------------

docs/enums.rst

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
**********************************************************************
2+
Enums
3+
**********************************************************************
4+
5+
pygit2 exposes libgit2 constants as Python enums in the :mod:`pygit2.enums`
6+
module. They are preferred over the top-level ``GIT_*`` integer constants.
7+
8+
.. contents:: Contents
9+
:local:
10+
11+
12+
Repository
13+
==========
14+
15+
.. autoclass:: pygit2.enums.RepositoryInitFlag
16+
:members:
17+
18+
.. autoclass:: pygit2.enums.RepositoryInitMode
19+
:members:
20+
21+
.. autoclass:: pygit2.enums.RepositoryOpenFlag
22+
:members:
23+
24+
.. autoclass:: pygit2.enums.RepositoryState
25+
:members:
26+
27+
28+
References and branches
29+
=======================
30+
31+
.. autoclass:: pygit2.enums.BranchType
32+
:members:
33+
34+
.. autoclass:: pygit2.enums.ReferenceFilter
35+
:members:
36+
37+
.. autoclass:: pygit2.enums.ReferenceType
38+
:members:
39+
40+
.. autoclass:: pygit2.enums.ResetMode
41+
:members:
42+
43+
.. autoclass:: pygit2.enums.RevSpecFlag
44+
:members:
45+
46+
47+
Objects
48+
=======
49+
50+
.. autoclass:: pygit2.enums.ObjectType
51+
:members:
52+
53+
.. autoclass:: pygit2.enums.FileMode
54+
:members:
55+
56+
57+
Diff
58+
====
59+
60+
.. autoclass:: pygit2.enums.DeltaStatus
61+
:members:
62+
63+
.. autoclass:: pygit2.enums.DiffFind
64+
:members:
65+
66+
.. autoclass:: pygit2.enums.DiffFlag
67+
:members:
68+
69+
.. autoclass:: pygit2.enums.DiffOption
70+
:members:
71+
72+
.. autoclass:: pygit2.enums.DiffStatsFormat
73+
:members:
74+
75+
76+
Status
77+
======
78+
79+
.. autoclass:: pygit2.enums.FileStatus
80+
:members:
81+
82+
83+
Checkout
84+
========
85+
86+
.. autoclass:: pygit2.enums.CheckoutNotify
87+
:members:
88+
89+
.. autoclass:: pygit2.enums.CheckoutStrategy
90+
:members:
91+
92+
93+
Merge
94+
=====
95+
96+
.. autoclass:: pygit2.enums.MergeAnalysis
97+
:members:
98+
99+
.. autoclass:: pygit2.enums.MergeFavor
100+
:members:
101+
102+
.. autoclass:: pygit2.enums.MergeFileFlag
103+
:members:
104+
105+
.. autoclass:: pygit2.enums.MergeFlag
106+
:members:
107+
108+
.. autoclass:: pygit2.enums.MergePreference
109+
:members:
110+
111+
112+
Blame
113+
=====
114+
115+
.. autoclass:: pygit2.enums.BlameFlag
116+
:members:
117+
118+
119+
Filters
120+
=======
121+
122+
.. autoclass:: pygit2.enums.FilterMode
123+
:members:
124+
125+
.. autoclass:: pygit2.enums.FilterFlag
126+
:members:
127+
128+
.. autoclass:: pygit2.enums.BlobFilter
129+
:members:
130+
131+
132+
Attributes
133+
==========
134+
135+
.. autoclass:: pygit2.enums.AttrCheck
136+
:members:
137+
138+
139+
Remotes
140+
=======
141+
142+
.. autoclass:: pygit2.enums.CredentialType
143+
:members:
144+
145+
.. autoclass:: pygit2.enums.FetchPrune
146+
:members:
147+
148+
149+
Submodules
150+
==========
151+
152+
.. autoclass:: pygit2.enums.SubmoduleIgnore
153+
:members:
154+
155+
.. autoclass:: pygit2.enums.SubmoduleStatus
156+
:members:
157+
158+
159+
Stash
160+
=====
161+
162+
.. autoclass:: pygit2.enums.StashApplyProgress
163+
:members:
164+
165+
166+
Revwalk
167+
=======
168+
169+
.. autoclass:: pygit2.enums.SortMode
170+
:members:
171+
172+
.. autoclass:: pygit2.enums.DescribeStrategy
173+
:members:
174+
175+
176+
Apply
177+
=====
178+
179+
.. autoclass:: pygit2.enums.ApplyLocation
180+
:members:
181+
182+
183+
Library
184+
=======
185+
186+
.. autoclass:: pygit2.enums.Feature
187+
:members:
188+
189+
.. autoclass:: pygit2.enums.Option
190+
:members:
191+
192+
.. autoclass:: pygit2.enums.ConfigLevel
193+
:members:

docs/filters.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ Registering filters
1919
.. autofunction:: pygit2.filter_register
2020
.. autofunction:: pygit2.filter_unregister
2121

22+
Loading filters
23+
===============
24+
25+
.. automethod:: pygit2.Repository.load_filter_list
26+
27+
The FilterList type
28+
-------------------
29+
30+
.. autoclass:: pygit2.filter.FilterList
31+
:members:
32+
2233
Example
2334
=======
2435

docs/general.rst

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,41 @@ library that has been built against. The version number has a
1818
.. py:data:: LIBGIT2_VER_MAJOR
1919
2020
Integer value of the major version number. For example, for the version
21-
``0.26.0``::
21+
``1.9.4``::
2222

2323
>>> print(pygit2.LIBGIT2_VER_MAJOR)
24-
0
24+
1
2525

2626
.. py:data:: LIBGIT2_VER_MINOR
2727
2828
Integer value of the minor version number. For example, for the version
29-
``0.26.0``::
29+
``1.9.4``::
3030

3131
>>> print(pygit2.LIBGIT2_VER_MINOR)
32-
26
32+
9
3333

3434
.. py:data:: LIBGIT2_VER_REVISION
3535
3636
Integer value of the revision version number. For example, for the version
37-
``0.26.0``::
37+
``1.9.4``::
3838

3939
>>> print(pygit2.LIBGIT2_VER_REVISION)
40-
0
40+
4
4141

4242
.. py:data:: LIBGIT2_VER
4343
4444
Tuple value of the revision version numbers. For example, for the version
45-
``0.26.0``::
45+
``1.9.4``::
4646

4747
>>> print(pygit2.LIBGIT2_VER)
48-
(0, 26, 0)
48+
(1, 9, 4)
4949

5050
.. py:data:: LIBGIT2_VERSION
5151
5252
The libgit2 version number as a string::
5353

5454
>>> print(pygit2.LIBGIT2_VERSION)
55-
'0.26.0'
55+
'1.9.4'
5656

5757
Options
5858
=========
@@ -80,3 +80,11 @@ Exception when trying to create an object (reference, etc) that already exists.
8080
:undoc-members:
8181

8282
Exception when an input specification such as a reference name is invalid.
83+
84+
.. autoexception:: pygit2.Passthrough
85+
:members:
86+
:show-inheritance:
87+
:undoc-members:
88+
89+
Exception that can be raised from a callback to tell libgit2 to behave as if
90+
that callback had not been set. See :doc:`callbacks` for details.

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ Table of Contents
6262
backends
6363
blame
6464
branches
65+
callbacks
6566
commit_log
6667
config
6768
diff
69+
enums
6870
features
6971
filters
7072
index_file

docs/objects.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,23 @@ them to the Git object database:
112112

113113
Example:
114114

115-
>>> id = repo.create_blob('foo bar') # Creates blob from a byte string
115+
>>> id = repo.create_blob(b'foo bar') # Creates blob from a byte string
116116
>>> blob = repo[id]
117117
>>> blob.data
118-
'foo bar'
118+
b'foo bar'
119119

120120
There are also some functions to calculate the id for a byte string without
121121
creating the blob object:
122122

123123
.. autofunction:: pygit2.hash
124124
.. autofunction:: pygit2.hashfile
125125

126+
To calculate the hash of a file using the repository's filtering rules (e.g.
127+
``core.safecrlf``), use the repository's instance method:
128+
129+
.. automethod:: pygit2.Repository.hashfile
130+
:noindex:
131+
126132
Streaming blob content
127133
----------------------
128134

0 commit comments

Comments
 (0)