choldgraf / sphinx-social-previews

Generate a social media preview image from page metadata with Sphinx
Other
4 stars 0 forks source link

Error raised when using this extension - `'NoneType' object has no attribute 'strip'` #8

Open consideRatio opened 1 year ago

consideRatio commented 1 year ago

@choldgraf I'm running into the following in the 2i2c-org/infrastructure repo when trying make build following https://github.com/2i2c-org/sphinx-2i2c-theme/pull/13 added this project as a dependency.

Traceback (most recent call last):
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/application.py", line 330, in build
    self.builder.build_update()
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 286, in build_update
    self.build(to_build,
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 350, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 524, in write
    self._write_serial(sorted(docnames))
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 534, in _write_serial
    self.write_doc(docname, doctree)
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 625, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 1026, in handle_page
    newtmpl = self.app.emit_firstresult('html-page-context', pagename,
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/application.py", line 457, in emit_firstresult
    return self.events.emit_firstresult(event, *args,
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/events.py", line 112, in emit_firstresult
    for result in self.emit(name, *args, allowed_exceptions=allowed_exceptions):
  File "/home/erik/mambaforge/lib/python3.10/site-packages/sphinx/events.py", line 102, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function render_page_card at 0x7f68ddbebe20> for event 'html-page-context' threw an exception (exception: 'NoneType' object has no attribute 'strip')

Extension error (sphinx_social_previews.card):
Handler <function render_page_card at 0x7f68ddbebe20> for event 'html-page-context' threw an exception (exception: 'NoneType' object has no attribute 'strip')

The only place strip shows up in this codebase is in card.py in these three locations.

https://github.com/choldgraf/sphinx-social-previews/blob/7612d37737a9445a92d19e9aed4814969c05a446/sphinx_social_previews/card.py#L253-L256

https://github.com/choldgraf/sphinx-social-previews/blob/7612d37737a9445a92d19e9aed4814969c05a446/sphinx_social_previews/card.py#L269-L270

https://github.com/choldgraf/sphinx-social-previews/blob/7612d37737a9445a92d19e9aed4814969c05a446/sphinx_social_previews/card.py#L311-L312

choldgraf commented 1 year ago

Hmmm - I am a little bit hesitant to debug this one because I'm really hoping that I can deprecate that package after it gets merge upstream into sphinext.opengraph: https://github.com/wpilibsuite/sphinxext-opengraph/pull/88

How do you feel about living on the edge and making our docs depend on that PR branch to see how it works in our documentation? Is that too bleeding edge?