-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve style for sphinx-sqlalchemy extension
- Loading branch information
Showing
9 changed files
with
120 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Example SQLAlchemy ORM models.""" | ||
|
||
from sqlalchemy import CheckConstraint, Column, ForeignKey, UniqueConstraint, orm, types | ||
|
||
Base = orm.declarative_base() | ||
|
||
|
||
class User(Base): | ||
"""A ``user``.""" | ||
|
||
__tablename__ = "dbusers" | ||
__table_args__ = (UniqueConstraint("first_name", "last_name"),) | ||
pk = Column(types.Integer, primary_key=True) | ||
first_name = Column(types.String, doc="The name of the user.") | ||
last_name = Column(types.String(255), doc="The surname of the user.") | ||
dob = Column(types.Date, nullable=False, doc="The date of birth.") | ||
|
||
|
||
class Address(Base): | ||
"""An address.""" | ||
|
||
__tablename__ = "addresses" | ||
__table_args__ = (CheckConstraint("number>0", name="check1"),) | ||
pk = Column(types.Integer, primary_key=True) | ||
number = Column(types.Integer, nullable=False, doc="The number of the address.") | ||
postcode = Column( | ||
types.String, nullable=False, index=True, doc="The postcode of the address." | ||
) | ||
user_id = Column(types.Integer, ForeignKey("dbusers.pk")) | ||
user = orm.relationship("User") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
sphinx-sqlalchemy | ||
================= | ||
|
||
Sphinx extension for documenting SQLAlchemy ORMs. | ||
|
||
- **Documentation**: https://sphinx-sqlalchemy.readthedocs.io/ | ||
- **Source Code**: https://github.com/sphinx-extensions2/sphinx-sqlalchemy | ||
|
||
Usage | ||
----- | ||
|
||
Install ``sphinx_sqlalchemy``: | ||
|
||
.. code-block:: bash | ||
pip install sphinx_sqlalchemy | ||
Add ``sphinx_sqlalchemy`` to your ``conf.py``: | ||
|
||
.. code-block:: python | ||
extensions = [ | ||
'sphinx_sqlalchemy', | ||
] | ||
Example | ||
------- | ||
|
||
.. code-block:: none | ||
.. sqla-model:: sqla_models.User | ||
.. sqla-model:: ~sqla_models.Address | ||
.. sqla-model:: sqla_models.User | ||
|
||
.. sqla-model:: ~sqla_models.Address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
dl.sqla dt { | ||
color: var(--sig-name); | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
dl.sqla dt > em { | ||
font-weight: 400; | ||
font-style: normal; | ||
color: var(--sig-param); | ||
} | ||
|
||
dl.sqla dd > p.rubric { | ||
margin-top: 1.5rem; | ||
text-transform: uppercase; | ||
font-size: 0.76rem; | ||
} | ||
|
||
dl.sqla dd > p.rubric + .table-wrapper { | ||
margin-top: 0.75rem; | ||
border-left: 0; | ||
border-right: 0; | ||
border-radius: 0; | ||
} | ||
|
||
dl.sqla p.rubric + .table-wrapper th, | ||
dl.sqla p.rubric + .table-wrapper td { | ||
border-left: 0; | ||
border-right: 0; | ||
background-color: transparent; | ||
} | ||
dl.sqla p.rubric + .table-wrapper td > p { | ||
margin: 0; | ||
} | ||
dl.sqla p.rubric + .table-wrapper tr.row-odd { | ||
background-color: transparent; | ||
} | ||
dl.sqla p.rubric + .table-wrapper tr.row-even { | ||
background-color: var(--yue-c-row-background); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters