diff --git a/docx/api.py b/docx/api.py index 3adc3622e..0a4e02eab 100644 --- a/docx/api.py +++ b/docx/api.py @@ -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): @@ -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: diff --git a/tests/test_api.py b/tests/test_api.py index fd375001c..8c728a318 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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_): @@ -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 @@ -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