Skip to content

Commit

Permalink
Merge branch 'master' into rhs-toc-adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
AakashGfude committed Apr 30, 2023
2 parents d00b16f + 02f54de commit eb7e422
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions quantecon_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def add_static_path(app):
def add_to_context(app, pagename, templatename, context, doctree):
"""Functions and variable additions to context."""

config_theme = app.config.html_theme_options

def sbt_generate_toctree_html(
level=1,
include_item_names=False,
Expand Down Expand Up @@ -169,9 +171,11 @@ def get_github_src_folder(app):
github_repo = context["github_repo"]
if github_repo in app.srcdir:
index = app.srcdir.rfind(github_repo)
branch = context["github_version"]
branch = config_theme.get("nb_branch", "")
if branch == "":
branch = "main"
folder = app.srcdir[index + len(github_repo) :]
return "/tree/" + branch + folder
return "/blob/" + branch + folder
return ""

# Pull metadata about the master doc
Expand Down Expand Up @@ -227,7 +231,6 @@ def get_github_src_folder(app):
# Add HTML context variables that the pydata theme uses that we configure elsewhere
# For some reason the source_suffix sometimes isn't there even when doctree is
if doctree and context.get("page_source_suffix"):
config_theme = app.config.html_theme_options
repo_url = config_theme.get("repository_url", "")
# Only add the edit button if `repository_url` is given
if repo_url:
Expand Down

1 comment on commit eb7e422

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.