Skip to content

Commit

Permalink
convert default configuration getters from lambdas in an attempt to a…
Browse files Browse the repository at this point in the history
…ddress #17
  • Loading branch information
bckohan committed Mar 5, 2024
1 parent dff40f6 commit cace3d9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 3 additions & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ sphinx-click_ may be more appropriate and will also work for Typer_ commands.
See the github_ repository for issue tracking and source code and install from
PyPI_ with ``pip install sphinxcontrib-typer``.

For example, commands and subcommands are renderable separately in three
For example, commands and subcommands are renderable separately in four
different formats:

* svg
* html
* text
* png

.. typer:: examples.example.app
:convert-png: latex
:preferred: html

|
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ typing-extensions = { version = ">=3.7.4.3", python = "<3.9" }
scikit-learn = "^1.3.2"
beautifulsoup4 = "^4.12.2"
pypdf = ">=3.17.3,<5.0.0"
sphinx-autobuild = [
{ version = ">=2024.2.4", python = ">=3.9"},
{ version = "<2024.2.4", python = "<3.9"},
]


[tool.poetry.extras]
Expand Down
26 changes: 21 additions & 5 deletions sphinxcontrib/typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,13 +923,29 @@ def setup(app: application.Sphinx) -> t.Dict[str, t.Any]:
# Need autodoc to support mocking modules
app.add_directive('typer', TyperDirective)

def get_default_render_html(_):
return typer_render_html

def get_default_get_iframe_height(_):
return typer_get_iframe_height

def get_default_svg2pdf(_):
return typer_svg2pdf

def get_default_convert_png(_):
return typer_convert_png

def get_default_web_driver(_):
return typer_get_web_driver

app.add_config_value(
'typer_render_html', lambda _: typer_render_html, 'env'
'typer_render_html', get_default_render_html, 'env'
)

app.add_config_value(
'typer_get_iframe_height', lambda _: typer_get_iframe_height, 'env'
'typer_get_iframe_height', get_default_get_iframe_height, 'env'
)
app.add_config_value('typer_svg2pdf', lambda _: typer_svg2pdf, 'env')
app.add_config_value('typer_svg2pdf', get_default_svg2pdf, 'env')
app.add_config_value('typer_iframe_height_padding', 30, 'env')
app.add_config_value(
'typer_iframe_height_cache_path',
Expand All @@ -938,10 +954,10 @@ def setup(app: application.Sphinx) -> t.Dict[str, t.Any]:
)

app.add_config_value(
'typer_convert_png', lambda _: typer_convert_png, 'env'
'typer_convert_png', get_default_convert_png, 'env'
)
app.add_config_value(
'typer_get_web_driver', lambda _: typer_get_web_driver, 'env'
'typer_get_web_driver', get_default_web_driver, 'env'
)

return {
Expand Down

0 comments on commit cace3d9

Please sign in to comment.