Skip to content

Commit

Permalink
Maintenance: Add ReadTheDocs configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvuckovic committed Aug 3, 2023
1 parent a586c84 commit 42e9ade
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 6 deletions.
206 changes: 206 additions & 0 deletions .github/rtd-conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@


###########################################################################
# auto-created readthedocs.org specific configuration #
###########################################################################


#
# The following code was added during an automated build on readthedocs.org
# It is auto created and injected for every build. The result is based on the
# conf.py.tmpl file found in the readthedocs.org codebase:
# https://github.com/rtfd/readthedocs.org/blob/main/readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
#
# Note: this file shouldn't rely on extra dependencies.

import importlib
import sys
import os.path

# Borrowed from six.
PY3 = sys.version_info[0] == 3
string_types = str if PY3 else basestring

from sphinx import version_info

# Get suffix for proper linking to GitHub
# This is deprecated in Sphinx 1.3+,
# as each page can have its own suffix
if globals().get('source_suffix', False):
if isinstance(source_suffix, string_types):
SUFFIX = source_suffix
elif isinstance(source_suffix, (list, tuple)):
# Sphinx >= 1.3 supports list/tuple to define multiple suffixes
SUFFIX = source_suffix[0]
elif isinstance(source_suffix, dict):
# Sphinx >= 1.8 supports a mapping dictionary for multiple suffixes
SUFFIX = list(source_suffix.keys())[0] # make a ``list()`` for py2/py3 compatibility
else:
# default to .rst
SUFFIX = '.rst'
else:
SUFFIX = '.rst'

# Add RTD Static Path. Add to the end because it overwrites previous files.
if not 'html_static_path' in globals():
html_static_path = []
if os.path.exists('_static'):
html_static_path.append('_static')

# Add RTD Theme only if they aren't overriding it already
using_rtd_theme = (
(
'html_theme' in globals() and
html_theme in ['default'] and
# Allow people to bail with a hack of having an html_style
'html_style' not in globals()
) or 'html_theme' not in globals()
)
if using_rtd_theme:
html_theme = 'sphinx_rtd_theme'
html_style = None
html_theme_options = {}


# This following legacy behavior will gradually be sliced out until its deprecated and removed.
# Skipped for Sphinx 6+
# Skipped by internal Feature flag SKIP_SPHINX_HTML_THEME_PATH
# Skipped by all new projects since SKIP_SPHINX_HTML_THEME_PATH's introduction (jan 2023)
if (
using_rtd_theme
and version_info < (6,0)
and not False
):
theme = importlib.import_module('sphinx_rtd_theme')
if 'html_theme_path' in globals():
html_theme_path.append(theme.get_html_theme_path())
else:
html_theme_path = [theme.get_html_theme_path()]

# Define websupport2_base_url and websupport2_static_url
if globals().get('websupport2_base_url', False):
websupport2_base_url = 'https://readthedocs.org/websupport'
websupport2_static_url = 'https://assets.readthedocs.org/static/'


#Add project information to the template context.
context = {
'using_theme': using_rtd_theme,
'html_theme': html_theme,
'current_version': "pre-release",
'version_slug': "pre-release",
'MEDIA_URL': "https://media.readthedocs.org/",
'STATIC_URL': "https://assets.readthedocs.org/static/",
'PRODUCTION_DOMAIN': "readthedocs.org",
'proxied_static_path': "/_/static/",
'versions': [
("latest", "/en/latest/"),
("pre-release", "/en/pre-release/"),
],
'downloads': [
("html", "//docs.zammad.org/_/downloads/en/pre-release/htmlzip/"),
("epub", "//docs.zammad.org/_/downloads/en/pre-release/epub/"),
],
'subprojects': [
],
'slug': 'zammad',
'name': u'zammad-documentation',
'rtd_language': u'en',
'programming_language': u'ruby',
'canonical_url': '',
'analytics_code': 'None',
'single_version': False,
'conf_py_path': '/',
'api_host': 'https://readthedocs.org',
'github_user': 'zammad',
'proxied_api_host': '/_',
'github_repo': 'zammad-documentation',
'github_version': 'pre-release',
'display_github': True,
'bitbucket_user': 'None',
'bitbucket_repo': 'None',
'bitbucket_version': 'pre-release',
'display_bitbucket': False,
'gitlab_user': 'None',
'gitlab_repo': 'None',
'gitlab_version': 'pre-release',
'display_gitlab': False,
'READTHEDOCS': True,
'using_theme': (html_theme == "default"),
'new_theme': (html_theme == "sphinx_rtd_theme"),
'source_suffix': SUFFIX,
'ad_free': False,
'docsearch_disabled': False,
'user_analytics_code': '',
'global_analytics_code': 'UA-17997319-1',
'commit': 'f587f470',
}

# For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
if version_info >= (1, 8):
if not globals().get('html_baseurl'):
html_baseurl = context['canonical_url']
context['canonical_url'] = None





if 'html_context' in globals():
for key in context:
if key not in html_context:
html_context[key] = context[key]
else:
html_context = context

# Add custom RTD extension
if 'extensions' in globals():
# Insert at the beginning because it can interfere
# with other extensions.
# See https://github.com/rtfd/readthedocs.org/pull/4054
extensions.insert(0, "readthedocs_ext.readthedocs")
else:
extensions = ["readthedocs_ext.readthedocs"]

# Add External version warning banner to the external version documentation
if 'branch' == 'external':
extensions.insert(1, "readthedocs_ext.external_version_warning")
readthedocs_vcs_url = 'None'
readthedocs_build_url = 'https://readthedocs.org/projects/zammad/builds/21493455/'

project_language = 'en'

# User's Sphinx configurations
language_user = globals().get('language', None)
latex_engine_user = globals().get('latex_engine', None)
latex_elements_user = globals().get('latex_elements', None)

# Remove this once xindy gets installed in Docker image and XINDYOPS
# env variable is supported
# https://github.com/rtfd/readthedocs-docker-images/pull/98
latex_use_xindy = False

chinese = any([
language_user in ('zh_CN', 'zh_TW'),
project_language in ('zh_CN', 'zh_TW'),
])

japanese = any([
language_user == 'ja',
project_language == 'ja',
])

if chinese:
latex_engine = latex_engine_user or 'xelatex'

latex_elements_rtd = {
'preamble': '\\usepackage[UTF8]{ctex}\n',
}
latex_elements = latex_elements_user or latex_elements_rtd
elif japanese:
latex_engine = latex_engine_user or 'platex'

# Make sure our build directory is always excluded
exclude_patterns = globals().get('exclude_patterns', [])
exclude_patterns.extend(['_build'])
23 changes: 23 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
apt_packages:
- gettext
tools:
python: '3.11'

sphinx:
configuration: conf.py
fail_on_warning: true

formats:
- htmlzip
- epub

python:
install:
- requirements: requirements.txt
16 changes: 12 additions & 4 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_static_path = ['_static']

# Suppress "WARNING: unknown mimetype for ..." during EPUB builds.
# https://github.com/sphinx-doc/sphinx/issues/3214
suppress_warnings = ['epub.unknown_project_files']

on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd: # only import and set the theme if we're building docs locally
# Override default css to solve issues (e.g. width, overflows)
Expand Down Expand Up @@ -54,16 +58,20 @@ def setup(app):
]

# Get current version we're on for possible version warning
version = os.environ.get('READTHEDOCS_VERSION')
rtd_version = os.environ.get('READTHEDOCS_VERSION')

# If we're **not on latest**, we'll display a deprecation warning.
if version == 'latest':
branch = version
elif version == 'pre-release':
if rtd_version == 'latest':
branch = rtd_version
elif rtd_version == 'pre-release':
branch = "pre-release"
else:
branch = "old-version"

# Ensure `version` config is set due to EPUB requirements:
# WARNING: conf value "version" should not be empty for EPUB3
version = branch

# Default definitions for this documentations version warnings if applicable
# https://sphinx-version-warning.readthedocs.io/en/latest/configuration.html
versionwarning_project_slug = "zammad-admin-documentation"
Expand Down
4 changes: 2 additions & 2 deletions locale/user-docs.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Zammad (for Agents) \n"
"Project-Id-Version: Zammad (for Agents) pre-release\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-26 09:56+0100\n"
"POT-Creation-Date: 2023-08-03 11:46+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down

0 comments on commit 42e9ade

Please sign in to comment.