Skip to content

Commit

Permalink
docs: social-cards
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Nov 3, 2023
1 parent f669afc commit 392cd30
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ help:
preview: html
open "$(BUILDDIR)/html/index.html"

clean:
rm -rf "$(BUILDDIR)"

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
Expand Down
Binary file added docs/_static/fonts/NotoColorEmoji-Regular.ttf
Binary file not shown.
Binary file added docs/_static/fonts/NotoSansJP-Regular.ttf
Binary file not shown.
Binary file added docs/_static/fonts/Roboto-Regular.ttf
Binary file not shown.
17 changes: 15 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import pathlib
import sys
import urllib.parse

import matplotlib.font_manager

# ensure kani is available in path
sys.path.append("..")
Expand Down Expand Up @@ -62,8 +64,19 @@
}

# sphinxext.opengraph
# load correct fonts for card generation
ogp_fonts = {
"Noto Sans Japanese": "NotoSansJP-Regular.ttf",
"Roboto": "Roboto-Regular.ttf",
"Noto Sans Emoji": "NotoColorEmoji-Regular.ttf",
}
for fontname, fontpath in ogp_fonts.items():
path_font = pathlib.Path(__file__).parent / "_static/fonts" / fontpath
font = matplotlib.font_manager.FontEntry(fname=str(path_font), name=fontname)
matplotlib.font_manager.fontManager.ttflist.append(font)

ogp_social_cards = {
"enable": False, # the bundled Roboto font does not support kanji
"font": [*ogp_fonts.keys(), "sans-serif"],
}

# sphinx_copybutton
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ sphinxemoji~=0.2.0
sphinx-copybutton~=0.5.2
sphinx-inline-tabs~=2023.4.21
sphinx-sitemap~=2.5.1
sphinxext-opengraph~=0.8.2
sphinxext-opengraph~=0.9.0

0 comments on commit 392cd30

Please sign in to comment.