Skip to main content

A tool to convert Markdown documents into a single .docx report with proper formatting

Project description

Report Maker

This Python package provides tools for compiling multiple Markdown sources and Python source files together into a single .docx report file while also adding extra information like title page, ToC, and appendices while respecting Governmental Standards (aka GOSTs).

This project used to be term 4 educational practice in the GUAP university but outgrew that. The original code, as well as the term project report, can be seen here.

Features

  • Converts Markdown pages, including:
    • Support for extended Markdown syntax
    • Configurable Markdown extensions list
    • Full support of fancy code blocks, like syntax highlight or math expressions
    • Automatically numbered chapters
    • Automatically numbered and labeled pictures
    • Automatically numbered appendix
  • Inserts "infrastructural" pages, including:
    • Templated document, like (must be provided by the active template)
    • Plain document, like Table of Contents (must be provided by the active template)
    • Source code in the document appendix
    • Source code license file in the document appendix
  • Full external templates support
  • (Planned only) Full external extensions support

Usage

  1. Install via pip:
    pip install report-maker[all]
    
  2. Install any of the template plugins:
    • For GOTS-7.32, install as:
      pip install report-maker-template-gost-7.32
      
  3. Add report-composer.conf config (see below)
  4. Run report-composer (or python -m report_composer)

Documentation

Feature flags

The project comes with a number of feature flags, some of them (especially math-related) are quite heavy:

math : Plugins to convert inline math code and math code blocks into MS Word math blocks.

code : Plugins to add code blocks highlights and source code formatting

extras : Plugins for extra functionality

all : All possible feature flags

Command-line Options

Usage:

report-maker [OPTIONS]

Options:

-h|--help : Show help message and exit

--config|-c CONFIG : Path to the configuration file Default value: report-composer.conf

--log-level|-l DEBUG|INFO|WARNING|ERROR|CRITICAL : Logging level for the app Default value: INFO

Composer Config

The Report Raker uses the report composer to compose the report. The latter requires the composer config in HOCON format, usually named report-composer.conf

The composer config MUST contain composer top-level section. This section may have the following properties:

  • template (string): REQUIRED. ID of the template used. See Templating.
  • build_dir (relative path): Optional, default: build/. Directory used to store temporary files during document build. May contain caches for faster project re-building.
  • target (relative path): Optional, default: report.docx. Path to the resulting document, relative to the current working directory.
  • parts (list): REQUIRED. List of parts to compose. All parts are executed in order. See below.

Composer Parts : All composer parts MUST define name (unique string) and type. Other properties vary for different part types.

Markdown Converter (type: markdown) : Module which (optionally) discovers and converts Markdown files. Supported parameters:

  • root (relative path): REQUIRED. Root directory for the module, relative to the working directory.
  • discover (boolean): REQUIRED. Defines the behaviour of this module.
    • With discover: true, automatically includes all files matching a pattern. Patterns may be overridden via patterns (list of strings) option. By default, recursively includes all Markdown (*.md, *.markdown) files. Files are sorted alphabetically.
    • With discover: false, module includes only files listed in the files option. Files are ordered as listed.
  • files (list): A list of files to include. Each file must have either file or glob:
    • file (relative path): Single file relative to the root
    • glob (relative path pattern): Pattern of files relative toe the root
    • is_main_body (boolean): Optional, default: false. May be set to true for main chapters, affects formatting.

Source Code Converter (type: source-code) : Behaves similarly to the Markdown Converter, but discovers and inserts source code files.

  • root (relative path): REQUIRED. Root directory for the module, relative to the working directory.
  • discover (boolean): REQUIRED. Defines the behaviour of this module.
    • With discover: true, automatically includes all files matching a pattern. Patterns may be overridden via patterns (list of strings) option. By default, recursively includes all Python source code (*.py, *.pyi) files. Files are sorted alphabetically.
    • With discover: false, module includes only files listed in the files option. Files are ordered as listed.
  • files (list): A list of files to include. Each file must have either file or glob:
    • file (relative path): Single file relative to the root
    • glob (relative path pattern): Pattern of files relative toe the root
  • style_profile (string): Optional, a name for the Pygments profile
  • split_code_blocks (boolean): Optional, default: true. When set, code blocks are split into paragraphs by empty lines.

Static File (type: document) : Inserts the file from document_path (relative path). Styles are merged, otherwise unchanged.

Static Template (type: from-template) : Inserts the static file document_path (path from the template root) from the active template. Behaves similarly to Static File.

Dynamic Template (type: template) : Inserts the dynamic template template (path from the template root) from the active template. Substitutes values listed in the attributes (config section). Otherwise, behaves like Static Template. Refer to the template's documentation for the list of attributes required.

License Reference (type: license) : Inserts the license text either from a file or from templates. Supported parameters:

  • license_kind: custom or built-in
    • With license_kind: custom, no dynamic logic is used
    • With license_kind: built-in, license may be rendered by the license package
    • Regardless of choice, license_name and license_file options are respected.
  • license_id (string): Required if built-in, license identifier from the license library
  • license_name (string): Required if custom, license human-readable name
  • license_file (string): Required if custom, a license file to include
  • options (config section): Options for rendering license text, like author's name or email

Appendix Wrapper (type: appendix) : Wraps the module defined in appendix as an appendix. Appendices are numbered by default, use numbered: false to disable. Otherwise, the module is unaffected.

Example configuration

Example configuration for the GOST-7.32 template

paths:
{
    build_dir: build
    data_dir: docs
    target_dir: out
    source_code: src
}

composer:
{
    template: "gost-7.32"
    build_dir: ${paths.build_dir}
    target: ${paths.target_dir}/report.docx
    
    parts:
    [
        {
            name: title
            type: document
            document_path: ${paths.data_dir}/src/front-page.docx
        },
        {
            name: toc
            type: from-template
            document_path: "toc.docx"
        },
        {
            name: body
            type: markdown
            discover: false
            root: ${paths.data_dir}/report
            files:
            [
                { file = "intro.md",        is_main_body = false },
                { glob = "chapter-*.md",    is_main_body = true  },
                { file = "conclusion.md",   is_main_body = false },
                { file = "sources.md",      is_main_body = false },
            ]
        },
        {
            name: source-code
            type: appendix
            appendix:
            {
                type: source-code
                discover: true
                root: ${paths.source_code}
            }
        },
        {
            name: license
            type: appendix
            appendix:
            {
                type: license
                license_kind: built-in
                license_id: "BSD-2-Clause"
                license_file: "License.txt"
                
                font_size_override: 8
                options:
                {
                    name: "Peter Zaitcev"
                    email: "zaitcev.po@gmai.com"
                }
            }
        },
    ]
}

Templating

Report Maker requires an installed template extension to run. A list of all official extensions can be found here: https://gitlab.com/Hares-Lab/report-maker/templates

Third-parties may also provide their own extensions.

Licensing

see: LICENSE.txt

BSD-2 License. Copyright (c) Peter Zaitcev, 2025.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

report_maker-0.2.0.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

report_maker-0.2.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file report_maker-0.2.0.tar.gz.

File metadata

  • Download URL: report_maker-0.2.0.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for report_maker-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3df99d9c1ebb2fb71468d29da0f50540638eb56fca2a242fb21e0e2ce65662ff
MD5 4760eea622601b684a6e87e4fc799c0c
BLAKE2b-256 b16d638712d4c6c113baa7db6cab2a95e45ffad501158487293e5f12f1ba7599

See more details on using hashes here.

File details

Details for the file report_maker-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: report_maker-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 39.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for report_maker-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8232563cfde9f4fdea5b42136585090d95b648b3ad2fb33ba4875089a37061bf
MD5 d588cb4a42cd4a01933b8fc3c8464d94
BLAKE2b-256 3b5606c18fbaad7d674c6c4e1609f712e0184ffcc23fae6aa7adf82770ad5b2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page