From aeab34f3fc8a35ca589776052fd834cadbc978e3 Mon Sep 17 00:00:00 2001 From: Kareem Khazem Date: Thu, 13 Jul 2023 09:32:06 +0100 Subject: [PATCH] Minor fixes --- scripts/gen_format_schemas.py | 12 ++++++++++-- tools/benchcomp/benchcomp/__init__.py | 2 +- tools/benchcomp/benchcomp/schemas.py | 3 +-- tools/benchcomp/requirements.txt | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/gen_format_schemas.py b/scripts/gen_format_schemas.py index 3cc3e3d5b433..390c743aa5f6 100755 --- a/scripts/gen_format_schemas.py +++ b/scripts/gen_format_schemas.py @@ -1,6 +1,16 @@ #!/usr/bin/env python3 # Copyright Kani Contributors # SPDX-License-Identifier: Apache-2.0 OR MIT +# +# Generate documentation for every public class in the `benchcomp.schemas` +# module. This script generates one Markdown file for each class; these Markdown +# files can then be included in the Kani book. +# +# The script first dumps the schema into JSON Draft-07 [1] format, and then used +# the json_schema_for_humans package to render that into Markdown. +# +# [1] https://json-schema.org/draft-07/json-schema-release-notes.html + import inspect import json @@ -45,8 +55,6 @@ def main(): with open(tmpdir / f"{name}.json", "w") as handle: print(json.dumps(schema_docs, indent=2), file=handle) - with open(f"/tmp/{name}.json", "w") as handle: - print(json.dumps(schema_docs, indent=2), file=handle) jsfh.generate.generate_from_filename( tmpdir, out_dir / f"{name}.md", config=config) diff --git a/tools/benchcomp/benchcomp/__init__.py b/tools/benchcomp/benchcomp/__init__.py index 0d0ead2d77aa..8cc9583d9bdd 100644 --- a/tools/benchcomp/benchcomp/__init__.py +++ b/tools/benchcomp/benchcomp/__init__.py @@ -20,7 +20,7 @@ class _SchemaValidator: """Validate data structures with a schema Objects of this class are callable, with a single `data` argument. The data - is validated and returned if the `schema` packages is installed, or returned + is validated and returned if the `schema` package is installed, or returned if not. """ diff --git a/tools/benchcomp/benchcomp/schemas.py b/tools/benchcomp/benchcomp/schemas.py index 6c786d0c3c38..2708c692c9db 100644 --- a/tools/benchcomp/benchcomp/schemas.py +++ b/tools/benchcomp/benchcomp/schemas.py @@ -46,9 +46,8 @@ def _replace_types(self, schema_dict): def __call__(self): s = self.get_raw_schema() - name, description = s["name"], s["description"] ret = self._replace_types(s["schema"]) - return schema.Schema(ret, name=name, description=description) + return schema.Schema(ret, name=s["name"], description=s["description]") diff --git a/tools/benchcomp/requirements.txt b/tools/benchcomp/requirements.txt index 5740eef76b4e..6c344fa3c238 100644 --- a/tools/benchcomp/requirements.txt +++ b/tools/benchcomp/requirements.txt @@ -1,3 +1,3 @@ -schema json-schema-for-humans pyyaml +schema