Skip to content

Commit

Permalink
doc: Add GitHub links in the localtoc
Browse files Browse the repository at this point in the history
Add 4 GitHub links in the localtoc menu:
- view source: link to current page's source file
- edit source: edit the current page
- create doc issue: create an issue
- create project issue: create an issue

Add Font-Awesome css and use some icons before the links
to separate those links from the TOC. A `Content` is added as
the title for the TOC.

Signed-off-by: Yihong Wang <[email protected]>
  • Loading branch information
yhwang committed Aug 14, 2023
1 parent 1c1855d commit 3cb555f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions presto-docs/src/main/sphinx/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# Import the theme's layout. #}
{% extends '!layout.html' %}

{%- block fonticon %}
{# add Font Awesome here #}
<link rel="stylesheet" href="{{ pathto('_static/fonts/font-awesome.css', 1) }}"/>
{{ super() }}
{%- endblock %}
50 changes: 50 additions & 0 deletions presto-docs/src/main/sphinx/_templates/localtoc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{# there is no extension block in localtoc.html. copy the original localtoc.html #}
{% set toc_nodes = derender_toc(toc, True, pagename) if display_toc else [] %}
<nav class="md-nav md-nav--secondary">
{# add github links here #}
<ul class="md-nav__list" data-md-scrollfix="">
<li class="md-nav__item">
<a class="md-nav__link" target="_blank" href="{{ pathto(theme_repo_url + '/tree/master/presto-docs/src/main/sphinx/' + pagename + '.rst', true)|e }}">
<i class="fa fa-file-text" aria-hidden="true"></i>
{{ _('View page source') }}
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" target="_blank" href="{{ pathto(theme_repo_url + '/edit/master/presto-docs/src/main/sphinx/' + pagename + '.rst', true)|e }}">
<i class="fa fa-pencil-square" aria-hidden="true"></i>
{{ _('Edit this page') }}
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" target="_blank" href="{{ pathto(theme_repo_url + '/issues/new?title=Documentation&labels=docs', true)|e }}">
<i class="fa fa-list" aria-hidden="true"></i>
{{ _('Create docs issue') }}
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" target="_blank" href="{{ pathto(theme_repo_url + '/issues/new', true)|e }}">
<i class="fa fa-list" aria-hidden="true"></i>
{{ _('Create project issue') }}
</a>
</li>
</ul>
{%- if display_toc and toc_nodes and sidebars and 'localtoc.html' in sidebars %}
<label class="md-nav__title" for="__toc">{{ _('Contents') }}</label>
{%- endif %}
<ul class="md-nav__list" data-md-scrollfix="">
{%- if display_toc and sidebars and 'localtoc.html' in sidebars %}
{%- for item in toc_nodes recursive %}
<li class="md-nav__item"><a href="{{ item.href|e }}" class="md-nav__link" data-md-state="blur">{{ item.contents }}</a>
{%- if item.children -%}
<nav class="md-nav">
<ul class="md-nav__list">{{ loop(item.children) }}</ul>
</nav>
{%- endif %}
</li>
{%- endfor %}
{%- endif %}
{%- if show_source %}
{% include "sourcelink.html" %}
{%- endif %}
</ul>
</nav>

0 comments on commit 3cb555f

Please sign in to comment.