Return a heading paragraph newly added to the end of the document. The heading paragraph will contain `text` and have its paragraph style determined by `level`. If `level` is 0, the style is set to `Title`. If `level` is 1 (or omitted), `Heading 1` is used. Otherwise the sty
(self, text: str = "", level: int = 1)
| 88 | return comment |
| 89 | |
| 90 | def add_heading(self, text: str = "", level: int = 1): |
| 91 | """Return a heading paragraph newly added to the end of the document. |
| 92 | |
| 93 | The heading paragraph will contain `text` and have its paragraph style |
| 94 | determined by `level`. If `level` is 0, the style is set to `Title`. If `level` |
| 95 | is 1 (or omitted), `Heading 1` is used. Otherwise the style is set to `Heading |
| 96 | {level}`. Raises |ValueError| if `level` is outside the range 0-9. |
| 97 | """ |
| 98 | if not 0 <= level <= 9: |
| 99 | raise ValueError("level must be in range 0-9, got %d" % level) |
| 100 | style = "Title" if level == 0 else "Heading %d" % level |
| 101 | return self.add_paragraph(text, style) |
| 102 | |
| 103 | def add_page_break(self): |
| 104 | """Return newly |Paragraph| object containing only a page break.""" |