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

🐛 FIX: Docs build against non-html formats #88

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ jobs:
- name: Run pytest
run: pytest

docs-build-format:

runs-on: ubuntu-latest
strategy:
matrix:
format: [html, latex, man]

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[rtd]
- name: Build documentation
run: sphinx-build -nW --keep-going -b ${{ matrix.format }} docs/ docs/_build/${{ matrix.format }}

publish:

name: Publish to PyPi
Expand Down
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

extensions = ["myst_parser", "sphinx_design"]

suppress_warnings = ["design.fa-build"]
sd_fontawesome_latex = True

html_theme = os.environ.get("SPHINX_THEME", "alabaster")
html_title = f"Sphinx Design ({html_theme.replace('_', '-')})"

Expand Down
33 changes: 29 additions & 4 deletions sphinx_design/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
from docutils import nodes
from docutils.parsers.rst import directives
from sphinx.application import Sphinx
from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective, SphinxRole

from . import compiled
from .shared import WARNING_TYPE

logger = logging.getLogger(__name__)

OCTICON_VERSION = "v16.1.1"

Expand All @@ -35,9 +39,9 @@ def setup_icons(app: Sphinx) -> None:
fontawesome,
html=(visit_fontawesome_html, depart_fontawesome_html),
latex=(visit_fontawesome_latex, None),
text=(None, None),
man=(None, None),
texinfo=(None, None),
man=(visit_fontawesome_warning, None),
text=(visit_fontawesome_warning, None),
texinfo=(visit_fontawesome_warning, None),
)


Expand Down Expand Up @@ -207,8 +211,29 @@ def add_fontawesome_pkg(app, config):


def visit_fontawesome_latex(self, node):
"""Add latex fonteawesome icon, if configured, else warn."""
if self.config.sd_fontawesome_latex:
self.body.append(f"\\faicon{{{node['icon_name']}}}")
self.body.append(f"\\faicon{{{node['icon']}}}")
else:
logger.warning(
"Fontawesome icons not included in LaTeX output, "
f"consider 'sd_fontawesome_latex=True' [{WARNING_TYPE}.fa-build]",
location=node,
type=WARNING_TYPE,
subtype="fa-build",
)
raise nodes.SkipNode


def visit_fontawesome_warning(self, node: nodes.Element) -> None:
"""Warn that fontawesome is not supported for this builder."""
logger.warning(
"Fontawesome icons not supported for builder: "
f"{self.builder.name} [{WARNING_TYPE}.fa-build]",
location=node,
type=WARNING_TYPE,
subtype="fa-build",
)
raise nodes.SkipNode


Expand Down