Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docx/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def add_heading(self, text='', level=1):
Return a heading paragraph newly added to the end of the document,
populated with *text* and having the heading paragraph style
determined by *level*. If *level* is 0, the style is set to
``'Title'``. If *level* is 1 (or not present), ``'Heading1'`` is used.
Otherwise the style is set to ``'Heading{level}'``. If *level* is
``'Title'``. If *level* is 1 (or not present), ``'Heading 1'`` is used.
Otherwise the style is set to ``'Heading {level}'``. If *level* is
outside the range 0-9, |ValueError| is raised.
"""
if not 0 <= level <= 9:
raise ValueError("level must be in range 0-9, got %d" % level)
style = 'Title' if level == 0 else 'Heading%d' % level
style = 'Title' if level == 0 else 'Heading %d' % level
return self.add_paragraph(text, style)

def add_page_break(self):
Expand Down Expand Up @@ -96,11 +96,11 @@ def add_section(self, start_type=WD_SECTION.NEW_PAGE):
"""
return self._document_part.add_section(start_type)

def add_table(self, rows, cols, style='LightShading-Accent1'):
def add_table(self, rows, cols, style='Light Shading Accent 1'):
"""
Add a table having row and column counts of *rows* and *cols*
respectively and table style of *style*. If *style* is |None|, a
table with no style is produced.
table with 'Light Shading Accent 1' style is produced.
"""
table = self._document_part.add_table(rows, cols)
if style:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def it_creates_numbering_part_on_first_access_if_not_present(

@pytest.fixture(params=[
('', None),
('', 'Heading1'),
('foo\rbar', 'BodyText'),
('', 'Heading 1'),
('foo\rbar', 'Body Text'),
])
def add_paragraph_fixture(
self, request, document, document_part_, paragraph_):
Expand All @@ -178,7 +178,7 @@ def add_heading_fixture(
self, request, document, add_paragraph_, paragraph_):
level = request.param
text = 'Spam vs. Bacon'
style = 'Title' if level == 0 else 'Heading%d' % level
style = 'Title' if level == 0 else 'Heading %d' % level
return document, add_paragraph_, paragraph_, text, level, style

@pytest.fixture
Expand All @@ -199,7 +199,7 @@ def add_picture_fixture(self, request, run_, picture_):
def add_section_fixture(self, document, start_type_, section_):
return document, start_type_, section_

@pytest.fixture(params=[None, 'LightShading-Accent1', 'foobar'])
@pytest.fixture(params=[None, 'Light Shading Accent 1', 'foobar'])
def add_table_fixture(self, request, document, document_part_, table_):
rows, cols = 4, 2
style = expected_style = request.param
Expand Down