mirror of
https://github.com/invoke-ai/InvokeAI
synced 2026-04-19 05:05:59 +02:00
* feat(docs): new docs scaffold * feat(docs): update alternate launchers section * feat(docs): add contributor section * fix(docs): update description of lynxhub launcher mention * feat(docs): add more docs * feat(docs): setup index page * feat(docs): add more docs, rewrote a few pages * feat(docs): add todo * feat(docs): set up internationalization * fix(docs): admonition typo * feat(docs): add invoke styles * feat(docs): add more invoke styling, revamp splash page, remove theme switcher * fix(docs): expressive code sh styles without title * chore(docs): cleanup readme * chore(docs): add new github pages workflow * fix(docs): remove base path * chore(docs): add initial translations CI, powered by Crowdin * feat(docs): upgrade astro * feat(docs): enhance new contributor guide * feat(docs): various enhancements - improve homepage; - enhance some docs pages; - override some layout components; - enhance interactivity and qol styling; - create new download page + component; - add llms.txt; - remove unused logo component; * feat(docs): isolate new docs * style(docs): use md reference links over utility links * chore(docs): specify package manager * feat(docs): releases page * feat(docs): add page context menus * feat(docs): sort workflows sidebar items * fix(docs): relative links on homepage * feat(docs): add text tool and recall params api guides * feat(docs): fix faq links, create models concept page * chore(docs): set CI to new dir, update deployment url * feat(docs): generate settings and api json for pages - update deploy script - add api and settings component to render generated json - increase page content width * style(docs): remove relative path for component import * fix(docs): resolve tests by regenerating json * fix(docs): fixing the test for real this time - sorts openapi output map required field - missing `__name__` attributes - resolved components name keyerror * feat(docs): finish 'adding nodes' page * feat(docs): upgrade astro + starlight, add link tester * chore(docs): upgrade astro * feat(docs): add prompting guides * fix(docs): generated openapi * fix(docs): ci node version * fix(docs): invalid links * fix(docs): md aside formatting * feat(docs): reorder 'configuration' category * feat(docs): change contributor checklist to steps list * chore(docs): upgrade deps * feat(docs): splash page image styling * feat(docs): add gallery marquee to homepage * feat(docs): add splash page marquee gallery * feat(docs): remove openapi generation * fix(docs): regenerate settings json * fix(docs): json generation test --------- Co-authored-by: joshistoast <me@joshcorbett.com> Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
78 lines
2.7 KiB
Python
78 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import json
|
|
from pathlib import Path
|
|
|
|
|
|
def _load_module(module_path: Path, module_name: str):
|
|
spec = importlib.util.spec_from_file_location(module_name, module_path)
|
|
assert spec is not None
|
|
assert spec.loader is not None
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def test_docs_json_export_bundle_structure():
|
|
module = _load_module(Path("scripts/generate_docs_json.py"), "generate_docs_json")
|
|
|
|
bundle = module.build_docs_bundle()
|
|
|
|
assert set(bundle.keys()) == {"invocation_context", "settings"}
|
|
|
|
|
|
def test_docs_json_export_includes_images_interface_and_host_setting():
|
|
module = _load_module(Path("scripts/generate_docs_json.py"), "generate_docs_json")
|
|
|
|
bundle = module.build_docs_bundle()
|
|
|
|
interface_names = {interface["name"] for interface in bundle["invocation_context"]["interfaces"]}
|
|
assert "ImagesInterface" in interface_names
|
|
|
|
setting_names = {setting["name"] for setting in bundle["settings"]["settings"]}
|
|
assert "host" in setting_names
|
|
assert "schema_version" not in setting_names
|
|
|
|
|
|
def test_docs_json_export_includes_rendering_metadata():
|
|
module = _load_module(Path("scripts/generate_docs_json.py"), "generate_docs_json")
|
|
|
|
bundle = module.build_docs_bundle()
|
|
|
|
images_interface = next(
|
|
interface for interface in bundle["invocation_context"]["interfaces"] if interface["name"] == "ImagesInterface"
|
|
)
|
|
save_method = next(method for method in images_interface["methods"] if method["name"] == "save")
|
|
host_setting = next(setting for setting in bundle["settings"]["settings"] if setting["name"] == "host")
|
|
|
|
assert save_method["description"]
|
|
assert "parameters" in save_method
|
|
assert save_method["parameters"]
|
|
|
|
assert host_setting["env_var"] == "INVOKEAI_HOST"
|
|
assert host_setting["category"] == "WEB"
|
|
assert "validation" in host_setting
|
|
assert host_setting["validation"] == {}
|
|
|
|
|
|
def test_docs_json_export_writes_expected_files(tmp_path: Path):
|
|
module = _load_module(Path("scripts/generate_docs_json.py"), "generate_docs_json")
|
|
|
|
bundle = module.build_docs_bundle()
|
|
module.write_docs_bundle(bundle, tmp_path)
|
|
|
|
invocation_context_path = tmp_path / "invocation-context.json"
|
|
settings_path = tmp_path / "settings.json"
|
|
|
|
assert sorted(path.name for path in tmp_path.iterdir()) == [
|
|
"invocation-context.json",
|
|
"settings.json",
|
|
]
|
|
|
|
invocation_context_payload = json.loads(invocation_context_path.read_text())
|
|
settings_payload = json.loads(settings_path.read_text())
|
|
|
|
assert invocation_context_payload == bundle["invocation_context"]
|
|
assert settings_payload == bundle["settings"]
|