-
Notifications
You must be signed in to change notification settings - Fork 25
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
Not sure how to fix KeyError: 'class' #1586
Comments
Hi @ajh30117 and thank you for reporting this issue. It looks like this might be a bug in the theme or something I didn't anticipate, such as another extension. Unfortunately, it's going to take a while before I can look at this in depth, but if you could paste your |
Hi @kai687 sure, here is my # -- General configuration ------------------------------------
# -- General configuration
# -- For Awesome Sphinx Theme ---------------------------------
from sphinxawesome_theme.postprocess import Icons
from sphinxawesome_theme import ThemeOptions, __version__
from dataclasses import asdict
# -------------------------------------------------------------
project = "Locker"
author = "OpenPTC LLC"
copyright = "2023, OpenPTC LLC"
extensions = [
"sphinx.ext.duration",
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.autosectionlabel",
]
intersphinx_mapping = {
"rtd": ("https://docs.readthedocs.io/en/stable/", None),
"python": ("https://docs.python.org/3/", None),
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
}
intersphinx_disabled_domains = ["std"]
templates_path = ["_templates"]
# -- Options for EPUB output
epub_show_urls = "footnote"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinxawesome_theme"
html_title = "Locker Documentation"
html_permalinks_icon = Icons.permalinks_icon
theme_options = ThemeOptions(
logo_light = "images/OPENPTCLogoCropped.png",
logo_dark = "images/OPENPTCLogoCropped.png",
main_nav_links = {
"About": "/about_openptc.html", "Release Notes": "/release_notes.html"
},
show_prev_next=True,
awesome_external_links=True,
extra_header_link_icons={
"repository on GitHub": {
"link": "https://github.com/OpenPTC/kms",
"icon": (
'<svg height="26px" style="margin-top:-2px;display:inline" '
'viewBox="0 0 45 44" '
'fill="currentColor" xmlns="http://www.w3.org/2000/svg">'
'<path fill-rule="evenodd" clip-rule="evenodd" '
'd="M22.477.927C10.485.927.76 10.65.76 22.647c0 9.596 6.223 17.736 '
"14.853 20.608 1.087.2 1.483-.47 1.483-1.047 "
"0-.516-.019-1.881-.03-3.693-6.04 "
"1.312-7.315-2.912-7.315-2.912-.988-2.51-2.412-3.178-2.412-3.178-1.972-1.346.149-1.32.149-1.32 " # noqa
"2.18.154 3.327 2.24 3.327 2.24 1.937 3.318 5.084 2.36 6.321 "
"1.803.197-1.403.759-2.36 "
"1.379-2.903-4.823-.548-9.894-2.412-9.894-10.734 "
"0-2.37.847-4.31 2.236-5.828-.224-.55-.969-2.759.214-5.748 0 0 "
"1.822-.584 5.972 2.226 "
"1.732-.482 3.59-.722 5.437-.732 1.845.01 3.703.25 5.437.732 "
"4.147-2.81 5.967-2.226 "
"5.967-2.226 1.185 2.99.44 5.198.217 5.748 1.392 1.517 2.232 3.457 "
"2.232 5.828 0 "
"8.344-5.078 10.18-9.916 10.717.779.67 1.474 1.996 1.474 4.021 0 "
"2.904-.027 5.247-.027 "
"5.96 0 .58.392 1.256 1.493 1.044C37.981 40.375 44.2 32.24 44.2 "
'22.647c0-11.996-9.726-21.72-21.722-21.72" '
'fill="currentColor"/></svg>'
),
},
},
)
html_theme_options = asdict(theme_options)
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# -- Substitutions
rst_prolog = """
.. |Company| replace:: OpenPTC™
""" |
I haven't used the |
@kai687 I tried it, but that didn't work either. Thanks for the suggestion though. I've had some trouble with dependencies in the past, and had to add things to my requirements.txt file to get everything working with the correct versions. Do you think it could be a version mismatch? |
Yes it might be an issue. Keeping up with dependencies is difficult for me too, a lot of unresolved issues in this repo are due to changes in other packages :(. |
What version of Sphinx are you using @ajh30117 ? |
@astrojuanlu I'm using Sphinx 6.2.1. Thoughts? |
It's difficult to reproduce this without access to your project. I don't suppose it's a public repo? I added a fix which prevents this error, but it's possible that there are other issues. |
Don't fail when we don't have a `class` attribute in auto reference docs. I believe this is what's causing #1586.
Should be part of beta 7. Please re-open if you still have issues. |
Unfortunately it's not a public repo, no. That fix is working for me, and the sphinx awesome theme is live on our docs again. Thanks much. |
It seems some key in not defined and it's throwing an exception. I'm not sure what's going on. Any insight would be helpful. Thanks!
Traceback (most recent call last):
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\sphinx\events.py", line 96, in emit
results.append(listener.handler(self.app, *args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\sphinxawesome_theme\postprocess.py", line 219, in post_process_html
_modify_html(doc, app)
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\sphinxawesome_theme\postprocess.py", line 195, in _modify_html
_scrollspy(tree)
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\sphinxawesome_theme\postprocess.py", line 115, in _scrollspy
link.parent.name == "dt" and "sig" in link.parent["class"]
~~~~~~~~~~~^^^^^^^^^
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\bs4\element.py", line 1573, in getitem
return self.attrs[key]
~~~~~~~~~~^^^^^
KeyError: 'class'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\sphinx\cmd\build.py", line 285, in build_main
app.build(args.force_all, args.filenames)
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\sphinx\application.py", line 355, in build
self.events.emit('build-finished', None)
File "C:\Users\ajh30\AppData\Local\Programs\Python\Python312\Lib\site-packages\sphinx\events.py", line 107, in emit
raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function post_process_html at 0x000001768A5F8040> for event 'build-finished' threw an exception (exception: 'class')
Extension error (sphinxawesome_theme.postprocess):
Handler <function post_process_html at 0x000001768A5F8040> for event 'build-finished' threw an exception (exception: 'class')
PS C:\Users\ajh30\Documents\OpenPTC\kms>
The text was updated successfully, but these errors were encountered: