mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Allow `copyright` to contain multiple entries (#10983)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -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
|
||||
----------
|
||||
|
||||
2
doc/_themes/sphinx13/layout.html
vendored
2
doc/_themes/sphinx13/layout.html
vendored
@@ -54,7 +54,7 @@
|
||||
|
||||
{%- block footer %}
|
||||
<div class="footer" role="contentinfo">
|
||||
{% trans path=pathto('copyright'), copyright=copyright|e %}© <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 %}
|
||||
|
||||
@@ -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`.
|
||||
|
||||
@@ -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', []),
|
||||
|
||||
@@ -183,14 +183,30 @@
|
||||
|
||||
{%- 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 %}
|
||||
© {{ copyright_prefix }} {{ copyright }}.
|
||||
{% endtrans %}
|
||||
{%- if not loop.last %}<br/>{%- endif %}
|
||||
{% endfor %}
|
||||
{%- else %}
|
||||
{% trans trimmed copyright_prefix=copyright_prefix, copyright=copyright|e %}
|
||||
© {{ 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 %}© <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
|
||||
{%- else %}
|
||||
{% trans copyright=copyright|e %}© Copyright {{ copyright }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
{{- copyright_block() -}}
|
||||
{%- endif %}
|
||||
{%- if last_updated %}
|
||||
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
|
||||
|
||||
8
tests/roots/test-copyright-multiline/conf.py
Normal file
8
tests/roots/test-copyright-multiline/conf.py
Normal file
@@ -0,0 +1,8 @@
|
||||
copyright = (
|
||||
'2006-2009, Alice',
|
||||
'2010-2013, Bob',
|
||||
'2014-2017, Charlie',
|
||||
'2018-2021, David',
|
||||
'2022-2025, Eve',
|
||||
)
|
||||
html_theme = 'basic'
|
||||
3
tests/roots/test-copyright-multiline/index.rst
Normal file
3
tests/roots/test-copyright-multiline/index.rst
Normal file
@@ -0,0 +1,3 @@
|
||||
========================
|
||||
test-copyright-multiline
|
||||
========================
|
||||
@@ -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 ' © Copyright 2006-2009, Alice.<br/>' in content
|
||||
assert ' © Copyright 2010-2013, Bob.<br/>' in content
|
||||
assert ' © Copyright 2014-2017, Charlie.<br/>' in content
|
||||
assert ' © Copyright 2018-2021, David.<br/>' in content
|
||||
assert ' © Copyright 2022-2025, Eve.' in content
|
||||
|
||||
lines = (
|
||||
' © Copyright 2006-2009, Alice.<br/>\n \n'
|
||||
' © Copyright 2010-2013, Bob.<br/>\n \n'
|
||||
' © Copyright 2014-2017, Charlie.<br/>\n \n'
|
||||
' © Copyright 2018-2021, David.<br/>\n \n'
|
||||
' © Copyright 2022-2025, Eve.\n \n'
|
||||
)
|
||||
assert lines in content
|
||||
|
||||
Reference in New Issue
Block a user