Skip to content

Commit

Permalink
WIP breadcrumb site
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanov committed Jun 5, 2024
1 parent f6f44f9 commit c7bdc60
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/sites/breadcrumbs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions tests/sites/breadcrumbs/_templates/components/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{# Displays (and links to) the parent section(s) of the currently viewed page. #}
{%- block breadcrumbs %}
{#
If we have more than 3 parents (excluding the home page) then we remove
The ones in the middle and add an ellipsis.
#}
{% if parents|length>2 %}
{% set parents=[parents[0], {"title": '<i class="fa-solid fa-ellipsis"></i>'}, parents[-1]] %}
{% endif %}

The unattainable is unknown
{#- Hide breadcrumbs on the home page #}
{% if title and pagename != root_doc %}
<nav aria-label="{{ _('Breadcrumb') }}" class="d-print-none">
<ul class="bd-breadcrumbs">
{# Home icon #}
<li class="breadcrumb-item breadcrumb-home">
<a href="{{ pathto(root_doc) }}" class="nav-link" aria-label="{{ _('Home') }}">
<i class="fa-solid fa-home"></i>
</a>
</li>
{%- for doc in parents %}
{% if doc.link %}
<li class="breadcrumb-item"><a href="{{ doc.link|e }}" class="nav-link">{{ doc.title }}</a></li>
{% else %}
<li class="breadcrumb-item">{{ doc.title }}</li>
{% endif %}
{%- endfor %}
<li class="breadcrumb-item active" aria-current="page"><span class="ellipsis">{{ title }} THERE IS ONLY ZOMBO!!! </span></li>
</ul>
</nav>
{% endif %}
{%- endblock %}
27 changes: 27 additions & 0 deletions tests/sites/breadcrumbs/_templates/components/prev-next.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{# Displays links to the previous and next page in the TOCtree order. #}
<div class="prev-next-area">
{%- if prev %}
<a class="left-prev"
href="{{ prev.link|e }}"
title="{{ _('previous page') }}">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">{{ _("previous") }}</p>
<p class="prev-next-title">{{ prev_title or prev.title }}</p>
</div>
</a>
{%- endif %}

<a href="http://zombo.com">SAD ZOMBO.COM! </a>
{%- if next %}
<a class="right-next"
href="{{ next.link|e }}"
title="{{ _('next page') }}">
<div class="prev-next-info">
<p class="prev-next-subtitle">{{ _("next") }}</p>
<p class="prev-next-title">{{ next_title or next.title }}</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>
{%- endif %}
</div>
60 changes: 60 additions & 0 deletions tests/sites/breadcrumbs/_templates/theme.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[theme]
inherit = basic
# Note that we don't link the CSS file via Sphinx
# instead we manually link it in `webpack-macros.html`
stylesheet = styles/pydata-sphinx-theme.css
pygments_style = tango
sidebars = sidebar-nav-bs.html

[options]
# General configuration
sidebarwidth = 270
sidebar_includehidden = True
use_edit_page_button = False
external_links =
bitbucket_url =
github_url =
gitlab_url =
twitter_url =
icon_links_label = Icon Links
icon_links =
analytics =
show_prev_next = True
search_bar_text = Search the docs ...
navigation_with_keys = False
collapse_navigation = False
navigation_depth = 4
show_nav_level = 1
show_toc_level = 1
navbar_align = content
header_links_before_dropdown = 5
header_dropdown_text = More
switcher =
check_switcher = True
pygments_light_style = a11y-high-contrast-light
pygments_dark_style = a11y-high-contrast-dark
logo =
surface_warnings = True
back_to_top_button = True

# Template placement in theme layouts
navbar_start = navbar-logo
navbar_center = navbar-nav
navbar_end = theme-switcher, navbar-icon-links
navbar_persistent = search-button-field
article_header_start = breadcrumbs
article_header_end = breadcrumbs
article_footer_items = breadcrumbs
content_footer_items = breadcrumbs
primary_sidebar_start = breadcrumbs
primary_sidebar_end = sidebar-ethical-ads, breadcrumbs
footer_start = copyright, sphinx-version
footer_center = breadcrumbs
footer_end = theme-version
secondary_sidebar_items = page-toc, edit-this-page, sourcelink, breadcrumbs
show_version_warning_banner = False
announcement = breadcrumbs

# DEPRECATED (remove after 1.0 release)
pygment_light_style =
pygment_dark_style =
28 changes: 28 additions & 0 deletions tests/sites/breadcrumbs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Test conf file."""

# -- Project information -----------------------------------------------------

project = "PyData Tests"
copyright = "2020, Pydata community"
author = "Pydata community"

root_doc = "index"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
html_theme = "pydata_sphinx_theme"
html_logo = "_static/emptylogo.png"
html_copy_source = True
html_sourcelink_suffix = ""

templates_path=["_templates"]

# Base options, we can add other key/vals later
html_sidebars = {"section1/index": ["sidebar-nav-bs.html"]}

html_theme_options ={ "footer_center": ["breadcrumbs"]}

20 changes: 20 additions & 0 deletions tests/sites/breadcrumbs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Index ``with code`` in title
============================

.. toctree::
:caption: My caption
:numbered:

page1
page2
section1/index
google <https://google.com>

A header
--------

A sub-header
~~~~~~~~~~~~

A sub-sub-header
````````````````
14 changes: 14 additions & 0 deletions tests/sites/breadcrumbs/missing_url.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"name": "v0.7.1 (stable)",
"version": "0.7.1",
"url": "https://pydata-sphinx-theme.readthedocs.io/en/v0.7.1/"
},
{
"version": "0.7.0",
"url": "https://pydata-sphinx-theme.readthedocs.io/en/v0.7.0/"
},
{
"version": "0.6.3"
}
]
38 changes: 38 additions & 0 deletions tests/sites/breadcrumbs/page1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Page 1
======


secondary heading
~~~~~~~~~~~~~~~~~

tertiary heading
~~~~~~~~~~~~~~~~~

**normal link**

- https://pydata-sphinx-theme.readthedocs.io/en/latest/

**GitHub**

.. container:: github-container

https://github.com
https://github.com/pydata
https://github.com/pydata/pydata-sphinx-theme
https://github.com/pydata/pydata-sphinx-theme/pull/1012
https://github.com/orgs/pydata/projects/2

**GitLab**

.. container:: gitlab-container

https://gitlab.com
https://gitlab.com/gitlab-org
https://gitlab.com/gitlab-org/gitlab
https://gitlab.com/gitlab-org/gitlab/-/issues/375583
https://gitlab.com/gitlab-org/gitlab/issues/375583
https://gitlab.com/gitlab-org/gitlab/issues/
https://gitlab.com/gitlab-org/gitlab/issues
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/84669
https://gitlab.com/gitlab-org/gitlab/-/pipelines/511894707
https://gitlab.com/gitlab-com/gl-infra/production/-/issues/6788
9 changes: 9 additions & 0 deletions tests/sites/breadcrumbs/page2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:html_theme.sidebar_secondary.remove: true

Page :math:`\beta`
==================

.. code-block:: python
import pydata_sphinx_theme as pst
raise RuntimeError('Test of pygments highlighting')
6 changes: 6 additions & 0 deletions tests/sites/breadcrumbs/section1/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Section 1 index
===============
.. toctree::

page1
https://google.com
2 changes: 2 additions & 0 deletions tests/sites/breadcrumbs/section1/page1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Section 1 page1
===============
15 changes: 15 additions & 0 deletions tests/sites/breadcrumbs/switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"name": "v0.7.1 (stable)",
"version": "0.7.1",
"url": "https://pydata-sphinx-theme.readthedocs.io/en/v0.7.1/"
},
{
"version": "0.7.0",
"url": "https://pydata-sphinx-theme.readthedocs.io/en/v0.7.0/"
},
{
"version": "0.6.3",
"url": "https://pydata-sphinx-theme.readthedocs.io/en/v0.6.3/"
}
]
13 changes: 12 additions & 1 deletion tests/test_breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


@pytest.fixture(scope="module")
def url_base(path_repo=path_repo, path_docs_build=path_docs_build):
def url_base():
"""Start local server on built docs and return the localhost URL as the base URL."""
# Use a port that is not commonly used during development or else you will
# force the developer to stop running their dev server in order to run the
Expand Down Expand Up @@ -86,3 +86,14 @@ def test_breadcrumb_expansion(page: Page, url_base: str) -> None:
# required to display the text.
assert el.evaluate("e => e.clientWidth < e.scrollWidth", el) == True


def test_breadcrumbs_everywhere(sphinx_build_factory) -> None:
"""Test building the base html template and config."""
sphinx_build = sphinx_build_factory("breadcrumbs")

# Basic build with defaults
sphinx_build.build()
assert (sphinx_build.outdir / "index.html").exists(), sphinx_build.outdir.glob("*")
#TODO symlink the outdir into the path_docs_build/playwright_tests/ directory
import ipdb; ipdb.set_trace()

0 comments on commit c7bdc60

Please # to comment.