This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
/
__init__.py
67 lines (49 loc) · 2.05 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
A Sphinx theme for Open edX documentation.
"""
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import os
from warnings import warn
import six
from six.moves.urllib.parse import quote # pylint: disable=wrong-import-order
warn("The edx-sphinx-theme is deprecated. Switch to the sphinx-boook-theme. "
"See https://docs.openedx.org/en/latest/developers/how-tos/switch-to-the-sphinx-book-theme.html",
DeprecationWarning, stacklevel=2)
# When you change this, also update the CHANGELOG.rst file, thanks.
__version__ = '3.1.1'
# Use these constants in the conf.py for Sphinx in your repository
AUTHOR = 'edX Inc.'
COPYRIGHT = f'{datetime.datetime.now().year}, edX Inc.'
FEEDBACK_FORM_FMT = "https://docs.google.com/forms/d/1T5QGnYb_QnQoMO7T_eatq02miPTY40WVe3cgGphNAdY/" \
"viewform?entry.1952574704&entry.241692674={pageid}"
def get_html_theme_path():
"""
Get the absolute path of the directory containing the theme files.
"""
return os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def feedback_form_url(project, page):
"""
Create a URL for feedback on a particular page in a project.
"""
return FEEDBACK_FORM_FMT.format(pageid=quote(f"{project}: {page}"))
def update_context(app, pagename, templatename, context, doctree): # pylint: disable=unused-argument
"""
Update the page rendering context to include ``feedback_form_url``.
"""
context['feedback_form_url'] = feedback_form_url(app.config.project, pagename)
def setup(app):
"""
Sphinx extension to update the rendering context with the feedback form URL.
Arguments:
app (Sphinx): Application object for the Sphinx process
Returns:
a dictionary of metadata (http://www.sphinx-doc.org/en/stable/extdev/#extension-metadata)
"""
event = 'html-page-context' if six.PY3 else b'html-page-context'
app.connect(event, update_context)
return {
'parallel_read_safe': True,
'parallel_write_safe': True,
'version': __version__,
}