Skip to main content

Let your code take comprehensive notes and publish notes and figures as a beautiful consolidated PDF document.

Project description

Magazine

PyPi Version MIT License Read the Docs Issues
Let your code take comprehensive notes and publish notes and figures as a beautiful consolidated PDF document.

Idea

The magazine package helps you to create beautiful PDF reports of what has been done during the execution of your app.

  1. Your scripts or submodules can write topical reports in plain human-readable text, which could also include numerical results, data tables, figures, or citations.
  2. The collection of topics can be used to publish a glossy PDF document.

Example

from magazine import Magazine, Publish

E = 42
Magazine.report("Experiment", "The analysis found that energy equals {} Joule.", E)
Magazine.cite("10.1002/andp.19163540702")

with Publish("Report.pdf", "My physics report", info="Version 0.1") as M:
    M.add_topic("Experiment")
    M.add_references()

Example output PDF report

Instead of inline commands, you can also use a decorator to automatically write and format the content of the docstring section "Report" and its "References" section into the report.

@Magazine.reporting("Physics")
def Method_A(a, b, c=3):
    """
    A complex method to calculate the sum of numbers.

    Report
    ------
    The method "{function}" used input parameters {args}, and c={c}.
    Calculations have been performed following Einstein et al. (1935).
    The result was: {return}. During the process, the magic number {magic} appeared.

    References
    ----------
    Einstein, A., Podolsky, B., & Rosen, N. (1935). Can Quantum-Mechanical Description of Physical Reality Be Considered Complete? Physical Review, 47(10), 777–780. https://doi.org/10.1103/physrev.47.777

    """
    result = a + b + c

    # Function "_report" is provided by the decorator to communicate more variables
    _report["magic"] = 42

    return result

# When the function is called, it is automatically reported.
Method_A(2, 3, c=4)

Output in the PDF:

The method "Method_A" used input parameters (2, 3), and c=4. Calculations have been performed following Einstein et al. (1935). The result was: 9. During the process, the magic number 42 appeared.

Check also example.py and output/Magazine.pdf for more full examples.

Documentation

A documentation and API reference can be found on ReadTheDocs:

Install

pip install magazine

Requires:

  • fpdf2
  • habanero (optional, for academic citations)
  • neatlogger (wrapper for loguru)

Acknowledgements

  • Uses the Google font Roboto as it just looks great in PDFs.

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

magazine-0.3.0.tar.gz (291.1 kB view details)

Uploaded Source

Built Distribution

magazine-0.3.0-py3-none-any.whl (293.1 kB view details)

Uploaded Python 3

File details

Details for the file magazine-0.3.0.tar.gz.

File metadata

  • Download URL: magazine-0.3.0.tar.gz
  • Upload date:
  • Size: 291.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.11 Windows/10

File hashes

Hashes for magazine-0.3.0.tar.gz
Algorithm Hash digest
SHA256 479baee25534fc1520087257d367e54f9366f1bd202f8ab12954821f9809b67e
MD5 64fd4034427b7ff98136d635817d19df
BLAKE2b-256 393c0a9e8f559a7c0188857136385c9a9a47cd603ca041885dc86d107ad07bcd

See more details on using hashes here.

File details

Details for the file magazine-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: magazine-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 293.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.11 Windows/10

File hashes

Hashes for magazine-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 570c635b4ac99dbf635bf38776ea18f3383a53a4d1df6f8085ae35aa9a352f7d
MD5 3f0f3784cf608af5344cbd14cc0a1287
BLAKE2b-256 229735f4cfddbbf538d77d00ac3439c8e4b5ffa811d4ffbaf9345b9951edf48c

See more details on using hashes here.

Supported by

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