File: api-concepts.rst

package info (click to toggle)
python-docx 1.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,904 kB
  • sloc: xml: 25,311; python: 23,028; makefile: 176
file content (31 lines) | stat: -rw-r--r-- 1,287 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

API basics
==========

The API for |docx| is designed to make doing simple things simple, while
allowing more complex results to be achieved with a modest and incremental
investment of understanding.

It's possible to create a basic document using only a single object, the
|api-Document| object returned when opening a file. The methods on
|api-Document| allow *block-level* objects to be added to the end of the
document. Block-level objects include paragraphs, inline pictures, and tables.
Headings, bullets, and numbered lists are simply paragraphs with a particular
style applied.

In this way, a document can be "written" from top to bottom, roughly like
a person would if they knew exactly what they wanted to say This basic use
case, where content is always added to the end of the document, is expected to
account for perhaps 80% of actual use cases, so it's a priority to make it as
simple as possible without compromising the power of the overall API.


Inline objects
--------------

Each block-level method on |api-Document|, such as ``add_paragraph()``, returns
the block-level object created. Often the reference is unneeded; but when
inline objects must be created individually, you'll need the block-item
reference to do it.

... add example here as API solidifies ...