-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate benchcomp.yaml
documentation from schema
#2593
Closed
Closed
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
79b06d3
Rename old visualization generator script
karkhaz fc8b6b5
Add CSS comment style to copyright check
karkhaz 11f3ffe
Add `schema` schema for benchcomp config file
karkhaz b0be71f
Fix error in build-docs.sh
karkhaz e4d95b2
Generate benchcomp documentation from schemas
karkhaz f5f9118
Only use one suite
karkhaz 8ffdaed
remove spurious blank line
karkhaz 7137231
Use more accessible/less garish colors
karkhaz f6519de
Minor fixes
karkhaz 7a79c5f
Merge branch 'main' into kk-gen-docs
tautschnig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Copyright Kani Contributors | ||
* SPDX-License-Identifier: Apache-2.0 OR MIT | ||
*/ | ||
|
||
.schema_key { | ||
font-weight: bold !important; | ||
color: #dc322f !important; | ||
} | ||
.schema_type { | ||
color: #6c71c4 !important; | ||
text-decoration: underline !important; | ||
} | ||
.schema_desc { | ||
opacity: 35% !important; | ||
margin-left: 1em !important; | ||
font-style: italic !important; | ||
} | ||
.schema_comb { | ||
color: #268bd2 !important; | ||
} | ||
ul.schema li { | ||
list-style: none !important; | ||
} | ||
ul.schema { | ||
padding-left: 2em !important; | ||
background-color: #00000005 !important; | ||
border-left: solid 2px #00000005 !important; | ||
} |
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,62 @@ | ||
{# Copyright Kani Contributors #} | ||
{# SPDX-License-Identifier: Apache-2.0 OR MIT #} | ||
|
||
{% if schema.type_name == "list" %} | ||
<ul class="schema"> | ||
{% for sub_property in schema.iterate_properties %} | ||
<li>- {{ sub_property.property_name }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
|
||
{% if schema.type_name == "object" %} | ||
<ul class="schema"> | ||
{% for sub_property in schema.iterate_properties %} | ||
{% if sub_property.property_name %} | ||
<li> | ||
{% if sub_property.property_name == "_str" %} | ||
{% set name = "string" %} | ||
{% set type = "schema_type" %} | ||
{% else %} | ||
{% set name = sub_property.property_name %} | ||
{% set type = "schema_key" %} | ||
{% endif %} | ||
<span class="{{ type }}"> | ||
{% if name == sub_property.property_name %}"{% endif -%} | ||
{{ name }} | ||
{%- if name == sub_property.property_name %}"{% endif -%} | ||
</span>: | ||
{% if sub_property.type_name != "object" %} | ||
{% if name == sub_property.type_name %} | ||
<span class="schema_key">{{ name }}</span> | ||
{% endif %} | ||
<span class="schema_type">{{ sub_property.type_name }}</span> | ||
{% else %} | ||
{% if name == sub_property.type_name %} | ||
<span class="schema_key">{{ name }}</span>: | ||
{% endif %} | ||
{% endif %} | ||
<span class="schema_desc">{{ sub_property.description }}</span> | ||
</li> | ||
{% endif %} | ||
{% with schema=sub_property %} | ||
{% include "schema.jinja2.html" %} | ||
{% endwith %} | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
|
||
{% if schema.kw_any_of%} | ||
<span class="schema_comb">One of:</span> | ||
{% for sub_property in schema.kw_any_of.array_items %} | ||
{% if sub_property.property_name %} | ||
<li> | ||
<span class="schema_key">{{ sub_property.property_name }}</span> | ||
<span class="schema_desc">{{ sub_property.description }}</span> | ||
</li> | ||
{% endif %} | ||
{% with schema=sub_property %} | ||
{% include "schema.jinja2.html" %} | ||
{% endwith %} | ||
{% endfor %} | ||
{% endif %} |
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,64 @@ | ||
#!/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 | ||
import pathlib | ||
import sys | ||
import tempfile | ||
|
||
import json_schema_for_humans as jsfh | ||
import json_schema_for_humans.generation_configuration | ||
import json_schema_for_humans.generate | ||
import schema | ||
|
||
sys.path.append(str(pathlib.Path(__file__).parent.parent / "tools" / "benchcomp")) | ||
|
||
# autopep8: off | ||
import benchcomp.schemas | ||
# autopep8: on | ||
|
||
|
||
def main(): | ||
out_dir = pathlib.Path(sys.argv[1]).resolve() | ||
out_dir.mkdir(exist_ok=True, parents=True) | ||
|
||
template = ( | ||
pathlib.Path(__file__).parent.parent / | ||
"docs/src/schema.jinja2.html").resolve() | ||
config = jsfh.generation_configuration.GenerationConfiguration( | ||
template_name="md", examples_as_yaml=True, with_footer=False, | ||
copy_css=False, copy_js=False, custom_template_path=template) | ||
|
||
with tempfile.TemporaryDirectory() as tmpdir: | ||
tmpdir = pathlib.Path(tmpdir) | ||
for name, klass in inspect.getmembers(benchcomp.schemas): | ||
if not inspect.isclass(klass): | ||
continue | ||
if name.startswith("_"): | ||
continue | ||
|
||
s = schema.Schema(klass().get_raw_schema()["schema"]) | ||
schema_docs = s.json_schema( | ||
f"https://github.com/model-checking/kani/benchcomp/{name}") | ||
|
||
with open(tmpdir / f"{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) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to have a paragraph to explain the workflow of a variant in this configuration.