Classes
PageJSONGenerator
Generates per-page JSON files.
Creates a JSON file alongside each HTML page containing metadata,
c…
PageJSONGenerator
Generates per-page JSON files.
Creates a JSON file alongside each HTML page containing metadata, content, and graph connections for client-side features.
Methods 2
generate
Generate JSON files for all pages.
generate
def generate(self, pages: list[Page], accumulated_json: list[tuple[Any, dict[str, Any]]] | None = None) -> int
Generate JSON files for all pages.
Parameters 2
pages |
list[Page] |
List of pages to generate JSON for (used if accumulated_json not provided) |
accumulated_json |
list[tuple[Any, dict[str, Any]]] | None |
Optional pre-computed JSON data from rendering phase. If provided, uses this instead of iterating pages again. |
Returns
Number of JSON files generatedint
—
page_to_json
Convert page to JSON representation.
page_to_json
def page_to_json(self, page: Page, include_html: bool = True, include_text: bool = True, excerpt_length: int = 200) -> dict[str, Any]
Convert page to JSON representation.
Parameters 4
page |
Page |
Page object |
include_html |
bool |
Include full HTML content |
include_text |
bool |
Include plain text content |
excerpt_length |
int |
Length of excerpt |
Returns
Dictionary suitable for JSON serializationdict[str, Any]
—
Internal Methods 2
__init__
Initialize the JSON generator.
__init__
def __init__(self, site: Site, graph_data: dict[str, Any] | None = None, include_html: bool = False, include_text: bool = True) -> None
Initialize the JSON generator.
Parameters 4
site |
Site |
Site instance |
graph_data |
dict[str, Any] | None |
Optional pre-computed graph data for contextual minimap |
include_html |
bool |
Whether to include HTML content in JSON (default: False, HTML file already exists) |
include_text |
bool |
Whether to include plain text content in JSON (default: True) |
_get_page_connections
Get filtered graph data showing only connections to the current page.
_get_page_connections
def _get_page_connections(self, page: Page, graph_data: dict[str, Any], max_connections: int = 15) -> dict[str, Any] | None
Get filtered graph data showing only connections to the current page.
Parameters 3
page |
Page |
Page object to get connections for |
graph_data |
dict[str, Any] |
Full graph data from GraphVisualizer.generate_graph_data() |
max_connections |
int |
Maximum number of connected nodes to include |
Returns
Filtered graph data with only current page and its connections,
or None if page not in graphdict[str, Any] | None
—