Add sphinx-copybutton and Furo GitHub source links Add sphinx-copybutton to docs/requirements.txt and enable it in docs/source/conf.py when installed so code blocks have a one-click copy button. Configure source_repository, source_branch, and source_directory in Furo html_theme_options so each page links to its source on GitHub. Change-Id: I2ff652491cab59160b1fc7b730035ddb399cfce1
diff --git a/docs/requirements.txt b/docs/requirements.txt index 1750b45..54efa06 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt
@@ -1,2 +1,3 @@ furo>=2024.8.6 sphinx>=8.1.3 +sphinx-copybutton>=0.5.2
diff --git a/docs/source/conf.py b/docs/source/conf.py index 96d942c..f37e0a1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py
@@ -1,3 +1,4 @@ +import importlib.util from pathlib import Path import re @@ -51,6 +52,8 @@ 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig', ] +if importlib.util.find_spec('sphinx_copybutton') is not None: + extensions.append('sphinx_copybutton') master_doc = 'index' exclude_patterns = [] @@ -83,6 +86,11 @@ html_theme = 'furo' html_title = 'Ceres Solver' +html_theme_options = { + 'source_repository': 'https://github.com/ceres-solver/ceres-solver', + 'source_branch': 'master', + 'source_directory': 'docs/source/', +} html_domain_indices = True html_use_index = True html_split_index = False