Skip to content

Commit b9a180d

Browse files
authored
Merge pull request #127 from kaijensen55/docs/docstrings-standardization
docs: standardize docstrings (Google) + Ruff/napoleon config
2 parents 9c92e3d + 563ebd4 commit b9a180d

27 files changed

+1613
-1379
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.3
4+
hooks:
5+
- id: ruff-check
6+
args: [ --fix ]
7+
- id: ruff-format
8+
9+

Examples.ipynb

Lines changed: 989 additions & 989 deletions
Large diffs are not rendered by default.

docs/conf.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Configuration file for the Sphinx documentation builder.
43
#
@@ -24,7 +23,7 @@
2423
def parse_version(package):
2524

2625
init_file = '%s/%s/__init__.py' % (ROOT_PATH, package)
27-
with open(init_file, 'r', encoding='utf-8') as f:
26+
with open(init_file, encoding='utf-8') as f:
2827
for line in f.readlines():
2928
if '__version__' in line:
3029
return line.split('=')[1].strip()[1:-1]
@@ -53,12 +52,14 @@ def parse_version(package):
5352
# ones.
5453
extensions = [
5554
'sphinx.ext.autodoc',
55+
'sphinx.ext.autosummary',
5656
'sphinx.ext.todo',
5757
'sphinx.ext.coverage',
5858
'sphinx.ext.mathjax',
5959
'sphinx.ext.ifconfig',
6060
'sphinx.ext.viewcode',
6161
'sphinx.ext.githubpages',
62+
'sphinx.ext.napoleon',
6263
'sphinx_llms_txt',
6364
# 'IPython.sphinxext.ipython_console_highlighting',
6465
# 'IPython.sphinxext.ipython_directive',
@@ -192,3 +193,19 @@ def parse_version(package):
192193
epub_exclude_files = ['search.html']
193194

194195
# -- Extension configuration -------------------------------------------------
196+
197+
# Configure napoleon to parse Google-style docstrings
198+
napoleon_google_docstring = True
199+
napoleon_numpy_docstring = False
200+
napoleon_include_init_with_doc = False
201+
napoleon_preprocess_types = True
202+
203+
# Autodoc / autosummary configuration
204+
autosummary_generate = True
205+
autodoc_typehints = 'description'
206+
autodoc_default_options = {
207+
'members': True,
208+
'undoc-members': False,
209+
'inherited-members': True,
210+
'show-inheritance': True,
211+
}

docs/docstring_style.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Docstring Standardization
2+
=========================
3+
4+
Style
5+
-----
6+
7+
- Preferred style: `Google Python Style Guide (Docstrings) <https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings>`_.
8+
- Rendered via Sphinx with ``sphinx.ext.napoleon`` (Google-style parsing enabled).
9+
10+
Guidelines
11+
----------
12+
13+
- Include a short summary line in the imperative mood.
14+
- Provide sections as needed: ``Args``, ``Returns``, ``Yields``, ``Raises``, ``Notes``, ``Examples``.
15+
- Use explicit types and shapes when helpful; prefer concrete meanings over abbreviations.
16+
- Keep examples runnable when possible.
17+
18+

docs/index.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,10 @@ Supported Python versions: 3.7 – 3.14 (universal wheel)
5555
What's New
5656
==========
5757

58-
*Unreleased*
59-
6058
.. xbbg:changelog-start
6159
6260
.. xbbg:changelog-end
6361
64-
- Improve date parsing and stability in ``pipeline.format_raw`` (coerce datetime columns by name)
65-
- Normalize numeric types in ``const.ccy_pair`` to ensure stable representations
66-
- Fix ``core.utils.fstr``/``to_str`` formatting with explicit kwargs
67-
- Add docs build to CI and modernize CI matrix (Windows/Linux)
68-
- Switch to PyPI Trusted Publishing (OIDC)
69-
7062
*0.7.7a2* - Custom `config` and etc. for reference exchange (author `hceh`)
7163

7264
*0.7.6a2* - Use `blp.connect` for alternative Bloomberg connection (author `anxl2008`)
@@ -89,6 +81,14 @@ in ``/xbbg/markets/exch.yml``). See example of ``bdib`` below for more details.
8981

9082
*0.1.17* - Add ``adjust`` argument in ``bdh`` for easier dividend / split adjustments
9183

84+
Contents
85+
========
86+
87+
.. toctree::
88+
:maxdepth: 1
89+
90+
docstring_style
91+
9292
Tutorial
9393
========
9494

feeds/pub.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import pynng
2-
import trio
1+
from functools import partial
2+
33
import fire
44
import orjson
5+
import pynng
6+
import trio
57

68
from xbbg import blp
7-
from functools import partial
89

910
DEFAULT_FDLS = [
1011
'MKTDATA_EVENT_TYPE', 'EVT_TRADE_DATE_RT', 'TIME',
@@ -16,8 +17,7 @@
1617

1718

1819
async def live(channel: str, tickers, **kwargs):
19-
"""
20-
Broadcasts live data feeds
20+
"""Broadcasts live data feeds
2121
2222
Args:
2323
channel: channel name

feeds/sub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from functools import partial
2+
3+
import fire
14
import pynng
25
import trio
3-
import fire
4-
5-
from functools import partial
66

77
ADDRESS = 'ipc:///xbbg/stream'
88

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies = [
3535
# Kept for compatibility if consumers expect extras, but dev/test tooling
3636
# is managed via uv dependency groups below.
3737
test = ["pytest", "pytest-cov", "coverage", "codecov"]
38-
dev = ["ruff", "ipykernel", "build", "twine"]
38+
dev = ["ruff", "ipykernel", "build", "twine", "pre-commit"]
3939
docs = ["sphinx>=5.3.0", "sphinx-rtd-theme>=2.0.0", "sphinx-llms-txt>=0.7.0"]
4040

4141
[project.urls]
@@ -70,7 +70,10 @@ target-version = "py310"
7070
line-length = 120
7171
exclude = [
7272
"xbbg/feeds/*",
73+
"feeds/**",
7374
"docs/_build",
75+
"docs/conf.py",
76+
"Examples.ipynb",
7477
"dist",
7578
"venv",
7679
".venv",
@@ -82,6 +85,7 @@ select = [
8285
"W", # pycodestyle warnings
8386
"F", # pyflakes
8487
"I", # isort
88+
"D", # pydocstyle
8589
"UP", # pyupgrade
8690
"B", # flake8-bugbear
8791
"C4", # flake8-comprehensions
@@ -92,11 +96,14 @@ select = [
9296
ignore = [
9397
"E701", # multiple statements on one line (colon)
9498
"E501", # line too long
99+
"D104", # Missing docstring in public package
100+
"D107", # Missing docstring in __init__
95101
]
96102

97103
[tool.ruff.lint.per-file-ignores]
98104
"xbbg/__init__.py" = ["F401"]
99105
"xbbg/**/__init__.py" = ["F401"]
106+
"xbbg/tests/**" = ["D"]
100107

101108
[tool.ruff.lint.isort]
102109
known-first-party = ["xbbg"]
@@ -106,6 +113,9 @@ force-sort-within-sections = true
106113
[tool.ruff.lint.mccabe]
107114
max-complexity = 12
108115

116+
[tool.ruff.lint.pydocstyle]
117+
convention = "google"
118+
109119

110120

111121

0 commit comments

Comments
 (0)