docs: add 'edit-on-github' link to html theme

Closes IDF-1504
This commit is contained in:
Marius Vikhammer
2020-05-06 17:25:23 +08:00
parent a97cd645ad
commit 214f1fbbed
3 changed files with 33 additions and 13 deletions

View File

@@ -23,6 +23,8 @@ import re
import subprocess
from sanitize_version import sanitize_version
from idf_extensions.util import download_file_if_missing
from get_github_rev import get_github_rev
# build_docs on the CI server sometimes fails under Python3. This is a workaround:
sys.setrecursionlimit(3500)
@@ -218,6 +220,14 @@ html_redirect_pages = [tuple(l.split(' ')) for l in lines]
html_theme = 'sphinx_idf_theme'
# context used by sphinx_idf_theme
html_context = {
"display_github": True, # Add 'Edit on Github' link instead of 'View page source'
"github_user": "espressif",
"github_repo": "esp-idf",
"github_version": get_github_rev(),
}
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
@@ -237,6 +247,7 @@ html_theme = 'sphinx_idf_theme'
# of the sidebar.
html_logo = "../_static/espressif-logo.svg"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
@@ -387,6 +398,7 @@ def setup(app):
# Config values pushed by -D using the cmdline is not available when setup is called
app.connect('config-inited', setup_config_values)
app.connect('config-inited', setup_html_context)
def setup_config_values(app, config):
@@ -402,6 +414,11 @@ def setup_config_values(app, config):
app.add_config_value('pdf_file', pdf_name, 'env')
def setup_html_context(app, config):
# Setup path for 'edit on github'-link
config.html_context['conf_py_path'] = "/docs/{}/".format(app.config.language)
def setup_diag_font(app):
# blockdiag and other tools require a font which supports their character set
# the font file is stored on the download server to save repo size