funkwhale/docs/conf.py

198 wiersze
4.4 KiB
Python
Czysty Zwykły widok Historia

2017-06-25 17:05:31 +00:00
# All configuration values have a default; values that are commented out
# serve to show the default.
#
# https://www.sphinx-doc.org/en/master/usage/configuration.html
2017-07-17 20:00:32 +00:00
import os
from datetime import datetime
from pathlib import Path
from sphinx.application import Sphinx
from sphinx.util import logging
import funkwhale_api
2017-06-25 17:05:31 +00:00
logger = logging.getLogger(__name__)
2017-07-17 20:00:32 +00:00
2017-06-25 17:05:31 +00:00
2020-04-20 11:48:19 +00:00
FUNKWHALE_CONFIG = {
"FUNKWHALE_URL": "https://pod.funkwhale",
"DATABASE_URL": "postgres://localhost:5432/funkwhale",
2020-07-03 08:59:12 +00:00
"AWS_ACCESS_KEY_ID": "my_access_key",
"AWS_SECRET_ACCESS_KEY": "my_secret_key",
"AWS_STORAGE_BUCKET_NAME": "my_bucket",
2020-04-20 11:48:19 +00:00
}
os.environ.update(**FUNKWHALE_CONFIG)
2017-06-25 17:05:31 +00:00
# -- General configuration ------------------------------------------------
# General information about the project.
year = datetime.now().year
project = "funkwhale"
copyright = f"{year}, The Funkwhale Collective"
author = "The Funkwhale Collective"
version = funkwhale_api.__version__
release = version
2017-06-25 17:05:31 +00:00
2022-01-19 18:49:46 +00:00
extensions = [
"sphinx_copybutton",
2022-07-23 13:32:35 +00:00
"sphinx_design",
"sphinx.ext.autodoc",
"sphinx.ext.graphviz",
"sphinxcontrib.mermaid",
"myst_parser",
2022-01-19 18:49:46 +00:00
]
source_suffix = ".md"
include_patterns = [
"_static/**",
"*_documentation/**",
"*.md",
"**/*.md",
"*.rst",
"logo.svg",
]
exclude_patterns = [
"_build",
"_scripts",
".venv",
".DS_Store",
"Thumbs.db",
"*.py",
"*.sh",
]
templates_path = ["_templates"]
root_doc = "index"
# autodoc
autodoc_mock_imports = [
"celery",
"django_auth_ldap",
"ldap",
"persisting_theory",
"rest_framework",
2022-07-23 13:32:35 +00:00
"drf_spectacular",
]
2017-06-25 17:05:31 +00:00
# sphinx
pygments_style = "sphinx"
add_module_names = False
todo_include_todos = False
2017-06-25 17:05:31 +00:00
# myst
myst_enable_extensions = [
"colon_fence",
"attrs_block",
"tasklist",
"fieldlist",
"deflist",
]
2022-07-01 09:02:29 +00:00
myst_heading_anchors = 3
2017-06-25 17:05:31 +00:00
# internationalization
locale_dirs = ["locales/"]
gettext_compact = False
language = "en"
2017-06-25 17:05:31 +00:00
# copybutton
copybutton_exclude = ".linenos, .gp"
2017-06-25 17:05:31 +00:00
# -- Options for HTML output ----------------------------------------------
html_theme = "sphinx_rtd_theme"
html_context = {
2020-03-02 16:23:03 +00:00
"display_gitlab": True,
"gitlab_host": "dev.funkwhale.audio",
"gitlab_repo": "funkwhale",
"gitlab_user": "funkwhale",
"gitlab_version": "stable",
2020-03-02 16:23:03 +00:00
"conf_py_path": "/docs/",
2021-06-17 12:56:05 +00:00
"gitlab_url": "https://dev.funkwhale.audio/funkwhale/funkwhale",
}
2020-03-02 16:23:03 +00:00
html_logo = "logo.svg"
2022-10-26 20:19:03 +00:00
html_favicon = "../front/public/favicon.ico"
2022-04-26 12:04:02 +00:00
html_static_path = ["_static"]
html_css_files = ["css/translation-hint.css"]
html_js_files = ["js/translation-hint.js"]
2017-06-25 17:05:31 +00:00
# -- Options for HTMLHelp output ------------------------------------------
htmlhelp_basename = "funkwhaledoc"
2017-06-25 17:05:31 +00:00
# -- Options for LaTeX output ---------------------------------------------
latex_documents = [
(
root_doc,
"funkwhale.tex",
"Funkwhale Documentation",
"The Funkwhale Collective",
"manual",
)
2017-06-25 17:05:31 +00:00
]
# -- Options for manual page output ---------------------------------------
man_pages = [
(
root_doc,
"funkwhale",
"Funkwhale Documentation",
[author],
1,
)
]
2017-06-25 17:05:31 +00:00
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
root_doc,
"funkwhale",
"Funkwhale Documentation",
author,
"funkwhale",
"One line description of project.",
"Miscellaneous",
)
2017-06-25 17:05:31 +00:00
]
# -- Setup legacy redirects -----------------------------------------------
REDIRECT_TEMPLATE = """\
<html>
<head>
<meta http-equiv="refresh" content="1; url={url}" />
<script>
window.location.href = "{url}"
</script>
</head>
</html>
"""
redirects_file = Path("redirects.txt")
redirects = [
tuple(line.strip().split(", "))
for line in redirects_file.read_text(encoding="utf-8").splitlines()
]
2020-03-02 16:23:03 +00:00
def copy_legacy_redirects(app: Sphinx, docname):
2020-03-02 16:23:03 +00:00
if app.builder.name == "html":
for src_path, dest_url in redirects:
content = REDIRECT_TEMPLATE.format(url=dest_url)
redirect_path = Path(app.outdir) / src_path
redirect_path.parent.mkdir(parents=True, exist_ok=True)
redirect_path.write_text(content, encoding="utf-8")
def setup(app):
2020-03-02 16:23:03 +00:00
app.connect("build-finished", copy_legacy_redirects)