Skip to content

Commit 34a2a8a

Browse files
feat: update copyright statement, add license line (#105)
* footer: update copyright statement, add license line For #104: Requires the `license.name` and `license.url` config values. The format is now the standard: `© <year> <holder>` Places the license on a separate line and provides an optional link to it. Other: It turns out that `author` isn't part of the standard Sphinx config, so I copied it into the `html_context`. * chore: syntax fix for black linting --------- Co-authored-by: Michael Park <michael.park@canonical.com>
1 parent 618c969 commit 34a2a8a

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

canonical_sphinx/theme/templates/footer.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,26 @@
4343
<div class="copyright">
4444
{%- if hasdoc('copyright') %}
4545
{% trans path=pathto('copyright'), copyright=copyright|e -%}
46-
<a href="{{ path }}">Copyright</a> &#169; {{ copyright }}
46+
<a href="{{ path }}">&copy; {{ copyright }} {{ author }}</a>
4747
{%- endtrans %}
4848
{%- else %}
4949
{% trans copyright=copyright|e -%}
50-
Copyright &#169; {{ copyright }}
50+
&copy; {{ copyright }} {{ author }}
5151
{%- endtrans %}
5252
{%- endif %}
5353
</div>
5454
{%- endif %}
55+
{%- if license and license.name -%}
56+
{%- if license.url -%}
57+
<div class="license">
58+
This page is licensed under <a href="{{ license.url }}">{{ license.name }}</a>
59+
</div>
60+
{%- else -%}
61+
<div class="license">
62+
This page is licensed under {{ license.name }}
63+
</div>
64+
{%- endif -%}
65+
{%- endif -%}
5566

5667
{# mod: removed "Made with" #}
5768

docs/conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
55

66
project = "canonical-sphinx"
7-
copyright = "2024, Canonical"
8-
author = "Canonical"
7+
copyright = "2024"
8+
author = "Canonical Ltd."
99

1010
extensions = [
1111
"canonical_sphinx",
1212
]
1313

1414
html_context = {
15+
"author": author,
1516
"product_page": "github.com/canonical/canonical-sphinx",
1617
"github_url": "https://github.com/canonical/canonical-sphinx",
18+
"license": {
19+
"name": "LGPL-3.0-only",
20+
"url": "test.com",
21+
},
1722
}
1823

1924
html_theme_options = {

example/conf.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# curl -H 'Authorization: token <TOKEN>' \
4141
# -H 'Accept: application/vnd.github.v3.raw' \
4242
# https://api.github.com/repos/canonical/<REPO> | jq '.created_at'
43-
copyright = f"{datetime.today().year}, {author}"
43+
copyright = f"{datetime.today().year}"
4444

4545
# Set the path to your own static assets here
4646
html_static_path = ["_static"]
@@ -57,6 +57,18 @@
5757
# header) to ".sphinx/_static" and change the path here (start with "_static")
5858
# (default is the circle of friends)
5959
"product_tag": "_static/example-tag.png",
60+
# Inherit the author value
61+
"author": author,
62+
# Change your product's license name and a link to its file.
63+
# For the name, we recommend using the standard shorthand identifier from
64+
# https://spdx.org/licenses
65+
# For the URL, link directly to the canonical license statement, typically found on
66+
# the product's home page or in its GitHub project.
67+
#
68+
"license": {
69+
"name": "LGPL-3.0-only",
70+
"url": "https://github.com/canonical/sphinx-docs-starter-pack/blob/main/LICENSE",
71+
},
6072
# Change to the discourse instance you want to be able to link to
6173
# using the :discourse: metadata at the top of a file
6274
# (use an empty value if you don't want to link)

tests/integration/test_canonical_sphinx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_canonical_sphinx(example_project):
5959
# Copyright
6060
copyright_ = soup.find("div", {"class": "copyright"}).string.strip()
6161
year = datetime.today().year
62-
assert copyright_ == f"Copyright © {year}, Example Project Authors"
62+
assert copyright_ == f"© {year} Example Project Authors"
6363

6464
# Logo
6565
logo = soup.find("a", {"class": "p-logo"})

0 commit comments

Comments
 (0)