diff --git a/docs/conf.py b/docs/conf.py index c7e794ce7..77a5a5248 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -113,6 +113,7 @@ "binderhub_url": "https://mybinder.org", "colab_url": "https://colab.research.google.com/", "deepnote_url": "https://deepnote.com/", + "lightning_studio_url": "https://lightning.ai/", "notebook_interface": "jupyterlab", "thebe": True, # "jupyterhub_url": "https://datahub.berkeley.edu", # For testing diff --git a/docs/content/launch.md b/docs/content/launch.md index 8c851c344..aee537be6 100644 --- a/docs/content/launch.md +++ b/docs/content/launch.md @@ -85,6 +85,22 @@ html_theme_options = { This will create a new Deepnote project every time you click the launch button. ``` +## Lightning Studio + +To add [Lightning Studio](https://lightning.ai) links to your page, add the following configuration: + + +```python +html_theme_options = { + ... + "launch_buttons": { + "lightning_studio_url": "https://lightning.ai" + }, + ... +} +``` + + ## Live code cells with Thebe diff --git a/src/sphinx_book_theme/header_buttons/launch.py b/src/sphinx_book_theme/header_buttons/launch.py index c00f92937..08ef14cba 100644 --- a/src/sphinx_book_theme/header_buttons/launch.py +++ b/src/sphinx_book_theme/header_buttons/launch.py @@ -116,6 +116,7 @@ def add_launch_buttons( binderhub_url = launch_buttons.get("binderhub_url", "").strip("/") colab_url = launch_buttons.get("colab_url", "").strip("/") deepnote_url = launch_buttons.get("deepnote_url", "").strip("/") + lightning_studio_url = launch_buttons.get("lightning_studio_url", "").strip("/") # Loop through each provider and add a button for it if needed if binderhub_url: @@ -189,6 +190,22 @@ def add_launch_buttons( } ) + if lightning_studio_url: + if provider.lower() != "github": + SPHINX_LOGGER.warning(f"Provider {provider} not supported on Lightning.") + else: + github_path = f"%2F{org}%2F{repo}%2Fblob%2F{branch}%2F{path_rel_repo}" + url = f"{lightning_studio_url}/new?repo_url=https://github.com{github_path}" + launch_buttons_list.append( + { + "type": "link", + "text": "Lightning Studio", + "tooltip": translation("Launch on") + " Lightning Studio", + "icon": "_static/images/logo_lightning_studio.svg", + "url": url, + } + ) + # Add thebe flag in context if launch_buttons.get("thebe", False): launch_buttons_list.append( diff --git a/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg b/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg new file mode 100644 index 000000000..481762a96 --- /dev/null +++ b/src/sphinx_book_theme/theme/sphinx_book_theme/static/images/logo_lightning_studio.svg @@ -0,0 +1,3 @@ + diff --git a/tests/sites/base/conf.py b/tests/sites/base/conf.py index 63f37fe83..0bcf1ec88 100644 --- a/tests/sites/base/conf.py +++ b/tests/sites/base/conf.py @@ -27,6 +27,7 @@ "jupyterhub_url": "https://datahub.berkeley.edu", "colab_url": "https://colab.research.google.com", "deepnote_url": "https://deepnote.com", + "lightning_studio_url": "https://lightning.ai/", "notebook_interface": "jupyterlab", "thebe": True, }, diff --git a/tests/test_build/build__header-article.html b/tests/test_build/build__header-article.html index 7de4ade05..08deb39b7 100644 --- a/tests/test_build/build__header-article.html +++ b/tests/test_build/build__header-article.html @@ -57,6 +57,16 @@ +