Skip to content

failure to parse http links containing dashes #1887

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

Closed
NicNomadic opened this issue Jun 18, 2024 · 2 comments · Fixed by #1888
Closed

failure to parse http links containing dashes #1887

NicNomadic opened this issue Jun 18, 2024 · 2 comments · Fixed by #1888
Labels
kind: bug Something isn't working

Comments

@NicNomadic
Copy link

NicNomadic commented Jun 18, 2024

Building the following simple page fails because it contains a web link including a dash, when using pydata 0.15.3.

Extract from poetry.lock:

[[package]]
name = "pydata-sphinx-theme"
version = "0.15.3"
description = "Bootstrap-based Sphinx theme from the PyData community"
category = "main"
optional = false
python-versions = ">=3.9"

Reproducing the error:

$ cat >index.rst <<EOF
Welcome to the Documentation!
=============================

Report issues to https://gitlab.com/tezos/tezos/-/issues
EOF

$ cat >conf.py <<EOF
source_suffix = '.rst'
master_doc = 'index'
html_theme = "pydata_sphinx_theme"
EOF

$ poetry run sphinx-build -b html "." "_build"
Running Sphinx v7.3.7
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... copying static files... done
copying extra files... done
done
writing output... [100%] index
Exception occurred:
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/pydata_sphinx_theme/short_link.py", line 103, in parse_url
    url_type, element_number, *_ = parts
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected at least 2, got 1)
The full traceback has been saved in /var/folders/9y/r3w7mc6j3j79sp8qyp92rd_r0000gn/T/sphinx-err-__d87tta.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

$ cat /var/folders/9y/r3w7mc6j3j79sp8qyp92rd_r0000gn/T/sphinx-err-__d87tta.log
# Platform:         darwin; (macOS-10.16-x86_64-i386-64bit)
# Sphinx version:   7.3.7
# Python version:   3.11.6 (CPython)
# Docutils version: 0.21.2
# Jinja2 version:   3.1.4
# Pygments version: 2.18.0

# Last messages:
#   copying assets...
#   copying static files...
#   done
#   copying extra files...
#   done
#   done
#   
#   writing output... [100%]
#   index
#   

# Loaded extensions:
#   sphinx.ext.mathjax (7.3.7)
#   alabaster (0.7.16)
#   sphinxcontrib.applehelp (1.0.8)
#   sphinxcontrib.devhelp (1.0.6)
#   sphinxcontrib.htmlhelp (2.0.5)
#   sphinxcontrib.serializinghtml (1.1.10)
#   sphinxcontrib.qthelp (1.0.7)
#   pydata_sphinx_theme (unknown version)

# Traceback:
Traceback (most recent call last):
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/cmd/build.py", line 337, in build_main
    app.build(args.force_all, args.filenames)
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/application.py", line 351, in build
    self.builder.build_update()
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 293, in build_update
    self.build(to_build,
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 362, in build
    self.write(docnames, list(updated_docnames), method)
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 570, in write
    self._write_serial(sorted(docnames))
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 577, in _write_serial
    doctree = self.env.get_and_resolve_doctree(docname, self)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/environment/__init__.py", line 638, in get_and_resolve_doctree
    self.apply_post_transforms(doctree, docname)
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/environment/__init__.py", line 691, in apply_post_transforms
    transformer.apply_transforms()
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/transforms/__init__.py", line 84, in apply_transforms
    super().apply_transforms()  # type: ignore[misc]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/docutils/transforms/__init__.py", line 182, in apply_transforms
    transform.apply(**kwargs)
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/sphinx/transforms/post_transforms/__init__.py", line 44, in apply
    self.run(**kwargs)
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/pydata_sphinx_theme/short_link.py", line 54, in run
    node.children[0] = nodes.Text(self.parse_url(uri))
                                  ^^^^^^^^^^^^^^^^^^^
  File "/Users/nic/Library/Caches/pypoetry/virtualenvs/tezos-LY8-gUlI-py3.11/lib/python3.11/site-packages/pydata_sphinx_theme/short_link.py", line 103, in parse_url
    url_type, element_number, *_ = parts
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected at least 2, got 1)
@Carreau
Copy link
Collaborator

Carreau commented Jun 18, 2024

This is strange as there is already a test file (tests/sites/base/page1.rst), but I can confirm I can reproduce and have a fix, but I want to see why it is not caught by the other test.

Carreau added a commit to Carreau/pydata-sphinx-theme that referenced this issue Jun 18, 2024
Closes pydata#1887

Note that some non cannonical url (not having /-/) are not properly
shortened.
Carreau added a commit to Carreau/pydata-sphinx-theme that referenced this issue Jun 18, 2024
Closes pydata#1887

Note that some non cannonical url (not having /-/) are not properly
shortened.
@NicNomadic
Copy link
Author

I confirm that with v0.15.4 I get no more errors.
Thanks a lot for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants