Skip to content

Commit

Permalink
Add favicon to tmt docs (teemtee#3021)
Browse files Browse the repository at this point in the history
  • Loading branch information
happz authored and The-Mule committed Oct 14, 2024
1 parent 36a16d7 commit 4d11ec4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ docs/plugins/test-checks.rst
docs/_build
docs/spec
docs/stories
docs/_static/tmt-small.png

# Python

Expand Down
12 changes: 10 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
.DEFAULT_GOAL := help
.PHONY: help generate-plugins plugins/*.rst generate-stories generate-template-filters generate-autodocs clean

LOGO_SRC = https://raw.githubusercontent.com/teemtee/docs/main/logo/tmt-small.png
LOGO_DST = _static/tmt-small.png

clean:
rm -rf _build stories spec code/autodocs/*.rst code/template-filters.rst
rm -rf _build stories spec code/autodocs/*.rst code/template-filters.rst $(LOGO_DST)
find plugins -name "*.rst" ! -name index.rst | xargs rm -f

##
Expand All @@ -18,7 +21,12 @@ TEMPLATESDIR = templates

PLUGINS_TEMPLATE := $(TEMPLATESDIR)/plugins.rst.j2

generate: spec stories generate-lint-checks generate-template-filters generate-plugins generate-stories generate-autodocs ## Refresh all generated documentation sources
generate: $(LOGO_DST) spec stories generate-lint-checks generate-template-filters generate-plugins generate-stories generate-autodocs ## Refresh all generated documentation sources

# We can ignore the error: later, during the build, if the logo is
# missing, Sphinx will complain.
$(LOGO_DST):
-curl -f $(LOGO_SRC) -o $(LOGO_DST)

spec:
mkdir -p spec
Expand Down
11 changes: 7 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import subprocess
import sys
from pathlib import Path
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING, Any, Optional

if TYPE_CHECKING:
from sphinx.application import Sphinx
Expand Down Expand Up @@ -222,7 +222,7 @@ def _load_theme(
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
html_favicon = '_static/tmt-small.png'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down Expand Up @@ -313,12 +313,15 @@ def _load_theme(
]


def generate_tmt_docs(app: Sphinx) -> None:
def generate_tmt_docs(app: Sphinx, config: Any) -> None:
""" Run `make generate` to populate the auto-generated sources """

conf_dir = Path(app.confdir)
subprocess.run(["make", "generate"], cwd=conf_dir)


def setup(app: Sphinx) -> None:
app.connect("builder-inited", generate_tmt_docs)
# Generate sources after loading configuration. That should build
# everything, including the logo, before Sphinx starts checking
# whether all input files exist.
app.connect("config-inited", generate_tmt_docs)

0 comments on commit 4d11ec4

Please sign in to comment.