NLdoc.Conversion.Reader.Docx (NLdoc.Conversion.Reader.Docx v1.1.2)

View Source

The NLdoc.Conversion.Reader.Docx struct represents an opened Docx file.

This module provides functions for opening, converting and reading from Docx files.

Note: after opening a Docx file with open!/1, it is highly recommended to call close!/1 to clean up the temporary directory in which the Docx file was extracted.

Package Structure

The NLdoc.Conversion.Reader.Docx package is structured as follows:

  • NLdoc.Conversion.Reader.Docx: contains the main Docx struct and functions for opening and closing Docx files.
                         `convert!/1` is delegated to `NLdoc.Conversion.Reader.Docx.Convert`.
  • NLdoc.Conversion.Reader.Docx.AST: implements structures that represent the information contained in the files of a Docx document.
                             This is our Abstract Syntax Tree (AST), our internal representation of the contents of everything in a Docx document.
  • NLdoc.Conversion.Reader.Docx.Files: implements everything related to what files are in a Docx document:
                               `[Content_Types].xml`, `docProps/core.xml`, `document.xml`, `numbering.xml`,
                               `styles.xml`, `.rels` files etc.
  • NLdoc.Conversion.Reader.Docx.Convert: implements the actual conversion of AST to NLdoc spec.

Summary

Functions

Close a Docx struct, removing the temporary directory in which the Docx file was extracted. After this, the Docx struct can no longer be used as input to any functions in this module.

Open a Docx file and extract its contents to a temporary directory, raising errors when any of these steps fail. Returns a Docx struct that can be used with the rest of the functions in this module. When you're done with the Docx struct, you should call close!/1 to clean up the temporary directory.

Types

Functions

close!(docx)

@spec close!(t()) :: :ok

Close a Docx struct, removing the temporary directory in which the Docx file was extracted. After this, the Docx struct can no longer be used as input to any functions in this module.

convert!(docx)

See NLdoc.Conversion.Reader.Docx.Convert.convert/1.

open!(filepath)

@spec open!(String.t()) :: t()

Open a Docx file and extract its contents to a temporary directory, raising errors when any of these steps fail. Returns a Docx struct that can be used with the rest of the functions in this module. When you're done with the Docx struct, you should call close!/1 to clean up the temporary directory.