pygauss.docs module¶
Created on Tue Jun 16 15:52:53 2015
@author: chris sewell
-
class
pygauss.docs.
MSDocument
(docx=None)[source]¶ Bases:
object
a class to output a Microsoft Word Document
inherited api details for
docx.document.Document
can be found at; https://python-docx.readthedocs.org/en/latest/api/document.htmlthe class has an internal state for the number of calls to add_picture and add_table for use in caption numbering
Parameters: docx (str or file-like object) – can be either a path to a .docx file (a string) or a file-like object. If docx is missing or None, the built-in default document “template” is loaded. -
__dir__
()[source]¶ required to have
docx.document.Document
methods inIPython
tab completion
-
__getattr__
(name)[source]¶ required to get
docx.document.Document
methods
-
add_dataframe
(df, incl_indx=True, autofit=True, sig_figures=5, style='Medium List 1 Accent 1', caption=None)[source]¶ add dataframe as a table to the document
Parameters: Returns: pic – a table added to the document
Return type:
-
add_docstring
(docstring, style='Body Text', markdown=True)[source]¶ adds a doctring to the document
this function will split text into paragraphs (denominated by a separating blank line) remove new-line characters and add to document, allowing for markdown style text designated in
pygauss.docs.MSDocument.add_markdown()
Parameters: Returns: paras – a list of paragraphs added to the document
Return type:
-
add_markdown
(text='', style='Body Text', markup_dict=None, para=None)[source]¶ adds a paragraph to the document, allowing for paragraph/font styling akin to a stripped down version of markdown text:
paragraph level:
# Header (level denoted by number of #'s) - bullet list 1. numbered list
font level:
**bold** *italic* _{subscript} ^{superscript} ~~strikethrough~~ $mathML$
Parameters: - text (str) – the text to add
- style (str) – the style to apply (overriden if paragraph level markdown)
- markup_dict (dict) – if set will override built in font level markup {font_attribute:(start_chars, end_chars)}
- para (docx.text.paragraph.Paragraph) – a pre-existing paragraph to add the text to if set, will ignore paragraph level markdown
Returns: para – a paragraph added to the document
Return type:
-
add_mpl
(fig, dpi=None, width=None, height=None, pad_inches=0.2, caption=None)[source]¶ add matplotlib figure to the document
Parameters: Returns: pic – an inline picture added to the document
Return type:
-
add_picture
(image_path_or_stream, width=None, height=None)[source]¶ Return a new picture shape added in its own paragraph at the end of the document. The picture contains the image at image_path_or_stream, scaled based on width and height. If neither width nor height is specified, the picture appears at its native size. If only one is specified, it is used to compute a scaling factor that is then applied to the unspecified dimension, preserving the aspect ratio of the image. The native size of the picture is calculated using the dots-per-inch (dpi) value specified in the image file, defaulting to 72 dpi if no value is specified, as is often the case.
-