Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call embed_images when including a file #692

Merged
merged 7 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Unreleased: pdoc next

- Fix image embedding in included rST files.
([#692](https://github.com/mitmproxy/pdoc/pull/692), @meghprkh)
- Support type-hints from stub-only packages. E.g: `scipy-stubs`
([#671](https://github.com/mitmproxy/pdoc/pull/671), @erikdesmedt)
- Modify css styles for MathJax to remove unnessesary scroll bars
Expand Down
1 change: 1 addition & 0 deletions pdoc/docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ def _rst_admonition(m: re.Match[str]) -> str:
warnings.warn(f"Cannot include {val!r}: {e}")
included = "\n"
included = _rst_admonitions(included, loc.parent / val)
included = embed_images(included, loc.parent / val)
return indent(included, ind)
if type == "math":
return f"{ind}$${val}{contents}$$\n"
Expand Down
2 changes: 2 additions & 0 deletions test/testdata/flavors_rst.html
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ <h6 id="this-warning-has-a-title-only">This warning has a title only.</h6>

<p>Hello</p>

<p><img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHJvbGU9ImltZyIgYXJpYS1sYWJlbD0icGRvYyBsb2dvIiB3aWR0aD0iMzAwIiBoZWlnaHQ9IjE1MCIgdmlld0JveD0iLTEgMCA2MCAzMCI+PHRpdGxlPnBkb2M8L3RpdGxlPjxwYXRoIGQ9Ik0yOS42M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DggMS4zLjQ4LjY2IDAgMS4zMi0uNS42Ni0uNS42Ni0xLjQ4IDAtLjk4LS42Mi0xLjQ2LS42Mi0uNDgtMS4zNC0uNDgtLjcyIDAtMS4zNC41LS42Mi41LS42MiAxLjQ4IDAgLjk2LjY0IDEuNDZ6bTExLjQxMi0xLjQ0cTAgLjg0LjU2IDEuMzIuNTYuNDYgMS4xOC40Ni42NCAwIDEuMTgtLjM2LjU2LS4zOC45LS4zOC42IDAgMS40NiAxLjA2LjQ2LjU4LjQ2IDEuMDQgMCAuNzYtMS4xIDEuNDItMS4xNC44LTIuOC44LTEuODYgMC0zLjU4LTEuMzQtLjgyLS42NC0xLjM0LTEuNy0uNTItMS4wOC0uNTItMi4zNiAwLTEuMy41Mi0yLjM0LjUyLTEuMDYgMS4zNC0xLjcgMS42Ni0xLjMyIDMuNTQtMS4zMi43NiAwIDEuNDguMjIuNzIuMiAxLjA2LjRsLjMyLjJxLjM2LjI0LjU2LjM4LjUyLjQuNTIuOTIgMCAuNS0uNDIgMS4xNC0uNzIgMS4xLTEuMzggMS4xLS4zOCAwLTEuMDgtLjQ0LS4zNi0uMzQtMS4wNC0uMzQtLjY2IDAtMS4yNC40OC0uNTguNDgtLjU4IDEuMzR6IiBmaWxsPSJncmVlbiIvPjwvc3ZnPgo=" alt="pdoc logo" /></p>

<p>World!</p>

<p>\( 42 \)</p>
Expand Down
2 changes: 2 additions & 0 deletions test/testdata/flavors_rst_include/include.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Hello

![pdoc logo](../../../pdoc/templates/resources/pdoc-logo.svg)

.. include:: subinclude.rst
Loading