diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index cd73b3a8..5b44172f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -33,7 +33,7 @@ jobs: - name: Install dependencies run: | - pip install zensical mkdocstrings-python markdown-exec[ansi] + pip install zensical mkdocstrings-python markdown-exec[ansi] griffe-pydantic pip install pytest pytest-cov pytest-r-snapshot pip install matplotlib python-docx pypdf pip install -e '.[all]' diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a7b5420..eec162ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## rtflite (development version) + +### Documentation + +- Update mkdocstrings settings to render Pydantic field metadata + via `griffe-pydantic` in API reference docs (#189). +- Declare `RTFDocument._table_space` as a Pydantic private attribute to + prevent mkdocstrings render errors in static mode (#189). + ## rtflite 2.5.2 ### Documentation diff --git a/docs/assets/JetBrainsMono-Italic-Variable.woff2 b/docs/assets/JetBrainsMono-Italic-Variable.woff2 deleted file mode 100644 index 5e8a82e3..00000000 Binary files a/docs/assets/JetBrainsMono-Italic-Variable.woff2 and /dev/null differ diff --git a/docs/assets/JetBrainsMono-Variable.woff2 b/docs/assets/JetBrainsMono-Variable.woff2 deleted file mode 100644 index 856547f8..00000000 Binary files a/docs/assets/JetBrainsMono-Variable.woff2 and /dev/null differ diff --git a/docs/changelog.md b/docs/changelog.md index 4a7b5420..eec162ec 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,14 @@ # Changelog +## rtflite (development version) + +### Documentation + +- Update mkdocstrings settings to render Pydantic field metadata + via `griffe-pydantic` in API reference docs (#189). +- Declare `RTFDocument._table_space` as a Pydantic private attribute to + prevent mkdocstrings render errors in static mode (#189). + ## rtflite 2.5.2 ### Documentation diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 525bf09b..fffac29b 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -16,25 +16,9 @@ font-style: italic; } -@font-face { - font-display: swap; - font-family: "JetBrains Mono"; - src: url("../assets/JetBrainsMono-Variable.woff2") format("woff2"); - font-weight: 100 800; - font-style: normal; -} - -@font-face { - font-display: swap; - font-family: "JetBrains Mono"; - src: url("../assets/JetBrainsMono-Italic-Variable.woff2") format("woff2"); - font-weight: 100 800; - font-style: italic; -} - :root { --md-text-font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; - --md-code-font: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; + --md-code-font: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; } body { @@ -55,6 +39,7 @@ body { .md-nav { font-size: 1rem; + line-height: 1.15; } .md-nav__item--section>.md-nav__link { @@ -69,6 +54,10 @@ body { height: 150%; } +.md-ellipsis:has(.doc-symbol) { + font-size: 0.7em; +} + /* Content */ .md-typeset { @@ -109,6 +98,18 @@ h4 code { font-size: 0.8rem; } +h2.doc-heading { + font-size: 1rem; +} + +h3.doc-heading { + font-size: 0.9rem; +} + +.doc-contents.first>details>summary { + line-height: 1.5; +} + /* Banner */ .md-banner { diff --git a/pyproject.toml b/pyproject.toml index 9c587fe6..8026e600 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,6 +106,7 @@ dev = [ "zensical>=0.0.15", "mkdocstrings-python>=1.12.2", "markdown-exec[ansi]>=1.11.0", + "griffe-pydantic>=1.1.8", "ruff>=0.7.4", "isort>=5.13.2", "mypy>=1.17.1", diff --git a/src/rtflite/encode.py b/src/rtflite/encode.py index 8282a7fa..1cfda7bc 100644 --- a/src/rtflite/encode.py +++ b/src/rtflite/encode.py @@ -10,7 +10,14 @@ from pathlib import Path import polars as pl -from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator +from pydantic import ( + BaseModel, + ConfigDict, + Field, + PrivateAttr, + field_validator, + model_validator, +) from .convert import LibreOfficeConverter from .input import ( @@ -122,6 +129,7 @@ class RTFDocument(BaseModel): """ model_config = ConfigDict(arbitrary_types_allowed=True) + _table_space: int = PrivateAttr(default=0) # Core data df: pl.DataFrame | list[pl.DataFrame] | None = Field( diff --git a/src/rtflite/input.py b/src/rtflite/input.py index 1cf51126..f1591a32 100644 --- a/src/rtflite/input.py +++ b/src/rtflite/input.py @@ -247,7 +247,7 @@ class RTFPage(BaseModel): Defaults to "double" for closure. Note: - The nrow parameter represents the total row capacity of a page, + The `nrow` parameter represents the total row capacity of a page, not just data rows. Plan accordingly when setting this value. """ @@ -717,8 +717,8 @@ class RTFColumnHeader(TableAttributes): Note: - Headers automatically repeat on each page in multi-page documents - - Use col_rel_width to create spanning headers - - Border styles from RTFPage are applied to the first row + - Use `col_rel_width` to create spanning headers + - Border styles from `RTFPage` are applied to the first row """ model_config = ConfigDict(arbitrary_types_allowed=True) @@ -833,10 +833,11 @@ class RTFBody(TableAttributes): ``` Note: - When using subline_by: + When using `subline_by`: + - The specified columns are removed from the table display - Values appear as paragraph headers before each section - - Pagination is automatically enabled (new_page=True) + - Pagination is automatically enabled (`new_page=True`) - Formatting attributes apply uniformly to the entire table """ diff --git a/uv.lock b/uv.lock index 6dc7cd2f..ab9cbc11 100644 --- a/uv.lock +++ b/uv.lock @@ -410,6 +410,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/9c/83/3b1d03d36f224edded98e9affd0467630fc09d766c0e56fb1498cbb04a9b/griffe-1.15.0-py3-none-any.whl", hash = "sha256:6f6762661949411031f5fcda9593f586e6ce8340f0ba88921a0f2ef7a81eb9a3", size = 150705, upload-time = "2025-11-10T15:03:13.549Z" }, ] +[[package]] +name = "griffe-pydantic" +version = "1.1.8" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "griffe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/99/52/b05f582287f887f58a1738183d6dd0e799842b83f6f60d65c77ba90cee31/griffe_pydantic-1.1.8.tar.gz", hash = "sha256:72cde69c74c70f3dc0385a7a5243c736cd6bf6fcf8a41cae497383defe107041", size = 43425, upload-time = "2025-10-14T09:12:37.693Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/78/e3/94b2e39d841a1c07b586903177d3ee802c8ae87567449a541d14028eb657/griffe_pydantic-1.1.8-py3-none-any.whl", hash = "sha256:22212c94216e03bf43d30ff3bc79cd53fb973ae2fe81d8b7510242232a1e6764", size = 12852, upload-time = "2025-10-14T09:12:36.23Z" }, +] + [[package]] name = "iniconfig" version = "2.3.0" @@ -1879,6 +1891,7 @@ pdf = [ [package.dev-dependencies] dev = [ + { name = "griffe-pydantic" }, { name = "isort" }, { name = "markdown-exec", extra = ["ansi"] }, { name = "matplotlib" }, @@ -1906,6 +1919,7 @@ provides-extras = ["docx", "pdf"] [package.metadata.requires-dev] dev = [ + { name = "griffe-pydantic", specifier = ">=1.1.8" }, { name = "isort", specifier = ">=5.13.2" }, { name = "markdown-exec", extras = ["ansi"], specifier = ">=1.11.0" }, { name = "matplotlib", specifier = ">=3.10.5" }, diff --git a/zensical.toml b/zensical.toml index f6678dad..8f3ccddd 100644 --- a/zensical.toml +++ b/zensical.toml @@ -123,9 +123,30 @@ default_handler = "python" paths = ["src"] [project.plugins.mkdocstrings.handlers.python.options] +extensions = [{ griffe_pydantic = { schema = true } }] +filters = ["!^_"] +# Important for griffe_pydantic to render Pydantic models +force_inspection = false inherited_members = true +members_order = "source" +merge_init_into_class = true +separate_signature = true show_root_heading = true +show_signature_annotations = true show_source = false +signature_crossrefs = true +show_symbol_type_heading = true +show_symbol_type_toc = true + +[project.plugins.mkdocstrings.handlers.python.options.docstring_options] +ignore_init_summary = true + +[[project.plugins.mkdocstrings.handlers.python.import]] +url = "https://docs.python.org/3/objects.inv" +domains = ["py", "std"] + +[[project.plugins.mkdocstrings.handlers.python.import]] +url = "https://typing-extensions.readthedocs.io/en/latest/objects.inv" # ---------------------------------------------------------------------------- # Section for configuring markdown-exec plugin