feat: Rename generator configuration JSON object key

This commit is contained in:
oSumAtrIX 2023-10-29 23:37:37 +01:00
parent 1b85bfcda6
commit bd3e19de62
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 9 additions and 9 deletions

View File

@ -9,13 +9,13 @@ The file `generator.py` provides a list of static file generator classes. Each c
The configuration file `config.json` is read which contains the configuration for the API. The configuration file `config.json` is read which contains the configuration for the API.
By specifying the name of the generator in the `generators` array of the configuration, the corresponding generator will be used. The current object of the configuration is passed to the generator. By specifying the name of the generator in the `generators` array of the configuration, the corresponding generator will be used. The current object of the configuration is passed to the generator.
The following API configuration generates the `contributor` and `release` API for selected repositories: The following configuration generates static files using the `contributors` and `releases` generator for selected repositories:
```json ```json
{ {
"api": [ "api": [
{ {
"generators": ["release", "contributor"], "generators": ["releases", "contributors"],
"repositories": ["user/repo"] "repositories": ["user/repo"]
} }
] ]

View File

@ -1,5 +1,5 @@
{ {
"api": [ "configs": [
{ {
"generators": [ "generators": [
"release+contributor" "release+contributor"

12
main.py
View File

@ -4,13 +4,13 @@ from app.generator import DefaultGeneratorProvider
config = load_config() config = load_config()
output = config["output"] output = config["output"]
apis = config["api"] configs = config["configs"]
api_provider = DefaultGeneratorProvider() generator_provider = DefaultGeneratorProvider()
for api in apis: for config in configs:
for generator_name in api["generators"]: for generator_name in config["generators"]:
generator = api_provider.get(generator_name) generator = generator_provider.get(generator_name)
if generator is None: if generator is None:
continue continue
generator.generate(api, output) generator.generate(config, output)