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()

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 a={a}, b={b}, 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
    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.

Example output PDF report

Documentation

A documentation and API reference can be found on ReadTheDocs:

Install

pip install magazine

If you are working with uv, use uv add 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.9.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

magazine-0.3.9-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: magazine-0.3.9.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for magazine-0.3.9.tar.gz
Algorithm Hash digest
SHA256 0b1f4591f9a1185d832488c336fa60a30199afce0c0ee0c8b53ab65ec4230b06
MD5 fe0056bbf9e7a656a7445fdfd10a521e
BLAKE2b-256 fae39cbe8a28d4c3eef5d7766cb9a7b852f497c30579f4ebd9303a1cb5c6b1a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: magazine-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for magazine-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b27b542a7d61f406a92223fd3c06880e7bc732b04d0a89dabca90d8b5a991963
MD5 e421fa504707c3b975180b6779c60648
BLAKE2b-256 4ba7b05ad48bee57a9b94c131ec072e75dbce02decd0e282391a6569a28612ea

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