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 support for html logo and favicon as url #9381

Merged
merged 4 commits into from Jun 30, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions sphinx/builders/html/__init__.py
Expand Up @@ -468,9 +468,6 @@ def prepare_writing(self, docnames: Set[str]) -> None:
else:
self.last_updated = None

logo = path.basename(self.config.html_logo) if self.config.html_logo else ''
favicon = path.basename(self.config.html_favicon) if self.config.html_favicon else ''

self.relations = self.env.collect_relations()

rellinks: List[Tuple[str, str, str, str]] = []
Expand Down Expand Up @@ -513,8 +510,8 @@ def prepare_writing(self, docnames: Set[str]) -> None:
'rellinks': rellinks,
'builder': self.name,
'parents': [],
'logo': logo,
'favicon': favicon,
'logo': self.config.html_logo or '',
'favicon': self.config.html_favicon or '',
'html5_doctype': html5_ready and not self.config.html4_writer,
}
if self.theme:
Expand Down
5 changes: 5 additions & 0 deletions tests/roots/test-remote-logo/conf.py
@@ -0,0 +1,5 @@
latex_documents = [
('index', 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]
html_logo = "https://www.python.org/static/img/python-logo.png"
html_favicon = "https://www.python.org/static/favicon.ico"
32 changes: 32 additions & 0 deletions tests/roots/test-remote-logo/index.rst
@@ -0,0 +1,32 @@
The basic Sphinx documentation for testing
==========================================

Sphinx is a tool that makes it easy to create intelligent and beautiful
documentation for Python projects (or other documents consisting of multiple
reStructuredText sources), written by Georg Brandl. It was originally created
for the new Python documentation, and has excellent facilities for Python
project documentation, but C/C++ is supported as well, and more languages are
planned.

Sphinx uses reStructuredText as its markup language, and many of its strengths
come from the power and straightforwardness of reStructuredText and its parsing
and translating suite, the Docutils.

features
--------

Among its features are the following:

* Output formats: HTML (including derivative formats such as HTML Help, Epub
and Qt Help), plain text, manual pages and LaTeX or direct PDF output
using rst2pdf
* Extensive cross-references: semantic markup and automatic links
for functions, classes, glossary terms and similar pieces of information
* Hierarchical structure: easy definition of a document tree, with automatic
links to siblings, parents and children
* Automatic indices: general index as well as a module index
* Code handling: automatic highlighting using the Pygments highlighter
* Flexible HTML output using the Jinja 2 templating engine
* Various extensions are available, e.g. for automatic testing of snippets
and inclusion of appropriately formatted docstrings
* Setuptools integration
10 changes: 10 additions & 0 deletions tests/test_build_html.py
Expand Up @@ -1330,6 +1330,16 @@ def test_html_remote_images(app, status, warning):
assert not (app.outdir / 'python-logo.png').exists()


@pytest.mark.sphinx('html', testroot='remote-logo')
def test_html_remote_logo(app, status, warning):
app.builder.build_all()

result = (app.outdir / 'index.html').read_text()
assert ('<img class="logo" src="https://www.python.org/static/img/python-logo.png" alt="Logo"/>' in result)
assert ('<link rel="shortcut icon" href="https://www.python.org/static/favicon.ico"/>' in result)
assert not (app.outdir / 'python-logo.png').exists()


@pytest.mark.sphinx('html', testroot='basic')
def test_html_sidebar(app, status, warning):
ctx = {}
Expand Down