Skip to content

Commit c679558

Browse files
committed
Fix docs display
Fix missing docstrings
1 parent 03c5b84 commit c679558

File tree

10 files changed

+72
-9
lines changed

10 files changed

+72
-9
lines changed

config_framework/loaders/composite.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ def load(
2121
cls, *loaders: AbstractLoader,
2222
defaults: Optional[MutableMapping[str, Any]] = None
2323
):
24+
"""
25+
Initializes composite loader.
26+
27+
:param loaders: any number of different config sources that can be used for providing configuration.
28+
:param defaults: default values.
29+
:return: instance of composite loader.
30+
"""
2431
return cls(
2532
data=ChainMap(*loaders),
2633
defaults=defaults or {},

config_framework/loaders/dict.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ def load(
99
cls, data: MutableMapping[str, Any],
1010
defaults: Optional[MutableMapping[str, Any]] = None
1111
):
12+
"""
13+
Wrapper for dicts usage as config source.
14+
15+
:param data: argument expects dictionary that will be used as source.
16+
:param defaults: default values.
17+
:return: instance of dict loader.
18+
"""
1219
return cls(data=data, defaults=defaults or {})
1320

1421
def dump(self, include_defaults: bool = False) -> None:
1522
"""
16-
This method doesn't changes anything since dict is updated whenever
23+
This method doesn't change anything since dict is updated whenever
1724
values are changed.
1825
1926
:param include_defaults: specifies if

config_framework/loaders/env.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
class Environment(AbstractLoader):
88
@classmethod
99
def load(cls, defaults: Optional[MutableMapping[str, Any]] = None):
10+
"""
11+
Loads data from environment.
12+
13+
:param defaults: default values.
14+
:return: instance of env loader.
15+
"""
1016
return cls(data=dict(environ), defaults=defaults or {})
1117

1218
def dump(self, include_defaults: bool = False) -> None:
1319
"""
14-
This method doesn't changes env variables at all
20+
This method doesn't change env variables at all
1521
because not many types, convert properly into string env variable
1622
and can be loaded back.
1723

config_framework/loaders/json.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ def load(
3535
json_loader=json.load,
3636
json_dumper=partial(json.dump, ensure_ascii=False, indent=4),
3737
):
38+
"""
39+
Loads json file from path into loader.
40+
41+
:param path: where file with json is located.
42+
:param defaults: default values.
43+
:param encoding: which encoding does config file has (defaults to utf-8).
44+
:param json_loader: function that loads json file.
45+
:param json_dumper: function that dumps to json file.
46+
:return: instance of json loader.
47+
"""
3848
with open(path, encoding=encoding) as data_f:
3949
data = json_loader(data_f)
4050

config_framework/loaders/json_string.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ def load(
3030
json_loader=json.loads,
3131
json_dumper=partial(json.dumps, ensure_ascii=False, indent=4),
3232
):
33+
"""
34+
Loads json file from path into loader.
35+
36+
:param data_string: string with valid json formatted text.
37+
:param defaults: default values.
38+
:param encoding: which encoding does config file has (defaults to utf-8).
39+
:param json_loader: function that loads json from string.
40+
:param json_dumper: function that dumps to json string.
41+
:return: instance of json string loader.
42+
"""
3343
data = json_loader(data_string)
3444

3545
return cls(
@@ -39,7 +49,7 @@ def load(
3949

4050
def dump(self, include_defaults: bool = False) -> None:
4151
"""
42-
This method doesn't changes anything at all
52+
This method doesn't change anything at all
4353
because strings are unchangeable.
4454
4555
:param include_defaults: specifies if

config_framework/loaders/toml_full_features.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ def load(
3737
3838
:param path: path that is used to load config.
3939
:param defaults: default values.
40-
:param loader_kwargs: used for specifying parameters, according to
41-
tomls' documentation of `toml.load` function.
42-
:param dumper_kwargs: used for specifying parameters, according to
43-
tomls' documentation of `toml.dump` function.
40+
:param loader_kwargs: used for specifying parameters, according to toml documentation of `toml.load` function.
41+
:param dumper_kwargs: used for specifying parameters, according to toml documentation of `toml.dump` function.
4442
:param encoding: which encoding should be used for a file.
4543
:return: instance of TomlReadOnly class.
4644
"""

config_framework/loaders/toml_read_only.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ def load(
4040
4141
:param path: path that is used to load config.
4242
:param defaults: default values.
43-
:param loader_kwargs: used for specifying parameters, according to
44-
tomllibs' documentation of `tomllib.load` function.
43+
:param loader_kwargs: used for specifying parameters, according to tomllib documentation of `tomllib.load`
44+
function.
45+
4546
:param dumper_kwargs: not used.
4647
:param encoding: which encoding should be used for a file.
48+
4749
:return: instance of TomlReadOnly class.
4850
"""
4951
with open(path, encoding=encoding, mode="b") as data_f:

config_framework/loaders/yaml.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ def load(
4343
yaml_loader=partial(yaml.load, Loader=Loader),
4444
yaml_dumper=partial(yaml.dump, Dumper=Dumper),
4545
):
46+
"""
47+
Loads yaml from file.
48+
49+
:param path: where is yaml file to load data from.
50+
:param defaults: default values for config.
51+
:param encoding: which encoding does config file has (defaults to utf-8).
52+
:param yaml_loader: function that is used for loading data from file.
53+
:param yaml_dumper: function that is used for saving data to file.
54+
:return: instance of yaml loader.
55+
"""
4656
with open(path, encoding=encoding) as data_f:
4757
data = yaml_loader(data_f)
4858

docs/source/config_framework.loaders.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ Submodules
4040
:show-inheritance:
4141

4242

43+
.. automodule:: config_framework.loaders.toml_full_features
44+
:members:
45+
:undoc-members:
46+
:show-inheritance:
47+
48+
49+
.. automodule:: config_framework.loaders.toml_read_only
50+
:members:
51+
:undoc-members:
52+
:show-inheritance:
53+
54+
4355
.. automodule:: config_framework.loaders.yaml
4456
:members:
4557
:undoc-members:

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Example of usage
9292
# create an instance of like this: ConfigSample(frozen=False)
9393
# But right now it will raise NotImplementedError
9494
config.some_value = "random"
95+
9596
See examples with explanation `here <https://github.com/Rud356/ConfigFramework/blob/master/examples/>`_
9697

9798
Supported config formats

0 commit comments

Comments
 (0)