Skip to content

Commit fd1d336

Browse files
committed
rfctr: modernize formatting
1 parent 5720a88 commit fd1d336

File tree

7 files changed

+42
-65
lines changed

7 files changed

+42
-65
lines changed

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
110110
.. |_Header| replace:: :class:`._Header`
111111
112+
.. |ImageParts| replace:: :class:`.ImageParts`
113+
112114
.. |Inches| replace:: :class:`.Inches`
113115
114116
.. |InlineShape| replace:: :class:`.InlineShape`

docx/document.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ def save(self, path_or_stream):
136136

137137
@property
138138
def sections(self):
139-
"""
140-
A |Sections| object providing access to each section in this
141-
document.
142-
"""
139+
"""|Sections| object providing access to each section in this document."""
143140
return Sections(self._element)
144141

145142
@property

docx/oxml/section.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# encoding: utf-8
22

3-
"""
4-
Section-related custom element classes.
5-
"""
3+
"""Section-related custom element classes"""
64

7-
from __future__ import absolute_import, print_function
5+
from __future__ import absolute_import, division, print_function, unicode_literals
86

97
from copy import deepcopy
108

11-
from ..enum.section import WD_ORIENTATION, WD_SECTION_START
12-
from .simpletypes import ST_SignedTwipsMeasure, ST_TwipsMeasure
13-
from .xmlchemy import BaseOxmlElement, OptionalAttribute, ZeroOrOne
9+
from docx.enum.section import WD_ORIENTATION, WD_SECTION_START
10+
from docx.oxml.simpletypes import ST_SignedTwipsMeasure, ST_TwipsMeasure
11+
from docx.oxml.xmlchemy import BaseOxmlElement, OptionalAttribute, ZeroOrOne
1412

1513

1614
class CT_PageMar(BaseOxmlElement):
@@ -38,25 +36,18 @@ class CT_PageSz(BaseOxmlElement):
3836

3937

4038
class CT_SectPr(BaseOxmlElement):
41-
"""
42-
``<w:sectPr>`` element, the container element for section properties.
43-
"""
44-
__child_sequence__ = (
45-
'w:footnotePr', 'w:endnotePr', 'w:type', 'w:pgSz', 'w:pgMar',
46-
'w:paperSrc', 'w:pgBorders', 'w:lnNumType', 'w:pgNumType', 'w:cols',
47-
'w:formProt', 'w:vAlign', 'w:noEndnote', 'w:titlePg',
48-
'w:textDirection', 'w:bidi', 'w:rtlGutter', 'w:docGrid',
49-
'w:printerSettings', 'w:sectPrChange',
39+
"""`w:sectPr` element, the container element for section properties"""
40+
41+
_tag_seq = (
42+
'w:footnotePr', 'w:endnotePr', 'w:type', 'w:pgSz', 'w:pgMar', 'w:paperSrc',
43+
'w:pgBorders', 'w:lnNumType', 'w:pgNumType', 'w:cols', 'w:formProt', 'w:vAlign',
44+
'w:noEndnote', 'w:titlePg', 'w:textDirection', 'w:bidi', 'w:rtlGutter',
45+
'w:docGrid', 'w:printerSettings', 'w:sectPrChange',
5046
)
51-
type = ZeroOrOne('w:type', successors=(
52-
__child_sequence__[__child_sequence__.index('w:type')+1:]
53-
))
54-
pgSz = ZeroOrOne('w:pgSz', successors=(
55-
__child_sequence__[__child_sequence__.index('w:pgSz')+1:]
56-
))
57-
pgMar = ZeroOrOne('w:pgMar', successors=(
58-
__child_sequence__[__child_sequence__.index('w:pgMar')+1:]
59-
))
47+
type = ZeroOrOne("w:type", successors=_tag_seq[3:])
48+
pgSz = ZeroOrOne("w:pgSz", successors=_tag_seq[4:])
49+
pgMar = ZeroOrOne("w:pgMar", successors=_tag_seq[5:])
50+
del _tag_seq
6051

6152
@property
6253
def bottom_margin(self):

docx/package.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,22 @@
1313

1414

1515
class Package(OpcPackage):
16-
"""
17-
Customizations specific to a WordprocessingML package.
18-
"""
16+
"""Customizations specific to a WordprocessingML package"""
17+
1918
def after_unmarshal(self):
20-
"""
21-
Called by loading code after all parts and relationships have been
22-
loaded, to afford the opportunity for any required post-processing.
19+
"""Called by loading code after all parts and relationships have been loaded.
20+
21+
This method affords the opportunity for any required post-processing.
2322
"""
2423
self._gather_image_parts()
2524

2625
@lazyproperty
2726
def image_parts(self):
28-
"""
29-
Collection of all image parts in this package.
30-
"""
27+
"""|ImageParts| collection object for this package."""
3128
return ImageParts()
3229

3330
def _gather_image_parts(self):
34-
"""
35-
Load the image part collection with all the image parts in package.
36-
"""
31+
"""Load the image part collection with all the image parts in package."""
3732
for rel in self.iter_rels():
3833
if rel.is_external:
3934
continue

docx/section.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# encoding: utf-8
22

3-
"""
4-
The |Section| object and related proxy classes.
5-
"""
3+
"""The |Section| object and related proxy classes"""
64

7-
from __future__ import absolute_import, print_function, unicode_literals
5+
from __future__ import absolute_import, division, print_function, unicode_literals
86

97
from collections import Sequence
108

119

1210
class Sections(Sequence):
11+
"""Sequence of |Section| objects corresponding to the sections in the document.
12+
13+
Supports ``len()``, iteration, and indexed access.
1314
"""
14-
Sequence of |Section| objects corresponding to the sections in the
15-
document. Supports ``len()``, iteration, and indexed access.
16-
"""
15+
1716
def __init__(self, document_elm):
1817
super(Sections, self).__init__()
1918
self._document_elm = document_elm
@@ -34,9 +33,8 @@ def __len__(self):
3433

3534

3635
class Section(object):
37-
"""
38-
Document section, providing access to section and page setup settings.
39-
"""
36+
"""Document section, providing access to section and page-setup settings."""
37+
4038
def __init__(self, sectPr):
4139
super(Section, self).__init__()
4240
self._sectPr = sectPr

docx/settings.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
# encoding: utf-8
22

3-
"""
4-
Settings object, providing access to document-level settings.
5-
"""
3+
"""Settings object, providing access to document-level settings"""
64

7-
from __future__ import (
8-
absolute_import, division, print_function, unicode_literals
9-
)
5+
from __future__ import absolute_import, division, print_function, unicode_literals
106

11-
from .shared import ElementProxy
7+
from docx.shared import ElementProxy
128

139

1410
class Settings(ElementProxy):
15-
"""
16-
Provides access to document-level settings for a document. Accessed using
17-
the :attr:`.Document.settings` property.
11+
"""Provides access to document-level settings for a document.
12+
13+
Accessed using the :attr:`.Document.settings` property.
1814
"""
1915

2016
__slots__ = ()

tests/test_section.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# encoding: utf-8
22

3-
"""
4-
Test suite for the docx.section module
5-
"""
3+
"""Unit test suite for the docx.section module"""
64

7-
from __future__ import absolute_import, print_function, unicode_literals
5+
from __future__ import absolute_import, division, print_function, unicode_literals
86

97
import pytest
108

0 commit comments

Comments
 (0)