feat: Rename types key to generators

This commit is contained in:
oSumAtrIX 2023-10-29 23:18:05 +01:00
parent 046fb6991a
commit 75eccddc5b
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 10 additions and 10 deletions

View File

@ -7,7 +7,7 @@ Repository to host a static API using GitHub workflows.
When CI is ran, static files are generated and commited to the `gh-pages` branch. When CI is ran, static files are generated and commited to the `gh-pages` branch.
The file `generator.py` provides a list of static file generator classes. Each class has a name. The file `generator.py` provides a list of static file generator classes. Each class has a name.
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 `types` 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 API configuration generates the `contributor` and `release` API for selected repositories:
@ -15,7 +15,7 @@ The following API configuration generates the `contributor` and `release` API fo
{ {
"api": [ "api": [
{ {
"types": ["release", "contributor"], "generators": ["release", "contributor"],
"repositories": ["user/repo"] "repositories": ["user/repo"]
} }
] ]

View File

@ -1,7 +1,7 @@
{ {
"api": [ "api": [
{ {
"types": [ "generators": [
"release+contributor" "release+contributor"
], ],
"repositories": [ "repositories": [
@ -9,7 +9,7 @@
] ]
}, },
{ {
"types": [ "generators": [
"social" "social"
], ],
"socials": { "socials": {
@ -17,13 +17,13 @@
} }
}, },
{ {
"types": [ "generators": [
"team" "team"
], ],
"organization": "yourorg" "organization": "yourorg"
}, },
{ {
"types": [ "generators": [
"donation" "donation"
], ],
"links": { "links": {

View File

@ -9,8 +9,8 @@ apis = config["api"]
api_provider = DefaultApiProvider() api_provider = DefaultApiProvider()
for api in apis: for api in apis:
for type in api["types"]: for generator_name in api["generators"]:
api_type = api_provider.get(type) generator = api_provider.get(generator_name)
if api_type is None: if generator is None:
continue continue
api_type.generate(api, output) generator.generate(api, output)