Skip to content

Commit

Permalink
Merge b74df28 into 29abc4e
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Dec 9, 2020
2 parents 29abc4e + b74df28 commit be36e47
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 239 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ jobs:
- name: install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -U .
pip install -r dev-requirements.txt
- name: install semantic-release
run:
npm install @semantic-release/exec
- name: generate queenbee schemas
run:
python ./gen_schemas.py
- name: run semantic release
run:
npx semantic-release
Expand Down
20 changes: 19 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/github",
{
"assets": [
{
"path": "docs/_static/schemas/queenbee.json",
"label": "Queenbee schema"
},
{
"path": "docs/_static/schemas/queenbee_inheritance.json",
"label": "Queenbee schema with inheritance"
},
{
"path": "docs/_static/schemas/queenbee_mapper.json",
"label": "Queenbee schema mapper"
}
]
}
],
[
"@semantic-release/exec",
{
Expand Down
90 changes: 0 additions & 90 deletions docs.py

This file was deleted.

56 changes: 2 additions & 54 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from queenbee.repository import RepositoryIndex
from queenbee.job import Job
from queenbee.recipe import Recipe
from queenbee.plugin import Plugin
from queenbee._openapi import get_openapi
import json
import sphinx_bootstrap_theme
import os
import sys
Expand Down Expand Up @@ -247,51 +241,5 @@
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True


folder = os.path.join(os.path.dirname(__file__), '_static/schemas')
if not os.path.isdir(folder):
os.mkdir(folder)

with open(os.path.join(folder, 'job-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(schema_class=Job, title='Queenbee Job Schema',
description='Schema documentation for Queenbee Jobs'),
out_file,
indent=2
)

with open(os.path.join(folder, 'plugin-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(schema_class=Plugin, title='Queenbee Plugin Schema',
description='Schema documentation for Queenbee Plugins'),
out_file,
indent=2
)

with open(os.path.join(folder, 'recipe-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(schema_class=Recipe, title='Queenbee Recipe Schema',
description='Schema documentation for Queenbee Recipes'),
out_file,
indent=2
)

with open(os.path.join(folder, 'repository-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(schema_class=RepositoryIndex, title='Queenbee Repository Schema',
description='Schema documentation for Queenbee Recipes'),
out_file,
indent=2
)

with open(os.path.join(folder, 'job-schema.json'), 'w') as out_file:
out_file.write(Job.schema_json())

with open(os.path.join(folder, 'plugin-schema.json'), 'w') as out_file:
out_file.write(Plugin.schema_json())

with open(os.path.join(folder, 'recipe-schema.json'), 'w') as out_file:
out_file.write(Recipe.schema_json())

with open(os.path.join(folder, 'repository-schema.json'), 'w') as out_file:
out_file.write(RepositoryIndex.schema_json())
# generate schemas
import gen_schemas
134 changes: 134 additions & 0 deletions gen_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
"""A module to generate OpenAPI and JSONSchemas."""

import json
import os

from pkg_resources import get_distribution

from pydantic_openapi_helper.core import get_openapi
from pydantic_openapi_helper.inheritance import class_mapper

from queenbee.repository import RepositoryIndex
from queenbee.job import Job
from queenbee.recipe import Recipe
from queenbee.plugin import Plugin

folder = os.path.join(os.path.dirname(__file__), 'docs/_static/schemas')
if not os.path.isdir(folder):
os.mkdir(folder)

VERSION = '.'.join(get_distribution('queenbee').version.split('.')[:3])

info = {
"description": "",
"version": VERSION,
"title": "",
"contact": {
"name": "Ladybug Tools",
"email": "info@ladybug.tools",
"url": "https://github.com/ladybug-tools/queenbee"
},
"x-logo": {
"url": "https://www.ladybug.tools/assets/img/honeybee.png",
"altText": "Queenbee logo"
},
"license": {
"name": "MIT",
"url": "https://github.com/ladybug-tools/queenbee-schema/blob/master/LICENSE"
}
}

with open(os.path.join(folder, 'job-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(
base_object=[Job], title='Queenbee Job Schema',
description='Schema documentation for Queenbee Jobs',
version=VERSION
),
out_file,
indent=2
)

with open(os.path.join(folder, 'plugin-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(
base_object=[Plugin], title='Queenbee Plugin Schema',
description='Schema documentation for Queenbee Plugins',
version=VERSION
),
out_file,
indent=2
)

with open(os.path.join(folder, 'recipe-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(
base_object=[Recipe], title='Queenbee Recipe Schema',
description='Schema documentation for Queenbee Recipes',
version=VERSION
),
out_file,
indent=2
)

with open(os.path.join(folder, 'repository-openapi.json'), 'w') as out_file:
json.dump(
get_openapi(
base_object=[RepositoryIndex], title='Queenbee Repository Schema',
description='Schema documentation for Queenbee Recipes',
version=VERSION
),
out_file,
indent=2
)

with open(os.path.join(folder, 'job-schema.json'), 'w') as out_file:
out_file.write(Job.schema_json())

with open(os.path.join(folder, 'plugin-schema.json'), 'w') as out_file:
out_file.write(Plugin.schema_json())

with open(os.path.join(folder, 'recipe-schema.json'), 'w') as out_file:
out_file.write(Recipe.schema_json())

with open(os.path.join(folder, 'repository-schema.json'), 'w') as out_file:
out_file.write(RepositoryIndex.schema_json())

# write openapi with inheritance and mapper json files
# these files are mainly used for creating .NET SDK
external_docs = {
"description": "OpenAPI Specification with Inheritance",
"url": "./queenbee_inheritance.json"
}

openapi = get_openapi(
[Recipe, Plugin, Job],
title='Queenbee Schema',
description='Documentation for Queenbee schema.',
version=VERSION, info=info,
external_docs=external_docs
)
with open(os.path.join(folder, 'queenbee.json'), 'w') as out_file:
json.dump(openapi, out_file, indent=2)

# with inheritance
openapi = get_openapi(
[Recipe, Plugin, Job],
title='Queenbee Schema with Inheritance',
description='Documentation for Queenbee schema.',
version=VERSION, info=info,
inheritance=True,
external_docs=external_docs
)
with open(os.path.join(folder, 'queenbee_inheritance.json'), 'w') as out_file:
json.dump(openapi, out_file, indent=2)

# add the mapper file
with open(os.path.join(folder, 'queenbee_mapper.json'), 'w') as out_file:
json.dump(
class_mapper(
[Recipe, Plugin, Job],
['queenbee', 'queenbee.interface']
),
out_file, indent=2
)
Loading

0 comments on commit be36e47

Please sign in to comment.