Skip to content

Commit

Permalink
add processing on docstring for both kinds of tables
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Mar 21, 2024
1 parent 06d267b commit db4cae4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,25 @@ def linkcode_resolve(domain, info):
# -- code block style --------------------------------------------------------
pygments_style = "default"
pygements_dark_style = "monokai"

# -- preprocess docstrings ---------------------------------------------------
from typing import List
from types import ModuleType
from sphinx.application import Sphinx
from sphinx.ext.autodoc import Options


def _clip_rst_tables(app: Sphinx, what: str, name: str, obj: ModuleType, options: Options, lines: List[str]):
"""The ResidueMode docstring contains an RST table and an ASCII table because
the former gets omitted in IDEs like VSCode and the latter won't render properly in
Sphinx docs. This chops out the ASCII table when rendering autodocs.
"""
if what == "class" and name == "cool_seq_tool.schemas.ResidueMode":
for i in range(len(lines) -1, -1, -1):
line = lines[i]
if line.count("|") >= 8:
del lines[i]
print("Running preprocessing on ResidueMode docstring...")

def setup(app: Sphinx):
app.connect("autodoc-process-docstring", _clip_rst_tables)
5 changes: 5 additions & 0 deletions src/cool_seq_tool/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class ResidueMode(str, Enum):
careful to define the coordinate mode of their data when calling ``cool-seq-tool``
functions.
| | C | | T | | G | |
ZERO | | 0 | | 1 | | 2 | |
RESIDUE | | 1 | | 2 | | 3 | |
INTER_RESIDUE | 0 | | 1 | | 2 | | 3 |
.. tabularcolumns:: |L|C|C|C|C|C|C|C|
.. list-table::
:header-rows: 1
Expand Down

0 comments on commit db4cae4

Please sign in to comment.