Skip to content

Commit

Permalink
馃敡 MAINTAIN: Add warning for uninitialised render
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Jan 9, 2022
1 parent 23f15b1 commit ffdd3ad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions myst_parser/docutils_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ def __init__(self, parser: MarkdownIt) -> None:
if k.startswith("render_") and k != "render_children"
}

def __getattr__(self, name: str):
"""Warn when the renderer has not been setup yet."""
if name in (
"md_env",
"config",
"document",
"current_node",
"reporter",
"language_module_rst",
"_level_to_elem",
):
raise AttributeError(
f"'{name}' attribute is not available until setup_render() is called"
)
raise AttributeError(
f"'{type(self).__name__}' object has no attribute '{name}'"
)

def setup_render(
self, options: Dict[str, Any], env: MutableMapping[str, Any]
) -> None:
Expand Down

0 comments on commit ffdd3ad

Please sign in to comment.