lsdocs_plugin.testing #
Run a plugin's handlers in-process, as the host would, for tests.
Each function returns (result, events): the handler's result normalized
to the full protocol shape, and the events it sent (log lines, progress,
diagnostics) as dicts with a kind key:
from lsdocs_plugin import testing
result, events = testing.parse(plugin, "a.txt", "hello")
assert result["document"]["children"][0]["value"] == "hello"variable Result #
= function call #
-> Calls method ("parse", "parse/transform/each",
"render/transform/each", "render", "render/transform/all" or
"initialize") with params. settings are given to the
handler as ctx.settings; without them, the plugin's
config_files are read from config["dir"] (config is
ctx.config: dir and name). project and site are
ctx.project (root, source_dir, files) and ctx.site
(title, base_url).
function parse #
-> Parses text as the file source.
function read #
-> Runs parse/transform/each on document.
function apply #
-> Runs the transformer on document with collected data.
function render #
-> Renders document to format. output is returned as bytes.
function render_all #
-> Runs render/transform/all for pages (dicts with source, path
and optional metadata and data). Each file's output is returned as bytes.