Skip to content

Commit

Permalink
Another attempt at circumventing the pydata theme hack (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Jul 4, 2023
1 parent c1a5e37 commit 4ee6da0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__/
_version.py
/build/
/dist/
/.python-version

# Testing
/.coverage
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test = [
]
doc = [
'scanpydoc[typehints]',
'sphinx<7', # https://github.com/readthedocs/sphinx_rtd_theme/issues/1463
'sphinx-rtd-theme',
]
typehints = ['sphinx-autodoc-typehints>=1.15.2']
Expand Down
9 changes: 5 additions & 4 deletions src/scanpydoc/definition_list_typed_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def make_refs(role_name, name, node):
def handle_item(
fieldarg: str, content: list[nodes.inline]
) -> nodes.definition_list_item:
head = nodes.term()
head = nodes.inline()
head += make_refs(self.rolename, fieldarg, addnodes.literal_strong)
field_type = types.pop(fieldarg, None)
if field_type is not None:
Expand All @@ -61,15 +61,16 @@ def handle_item(
else:
head += field_type

# Contents are wrapped into a span for pydata sphinx theme
head_wrap = nodes.term("", "", head)
body_content = nodes.paragraph("", "", *content)
body = nodes.definition("", body_content)

return nodes.definition_list_item("", head, body)
return nodes.definition_list_item("", head_wrap, body)

field_name = nodes.field_name("", self.label)
assert not self.can_collapse
# “field-list” for pydata sphinx theme
body_node = self.list_type(classes=["field-list"])
body_node = self.list_type(classes=["simple"])
for field_arg, content in items:
body_node += handle_item(field_arg, content)
field_body = nodes.field_body("", body_node)
Expand Down

0 comments on commit 4ee6da0

Please sign in to comment.