9. API Reference

class docxbuilder.DocxBuilder(app)
default_translator_class

alias of docxbuilder.writer.DocxTranslator

init()

Load necessary templates and perform initialization. The default implementation does nothing.

get_outdated_docs()

Return an iterable of output files that are outdated, or a string describing what an update build will build.

If the builder does not output individual files corresponding to source files, return a string here. If it does, return an iterable of those files that need to be written.

get_target_uri(docname, typ=None)

Return the target URI for a document name.

typ can be used to qualify the link characteristic for individual builders.

prepare_writing(docnames)

A place where you can add logic before write_doc() is run

write_doc(docname, doctree)

Where you actually write something to the filesystem.

finish()

Finish the building process.

The default implementation does nothing.

class docxbuilder.writer.DocxTranslator(document, builder)

Visitor to generate a docx document.

Variables:builder – Sphinx builder.
visit_admonition_node(node, add_title=False)

Insert a table of admonition represented by the node.

This function shall be called from visit method for the node

Parameters:
  • node – A node which represents an admonition.
  • add_title – If add_title is true, the text corresponding to the node tagname is used as the admonition title. If false, the first child of the node is used.
depart_admonition_node(node, style=None, align='center', margin='10%')

Insert a table of admonition represented by the node.

This function shall be called from depart method for the node

Parameters:
  • node – A node which represents an admonition.
  • style – A style name applied to the admonition table. If style is None, the node’s admonition class or tagname is used.
  • align – Alignment of the admonition table.
  • margin – A total margin between the table and page.
visit_image_node(node, alt, get_filepath)

Insert an image represented by the node.

This function shall be called from visit method for the node

Parameters:
  • node – A node which represents an image.
  • alt – An alternative text used when get_filepath is unable to return a valid image path. alt may be a tuple of the text and a string which specified an language in order to highlight the text.
  • get_filepath – A function which extract a path of the image from the node. This function must take the translator as first parameter, and the node as second parameter.
unknown_visit(node)

Called when entering unknown Node types.

Raise an exception unless overridden.