diff --git a/README.md b/README.md index efacec6..7967271 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ Repository to host a static API using GitHub workflows. ## How it works -On CI trigger static files are generated and commited to the `gh-pages` branch. - -The static files are generated by the configuration provided in a `config.json` file in the root. -The API configuration consists out of an array of objects. Each object is responsible for an API. Based on the provided pair with the key `type` in these objects a method in `generator.py` is selected to generate the API. The objects are passed to the corresponding method to consume additional key-value pairs. +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. 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": [ { - "type": "release+contributor", + "types": ["release", "contributor"], "repositories": ["user/repo"] } ] diff --git a/config.example.json b/config.example.json index c6b5f34..858d403 100644 --- a/config.example.json +++ b/config.example.json @@ -1,23 +1,31 @@ { "api": [ { - "type": "release+contributor", + "types": [ + "release+contributor" + ], "repositories": [ "user/repo" ] }, { - "type": "social", + "types": [ + "social" + ], "socials": { "website": "https://yourwebsite.com" } }, { - "type": "team", + "types": [ + "team" + ], "organization": "yourorg" }, { - "type": "donation", + "types": [ + "donation" + ], "links": { "liberapay": "https://liberapay.com/yourteam", "github": "https://github.com/sponsors/yourteam" diff --git a/main.py b/main.py index 845a337..523b9fe 100644 --- a/main.py +++ b/main.py @@ -9,9 +9,7 @@ apis = config["api"] api_provider = DefaultApiProvider() for api in apis: - types = api["type"].split("+") - del api["type"] # Don't need the type for the api anymore below - for type in types: + for type in api["types"]: api_type = api_provider.get(type) if api_type is None: continue