Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e24c77d

Browse files
committed
fix: python-openxml#266 miscellaneous doc updates
1 parent d563fa4 commit e24c77d

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

docs/index.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,22 @@ Here's an example of what |docx| can do:
4242

4343
document.add_picture('monty-truth.png', width=Inches(1.25))
4444

45+
records = (
46+
(3, '101', 'Spam'),
47+
(7, '422', 'Eggs'),
48+
(4, '631', 'Spam, spam, eggs, and spam')
49+
)
50+
4551
table = document.add_table(rows=1, cols=3)
4652
hdr_cells = table.rows[0].cells
4753
hdr_cells[0].text = 'Qty'
4854
hdr_cells[1].text = 'Id'
4955
hdr_cells[2].text = 'Desc'
50-
for item in recordset:
56+
for qty, id, desc in records:
5157
row_cells = table.add_row().cells
52-
row_cells[0].text = str(item.qty)
53-
row_cells[1].text = str(item.id)
54-
row_cells[2].text = item.desc
58+
row_cells[0].text = str(qty)
59+
row_cells[1].text = id
60+
row_cells[2].text = desc
5561

5662
document.add_page_break()
5763

docs/user/quickstart.rst

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ supports indexed access, like a list::
115115
row.cells[0].text = 'Foo bar to you.'
116116
row.cells[1].text = 'And a hearty foo bar to you too sir!'
117117

118-
The ``.rows`` and ``.columns`` collections on a table are iterable, so you can
119-
use them directly in a ``for`` loop. Same with the ``.cells`` sequences on
120-
a row or column::
118+
The ``.rows`` and ``.columns`` collections on a table are iterable, so you
119+
can use them directly in a ``for`` loop. Same with the ``.cells`` sequences
120+
on a row or column::
121121

122122
for row in table.rows:
123123
for cell in row.cells:
@@ -137,7 +137,11 @@ This can be very handy for the variable length table scenario we mentioned
137137
above::
138138

139139
# get table data -------------
140-
items = get_things_from_database_or_something()
140+
items = (
141+
(7, '1024', 'Plush kittens'),
142+
(3, '2042', 'Furbees'),
143+
(1, '1288', 'French Poodle Collars, Deluxe'),
144+
)
141145

142146
# add table ------------------
143147
table = document.add_table(1, 3)
@@ -229,14 +233,11 @@ thing. You can also apply a style afterward. These two lines are equivalent to
229233
the one above::
230234

231235
paragraph = document.add_paragraph('Lorem ipsum dolor sit amet.')
232-
paragraph.style = 'ListBullet'
236+
paragraph.style = 'List Bullet'
233237

234-
The style is specified using its style ID, 'ListBullet' in this example.
235-
Generally, the style ID is formed by removing the spaces in the style name as
236-
it appears in the Word user interface (UI). So the style 'List Number 3'
237-
would be specified as ``'ListNumber3'``. However, note that if you are using
238-
a localized version of Word, the style ID may be derived from the English
239-
style name and may not correspond so neatly to its style name in the Word UI.
238+
The style is specified using its style name, 'List Bullet' in this example.
239+
Generally, the style name is exactly as it appears in the Word user interface
240+
(UI).
240241

241242

242243
Applying bold and italic
@@ -324,8 +325,4 @@ the same result as the lines above::
324325
run = paragraph.add_run('text with emphasis.')
325326
run.style = 'Emphasis'
326327

327-
As with a paragraph style, the style ID is formed by removing the spaces in
328-
the name as it appears in the Word UI. So the style 'Subtle Emphasis' would
329-
be specified as ``'SubtleEmphasis'``. Note that if you are using
330-
a localized version of Word, the style ID may be derived from the English
331-
style name and may not correspond to its style name in the Word UI.
328+
As with a paragraph style, the style name is as it appears in the Word UI.

docx/styles/styles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __getitem__(self, key):
5151
'style lookup by style_id is deprecated. Use style name as '
5252
'key instead.'
5353
)
54-
warn(msg, UserWarning)
54+
warn(msg, UserWarning, stacklevel=2)
5555
return StyleFactory(style_elm)
5656

5757
raise KeyError("no style with name '%s'" % key)

0 commit comments

Comments
 (0)