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

Add favicon to tmt docs #3021

Merged
merged 2 commits into from
Jun 26, 2024
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
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)
Loading