Skip to content

Using a non-existent reference for clickable card link gives confusing error message #27

@jorisvandenbossche

Description

@jorisvandenbossche

Describe the problem

When creating a clickable card with :link: on the card directive (https://sphinx-design.readthedocs.io/en/furo-theme/cards.html#clickable-cards) using an internal sphinx reference, if that reference doesn't exist, you get a confusing error message:

So for example in the below snippet (from the docs) with a "missing" link reference:

.. card:: Clickable Card (internal)
    :link: missing
    :link-type: doc

    The entire card can be clicked to navigate to the ``cards`` reference target.

This gives "AssertionError: Losing "classes" attribute: ['sd-stretched-link']" error.

You can still see that sphinx also warns about an "unknown document", but it's easy to miss that in the output.

The full traceback is included below:

Details

Running Sphinx v5.0.0+/d194e0f49
...
reading sources... [100%] index

pickling environment... done
checking consistency... done
preparing documents... done
/home/joris/scipy/pandas/doc/source/index.rst:27: WARNING: unknown document: missing

Traceback (most recent call last):
  File "/home/joris/scipy/repos/sphinx/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/home/joris/scipy/repos/sphinx/sphinx/application.py", line 343, in build
    self.builder.build_update()
  File "/home/joris/scipy/repos/sphinx/sphinx/builders/__init__.py", line 293, in build_update
    self.build(to_build,
  File "/home/joris/scipy/repos/sphinx/sphinx/builders/__init__.py", line 357, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/joris/scipy/repos/sphinx/sphinx/builders/__init__.py", line 528, in write
    self._write_parallel(sorted(docnames),
  File "/home/joris/scipy/repos/sphinx/sphinx/builders/__init__.py", line 552, in _write_parallel
    doctree = self.env.get_and_resolve_doctree(firstname, self)
  File "/home/joris/scipy/repos/sphinx/sphinx/environment/__init__.py", line 532, in get_and_resolve_doctree
    self.apply_post_transforms(doctree, docname)
  File "/home/joris/scipy/repos/sphinx/sphinx/environment/__init__.py", line 578, in apply_post_transforms
    transformer.apply_transforms()
  File "/home/joris/scipy/repos/sphinx/sphinx/transforms/__init__.py", line 86, in apply_transforms
    super().apply_transforms()
  File "/home/joris/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "/home/joris/scipy/repos/sphinx/sphinx/transforms/post_transforms/__init__.py", line 43, in apply
    self.run(**kwargs)
  File "/home/joris/scipy/repos/sphinx/sphinx/transforms/post_transforms/__init__.py", line 120, in run
    node.replace_self(newnodes)
  File "/home/joris/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/docutils/nodes.py", line 1015, in replace_self
    assert not self[att], \
AssertionError: Losing "classes" attribute: ['sd-stretched-link']

Exception occurred:
  File "/home/joris/miniconda3/envs/pandas-dev/lib/python3.8/site-packages/docutils/nodes.py", line 1015, in replace_self
    assert not self[att], \
AssertionError: Losing "classes" attribute: ['sd-stretched-link']

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions