Skip to content

Commit 1af4506

Browse files
committed
✨ NEW: Nested parse class docstrings
1 parent 050b659 commit 1af4506

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.1.1 (November 2021)
4+
5+
✨ NEW: Nested parse class docstrings
6+
37
## v0.1.0 (November 2021)
48

59
Initial release.

docs/example/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class User(Base):
8-
"""A user."""
8+
"""A ``user``."""
99

1010
__tablename__ = "dbusers"
1111
__table_args__ = (UniqueConstraint("first_name", "last_name"),)

sphinx_sqlalchemy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Sphinx extension for documenting SQLAlchemy ORMs"""
22
from typing import TYPE_CHECKING
33

4-
__version__ = "0.1.0"
4+
__version__ = "0.1.1"
55

66
if TYPE_CHECKING:
77
from sphinx.application import Sphinx

sphinx_sqlalchemy/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import List, Optional, Set
33

44
from docutils import nodes
5+
from docutils.statemachine import StringList
56

67
# from docutils.parsers.rst import directives
78
from sphinx.application import Sphinx
@@ -93,7 +94,11 @@ def add_content(self, mapper: Mapper, definition: nodes.definition) -> None:
9394

9495
# class documentation
9596
if mapper.class_.__doc__:
96-
definition += nodes.paragraph(text=f"{mapper.class_.__doc__}")
97+
self.state.nested_parse(
98+
StringList(mapper.class_.__doc__.splitlines()),
99+
self.content_offset,
100+
definition,
101+
)
97102

98103
# column documentation
99104
if mapper.columns:

0 commit comments

Comments
 (0)