Updated docs
This commit is contained in:
69
docs/build/html/_sources/deprecated.md.txt
vendored
Normal file
69
docs/build/html/_sources/deprecated.md.txt
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
# Deprecated
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [ConfigurationModelABC.from_dict](#ConfigurationModelABC-from_dict-method)
|
||||
|
||||
## ConfigurationModelABC from_dict method
|
||||
|
||||
We now process the configuration models directly in the configuration by recursive parameter parsing.
|
||||
|
||||
The JSONProcessor now goes through the JSON and the arguments of the __init__ and links the attributes by name from the
|
||||
JSON and the name of the keyword argument.
|
||||
Now, based on the type, either simply assigns the value. With a ``dict`` the processor is called recursively and so the
|
||||
JSON is processed further. This way nested ConfigurationModels can be processed.
|
||||
|
||||
For this the code must be adapted as follows:
|
||||
|
||||
From this:
|
||||
|
||||
```sh
|
||||
class VersionSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self.major: Optional[str] = "0"
|
||||
self.minor: Optional[str] = "0"
|
||||
self.micro: Optional[str] = "0"
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
self.major = settings["Major"]
|
||||
self.minor = settings["Minor"]
|
||||
micro = settings["Micro"]
|
||||
if micro != '':
|
||||
self.micro = micro
|
||||
```
|
||||
|
||||
To this:
|
||||
|
||||
```sh
|
||||
class VersionSettings(ConfigurationModelABC):
|
||||
def __init__(self, major: str = None, minor: str = None, micro: str = None):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self.major: Optional[str] = major
|
||||
self.minor: Optional[str] = minor
|
||||
self.micro: Optional[str] = micro if micro != "" else None
|
||||
```
|
||||
|
||||
This makes the [from_dict](#from_dict) function obsolete.
|
||||
|
||||
A few rules must be observed:
|
||||
|
||||
- Only simple types can be processed
|
||||
<br>
|
||||
Wrong: ```dict[str, str]```
|
||||
<br>
|
||||
Correct: ```dict```
|
||||
<br>
|
||||
<br>
|
||||
Incorrect: ```list[str]```
|
||||
<br>
|
||||
Correct: ```list```
|
||||
|
||||
- The arguments must be optional, i.e. created as kwargs
|
||||
<br>
|
||||
Incorrect: ```def __init__(self, x: int, y: int)```
|
||||
<br>
|
||||
Correct: ```def __init__(self, x: int = None, y: int = None)```
|
3
docs/build/html/_sources/index.rst.txt
vendored
3
docs/build/html/_sources/index.rst.txt
vendored
@@ -14,7 +14,7 @@ This CPL docs help you learn, understand and use the package. From your first ap
|
||||
Features
|
||||
--------
|
||||
- cpl-core
|
||||
- Expandle
|
||||
- Expandable
|
||||
- Application base
|
||||
- Standardized application classes
|
||||
- Application object builder
|
||||
@@ -87,6 +87,7 @@ These pages go into great detail about everything the Library can do.
|
||||
introduction
|
||||
getting_started
|
||||
contributing
|
||||
deprecated
|
||||
cpl_cli
|
||||
cpl_core
|
||||
cpl_discord
|
||||
|
Reference in New Issue
Block a user