[PATCH 6/7] docs: Add license note to the HTML page footer

Peter Maydell posted 7 patches 4 years, 7 months ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>
[PATCH 6/7] docs: Add license note to the HTML page footer
Posted by Peter Maydell 4 years, 7 months ago
The standard Sphinx/RTD HTML page footer gives a copyright line
(based on the 'copyright' variable set in conf.py) and a line "Built
with Sphinx using a theme provided by Read the Docs" (which can be
disabled via the html_show_sphinx variable, but we leave it enabled).
As a free software project, we'd like to also mention the license
QEMU and its manual are released under.

Add a template footer.html which defines the 'extrafooter' block that
the RtD theme provides for this purpose.  The new line of text will
go below the existing copyright and sphinx-acknowledgement lines.
(Unfortunately the RTD footer template does not permit putting it
after the copyright but before the sphinx-acknowledgement.)

We use the templating functionality to make the new text also be a
hyperlink to the about/license.html page of the manual.

Unlike rst files, HTML template files are not reported to our depfile
plugin, so we maintain a manual list in meson.build.  New template
files should be rare, so not being able to auto-generate the
dependency info is not too awkward.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
I know nothing about Jinja, and have merely cargo-culted the
"make a link to a document" stuff from the handling of the
optional copyright link in /usr/share/sphinx_rtd_theme/footer.html ...
---
 docs/_templates/footer.html | 12 ++++++++++++
 docs/meson.build            |  3 ++-
 MAINTAINERS                 |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 docs/_templates/footer.html

diff --git a/docs/_templates/footer.html b/docs/_templates/footer.html
new file mode 100644
index 00000000000..4c15e17d2a8
--- /dev/null
+++ b/docs/_templates/footer.html
@@ -0,0 +1,12 @@
+{% extends "!footer.html" %}
+{% block extrafooter %}
+
+<!-- Empty para to force a blank line after "Built with Sphinx ..." -->
+<p></p>
+
+{% trans path=pathto('about/license') %}
+<p><a href="{{ path }}">QEMU and this manual are released under the
+GNU General Public License, version 2.</a></p>
+{% endtrans %}
+{{ super() }}
+{% endblock %}
diff --git a/docs/meson.build b/docs/meson.build
index 855e3916e90..300b1343291 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -44,6 +44,7 @@ if build_docs
                           meson.source_root() / 'docs/sphinx/qapidoc.py',
                           meson.source_root() / 'docs/sphinx/qmp_lexer.py',
                           qapi_gen_depends ]
+  sphinx_template_files = [ meson.source_root() / 'docs/_templates/footer.html' ]
 
   have_ga = have_tools and config_host.has_key('CONFIG_GUEST_AGENT')
 
@@ -76,7 +77,7 @@ if build_docs
                 output: 'docs.stamp',
                 input: files('conf.py'),
                 depfile: 'docs.d',
-                depend_files: sphinx_extn_depends,
+                depend_files: [ sphinx_extn_depends, sphinx_template_files ],
                 command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
                           '-Ddepfile_stamp=@OUTPUT0@',
                           '-b', 'html', '-d', private_dir,
diff --git a/MAINTAINERS b/MAINTAINERS
index cfbf7ef79bc..790d857f6c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3410,6 +3410,7 @@ S: Maintained
 F: docs/conf.py
 F: docs/*/conf.py
 F: docs/sphinx/
+F: docs/_templates/
 
 Miscellaneous
 -------------
-- 
2.20.1


Re: [PATCH 6/7] docs: Add license note to the HTML page footer
Posted by Daniel P. Berrangé 4 years, 7 months ago
On Mon, Jul 05, 2021 at 10:55:46AM +0100, Peter Maydell wrote:
> The standard Sphinx/RTD HTML page footer gives a copyright line
> (based on the 'copyright' variable set in conf.py) and a line "Built
> with Sphinx using a theme provided by Read the Docs" (which can be
> disabled via the html_show_sphinx variable, but we leave it enabled).
> As a free software project, we'd like to also mention the license
> QEMU and its manual are released under.
> 
> Add a template footer.html which defines the 'extrafooter' block that
> the RtD theme provides for this purpose.  The new line of text will
> go below the existing copyright and sphinx-acknowledgement lines.
> (Unfortunately the RTD footer template does not permit putting it
> after the copyright but before the sphinx-acknowledgement.)
> 
> We use the templating functionality to make the new text also be a
> hyperlink to the about/license.html page of the manual.
> 
> Unlike rst files, HTML template files are not reported to our depfile
> plugin, so we maintain a manual list in meson.build.  New template
> files should be rare, so not being able to auto-generate the
> dependency info is not too awkward.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> I know nothing about Jinja, and have merely cargo-culted the
> "make a link to a document" stuff from the handling of the
> optional copyright link in /usr/share/sphinx_rtd_theme/footer.html ...
> ---
>  docs/_templates/footer.html | 12 ++++++++++++
>  docs/meson.build            |  3 ++-
>  MAINTAINERS                 |  1 +
>  3 files changed, 15 insertions(+), 1 deletion(-)
>  create mode 100644 docs/_templates/footer.html

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|