Skip to content

Commit

Permalink
GH-59 Fix external links on sidetoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
schettino72 committed Jul 22, 2021
1 parent 37a851d commit 3bf0ba2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changes
=======

0.8.0 (*unreleased*)
====================

- GH-59 Fix external links on sidetoc


0.7.3 (*2021-05-16*)
====================

Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
author = 'Eduardo Naufel Schettino'

# The short X.Y version
version = '0.7'
version = '0.8'
# The full version, including alpha/beta/rc tags
release = '0.7.3'
release = '0.8.0'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="sphinx_press_theme",
version="0.7.3",
version="0.8.0",
url="https://schettino72.github.io/sphinx_press_site/",
license="MIT",
author="Eduardo Naufel Schettino <schetino72>",
Expand Down
8 changes: 7 additions & 1 deletion sphinx_press_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sphinx import addnodes
from sphinx.util.osutil import relative_uri

__version__ = (0, 7, 3)
__version__ = (0, 8, 0)


class SimpleTocTreeCollector(EnvironmentCollector):
Expand Down Expand Up @@ -107,10 +107,15 @@ def add_toctree_data(app, pagename, templatename, context, doctree):

# add toc tree items, expand one more level if toctree is current page
entries = []
# entries contain a pair (title, name|external url)
# if name of document is given and not title, title is taken from document
for title, name in tree['entries']:
if not title:
title = app.env.titles[name].astext()

# check if entry is an external resource
ext_resource = '://' in name

current1 = (pagename == name)
children = []
if current1:
Expand All @@ -123,6 +128,7 @@ def add_toctree_data(app, pagename, templatename, context, doctree):
'title': title,
'current': current1,
'children': children,
'ext_resource': ext_resource,
})

toc_docname = tree['parent'] # docname where this toc appears
Expand Down
2 changes: 1 addition & 1 deletion sphinx_press_theme/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ sidebars = util/searchbox.html, util/sidetoc.html
[options]
analytics_id =
external_links =
press_version = 0.7.3
press_version = 0.8.0
7 changes: 6 additions & 1 deletion sphinx_press_theme/util/sidetoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
</p>
<ul class="{% if toc.current %}current{% endif %}">
{% for entry in toc.entries %}
<li class="toctree-l1 {% if entry.current %}current{% endif %}"><a href="{{ pathto(entry.name) }}" class="reference internal {% if entry.current %}current{% endif %}">{{entry.title}}</a>
<li class="toctree-l1 {% if entry.current %}current{% endif %}">
{% if entry.ext_resource %}
<a href="{{ pathto(entry.name, 1) }}" class="reference">{{entry.title}} <outboundlink></outboundlink></a>
{% else %}
<a href="{{ pathto(entry.name) }}" class="reference internal {% if entry.current %}current{% endif %}">{{entry.title}}</a>
{% endif %}

{% if entry.children %}
<ul>
Expand Down

0 comments on commit 3bf0ba2

Please sign in to comment.