Skip to content
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
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Features added
This behaviour may also be controlled by options on object description
directives, for example :rst:dir:`py:function:single-line-parameter-list`.
Patch by Thomas Louf, Adam Turner, and Jean-François Burnol.
* #10983: Support for multiline copyright statements in the footer block.
Patch by Stefanie Molin

Bugs fixed
----------
Expand Down
2 changes: 1 addition & 1 deletion doc/_themes/sphinx13/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h3>{{ _('Site navigation') }}</h3>

{%- block footer %}
<div class="footer" role="contentinfo">
{% trans path=pathto('copyright'), copyright=copyright|e %}&#169; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
{{ copyright_block() }}
{% trans sphinx_version=sphinx_version|e %}Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
</div>
{%- endblock %}
4 changes: 4 additions & 0 deletions doc/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Project information

A copyright statement in the style ``'2008, Author Name'``.

.. versionchanged:: 7.1
The value may now be a sequence of copyright statements in the above form,
which will be displayed each to their own line.

.. confval:: project_copyright

An alias of :confval:`copyright`.
Expand Down
4 changes: 2 additions & 2 deletions sphinx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class Config:
# general options
'project': ('Python', 'env', []),
'author': ('unknown', 'env', []),
'project_copyright': ('', 'html', [str]),
'copyright': (lambda c: c.project_copyright, 'html', [str]),
'project_copyright': ('', 'html', [str, tuple, list]),
'copyright': (lambda c: c.project_copyright, 'html', [str, tuple, list]),
'version': ('', 'env', []),
'release': ('', 'env', []),
'today': ('', 'env', []),
Expand Down
26 changes: 21 additions & 5 deletions sphinx/themes/basic/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,30 @@ <h3>{{ _('Navigation') }}</h3>

{%- block relbar2 %}{{ relbar() }}{% endblock %}

{%- macro copyright_block() %}
{%- if hasdoc('copyright') %}
{%- set copyright_prefix = '<a href="' + pathto('copyright') + '">' + _('Copyright') + '</a>' -%}
{%- else %}
{%- set copyright_prefix = _('Copyright') %}
{%- endif %}
{%- if copyright is iterable and copyright is not string %}
{% for copyright_line in copyright %}
{% trans trimmed copyright_prefix=copyright_prefix, copyright=copyright_line|e %}
&#169; {{ copyright_prefix }} {{ copyright }}.
{% endtrans %}
{%- if not loop.last %}<br/>{%- endif %}
{% endfor %}
{%- else %}
{% trans trimmed copyright_prefix=copyright_prefix, copyright=copyright|e %}
&#169; {{ copyright_prefix }} {{ copyright }}.
{% endtrans %}
{%- endif %}
{%- endmacro %}

{%- block footer %}
<div class="footer" role="contentinfo">
{%- if show_copyright %}
{%- if hasdoc('copyright') %}
{% trans path=pathto('copyright'), copyright=copyright|e %}&#169; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
{%- else %}
{% trans copyright=copyright|e %}&#169; Copyright {{ copyright }}.{% endtrans %}
{%- endif %}
{{- copyright_block() -}}
{%- endif %}
{%- if last_updated %}
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
Expand Down
8 changes: 8 additions & 0 deletions tests/roots/test-copyright-multiline/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
copyright = (
'2006-2009, Alice',
'2010-2013, Bob',
'2014-2017, Charlie',
'2018-2021, David',
'2022-2025, Eve',
)
html_theme = 'basic'
3 changes: 3 additions & 0 deletions tests/roots/test-copyright-multiline/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
========================
test-copyright-multiline
========================
22 changes: 22 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,25 @@ def test_conf_py_nitpick_ignore_list(tempdir):
# Then the default nitpick_ignore[_regex] is an empty list
assert cfg.nitpick_ignore == []
assert cfg.nitpick_ignore_regex == []


@pytest.mark.sphinx(testroot='copyright-multiline')
def test_multi_line_copyright(app, status, warning):
app.builder.build_all()

content = (app.outdir / 'index.html').read_text(encoding='utf-8')

assert ' &#169; Copyright 2006-2009, Alice.<br/>' in content
assert ' &#169; Copyright 2010-2013, Bob.<br/>' in content
assert ' &#169; Copyright 2014-2017, Charlie.<br/>' in content
assert ' &#169; Copyright 2018-2021, David.<br/>' in content
assert ' &#169; Copyright 2022-2025, Eve.' in content

lines = (
' &#169; Copyright 2006-2009, Alice.<br/>\n \n'
' &#169; Copyright 2010-2013, Bob.<br/>\n \n'
' &#169; Copyright 2014-2017, Charlie.<br/>\n \n'
' &#169; Copyright 2018-2021, David.<br/>\n \n'
' &#169; Copyright 2022-2025, Eve.\n \n'
)
assert lines in content