Skip to content

Commit 3574fb1

Browse files
authored
Merge pull request #2860 from cta-observatory/fix-writer-deprecation-warning
Fix PendingDeprecationWarning for docutils arg
2 parents 92a43c7 + c4db982 commit 3574fb1

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/ctapipe/core/component.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from logging import getLogger
99

1010
from docutils.core import publish_parts
11+
from docutils.writers.html5_polyglot import Writer as HTML5Writer
1112
from traitlets import TraitError
1213
from traitlets.config import Configurable
1314

@@ -250,12 +251,13 @@ def _repr_html_(self):
250251
"""nice HTML rep, with blue for non-default values"""
251252
traits = self.traits()
252253
name = self.__class__.__name__
253-
docstring = (
254-
publish_parts(cleandoc(self.__class__.__doc__), writer_name="html")[
255-
"html_body"
256-
]
257-
or "Undocumented"
258-
)
254+
255+
if not self.__class__.__doc__:
256+
docstring = "Undocumented"
257+
else:
258+
clean_doc = cleandoc(self.__class__.__doc__)
259+
writer = HTML5Writer()
260+
docstring = publish_parts(clean_doc, writer=writer)["html_body"]
259261
lines = [
260262
'<div style="border:1px solid black; max-width: 700px; padding:2em; word-wrap:break-word;">',
261263
f"<b>{name}</b>",

0 commit comments

Comments
 (0)