class documentation

class EpubBuilder(StandaloneHTMLBuilder):

Known subclasses: sphinx.builders.epub3.Epub3Builder

View In Hierarchy

Builder that outputs epub files.

It creates the metainfo files container.opf, toc.ncx, mimetype, and META-INF/container.xml. Afterwards, all necessary files are zipped to an epub file.

Method add​_visible​_links Add visible link targets for external links
Method build​_container Write the metainfo file META-INF/container.xml.
Method build​_content Write the metainfo file content.opf It contains bibliographic data, a file list and the spine (the reading order).
Method build​_epub Write the epub file.
Method build​_mimetype Write the metainfo file mimetype.
Method build​_navpoints Create the toc navigation structure.
Method build​_toc Write the metainfo file toc.ncx.
Method check​_refnodes Undocumented
Method content​_metadata Create a dictionary with all metadata for the content.opf file properly escaped.
Method copy​_download​_files Undocumented
Method copy​_image​_files Copy image files to destination directory. This overwritten method can use Pillow to convert image files.
Method copy​_image​_files​_pil Copy images using Pillow, the Python Imaging Library. The method tries to read and write the files with Pillow, converting the format and resizing the image if necessary/possible.
Method create​_build​_info Undocumented
Method fix​_fragment Return a href/id attribute with colons replaced by hyphens.
Method fix​_genindex Fix href attributes for genindex pages.
Method fix​_ids Replace colons with hyphens in href and id attributes.
Method get​_refnodes Collect section titles, their depth in the toc and the refuri.
Method get​_theme​_config Undocumented
Method get​_toc Get the total table of contents, containing the root_doc and pre and post files not managed by sphinx.
Method handle​_page Create a rendered page.
Method init Load necessary templates and perform initialization. The default implementation does nothing.
Method is​_vector​_graphics Does the filename extension indicate a vector graphic format?
Method make​_id Return a unique id for name.
Method new​_navpoint Create a new entry in the toc from the node at given level.
Method toc​_add​_files Add the root_doc, pre and post files to a list of refnodes.
Method toc​_metadata Create a dictionary with all metadata for the toc.ncx file properly escaped.
Method write​_doc Write one document file.
Class Variable add​_permalinks Undocumented
Class Variable allow​_sharp​_as​_current​_path Undocumented
Class Variable copysource Undocumented
Class Variable doctype Undocumented
Class Variable download​_support Undocumented
Class Variable embedded Undocumented
Class Variable html​_scaled​_image​_link Undocumented
Class Variable search Undocumented
Class Variable supported​_image​_types Undocumented
Class Variable supported​_remote​_images Undocumented
Class Variable template​_dir Undocumented
Instance Variable files Undocumented
Instance Variable id​_cache Undocumented
Instance Variable ignored​_files Undocumented
Instance Variable link​_suffix Undocumented
Instance Variable out​_suffix Undocumented
Instance Variable playorder Undocumented
Instance Variable refnodes Undocumented
Instance Variable tocid Undocumented
Instance Variable use​_index Undocumented

Inherited from StandaloneHTMLBuilder:

Class Variable format Undocumented
Class Variable name Undocumented
Method __init__ Undocumented
Method ​_get​_local​_toctree Undocumented
Method ​_get​_style​_filename Undocumented
Method ​_get​_translations​_js Undocumented
Method add​_css​_file Undocumented
Method add​_js​_file Undocumented
Method add​_sidebars Undocumented
Method cleanup Cleanup any resources.
Method copy​_extra​_files copy html_extra_path files.
Method copy​_html​_favicon Undocumented
Method copy​_html​_logo Undocumented
Method copy​_html​_static​_files Undocumented
Method copy​_static​_files Undocumented
Method copy​_stemmer​_js Copy a JavaScript file for stemmer.
Method copy​_theme​_static​_files Undocumented
Method copy​_translation​_js Copy a JavaScript file for translations.
Method create​_pygments​_style​_file create a style file for pygments.
Method dump​_inventory Undocumented
Method dump​_search​_index Undocumented
Method finish Finish the building process.
Method gen​_additional​_pages Undocumented
Method gen​_indices Undocumented
Method gen​_pages​_from​_extensions Undocumented
Method get​_asset​_paths Return list of paths for assets (ex. templates, CSS, etc.).
Method get​_doc​_context Collect items for the template context of a page.
Method get​_outdated​_docs Return an iterable of output files that are outdated, or a string describing what an update build will build.
Method get​_outfilename Undocumented
Method get​_target​_uri Return the target URI for a document name.
Method handle​_finish Undocumented
Method index​_page Undocumented
Method init​_css​_files Undocumented
Method init​_highlighter Undocumented
Method init​_js​_files Undocumented
Method init​_templates Undocumented
Method load​_indexer Undocumented
Method post​_process​_images Pick the best candidate for an image and link down-scaled images to their high res version.
Method prepare​_writing A place where you can add logic before write_doc is run
Method render​_partial Utility: Render a lone doctree node.
Method update​_page​_context Undocumented
Method write​_buildinfo Undocumented
Method write​_doc​_serialized Handle parts of write_doc that must be called in the main process if parallel build is active.
Method write​_domain​_indices Undocumented
Method write​_genindex Undocumented
Class Variable allow​_parallel Undocumented
Class Variable epilog Undocumented
Class Variable indexer​_dumps​_unicode Undocumented
Class Variable searchindex​_filename Undocumented
Class Variable supported​_data​_uri​_images Undocumented
Instance Variable ​_css​_files Undocumented
Instance Variable ​_script​_files Undocumented
Instance Variable build​_info Undocumented
Instance Variable css​_files Undocumented
Instance Variable current​_docname Undocumented
Instance Variable dark​_highlighter Undocumented
Instance Variable dlpath Undocumented
Instance Variable docsettings Undocumented
Instance Variable docwriter Undocumented
Instance Variable domain​_indices Undocumented
Instance Variable fignumbers Undocumented
Instance Variable globalcontext Undocumented
Instance Variable highlighter Undocumented
Instance Variable imagedir Undocumented
Instance Variable imgpath Undocumented
Instance Variable indexer Undocumented
Instance Variable last​_updated Undocumented
Instance Variable relations Undocumented
Instance Variable script​_files Undocumented
Instance Variable secnumbers Undocumented
Instance Variable theme Undocumented
Instance Variable theme​_options Undocumented
Property default​_translator​_class Undocumented
Property math​_renderer​_name Undocumented

Inherited from Builder (via StandaloneHTMLBuilder):

Method build Main build method.
Method build​_all Build all source files.
Method build​_specific Only rebuild as much as needed for changes in the filenames.
Method build​_update Only rebuild what was changed or added since last build.
Method get​_relative​_uri Return a relative URI between two source filenames.
Instance Variable events Undocumented
Method ​_read​_parallel Undocumented
Method ​_read​_serial Undocumented
Method ​_write​_parallel Undocumented
Method ​_write​_serial Undocumented
Method compile​_all​_catalogs Undocumented
Method compile​_catalogs Undocumented
Method compile​_specific​_catalogs Undocumented
Method compile​_update​_catalogs Undocumented
Method create​_template​_bridge Return the template bridge configured.
Method create​_translator Return an instance of translator.
Method get​_builder​_config Return a builder specific option.
Method get​_translator​_class Return a class of translator.
Method read (Re-)read all files new or changed since last update.
Method read​_doc Parse a file and add/update inventory entries for the doctree.
Method set​_environment Store BuildEnvironment object.
Method write Undocumented
Method write​_doctree Write the doctree to a file.
Class Variable use​_message​_catalog Undocumented
Class Variable versioning​_compare Undocumented
Class Variable versioning​_method Undocumented
Instance Variable app Undocumented
Instance Variable confdir Undocumented
Instance Variable config Undocumented
Instance Variable doctreedir Undocumented
Instance Variable env Undocumented
Instance Variable finish​_tasks Undocumented
Instance Variable images Undocumented
Instance Variable outdir Undocumented
Instance Variable parallel​_ok Undocumented
Instance Variable srcdir Undocumented
Instance Variable tags Undocumented
Instance Variable templates Undocumented
def add_visible_links(self, tree, show_urls='inline'):
Add visible link targets for external links
Parameters
tree:nodes.documentUndocumented
show​_urls:strUndocumented
def build_container(self, outname='META-INF/container.xml'):
Write the metainfo file META-INF/container.xml.
Parameters
outname:strUndocumented
def build_content(self):
Write the metainfo file content.opf It contains bibliographic data, a file list and the spine (the reading order).
def build_epub(self):

Write the epub file.

It is a zip file with the mimetype file stored uncompressed as the first entry.

def build_mimetype(self):
Write the metainfo file mimetype.
def build_navpoints(self, nodes):

Create the toc navigation structure.

Subelements of a node are nested inside the navpoint. For nested nodes the parent node is reinserted in the subnav.

Parameters
nodes:List[Dict[str, Any]]Undocumented
Returns
List[NavPoint]Undocumented
def build_toc(self):
Write the metainfo file toc.ncx.
def check_refnodes(self, nodes):

Undocumented

Parameters
nodes:List[Dict[str, Any]]Undocumented
def content_metadata(self):
Create a dictionary with all metadata for the content.opf file properly escaped.
Returns
Dict[str, Any]Undocumented
def copy_download_files(self):
def copy_image_files(self):
Copy image files to destination directory. This overwritten method can use Pillow to convert image files.
def copy_image_files_pil(self):
Copy images using Pillow, the Python Imaging Library. The method tries to read and write the files with Pillow, converting the format and resizing the image if necessary/possible.
def create_build_info(self):
def fix_fragment(self, prefix, fragment):
Return a href/id attribute with colons replaced by hyphens.
Parameters
prefix:strUndocumented
fragment:strUndocumented
Returns
strUndocumented
def fix_genindex(self, tree):
Fix href attributes for genindex pages.
Parameters
tree:List[Tuple[str, List[Tuple[str, Any]]]]Undocumented
def fix_ids(self, tree):

Replace colons with hyphens in href and id attributes.

Some readers crash because they interpret the part as a transport protocol specification.

Parameters
tree:nodes.documentUndocumented
def get_refnodes(self, doctree, result):
Collect section titles, their depth in the toc and the refuri.
Parameters
doctree:NodeUndocumented
result:List[Dict[str, Any]]Undocumented
Returns
List[Dict[str, Any]]Undocumented
def get_theme_config(self):

Undocumented

Returns
Tuple[str, Dict]Undocumented
def get_toc(self):
Get the total table of contents, containing the root_doc and pre and post files not managed by sphinx.
def handle_page(self, pagename, addctx, templatename='page.html', outfilename=None, event_arg=None):

Create a rendered page.

This method is overwritten for genindex pages in order to fix href link attributes.

Parameters
pagename:strUndocumented
addctx:DictUndocumented
templatename:strUndocumented
outfilename:strUndocumented
event​_arg:AnyUndocumented
def init(self):
Load necessary templates and perform initialization. The default implementation does nothing.
def is_vector_graphics(self, filename):
Does the filename extension indicate a vector graphic format?
Parameters
filename:strUndocumented
Returns
boolUndocumented
def make_id(self, name):
Return a unique id for name.
Parameters
name:strUndocumented
Returns
strUndocumented
def new_navpoint(self, node, level, incr=True):
Create a new entry in the toc from the node at given level.
Parameters
node:Dict[str, Any]Undocumented
level:intUndocumented
incr:boolUndocumented
Returns
NavPointUndocumented
def toc_add_files(self, refnodes):
Add the root_doc, pre and post files to a list of refnodes.
Parameters
refnodes:List[Dict[str, Any]]Undocumented
def toc_metadata(self, level, navpoints):
Create a dictionary with all metadata for the toc.ncx file properly escaped.
Parameters
level:intUndocumented
navpoints:List[NavPoint]Undocumented
Returns
Dict[str, Any]Undocumented
def write_doc(self, docname, doctree):

Write one document file.

This method is overwritten in order to fix fragment identifiers and to add visible external links.

Parameters
docname:strUndocumented
doctree:nodes.documentUndocumented
add_permalinks: bool =
allow_sharp_as_current_path: bool =
copysource: bool =
doctype: str =

Undocumented

download_support: bool =
embedded: bool =
html_scaled_image_link: bool =
search: bool =
supported_image_types: list[str] =
supported_remote_images: bool =
template_dir: str =

Undocumented

files: List[str] =

Undocumented

id_cache: Dict[str, str] =

Undocumented

ignored_files =

Undocumented

link_suffix: str =
out_suffix: str =
playorder: int =

Undocumented

refnodes =

Undocumented

tocid: int =

Undocumented