-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #617 from bioimage-io/friendly_json_schema
Adds scripts for generating json schemas for humans
- Loading branch information
Showing
5 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import shutil | ||
import sys | ||
from pathlib import Path | ||
|
||
from json_schema_for_humans.generate import generate_from_filename | ||
from json_schema_for_humans.generation_configuration import GenerationConfiguration | ||
|
||
if __name__ == "__main__": | ||
glob_pattern = "dist/bioimageio_schema_*.json" | ||
schema_paths = list(Path().glob(glob_pattern)) | ||
if not schema_paths: | ||
raise FileNotFoundError( | ||
f"no json schema files found with pattern '{glob_pattern}'" | ||
) | ||
|
||
for schema_file_path in schema_paths: | ||
output_dir = Path() / f"dist/{schema_file_path.stem}" | ||
if output_dir.exists(): | ||
shutil.rmtree(output_dir) | ||
|
||
output_dir.mkdir(parents=True) | ||
|
||
generate_from_filename( | ||
schema_file_name=schema_file_path, | ||
result_file_name=str(output_dir / "index.html"), | ||
config=GenerationConfiguration( | ||
link_to_reused_ref=False, | ||
deprecated_from_description=True, | ||
default_from_description=True, | ||
examples_as_yaml=True, | ||
expand_buttons=True, | ||
description_is_markdown=True, | ||
copy_css=True, | ||
copy_js=True, | ||
), | ||
) | ||
|
||
print(f"Generated json schema docs at {output_dir}", file=sys.stderr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters