2017-06-25 17:05:31 +00:00
|
|
|
# All configuration values have a default; values that are commented out
|
|
|
|
# serve to show the default.
|
|
|
|
#
|
2023-07-17 19:35:44 +00:00
|
|
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
|
|
|
2017-07-17 20:00:32 +00:00
|
|
|
import os
|
2023-07-17 19:35:44 +00:00
|
|
|
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
|
|
|
|
2023-07-17 19:35:44 +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 = {
|
2023-07-17 19:35:44 +00:00
|
|
|
"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
|
|
|
}
|
2023-07-17 19:35:44 +00:00
|
|
|
os.environ.update(**FUNKWHALE_CONFIG)
|
|
|
|
|
2017-06-25 17:05:31 +00:00
|
|
|
# -- General configuration ------------------------------------------------
|
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
# 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 = [
|
2023-07-17 19:35:44 +00:00
|
|
|
"sphinx_copybutton",
|
2022-07-23 13:32:35 +00:00
|
|
|
"sphinx_design",
|
2023-07-17 19:35:44 +00:00
|
|
|
"sphinx.ext.autodoc",
|
|
|
|
"sphinx.ext.graphviz",
|
2022-10-09 17:44:08 +00:00
|
|
|
"sphinxcontrib.mermaid",
|
2023-07-17 19:35:44 +00:00
|
|
|
"myst_parser",
|
2022-01-19 18:49:46 +00:00
|
|
|
]
|
2023-07-17 19:35:44 +00:00
|
|
|
|
|
|
|
source_suffix = ".md"
|
|
|
|
include_patterns = [
|
|
|
|
"_static/**",
|
|
|
|
"*_documentation/**",
|
|
|
|
"*.md",
|
2023-11-01 13:16:32 +00:00
|
|
|
"**/*.md",
|
2023-07-17 19:35:44 +00:00
|
|
|
"*.rst",
|
|
|
|
"logo.svg",
|
|
|
|
]
|
|
|
|
exclude_patterns = [
|
|
|
|
"_build",
|
|
|
|
"_scripts",
|
|
|
|
".venv",
|
|
|
|
".DS_Store",
|
|
|
|
"Thumbs.db",
|
|
|
|
"*.py",
|
|
|
|
"*.sh",
|
|
|
|
]
|
2023-11-01 13:16:32 +00:00
|
|
|
templates_path = ["_templates"]
|
2023-07-17 19:35:44 +00:00
|
|
|
|
|
|
|
root_doc = "index"
|
|
|
|
|
|
|
|
# autodoc
|
2022-01-09 11:40:49 +00:00
|
|
|
autodoc_mock_imports = [
|
|
|
|
"celery",
|
|
|
|
"django_auth_ldap",
|
|
|
|
"ldap",
|
|
|
|
"persisting_theory",
|
|
|
|
"rest_framework",
|
2022-07-23 13:32:35 +00:00
|
|
|
"drf_spectacular",
|
2022-01-09 11:40:49 +00:00
|
|
|
]
|
2017-06-25 17:05:31 +00:00
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
# sphinx
|
|
|
|
pygments_style = "sphinx"
|
|
|
|
add_module_names = False
|
|
|
|
todo_include_todos = False
|
2017-06-25 17:05:31 +00:00
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
# myst
|
2023-06-18 12:46:01 +00:00
|
|
|
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
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
# internationalization
|
|
|
|
locale_dirs = ["locales/"]
|
|
|
|
gettext_compact = False
|
2023-01-30 11:23:19 +00:00
|
|
|
language = "en"
|
2017-06-25 17:05:31 +00:00
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
# copybutton
|
|
|
|
copybutton_exclude = ".linenos, .gp"
|
2017-06-25 17:05:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
# -- Options for HTML output ----------------------------------------------
|
|
|
|
|
2019-10-02 14:27:59 +00:00
|
|
|
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",
|
2021-09-21 11:36:16 +00:00
|
|
|
"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",
|
2019-10-02 14:27:59 +00:00
|
|
|
}
|
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"]
|
2023-07-17 19:35:44 +00:00
|
|
|
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 ------------------------------------------
|
|
|
|
|
2018-06-24 21:42:38 +00:00
|
|
|
htmlhelp_basename = "funkwhaledoc"
|
2017-06-25 17:05:31 +00:00
|
|
|
|
|
|
|
# -- Options for LaTeX output ---------------------------------------------
|
|
|
|
|
|
|
|
latex_documents = [
|
2022-01-09 11:40:49 +00:00
|
|
|
(
|
|
|
|
root_doc,
|
|
|
|
"funkwhale.tex",
|
2023-07-17 19:35:44 +00:00
|
|
|
"Funkwhale Documentation",
|
2022-01-09 11:40:49 +00:00
|
|
|
"The Funkwhale Collective",
|
|
|
|
"manual",
|
|
|
|
)
|
2017-06-25 17:05:31 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# -- Options for manual page output ---------------------------------------
|
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
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 = [
|
2018-06-24 21:42:38 +00:00
|
|
|
(
|
2021-09-21 11:36:16 +00:00
|
|
|
root_doc,
|
2018-06-24 21:42:38 +00:00
|
|
|
"funkwhale",
|
2023-07-17 19:35:44 +00:00
|
|
|
"Funkwhale Documentation",
|
2018-06-24 21:42:38 +00:00
|
|
|
author,
|
|
|
|
"funkwhale",
|
|
|
|
"One line description of project.",
|
|
|
|
"Miscellaneous",
|
|
|
|
)
|
2017-06-25 17:05:31 +00:00
|
|
|
]
|
2019-03-13 08:55:03 +00:00
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
# -- Setup legacy redirects -----------------------------------------------
|
2019-03-13 08:55:03 +00:00
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
REDIRECT_TEMPLATE = """\
|
2019-03-13 08:55:03 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2023-07-17 19:35:44 +00:00
|
|
|
<meta http-equiv="refresh" content="1; url={url}" />
|
2019-03-13 08:55:03 +00:00
|
|
|
<script>
|
2023-07-17 19:35:44 +00:00
|
|
|
window.location.href = "{url}"
|
2019-03-13 08:55:03 +00:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
</html>
|
|
|
|
"""
|
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
redirects_file = Path("redirects.txt")
|
|
|
|
redirects = [
|
|
|
|
tuple(line.strip().split(", "))
|
|
|
|
for line in redirects_file.read_text(encoding="utf-8").splitlines()
|
|
|
|
]
|
2019-03-13 08:55:03 +00:00
|
|
|
|
2020-03-02 16:23:03 +00:00
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
def copy_legacy_redirects(app: Sphinx, docname):
|
2020-03-02 16:23:03 +00:00
|
|
|
if app.builder.name == "html":
|
2023-07-17 19:35:44 +00:00
|
|
|
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")
|
2019-03-13 08:55:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def setup(app):
|
2020-03-02 16:23:03 +00:00
|
|
|
app.connect("build-finished", copy_legacy_redirects)
|