Skip to content

Commit 11394a0

Browse files
author
Steve Canny
committed
api: remove old Document.add_paragraph()
1 parent 4f98312 commit 11394a0

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

docx/api.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Document(object):
4949
is loaded.
5050
"""
5151
def __init__(self, docx=None):
52-
document = DocumentNew(docx)
52+
self._document = document = DocumentNew(docx)
5353
self._document_part = document._part
5454
self._package = document._part.package
5555

@@ -78,15 +78,7 @@ def add_page_break(self):
7878
return p
7979

8080
def add_paragraph(self, text='', style=None):
81-
"""
82-
Return a paragraph newly added to the end of the document, populated
83-
with *text* and having paragraph style *style*. *text* can contain
84-
tab (``\\t``) characters, which are converted to the appropriate XML
85-
form for a tab. *text* can also include newline (``\\n``) or carriage
86-
return (``\\r``) characters, each of which is converted to a line
87-
break.
88-
"""
89-
return self._document_part.add_paragraph(text, style)
81+
return self._document.add_paragraph(text, style)
9082

9183
def add_picture(self, image_path_or_stream, width=None, height=None):
9284
"""

tests/test_api.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ def it_should_raise_on_heading_level_out_of_range(self, document):
104104
with pytest.raises(ValueError):
105105
document.add_heading(level=10)
106106

107-
def it_can_add_a_paragraph(self, add_paragraph_fixture):
108-
document, text, style, paragraph_ = add_paragraph_fixture
109-
paragraph = document.add_paragraph(text, style)
110-
document._document_part.add_paragraph.assert_called_once_with(
111-
text, style
112-
)
113-
assert paragraph is paragraph_
114-
115107
def it_can_add_a_page_break(self, add_page_break_fixture):
116108
document, document_part_, paragraph_, run_ = add_page_break_fixture
117109
paragraph = document.add_page_break()
@@ -197,16 +189,6 @@ def it_creates_numbering_part_on_first_access_if_not_present(
197189

198190
# fixtures -------------------------------------------------------
199191

200-
@pytest.fixture(params=[
201-
('', None),
202-
('', 'Heading 1'),
203-
('foo\rbar', 'Body Text'),
204-
])
205-
def add_paragraph_fixture(self, request, document, document_part_,
206-
paragraph_):
207-
text, style = request.param
208-
return document, text, style, paragraph_
209-
210192
@pytest.fixture(params=[
211193
(0, 'Title'),
212194
(1, 'Heading 1'),

0 commit comments

Comments
 (0)