Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add links from reference manual to source code on GitHub (#703)

Benjamin Hackl12d7af38d1ea
diff --git a/docs/source/conf.py b/docs/source/conf.py
index dd222236d..37525b51b 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -57,6 +57,7 @@ extensions = [
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.extlinks",
+ "sphinx.ext.linkcode",
"sphinxext.opengraph",
"manim_directive",
]
@@ -104,6 +105,19 @@ html_static_path = ["_static"]
# This specifies any additional css files that will override the theme's
html_css_files = ["custom.css"]
+# source links to github
+def linkcode_resolve(domain, info):
+ if domain != "py":
+ return None
+ if not info["module"]:
+ return None
+ filename = info["module"].replace(".", "/")
+ version = os.getenv("READTHEDOCS_VERSION", "master")
+ if version == "latest":
+ version = "master"
+ return f"https://github.com/ManimCommunity/manim/blob/{version}/{filename}.py"
+
+
# external links
extlinks = {
"issue": ("https://github.com/ManimCommunity/manim/issues/%s", "issue "),