Skip to content

Commit 8e2f61a

Browse files
author
Steve Canny
committed
api: remove old Document.paragraphs
1 parent 4188ffd commit 8e2f61a

File tree

4 files changed

+2
-47
lines changed

4 files changed

+2
-47
lines changed

docx/api.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,7 @@ def inline_shapes(self):
7878

7979
@property
8080
def paragraphs(self):
81-
"""
82-
A list of |Paragraph| instances corresponding to the paragraphs in
83-
the document, in document order. Note that paragraphs within revision
84-
marks such as ``<w:ins>`` or ``<w:del>`` do not appear in this list.
85-
"""
86-
return self._document_part.paragraphs
81+
return self._document.paragraphs
8782

8883
@property
8984
def part(self):

docx/parts/document.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,6 @@ def numbering_part(self):
113113
self.relate_to(numbering_part, RT.NUMBERING)
114114
return numbering_part
115115

116-
@property
117-
def paragraphs(self):
118-
"""
119-
A list of |Paragraph| instances corresponding to the paragraphs in
120-
the document, in document order. Note that paragraphs within revision
121-
marks such as inserted or deleted do not appear in this list.
122-
"""
123-
return self.body.paragraphs
124-
125116
@lazyproperty
126117
def sections(self):
127118
"""

tests/parts/test_document.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ def it_has_a_body(self, body_fixture):
4141
_Body_.assert_called_once_with(body_elm, document_part)
4242
assert _body is _Body_.return_value
4343

44-
def it_provides_access_to_the_document_paragraphs(
45-
self, paragraphs_fixture):
46-
document_part, paragraphs_ = paragraphs_fixture
47-
paragraphs = document_part.paragraphs
48-
assert paragraphs is paragraphs_
49-
5044
def it_provides_access_to_the_document_sections(self, sections_fixture):
5145
document, document_elm, Sections_ = sections_fixture
5246
sections = document.sections
@@ -212,12 +206,6 @@ def nmprt_get_fixture(self, part_related_by_, numbering_part_):
212206
part_related_by_.return_value = numbering_part_
213207
return document_part, numbering_part_
214208

215-
@pytest.fixture
216-
def paragraphs_fixture(self, document_part_body_, body_, paragraphs_):
217-
document_part = DocumentPart(None, None, None, None)
218-
body_.paragraphs = paragraphs_
219-
return document_part, paragraphs_
220-
221209
@pytest.fixture
222210
def sections_fixture(self, Sections_):
223211
document_elm = a_document().with_nsdecls().element
@@ -317,10 +305,6 @@ def p_(self, request):
317305
def package_(self, request):
318306
return instance_mock(request, Package)
319307

320-
@pytest.fixture
321-
def paragraphs_(self, request):
322-
return instance_mock(request, list)
323-
324308
@pytest.fixture
325309
def part_related_by_(self, request):
326310
return method_mock(request, DocumentPart, 'part_related_by')

tests/test_api.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ def Package_(self, request):
8686

8787
class DescribeDocumentOld(object):
8888

89-
def it_provides_access_to_the_document_paragraphs(
90-
self, paragraphs_fixture):
91-
document, paragraphs_ = paragraphs_fixture
92-
paragraphs = document.paragraphs
93-
assert paragraphs is paragraphs_
94-
9589
def it_provides_access_to_the_document_sections(self, document):
9690
body = document.sections
9791
assert body is document._document_part.sections
@@ -117,10 +111,6 @@ def it_provides_access_to_its_styles(self, styles_fixture):
117111
def init_fixture(self, docx_, open_):
118112
return docx_, open_
119113

120-
@pytest.fixture
121-
def paragraphs_fixture(self, document, paragraphs_):
122-
return document, paragraphs_
123-
124114
@pytest.fixture
125115
def save_fixture(self, request, open_, package_):
126116
file_ = instance_mock(request, str)
@@ -153,11 +143,10 @@ def document_obj_(self, request):
153143
return instance_mock(request, docx.document.Document)
154144

155145
@pytest.fixture
156-
def document_part_(self, request, paragraphs_, tables_):
146+
def document_part_(self, request, tables_):
157147
document_part_ = instance_mock(
158148
request, DocumentPart, content_type=CT.WML_DOCUMENT_MAIN
159149
)
160-
document_part_.paragraphs = paragraphs_
161150
document_part_.tables = tables_
162151
return document_part_
163152

@@ -186,10 +175,6 @@ def package_(self, request, document_part_):
186175
package_.main_document_part = document_part_
187176
return package_
188177

189-
@pytest.fixture
190-
def paragraphs_(self, request):
191-
return instance_mock(request, list)
192-
193178
@pytest.fixture
194179
def run_(self, request):
195180
return instance_mock(request, Run)

0 commit comments

Comments
 (0)