Allow json output to work when using terraform viewcode
Before this patch, if you tried to produce JSON output from sphinx while using the sphinx_terraform.viewcode
Sphinx extension, you would get:
File "/venv/lib/python3.10/json/encoder.py", line 182, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type PosixPath is not JSON serializable
This is because the title
key in the context for the code page object in sphinx_terraform.viewcode.html.py:HtmlWriter.gen_sourcecode_html()
was set to a pathlib.Path
instead of a string.
This patch forces title
to be a string.
Edited by Chris Malek