-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
230 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,3 @@ wheel==0.37.1 | |
pytest==7.1.3 | ||
beautifulsoup4==4.11.1 | ||
setuptools==65.4.1 | ||
furo | ||
myst-parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
myst-parser==0.18.1 | ||
furo==2022.9.29 | ||
sphinx==5.2.3 | ||
sphinx-design | ||
./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
""" | ||
A helper script to test out what social previews look like. | ||
I should remove this when I'm happy with the result. | ||
""" | ||
# %load_ext autoreload | ||
# %autoreload 2 | ||
|
||
from pathlib import Path | ||
from textwrap import dedent | ||
from sphinxext.opengraph.socialcards import render_social_card, MAX_CHAR_PAGE_TITLE, MAX_CHAR_DESCRIPTION | ||
import random | ||
|
||
here = Path(__file__).parent | ||
|
||
# Dummy lorem text | ||
lorem = """ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum | ||
""".split() # noqa | ||
|
||
kwargs_fig = dict( | ||
image=here / "../source/_static/og-logo.png", | ||
image_mini=here / "../../sphinxext/opengraph/_static/sphinx-logo-shadow.png", | ||
) | ||
|
||
print("Generating previews of social media cards...") | ||
plt_objects = None | ||
embed_text = [] | ||
for perm in range(20): | ||
# Create dummy text description and pagetitle for this iteration | ||
random.shuffle(lorem) | ||
title = " ".join(lorem[:100]) | ||
title = title[: MAX_CHAR_PAGE_TITLE - 3] + "..." | ||
|
||
random.shuffle(lorem) | ||
desc = " ".join(lorem[:100]) | ||
desc = desc[: MAX_CHAR_DESCRIPTION - 3] + "..." | ||
|
||
path_tmp = Path(here / "../tmp") | ||
path_tmp.mkdir(exist_ok=True) | ||
path_out = Path(path_tmp / f"num_{perm}.png") | ||
|
||
plt_objects = render_social_card( | ||
path=path_out, | ||
site_title="Sphinx Social Card Demo", | ||
page_title=title, | ||
description=desc, | ||
siteurl="sphinxext-opengraph.readthedocs.io", | ||
plt_objects=plt_objects, | ||
kwargs_fig=kwargs_fig | ||
) | ||
|
||
path_examples_page_folder = here / ".." | ||
embed_text.append( | ||
dedent( | ||
f""" | ||
````{{grid-item}} | ||
```{{image}} ../{path_out.relative_to(path_examples_page_folder)} | ||
``` | ||
```` | ||
""" | ||
) | ||
) | ||
|
||
embed_text = "\n".join(embed_text) | ||
embed_text = f""" | ||
`````{{grid}} 2 | ||
:gutter: 5 | ||
{embed_text} | ||
````` | ||
""" | ||
|
||
# Write markdown text that we can use to embed these images in the docs | ||
(here / "../tmp/embed.txt").write_text(embed_text) | ||
|
||
print("Done generating previews of social media cards...") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.