Add durable portable graph publication
This commit is contained in:
parent
96e3965855
commit
1134c2d375
19 changed files with 2542 additions and 13 deletions
|
|
@ -10,9 +10,19 @@ import tempfile
|
|||
from pathlib import Path
|
||||
from typing import cast
|
||||
|
||||
from docforge.graph_projection import (
|
||||
GraphViewRequestV1,
|
||||
build_graph_projection_package,
|
||||
build_graph_view_plan,
|
||||
)
|
||||
from docforge.index import ProjectIndex
|
||||
from docforge.project import Project
|
||||
from docforge.rendering import RenderService
|
||||
from docforge_renderers.graph import (
|
||||
PORTABLE_GRAPH_CSS,
|
||||
PORTABLE_GRAPH_JAVASCRIPT,
|
||||
PortableGraphHtmlRenderer,
|
||||
)
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ASSET_ROOT = ROOT / "src" / "docforge" / "assets"
|
||||
|
|
@ -39,6 +49,30 @@ def _rendered_manual_html() -> str:
|
|||
return (project_root / relative_path).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def _portable_graph_html() -> str:
|
||||
project = Project.open(ROOT / "tests" / "fixtures" / "alpha")
|
||||
plan = build_graph_view_plan(
|
||||
project.load(),
|
||||
GraphViewRequestV1(
|
||||
view_id="web-quality",
|
||||
title="Portable graph quality fixture",
|
||||
root_node_id="guide.workflow",
|
||||
depth=2,
|
||||
max_nodes=20,
|
||||
max_edges=40,
|
||||
max_work=1_000,
|
||||
),
|
||||
False,
|
||||
)
|
||||
package = build_graph_projection_package(
|
||||
plan,
|
||||
renderer_id=PortableGraphHtmlRenderer.renderer_id,
|
||||
renderer_version=PortableGraphHtmlRenderer.renderer_version,
|
||||
max_output_bytes=1_000_000,
|
||||
)
|
||||
return PortableGraphHtmlRenderer().render(package).artifacts[0].content.decode("utf-8")
|
||||
|
||||
|
||||
def _tool(name: str) -> str:
|
||||
suffix = ".cmd" if os.name == "nt" else ""
|
||||
path = ROOT / "node_modules" / ".bin" / f"{name}{suffix}"
|
||||
|
|
@ -82,6 +116,16 @@ def main() -> int:
|
|||
],
|
||||
_rendered_manual_html(),
|
||||
),
|
||||
(
|
||||
"portable graph HTML",
|
||||
[
|
||||
_tool("html-validate"),
|
||||
"--stdin",
|
||||
"--stdin-filename=portable-graph.html",
|
||||
"--max-warnings=0",
|
||||
],
|
||||
_portable_graph_html(),
|
||||
),
|
||||
(
|
||||
"CSS",
|
||||
[
|
||||
|
|
@ -102,6 +146,26 @@ def main() -> int:
|
|||
],
|
||||
(ASSET_ROOT / "graph.js").read_text(encoding="utf-8"),
|
||||
),
|
||||
(
|
||||
"portable graph CSS",
|
||||
[
|
||||
_tool("stylelint"),
|
||||
"--stdin",
|
||||
"--stdin-filename=portable-graph.css",
|
||||
"--max-warnings=0",
|
||||
],
|
||||
PORTABLE_GRAPH_CSS,
|
||||
),
|
||||
(
|
||||
"portable graph JavaScript",
|
||||
[
|
||||
_tool("eslint"),
|
||||
"--stdin",
|
||||
"--stdin-filename=portable-graph.js",
|
||||
"--max-warnings=0",
|
||||
],
|
||||
PORTABLE_GRAPH_JAVASCRIPT,
|
||||
),
|
||||
)
|
||||
results = [_run(label, command, content) for label, command, content in checks]
|
||||
return 0 if all(results) else 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue