Skip to content
Snippets Groups Projects
Commit e55ef6f6 authored by mmcky's avatar mmcky
Browse files

Revert "rework to add local_paths rather than local_extensions"

This reverts commit 081f6fab.
parent 081f6fab
No related branches found
No related tags found
No related merge requests found
......@@ -123,17 +123,16 @@ This will **append** to the list of extensions already loaded by Jupyter Book.
### Adding Local Extensions
To add a local extension you can specify the path using `local_paths` such as:
To add a local extension that requires a path, use:
```yaml
sphinx:
extra_extensions: [my_extension]
local_paths:
- <path>
local_extensions:
<name>: <path>
```
This will **append** the path to the `sys.path` context so the local extension
can be found.
This will **append to the list of extensions already loaded by Jupyter Book and update the `sys.path` so
the local extension can be found.
### Specifying Sphinx Configuration Values
......
......@@ -285,9 +285,13 @@ def yaml_to_sphinx(yaml: dict):
if extension not in sphinx_config["extensions"]:
sphinx_config["extensions"].append(extension)
local_paths = yaml.get("sphinx", {}).get("local_paths")
if local_paths:
for path in local_paths:
local_extensions = yaml.get("sphinx", {}).get("local_extensions")
if local_extensions:
if "extensions" not in sphinx_config:
sphinx_config["extensions"] = get_default_sphinx_config()["extensions"]
for extension, path in local_extensions.items():
if extension not in sphinx_config["extensions"]:
sphinx_config["extensions"].append(extension)
if path not in sys.path:
sys.path.append(os.path.abspath(path))
......
......@@ -190,14 +190,11 @@
"type": "string"
}
},
"local_paths": {
"local_extensions": {
"type": [
"null",
"array"
],
"items": {
"type": "string"
}
"object"
]
},
"config": {
"type": [
......
......@@ -69,5 +69,5 @@ repository:
# Advanced and power-user settings
sphinx:
extra_extensions : # A list of extra extensions to load by Sphinx (added to those already used by JB).
local_paths : # A list of paths to be added to sys.path for loading local extensions
local_extensions : # A list of local extensions to load by sphinx specified by "name: path" items
config : # key-value pairs to directly over-ride the Sphinx configuration
......@@ -19,8 +19,8 @@ from jupyter_book.commands import sphinx
{"exclude_patterns": ["new"]},
{
"sphinx": {
"extra_extensions": ["other", "helloworld"],
"local_paths": ["./ext"],
"extra_extensions": ["other"],
"local_extensions": {"helloworld": "./ext"},
"config": {
"html_theme_options": {
"launch_buttons": {"binderhub_url": "other"}
......
......@@ -8,9 +8,8 @@ _user_config:
new: value
extra_extensions:
- other
- helloworld
local_paths:
- ./ext
local_extensions:
helloworld: ./ext
final:
author: The Jupyter Book community
comments_config:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment