Skip to content

Commit e09d02e

Browse files
stefmolinAA-Turner
andauthored
Allow copyright to contain multiple entries (#10983)
Co-authored-by: Adam Turner <[email protected]>
1 parent 86b07d4 commit e09d02e

File tree

8 files changed

+63
-8
lines changed

8 files changed

+63
-8
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Features added
3333
This behaviour may also be controlled by options on object description
3434
directives, for example :rst:dir:`py:function:single-line-parameter-list`.
3535
Patch by Thomas Louf, Adam Turner, and Jean-François Burnol.
36+
* #10983: Support for multiline copyright statements in the footer block.
37+
Patch by Stefanie Molin
3638

3739
Bugs fixed
3840
----------

doc/_themes/sphinx13/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h3>{{ _('Site navigation') }}</h3>
5454

5555
{%- block footer %}
5656
<div class="footer" role="contentinfo">
57-
{% trans path=pathto('copyright'), copyright=copyright|e %}&#169; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
57+
{{ copyright_block() }}
5858
{% trans sphinx_version=sphinx_version|e %}Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
5959
</div>
6060
{%- endblock %}

doc/usage/configuration.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ Project information
7373

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

76+
.. versionchanged:: 7.1
77+
The value may now be a sequence of copyright statements in the above form,
78+
which will be displayed each to their own line.
79+
7680
.. confval:: project_copyright
7781

7882
An alias of :confval:`copyright`.

sphinx/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class Config:
8989
# general options
9090
'project': ('Python', 'env', []),
9191
'author': ('unknown', 'env', []),
92-
'project_copyright': ('', 'html', [str]),
93-
'copyright': (lambda c: c.project_copyright, 'html', [str]),
92+
'project_copyright': ('', 'html', [str, tuple, list]),
93+
'copyright': (lambda c: c.project_copyright, 'html', [str, tuple, list]),
9494
'version': ('', 'env', []),
9595
'release': ('', 'env', []),
9696
'today': ('', 'env', []),

sphinx/themes/basic/layout.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,30 @@ <h3>{{ _('Navigation') }}</h3>
183183

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

186+
{%- macro copyright_block() %}
187+
{%- if hasdoc('copyright') %}
188+
{%- set copyright_prefix = '<a href="' + pathto('copyright') + '">' + _('Copyright') + '</a>' -%}
189+
{%- else %}
190+
{%- set copyright_prefix = _('Copyright') %}
191+
{%- endif %}
192+
{%- if copyright is iterable and copyright is not string %}
193+
{% for copyright_line in copyright %}
194+
{% trans trimmed copyright_prefix=copyright_prefix, copyright=copyright_line|e %}
195+
&#169; {{ copyright_prefix }} {{ copyright }}.
196+
{% endtrans %}
197+
{%- if not loop.last %}<br/>{%- endif %}
198+
{% endfor %}
199+
{%- else %}
200+
{% trans trimmed copyright_prefix=copyright_prefix, copyright=copyright|e %}
201+
&#169; {{ copyright_prefix }} {{ copyright }}.
202+
{% endtrans %}
203+
{%- endif %}
204+
{%- endmacro %}
205+
186206
{%- block footer %}
187207
<div class="footer" role="contentinfo">
188208
{%- if show_copyright %}
189-
{%- if hasdoc('copyright') %}
190-
{% trans path=pathto('copyright'), copyright=copyright|e %}&#169; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
191-
{%- else %}
192-
{% trans copyright=copyright|e %}&#169; Copyright {{ copyright }}.{% endtrans %}
193-
{%- endif %}
209+
{{- copyright_block() -}}
194210
{%- endif %}
195211
{%- if last_updated %}
196212
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
copyright = (
2+
'2006-2009, Alice',
3+
'2010-2013, Bob',
4+
'2014-2017, Charlie',
5+
'2018-2021, David',
6+
'2022-2025, Eve',
7+
)
8+
html_theme = 'basic'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
========================
2+
test-copyright-multiline
3+
========================

tests/test_config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,25 @@ def test_conf_py_nitpick_ignore_list(tempdir):
442442
# Then the default nitpick_ignore[_regex] is an empty list
443443
assert cfg.nitpick_ignore == []
444444
assert cfg.nitpick_ignore_regex == []
445+
446+
447+
@pytest.mark.sphinx(testroot='copyright-multiline')
448+
def test_multi_line_copyright(app, status, warning):
449+
app.builder.build_all()
450+
451+
content = (app.outdir / 'index.html').read_text(encoding='utf-8')
452+
453+
assert ' &#169; Copyright 2006-2009, Alice.<br/>' in content
454+
assert ' &#169; Copyright 2010-2013, Bob.<br/>' in content
455+
assert ' &#169; Copyright 2014-2017, Charlie.<br/>' in content
456+
assert ' &#169; Copyright 2018-2021, David.<br/>' in content
457+
assert ' &#169; Copyright 2022-2025, Eve.' in content
458+
459+
lines = (
460+
' &#169; Copyright 2006-2009, Alice.<br/>\n \n'
461+
' &#169; Copyright 2010-2013, Bob.<br/>\n \n'
462+
' &#169; Copyright 2014-2017, Charlie.<br/>\n \n'
463+
' &#169; Copyright 2018-2021, David.<br/>\n \n'
464+
' &#169; Copyright 2022-2025, Eve.\n \n'
465+
)
466+
assert lines in content

0 commit comments

Comments
 (0)