Skip to content

Commit 1c5bb28

Browse files
committed
rfctr: bulk best-efforts PEP 257 docstrings
Done by `docformatter`, it can't get the summary line right if it's too long, but adjusts the description block width and gets the shorter docstrings right, so a lot better than doing them all by hand. The rest will have to wait for hand curation as we go.
1 parent e88e1d5 commit 1c5bb28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2166
-3424
lines changed

src/docx/blkcntnr.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ class BlockItemContainer(Parented):
1313
"""Base class for proxy objects that can contain block items.
1414
1515
These containers include _Body, _Cell, header, footer, footnote, endnote, comment,
16-
and text box objects. Provides the shared functionality to add a block item like
17-
a paragraph or table.
16+
and text box objects. Provides the shared functionality to add a block item like a
17+
paragraph or table.
1818
"""
1919

2020
def __init__(self, element, parent):
2121
super(BlockItemContainer, self).__init__(parent)
2222
self._element = element
2323

2424
def add_paragraph(self, text="", style=None):
25-
"""
26-
Return a paragraph newly added to the end of the content in this
27-
container, having `text` in a single run if present, and having
28-
paragraph style `style`. If `style` is |None|, no paragraph style is
29-
applied, which has the same effect as applying the 'Normal' style.
25+
"""Return paragraph newly added to the end of the content in this container.
26+
27+
The paragraph has `text` in a single run if present, and is given paragraph
28+
style `style`.
29+
30+
If `style` is |None|, no paragraph style is applied, which has the same effect
31+
as applying the 'Normal' style.
3032
"""
3133
paragraph = self._add_paragraph()
3234
if text:
@@ -36,38 +38,36 @@ def add_paragraph(self, text="", style=None):
3638
return paragraph
3739

3840
def add_table(self, rows, cols, width):
41+
"""Return table of `width` having `rows` rows and `cols` columns.
42+
43+
The table is appended appended at the end of the content in this container.
44+
45+
`width` is evenly distributed between the table columns.
3946
"""
40-
Return a table of `width` having `rows` rows and `cols` columns,
41-
newly appended to the content in this container. `width` is evenly
42-
distributed between the table columns.
43-
"""
44-
from .table import Table
47+
from docx.table import Table
4548

4649
tbl = CT_Tbl.new_tbl(rows, cols, width)
4750
self._element._insert_tbl(tbl)
4851
return Table(tbl, self)
4952

5053
@property
5154
def paragraphs(self):
52-
"""
53-
A list containing the paragraphs in this container, in document
54-
order. Read-only.
55+
"""A list containing the paragraphs in this container, in document order.
56+
57+
Read-only.
5558
"""
5659
return [Paragraph(p, self) for p in self._element.p_lst]
5760

5861
@property
5962
def tables(self):
60-
"""
61-
A list containing the tables in this container, in document order.
63+
"""A list containing the tables in this container, in document order.
64+
6265
Read-only.
6366
"""
6467
from .table import Table
6568

6669
return [Table(tbl, self) for tbl in self._element.tbl_lst]
6770

6871
def _add_paragraph(self):
69-
"""
70-
Return a paragraph newly added to the end of the content in this
71-
container.
72-
"""
72+
"""Return paragraph newly added to the end of the content in this container."""
7373
return Paragraph(self._element.add_p(), self)

src/docx/dml/color.py

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77

88
class ColorFormat(ElementProxy):
9-
"""
10-
Provides access to color settings such as RGB color, theme color, and
11-
luminance adjustments.
12-
"""
9+
"""Provides access to color settings such as RGB color, theme color, and luminance
10+
adjustments."""
1311

1412
__slots__ = ()
1513

@@ -18,22 +16,19 @@ def __init__(self, rPr_parent):
1816

1917
@property
2018
def rgb(self):
21-
"""
22-
An |RGBColor| value or |None| if no RGB color is specified.
23-
24-
When :attr:`type` is `MSO_COLOR_TYPE.RGB`, the value of this property
25-
will always be an |RGBColor| value. It may also be an |RGBColor|
26-
value if :attr:`type` is `MSO_COLOR_TYPE.THEME`, as Word writes the
27-
current value of a theme color when one is assigned. In that case,
28-
the RGB value should be interpreted as no more than a good guess
29-
however, as the theme color takes precedence at rendering time. Its
30-
value is |None| whenever :attr:`type` is either |None| or
31-
`MSO_COLOR_TYPE.AUTO`.
32-
33-
Assigning an |RGBColor| value causes :attr:`type` to become
34-
`MSO_COLOR_TYPE.RGB` and any theme color is removed. Assigning |None|
35-
causes any color to be removed such that the effective color is
36-
inherited from the style hierarchy.
19+
"""An |RGBColor| value or |None| if no RGB color is specified.
20+
21+
When :attr:`type` is `MSO_COLOR_TYPE.RGB`, the value of this property will
22+
always be an |RGBColor| value. It may also be an |RGBColor| value if
23+
:attr:`type` is `MSO_COLOR_TYPE.THEME`, as Word writes the current value of a
24+
theme color when one is assigned. In that case, the RGB value should be
25+
interpreted as no more than a good guess however, as the theme color takes
26+
precedence at rendering time. Its value is |None| whenever :attr:`type` is
27+
either |None| or `MSO_COLOR_TYPE.AUTO`.
28+
29+
Assigning an |RGBColor| value causes :attr:`type` to become `MSO_COLOR_TYPE.RGB`
30+
and any theme color is removed. Assigning |None| causes any color to be removed
31+
such that the effective color is inherited from the style hierarchy.
3732
"""
3833
color = self._color
3934
if color is None:
@@ -53,18 +48,16 @@ def rgb(self, value):
5348

5449
@property
5550
def theme_color(self):
56-
"""
57-
A member of :ref:`MsoThemeColorIndex` or |None| if no theme color is
58-
specified. When :attr:`type` is `MSO_COLOR_TYPE.THEME`, the value of
59-
this property will always be a member of :ref:`MsoThemeColorIndex`.
60-
When :attr:`type` has any other value, the value of this property is
61-
|None|.
62-
63-
Assigning a member of :ref:`MsoThemeColorIndex` causes :attr:`type`
64-
to become `MSO_COLOR_TYPE.THEME`. Any existing RGB value is retained
65-
but ignored by Word. Assigning |None| causes any color specification
66-
to be removed such that the effective color is inherited from the
67-
style hierarchy.
51+
"""Member of :ref:`MsoThemeColorIndex` or |None| if no theme color is specified.
52+
53+
When :attr:`type` is `MSO_COLOR_TYPE.THEME`, the value of this property will
54+
always be a member of :ref:`MsoThemeColorIndex`. When :attr:`type` has any other
55+
value, the value of this property is |None|.
56+
57+
Assigning a member of :ref:`MsoThemeColorIndex` causes :attr:`type` to become
58+
`MSO_COLOR_TYPE.THEME`. Any existing RGB value is retained but ignored by Word.
59+
Assigning |None| causes any color specification to be removed such that the
60+
effective color is inherited from the style hierarchy.
6861
"""
6962
color = self._color
7063
if color is None or color.themeColor is None:
@@ -80,12 +73,13 @@ def theme_color(self, value):
8073
self._element.get_or_add_rPr().get_or_add_color().themeColor = value
8174

8275
@property
83-
def type(self):
84-
"""
85-
Read-only. A member of :ref:`MsoColorType`, one of RGB, THEME, or
86-
AUTO, corresponding to the way this color is defined. Its value is
87-
|None| if no color is applied at this level, which causes the
88-
effective color to be inherited from the style hierarchy.
76+
def type(self) -> MSO_COLOR_TYPE:
77+
"""Read-only.
78+
79+
A member of :ref:`MsoColorType`, one of RGB, THEME, or AUTO, corresponding to
80+
the way this color is defined. Its value is |None| if no color is applied at
81+
this level, which causes the effective color to be inherited from the style
82+
hierarchy.
8983
"""
9084
color = self._color
9185
if color is None:
@@ -98,9 +92,9 @@ def type(self):
9892

9993
@property
10094
def _color(self):
101-
"""
102-
Return `w:rPr/w:color` or |None| if not present. Helper to factor out
103-
repetitive element access.
95+
"""Return `w:rPr/w:color` or |None| if not present.
96+
97+
Helper to factor out repetitive element access.
10498
"""
10599
rPr = self._element.rPr
106100
if rPr is None:

0 commit comments

Comments
 (0)