| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The WD_TABLE_DIRECTION example showed `table.direction = WD_TABLE_DIRECTION.RTL`, but the actual property is `Table.table_direction`. Plain `table.direction = ...` is a silent no-op: it sets an ordinary attribute, raises nothing, and never writes `<w:bidiVisual>`, so users believe RTL was applied when it wasn't. Fixes the example in both the enum docstring and the hand-maintained .rst reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
What's wrong
The documented example for WD_TABLE_DIRECTION shows:
But the Table object exposes the property as table_direction, not direction. Because
Table has no __slots__, table.direction = WD_TABLE_DIRECTION.RTL does not raise — it
just creates a throwaway instance attribute that nothing ever reads and that never writes
<w:bidiVisual>. So the documented example is a silent no-op: the user gets no signal that
RTL was never applied, which is arguably worse than an error.
The stale example appears in two places:
What this PR changes
Replace table.direction with table.table_direction in both spots, so the documented example
actually applies right-to-left cell ordering. Docs only — no code/behavior change.
This also clears up the confusion behind #1502: RTL cell ordering is supported —
table.table_direction = WD_TABLE_DIRECTION.RTL writes <w:bidiVisual/> into w:tblPr. The
mechanism existed; the docs example was just mis-named.
How I verified it
Ran a small script against python-docx==1.2.0 (current latest, matching master):
All checks passed.
I put this together with some AI assistance for the drafting, and verified the behavior against
master myself with a small script before opening the PR. Happy to adjust to your preferences.