Skip to content

Commit 5a4203b

Browse files
committed
Merge branch 'feature/update-docs' into feature/return-config-entry-from-iter
2 parents 8ca94fc + 0c1f2d8 commit 5a4203b

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

docs/config.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ The Config type
1717
.. method:: Config.__iter__()
1818

1919
The :class:`Config` class has an iterator which can be used to loop
20-
through all the entries in the configuration. Each element is a tuple
21-
containing the name and the value of each configuration variable. Be
20+
through all the entries in the configuration. Each element is a ``ConfigEntry`` object containing the name, level, and value of each configuration variable. Be
2221
aware that this may return multiple versions of each entry if they are
2322
set multiple times in the configuration files.
2423

@@ -32,3 +31,14 @@ string. In order to apply the git-config parsing rules, you can use
3231

3332
.. automethod:: pygit2.Config.get_bool
3433
.. automethod:: pygit2.Config.get_int
34+
35+
36+
The ConfigEntry type
37+
====================
38+
39+
.. automethod:: pygit2.ConfigEntry.decode_as_string
40+
.. automethod:: pygit2.ConfigEntry._from_c
41+
.. automethod:: pygit2.ConfigEntry.name
42+
.. automethod:: pygit2.ConfigEntry.level
43+
.. automethod:: pygit2.ConfigEntry.value
44+
.. automethod:: pygit2.ConfigEntry.value_string

pygit2/config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ class ConfigEntry(object):
292292

293293
@classmethod
294294
def _from_c(cls, ptr, from_iterator=False):
295+
"""Builds the entry from a ``git_config_entry`` pointer. ``from_iterator``
296+
should be ``True`` when the entry was created during ``git_config_iterator``
297+
actions
298+
"""
295299
entry = cls.__new__(cls)
296300
entry._entry = ptr
297301
entry.from_iterator = from_iterator
@@ -303,20 +307,30 @@ def __del__(self):
303307

304308
@property
305309
def value(self):
310+
"""The raw ``cData`` entry value
311+
"""
306312
return self._entry.value
307313

308314
@property
309315
def level(self):
316+
"""The entry's ``git_config_level_t`` value
317+
"""
310318
return self._entry.level
311319

312320
@property
313321
def name(self):
322+
"""The entry's name
323+
"""
314324
return self.decode_as_string(self._entry.name)
315325

316326
@property
317327
def value_string(self):
328+
"""The entry's value as a string
329+
"""
318330
return self.decode_as_string(self.value)
319331

320332
@staticmethod
321333
def decode_as_string(value):
334+
"""Returns ``value`` as a decoded ``utf-8`` string.
335+
"""
322336
return ffi.string(value).decode('utf-8')

0 commit comments

Comments
 (0)