Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Gitlab url not ending with / #1148

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
"""
Bootstrap-based sphinx theme from the PyData community
"""
import json
import os
from pathlib import Path
import types
from functools import lru_cache
import json
from pathlib import Path
from urllib.parse import urlparse, urlunparse
import types

import jinja2
import requests
from bs4 import BeautifulSoup as bs
from docutils import nodes
from pygments.formatters import HtmlFormatter
from pygments.styles import get_all_styles
from requests.exceptions import ConnectionError, HTTPError, RetryError
from sphinx import addnodes
from sphinx.environment.adapters.toctree import TocTree
from sphinx.addnodes import toctree as toctree_node
from sphinx.transforms.post_transforms import SphinxPostTransform
from sphinx.util.nodes import NodeMatcher
from sphinx.environment.adapters.toctree import TocTree
from sphinx.errors import ExtensionError
from sphinx.transforms.post_transforms import SphinxPostTransform
from sphinx.util import logging
from pygments.formatters import HtmlFormatter
from pygments.styles import get_all_styles
import requests
from requests.exceptions import ConnectionError, HTTPError, RetryError
from sphinx.util.nodes import NodeMatcher

from .translator import BootstrapHTML5TranslatorMixin

Expand Down Expand Up @@ -737,7 +737,6 @@ def soup_to_python(soup, only_pages=False):
# ...

def extract_level_recursive(ul, navs_list):

for li in ul.find_all("li", recursive=False):
ref = li.a
url = ref["href"]
Expand Down Expand Up @@ -1030,7 +1029,7 @@ def parse_url(self, uri):
elif self.platform == "gitlab":
# cp. https://docs.gitlab.com/ee/user/markdown.html#gitlab-specific-references
if "/-/" in path and any(
map(uri.path.__contains__, ["issues", "merge_requests"])
map(uri.path.__contains__, ["issues/", "merge_requests/"])
):
group_and_subgroups, parts, *_ = path.split("/-/")
parts = parts.split("/")
Expand Down
2 changes: 2 additions & 0 deletions tests/sites/base/page1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Page 1
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
6 changes: 6 additions & 0 deletions tests/test_build/gitlab_links.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<a class="gitlab reference external" href="https://gitlab.com/gitlab-org/gitlab/issues/375583">
gitlab-org/gitlab/issues/375583
</a>
<a class="gitlab reference external" href="https://gitlab.com/gitlab-org/gitlab/issues/">
gitlab-org/gitlab/issues/
</a>
<a class="gitlab reference external" href="https://gitlab.com/gitlab-org/gitlab/issues">
gitlab-org/gitlab/issues
</a>
<a class="gitlab reference external" href="https://gitlab.com/gitlab-org/gitlab/-/merge_requests/84669">
gitlab-org/gitlab!84669
</a>
Expand Down