mirror of
https://github.com/revanced/revanced-static-api.git
synced 2025-04-29 22:24:37 +02:00
feat: Rename types
key to generators
This commit is contained in:
parent
046fb6991a
commit
75eccddc5b
@ -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.
|
||||
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.
|
||||
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:
|
||||
|
||||
@ -15,7 +15,7 @@ The following API configuration generates the `contributor` and `release` API fo
|
||||
{
|
||||
"api": [
|
||||
{
|
||||
"types": ["release", "contributor"],
|
||||
"generators": ["release", "contributor"],
|
||||
"repositories": ["user/repo"]
|
||||
}
|
||||
]
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"api": [
|
||||
{
|
||||
"types": [
|
||||
"generators": [
|
||||
"release+contributor"
|
||||
],
|
||||
"repositories": [
|
||||
@ -9,7 +9,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"types": [
|
||||
"generators": [
|
||||
"social"
|
||||
],
|
||||
"socials": {
|
||||
@ -17,13 +17,13 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"types": [
|
||||
"generators": [
|
||||
"team"
|
||||
],
|
||||
"organization": "yourorg"
|
||||
},
|
||||
{
|
||||
"types": [
|
||||
"generators": [
|
||||
"donation"
|
||||
],
|
||||
"links": {
|
||||
|
8
main.py
8
main.py
@ -9,8 +9,8 @@ apis = config["api"]
|
||||
api_provider = DefaultApiProvider()
|
||||
|
||||
for api in apis:
|
||||
for type in api["types"]:
|
||||
api_type = api_provider.get(type)
|
||||
if api_type is None:
|
||||
for generator_name in api["generators"]:
|
||||
generator = api_provider.get(generator_name)
|
||||
if generator is None:
|
||||
continue
|
||||
api_type.generate(api, output)
|
||||
generator.generate(api, output)
|
||||
|
Loading…
x
Reference in New Issue
Block a user