Cli

Command-line interface for pytexmd.

This module provides a CLI for processing LaTeX files and generating documentation.

pytexmd.cli.process_file(input_file: str, output_folder: str, depth: int = 3, output_suffix: str = '.md', project_name: str = 'My Project', author: str = 'Author', version: str = '1.0') None[source]

Process a LaTeX file and generate documentation.

Loads the LaTeX file, expands its content, generates Sphinx documentation, and converts the content to Markdown.

Parameters:
  • input_file (str) – Path to the input LaTeX file.

  • output_folder (str) – Path to the output folder for documentation.

  • depth (int, optional) – Depth for processing sections. Defaults to 3.

  • output_suffix (str, optional) – Suffix for output files. Defaults to “.md”.

Returns:

None

Example

process_file(“main.tex”, “docs”)

Config

pytexmd.config.set_latex_replacements(replacements)[source]

Core

Core utilities for processing LaTeX files and generating documentation.

This module provides the main entry point for converting LaTeX files to Markdown and generating Sphinx documentation.

pytexmd.core.process_file(input_file: str, output_folder: str, depth: int = 3, output_suffix: str = '.md', project_name: str = 'My Project', author: str = 'Author', version: str = '1.0') None[source]

Process a LaTeX file and generate documentation.

Loads the LaTeX file, expands its content, generates Sphinx documentation, and converts the content to Markdown.

Parameters:
  • input_file (str) – Path to the input LaTeX file.

  • output_folder (str) – Path to the output folder for documentation.

  • depth (int, optional) – Depth for processing sections. Defaults to 3.

  • output_suffix (str, optional) – Suffix for output files. Defaults to “.md”.

Returns:

None

Example

process_file(“main.tex”, “docs”)

File Loader

File loader utilities for LaTeX projects.

This module provides functions and classes to load LaTeX files and their associated resources (recursively), such as .tex, .bib, and image files. It also expands input{} commands in the main LaTeX file.

Typical usage example:

latex_file = load_tex_file(“main.tex”)

pytexmd.file_loader.load_tex_file(file_name: str) LatexFile[source]

Load a LaTeX file and its associated resources recursively.

Expands all input{} commands in the main file, and collects all .tex, .bib, and image files in the same directory tree.

Parameters:

file_name (str) – Path to the main LaTeX file.

Returns:

A named tuple containing the expanded content and dictionaries of found files.

Return type:

LatexFile

Raises:
  • FileNotFoundError – If the main file does not exist.

  • OSError – If there is an error reading files from disk.

Example

latex_file = load_tex_file(“main.tex”) print(latex_file.content)

class pytexmd.file_loader.LatexFile(content: str, tex_files: Dict[str, str], bib_files: Dict[str, str], image_files: Dict[str, str], all_files: Dict[str, str])[source]

Bases: NamedTuple

Container for loaded LaTeX project files.

content

The expanded content of the main LaTeX file, with input{} resolved.

Type:

str

tex_files

Mapping from base filename (without extension) to absolute path for .tex/.sty/.cls files.

Type:

Dict[str, str]

bib_files

Mapping from base filename (without extension) to absolute path for .bib/.bbl/.bibtex/.biblatex files.

Type:

Dict[str, str]

image_files

Mapping from base filename (without extension) to absolute path for image files.

Type:

Dict[str, str]

all_files

Combined mapping of all supported files.

Type:

Dict[str, str]

content: str

Alias for field number 0

tex_files: Dict[str, str]

Alias for field number 1

bib_files: Dict[str, str]

Alias for field number 2

image_files: Dict[str, str]

Alias for field number 3

all_files: Dict[str, str]

Alias for field number 4

Sphinx Doc

Sphinx documentation utilities for pytexmd.

This module provides functions to create Sphinx documentation structure and configuration files.

pytexmd.sphinx_doc.load_config_template() str[source]

Load the Sphinx configuration template.

Returns:

Contents of the configuration template file.

Return type:

str

pytexmd.sphinx_doc.create_config_file(output_dir: str, project_name: str, author: str, version: str) None[source]

Create a Sphinx conf.py configuration file in the source directory.

Parameters:
  • output_dir (str) – Directory where the Sphinx documentation is located.

  • project_name (str) – Name of the project.

  • author (str) – Author name.

  • version (str) – Project version.

Returns:

None

pytexmd.sphinx_doc.create_sphinx_documentation(output_dir: str, project_name: str = 'My Project', author: str = 'Author', version: str = '1.0') None[source]

Create a Sphinx documentation structure with source and build folders.

Parameters:
  • output_dir (str) – Directory where the Sphinx documentation will be created.

  • project_name (str, optional) – Name of the project. Defaults to “My Project”.

  • author (str, optional) – Author name. Defaults to “Author”.

  • version (str, optional) – Project version. Defaults to “1.0”.

Returns:

None

pytexmd.sphinx_doc.make_html(output_dir: str) None[source]

Build the Sphinx documentation to HTML format.

Parameters:

output_dir (str) – Directory where the Sphinx documentation is located.

Returns:

None

Module Contents

pytexmd.process_file(input_file: str, output_folder: str, depth: int = 3, output_suffix: str = '.md', project_name: str = 'My Project', author: str = 'Author', version: str = '1.0') None[source]

Process a LaTeX file and generate documentation.

Loads the LaTeX file, expands its content, generates Sphinx documentation, and converts the content to Markdown.

Parameters:
  • input_file (str) – Path to the input LaTeX file.

  • output_folder (str) – Path to the output folder for documentation.

  • depth (int, optional) – Depth for processing sections. Defaults to 3.

  • output_suffix (str, optional) – Suffix for output files. Defaults to “.md”.

Returns:

None

Example

process_file(“main.tex”, “docs”)