Skip to content

Commit

Permalink
BUG: templates_path in config was overriding value set in extension (#…
Browse files Browse the repository at this point in the history
…566)

* updating templates path

* moving to builder-inited and appending as well

* is this necessary to keep?

* config is needed

* filesystem layout link was updated

* adding jb project in tests, comments in init func

* adding jb project in tests, comments in init func

* added _build to gitignore

* have to add jupyter-book

* removing test for jupyter-book

* removing jb from dependency

* removing en/latest
  • Loading branch information
AakashGfude authored Jul 15, 2022
1 parent d213985 commit b232ca4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
_build

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is a short overview of the general architecture and structure of the repository, to help you orient yourself.

This theme uses [sphinx-theme-builder](https://sphinx-theme-builder.readthedocs.io/en/latest/) as its build backend, and follows the [filesystem layout](https://sphinx-theme-builder.readthedocs.io/en/latest/reference/filesystem-layout/) recommended by it.
This theme uses [sphinx-theme-builder](https://sphinx-theme-builder.readthedocs.io/en/latest/) as its build backend, and follows the [filesystem layout](https://sphinx-theme-builder.readthedocs.io/en/latest/filesystem-layout/) recommended by it.
See below for some more specific sections

```{contents}
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ See the [paragraph markup page](kitchen-sink/paragraph-markup.rst) for more refe

## `ABlog` - Blog post list

[ABlog](https://ablog.readthedocs.io/en/latest/) is a Sphinx extension for blogging with Sphinx.
[ABlog](https://ablog.readthedocs.io/) is a Sphinx extension for blogging with Sphinx.

Here's a sample post list:

Expand Down
14 changes: 13 additions & 1 deletion src/sphinx_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ def run(self):
return nodes


def update_general_config(app, config):
theme_dir = get_html_theme_path()
# Update templates for sidebar. Needed for jupyter-book builds as jb
# uses an instance of Sphinx class from sphinx.application to build the app.
# The __init__ function of which calls self.config.init_values() just
# before emitting `config-inited` event. The init_values function overwrites
# templates_path variable.
config.templates_path.append(os.path.join(theme_dir, "components"))


def setup(app: Sphinx):
# Register theme
theme_dir = get_html_theme_path()
Expand All @@ -176,6 +186,7 @@ def setup(app: Sphinx):

# Events
app.connect("builder-inited", update_thebe_config)
app.connect("config-inited", update_general_config)
app.connect("html-page-context", add_metadata_to_page)
app.connect("html-page-context", hash_html_assets)

Expand All @@ -194,7 +205,8 @@ def setup(app: Sphinx):
# Post-transforms
app.add_post_transform(HandleFootnoteTransform)

# Update templates for sidebar
# Update templates for sidebar, for builds where config-inited is not called
# (does not work in case of jupyter-book)
app.config.templates_path.append(os.path.join(theme_dir, "components"))

return {
Expand Down

0 comments on commit b232ca4

Please sign in to comment.