GeezerVison is showing github.com — acpt: add scenarios for TabStop property getters · python-openxml/python-docx@ff5e5c2
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +38Lines changed: 38 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +.. _WdTabAlignment: | | 2 | + | | 3 | +``WD_TAB_ALIGNMENT`` | | 4 | +==================== | | 5 | + | | 6 | +Specifies the tab stop alignment to apply. | | 7 | + | | 8 | +---- | | 9 | + | | 10 | +LEFT | | 11 | + Left-aligned. | | 12 | + | | 13 | +CENTER | | 14 | + Center-aligned. | | 15 | + | | 16 | +RIGHT | | 17 | + Right-aligned. | | 18 | + | | 19 | +DECIMAL | | 20 | + Decimal-aligned. | | 21 | + | | 22 | +BAR | | 23 | + Bar-aligned. | | 24 | + | | 25 | +LIST | | 26 | + List-aligned. (deprecated) | | 27 | + | | 28 | +CLEAR | | 29 | + Clear an inherited tab stop. | | 30 | + | | 31 | +END | | 32 | + Right-aligned. (deprecated) | | 33 | + | | 34 | +NUM | | 35 | + Left-aligned. (deprecated) | | 36 | + | | 37 | +START | | 38 | + Left-aligned. (deprecated) |
Collapse file Copy file name to clipboard +26Lines changed: 26 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +.. _WdTabLeader: | | 2 | + | | 3 | +``WD_TAB_LEADER`` | | 4 | +================= | | 5 | + | | 6 | +Specifies the character to use as the leader with formatted tabs. | | 7 | + | | 8 | +---- | | 9 | + | | 10 | +SPACES | | 11 | + Spaces. Default. | | 12 | + | | 13 | +DOTS | | 14 | + Dots. | | 15 | + | | 16 | +DASHES | | 17 | + Dashes. | | 18 | + | | 19 | +LINES | | 20 | + Double lines. | | 21 | + | | 22 | +HEAVY | | 23 | + A heavy line. | | 24 | + | | 25 | +MIDDLE_DOT | | 26 | + A vertically-centered dot. |
Collapse file Copy file name to clipboardExpand all lines: docs/api/enum/index.rst +3-1Lines changed: 3 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -15,8 +15,10 @@ can be found here: | 15 | 15 | WdColorIndex | 16 | 16 | WdLineSpacing | 17 | 17 | WdOrientation | | 18 | + WdRowAlignment | 18 | 19 | WdSectionStart | 19 | 20 | WdStyleType | 20 | | - WdRowAlignment | | 21 | + WdTabAlignment | | 22 | + WdTabLeader | 21 | 23 | WdTableDirection | 22 | 24 | WdUnderline |
Collapse file Copy file name to clipboardExpand all lines: docx/enum/text.py +74Lines changed: 74 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -195,6 +195,80 @@ class WD_LINE_SPACING(XmlEnumeration): | 195 | 195 | ) | 196 | 196 |
| 197 | 197 |
| | 198 | +class WD_TAB_ALIGNMENT(XmlEnumeration): | | 199 | + """ | | 200 | + Specifies the tab stop alignment to apply. | | 201 | + """ | | 202 | + | | 203 | + __ms_name__ = 'WdTabAlignment' | | 204 | + | | 205 | + __url__ = 'https://msdn.microsoft.com/EN-US/library/office/ff195609.aspx' | | 206 | + | | 207 | + __members__ = ( | | 208 | + XmlMappedEnumMember( | | 209 | + 'LEFT', 0, 'left', 'Left-aligned.' | | 210 | + ), | | 211 | + XmlMappedEnumMember( | | 212 | + 'CENTER', 1, 'center', 'Center-aligned.' | | 213 | + ), | | 214 | + XmlMappedEnumMember( | | 215 | + 'RIGHT', 2, 'right', 'Right-aligned.' | | 216 | + ), | | 217 | + XmlMappedEnumMember( | | 218 | + 'DECIMAL', 3, 'decimal', 'Decimal-aligned.' | | 219 | + ), | | 220 | + XmlMappedEnumMember( | | 221 | + 'BAR', 4, 'bar', 'Bar-aligned.' | | 222 | + ), | | 223 | + XmlMappedEnumMember( | | 224 | + 'LIST', 6, 'list', 'List-aligned. (deprecated)' | | 225 | + ), | | 226 | + XmlMappedEnumMember( | | 227 | + 'CLEAR', 101, 'clear', 'Clear an inherited tab stop.' | | 228 | + ), | | 229 | + XmlMappedEnumMember( | | 230 | + 'END', 102, 'end', 'Right-aligned. (deprecated)' | | 231 | + ), | | 232 | + XmlMappedEnumMember( | | 233 | + 'NUM', 103, 'num', 'Left-aligned. (deprecated)' | | 234 | + ), | | 235 | + XmlMappedEnumMember( | | 236 | + 'START', 104, 'start', 'Left-aligned. (deprecated)' | | 237 | + ), | | 238 | + ) | | 239 | + | | 240 | + | | 241 | +class WD_TAB_LEADER(XmlEnumeration): | | 242 | + """ | | 243 | + Specifies the character to use as the leader with formatted tabs. | | 244 | + """ | | 245 | + | | 246 | + __ms_name__ = 'WdTabLeader' | | 247 | + | | 248 | + __url__ = 'https://msdn.microsoft.com/en-us/library/office/ff845050.aspx' | | 249 | + | | 250 | + __members__ = ( | | 251 | + XmlMappedEnumMember( | | 252 | + 'SPACES', 0, 'none', 'Spaces. Default.' | | 253 | + ), | | 254 | + XmlMappedEnumMember( | | 255 | + 'DOTS', 1, 'dot', 'Dots.' | | 256 | + ), | | 257 | + XmlMappedEnumMember( | | 258 | + 'DASHES', 2, 'hyphen', 'Dashes.' | | 259 | + ), | | 260 | + XmlMappedEnumMember( | | 261 | + 'LINES', 3, 'underscore', 'Double lines.' | | 262 | + ), | | 263 | + XmlMappedEnumMember( | | 264 | + 'HEAVY', 4, 'heavy', 'A heavy line.' | | 265 | + ), | | 266 | + XmlMappedEnumMember( | | 267 | + 'MIDDLE_DOT', 5, 'middleDot', 'A vertically-centered dot.' | | 268 | + ), | | 269 | + ) | | 270 | + | | 271 | + | 198 | 272 | class WD_UNDERLINE(XmlEnumeration): | 199 | 273 | """ | 200 | 274 | Specifies the style of underline applied to a run of characters. | |
Collapse file Copy file name to clipboardExpand all lines: features/steps/tabstops.py +45Lines changed: 45 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | from behave import given, then | 8 | 8 |
| 9 | 9 | from docx import Document | | 10 | +from docx.enum.text import WD_TAB_ALIGNMENT, WD_TAB_LEADER | 10 | 11 | from docx.text.tabstops import TabStop | 11 | 12 |
| 12 | 13 | from helpers import test_docx | @@ -22,6 +23,30 @@ def given_a_tab_stops_having_count_tab_stops(context, count): | 22 | 23 | context.tab_stops = paragraph_format.tab_stops | 23 | 24 |
| 24 | 25 |
| | 26 | +@given('a tab stop 0.5 inches {in_or_out} from the paragraph left edge') | | 27 | +def given_a_tab_stop_inches_from_paragraph_left_edge(context, in_or_out): | | 28 | + tab_idx = {'out': 0, 'in': 1}[in_or_out] | | 29 | + document = Document(test_docx('tab-stops')) | | 30 | + paragraph_format = document.paragraphs[2].paragraph_format | | 31 | + context.tab_stop = paragraph_format.tab_stops[tab_idx] | | 32 | + | | 33 | + | | 34 | +@given('a tab stop having {alignment} alignment') | | 35 | +def given_a_tab_stop_having_alignment_alignment(context, alignment): | | 36 | + tab_idx = {'LEFT': 0, 'CENTER': 1, 'RIGHT': 2}[alignment] | | 37 | + document = Document(test_docx('tab-stops')) | | 38 | + paragraph_format = document.paragraphs[1].paragraph_format | | 39 | + context.tab_stop = paragraph_format.tab_stops[tab_idx] | | 40 | + | | 41 | + | | 42 | +@given('a tab stop having {leader} leader') | | 43 | +def given_a_tab_stop_having_leader_leader(context, leader): | | 44 | + tab_idx = {'no specified': 0, 'a dotted': 2}[leader] | | 45 | + document = Document(test_docx('tab-stops')) | | 46 | + paragraph_format = document.paragraphs[1].paragraph_format | | 47 | + context.tab_stop = paragraph_format.tab_stops[tab_idx] | | 48 | + | | 49 | + | 25 | 50 | # then ===================================================== | 26 | 51 |
| 27 | 52 | @then('I can access a tab stop by index') | @@ -43,3 +68,23 @@ def then_I_can_iterate_the_TabStops_object(context): | 43 | 68 | def then_len_tab_stops_is_count(context, count): | 44 | 69 | tab_stops = context.tab_stops | 45 | 70 | assert len(tab_stops) == int(count) | | 71 | + | | 72 | + | | 73 | +@then('tab_stop.alignment is {alignment}') | | 74 | +def then_tab_stop_alignment_is_alignment(context, alignment): | | 75 | + expected_value = getattr(WD_TAB_ALIGNMENT, alignment) | | 76 | + tab_stop = context.tab_stop | | 77 | + assert tab_stop.alignment == expected_value | | 78 | + | | 79 | + | | 80 | +@then('tab_stop.leader is {leader}') | | 81 | +def then_tab_stop_leader_is_leader(context, leader): | | 82 | + expected_value = getattr(WD_TAB_LEADER, leader) | | 83 | + tab_stop = context.tab_stop | | 84 | + assert tab_stop.leader == expected_value | | 85 | + | | 86 | + | | 87 | +@then('tab_stop.position is {position}') | | 88 | +def then_tab_stop_position_is_position(context, position): | | 89 | + tab_stop = context.tab_stop | | 90 | + assert tab_stop.position == int(position) |
Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard +37Lines changed: 37 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Feature: Tab stop properties | | 2 | + To change the properties of an individual tab stop | | 3 | + As a developer using python-docx | | 4 | + I need a set of read/write properties on TabStop | | 5 | + | | 6 | + | | 7 | + @wip | | 8 | + Scenario Outline: Get TabStop.position | | 9 | + Given a tab stop 0.5 inches <in-or-out> from the paragraph left edge | | 10 | + Then tab_stop.position is <position> | | 11 | + | | 12 | + Examples: tab stop positions | | 13 | + | in-or-out | position | | | 14 | + | in | 457200 | | | 15 | + | out | -457200 | | | 16 | + | | 17 | + | | 18 | + @wip | | 19 | + Scenario Outline: Get TabStop.alignment | | 20 | + Given a tab stop having <alignment> alignment | | 21 | + Then tab_stop.alignment is <alignment> | | 22 | + | | 23 | + Examples: tab stop alignments | | 24 | + | alignment | | | 25 | + | LEFT | | | 26 | + | RIGHT | | | 27 | + | | 28 | + | | 29 | + @wip | | 30 | + Scenario Outline: Get TabStop.leader | | 31 | + Given a tab stop having <leader> leader | | 32 | + Then tab_stop.leader is <value> | | 33 | + | | 34 | + Examples: tab stop leaders | | 35 | + | leader | value | | | 36 | + | no specified | SPACES | | | 37 | + | a dotted | DOTS | |
|