# Magazine
[![PyPi Version](https://img.shields.io/pypi/v/magazine.svg)](https://pypi.python.org/pypi/magazine/)
[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/mschroen/magazine/blob/main/LICENSE)
[![Read the Docs](https://readthedocs.org/projects/magazine/badge/?version=latest)](https://magazine.readthedocs.io/en/latest/?badge=latest)
[![Issues](https://img.shields.io/github/issues-raw/mschroen/magazine.svg?maxAge=25000)](https://github.com/mschroen/magazine/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
```python
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()
```
- View the resulting magazine in [output/Report.pdf](https://github.com/mschroen/magazine/blob/main/output/Report.pdf).
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.
```python
@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](https://github.com/mschroen/magazine/blob/main/example.py) and [output/Magazine.pdf](https://github.com/mschroen/magazine/blob/main/output/Magazine.pdf) for more full examples.
![Example output PDF report](https://github.com/mschroen/magazine/blob/main/docs/magazine-preview.png)
## Documentation
A documentation and API reference can be found on [ReadTheDocs](https://magazine.readthedocs.io/en/latest):
- [Magazine](https://magazine.readthedocs.io/en/latest/#magazine.magazine.Magazine) (class)
- [Publish](https://magazine.readthedocs.io/en/latest/#magazine.publish.Publish) (context manager)
- [PDF commands](https://magazine.readthedocs.io/en/latest/#magazine.publish.PDF) (class)
## Install
```bash
pip install magazine
```
Requires:
- fpdf2
- habanero (optional, for academic citations)
- neatlogger (wrapper for loguru)
## Acknowledgements
- Uses the Google font [Roboto](https://fonts.google.com/specimen/Roboto) as it just looks great in PDFs.
Raw data
{
"_id": null,
"home_page": "https://github.com/mschroen/magazine",
"name": "Magazine",
"maintainer": null,
"docs_url": null,
"requires_python": ">3.9",
"maintainer_email": null,
"keywords": "logging, reports, pdf",
"author": "Martin Schr\u00f6n",
"author_email": "martin@schroen.eu",
"download_url": "https://files.pythonhosted.org/packages/3a/d9/179048e01447be655069877dbe5e1a208b41b1dff051a116056e0bc68639/magazine-0.3.2.tar.gz",
"platform": null,
"description": "# Magazine\n[![PyPi Version](https://img.shields.io/pypi/v/magazine.svg)](https://pypi.python.org/pypi/magazine/)\n[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/mschroen/magazine/blob/main/LICENSE)\n[![Read the Docs](https://readthedocs.org/projects/magazine/badge/?version=latest)](https://magazine.readthedocs.io/en/latest/?badge=latest)\n[![Issues](https://img.shields.io/github/issues-raw/mschroen/magazine.svg?maxAge=25000)](https://github.com/mschroen/magazine/issues) \nLet your code take comprehensive notes and publish notes and figures as a beautiful consolidated PDF document.\n\n## Idea\n\nThe magazine package helps you to create beautiful PDF reports of what has been done during the execution of your app. \n1. Your scripts or submodules can write topical reports in plain human-readable text, which could also include numerical results, data tables, figures, or citations.\n2. The collection of topics can be used to publish a glossy PDF document.\n\n## Example\n\n```python\nfrom magazine import Magazine, Publish\n\nE = 42\nMagazine.report(\"Experiment\", \"The analysis found that energy equals {} Joule.\", E)\nMagazine.cite(\"10.1002/andp.19163540702\")\n\nwith Publish(\"Report.pdf\", \"My physics report\", info=\"Version 0.1\") as M:\n M.add_topic(\"Experiment\")\n M.add_references()\n```\n\n- View the resulting magazine in [output/Report.pdf](https://github.com/mschroen/magazine/blob/main/output/Report.pdf).\n\nInstead 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.\n\n```python\n@Magazine.reporting(\"Physics\")\ndef Method_A(a, b, c=3):\n \"\"\"\n A complex method to calculate the sum of numbers.\n\n Report\n ------\n The method \"{function}\" used input parameters {args}, and c={c}.\n Calculations have been performed following Einstein et al. (1935).\n The result was: {return}. During the process, the magic number {magic} appeared.\n\n References\n ----------\n Einstein, A., Podolsky, B., & Rosen, N. (1935). Can Quantum-Mechanical Description of Physical Reality Be Considered Complete? Physical Review, 47(10), 777\u2013780. https://doi.org/10.1103/physrev.47.777\n\n \"\"\"\n result = a + b + c\n\n # Function \"_report\" is provided by the decorator to communicate more variables\n _report[\"magic\"] = 42\n\n return result\n\n# When the function is called, it is automatically reported.\nMethod_A(2, 3, c=4)\n```\nOutput in the PDF:\n> The method \"Method_A\" used input parameters (2, 3), and c=4. Calculations have been performed following Einstein et\nal. (1935). The result was: 9. During the process, the magic number 42 appeared.\n\nCheck also [example.py](https://github.com/mschroen/magazine/blob/main/example.py) and [output/Magazine.pdf](https://github.com/mschroen/magazine/blob/main/output/Magazine.pdf) for more full examples.\n\n![Example output PDF report](https://github.com/mschroen/magazine/blob/main/docs/magazine-preview.png)\n\n\n## Documentation\n\nA documentation and API reference can be found on [ReadTheDocs](https://magazine.readthedocs.io/en/latest):\n- [Magazine](https://magazine.readthedocs.io/en/latest/#magazine.magazine.Magazine) (class)\n- [Publish](https://magazine.readthedocs.io/en/latest/#magazine.publish.Publish) (context manager)\n- [PDF commands](https://magazine.readthedocs.io/en/latest/#magazine.publish.PDF) (class)\n\n## Install\n\n```bash\npip install magazine\n```\n\nRequires:\n- fpdf2\n- habanero (optional, for academic citations)\n- neatlogger (wrapper for loguru)\n\n## Acknowledgements\n\n- Uses the Google font [Roboto](https://fonts.google.com/specimen/Roboto) as it just looks great in PDFs.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Let your code take comprehensive notes and publish notes and figures as a beautiful consolidated PDF document.",
"version": "0.3.2",
"project_urls": {
"Homepage": "https://github.com/mschroen/magazine",
"Repository": "https://github.com/mschroen/magazine"
},
"split_keywords": [
"logging",
" reports",
" pdf"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ffb4554907ccee2b0d1a0609d08255c0e238b6c0a732d74ba75ad321769cecef",
"md5": "3ac66d15d5652da4857b6600062bfaae",
"sha256": "aad991bc8b49266d92b42a86046a95bcaf5a397869de6aa023fa4467021a8c48"
},
"downloads": -1,
"filename": "magazine-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3ac66d15d5652da4857b6600062bfaae",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">3.9",
"size": 293221,
"upload_time": "2024-11-20T19:05:54",
"upload_time_iso_8601": "2024-11-20T19:05:54.212573Z",
"url": "https://files.pythonhosted.org/packages/ff/b4/554907ccee2b0d1a0609d08255c0e238b6c0a732d74ba75ad321769cecef/magazine-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3ad9179048e01447be655069877dbe5e1a208b41b1dff051a116056e0bc68639",
"md5": "cb6b1585bcc68eecd15991c534cf9903",
"sha256": "9a98f365c9e2b3f6bfaafebef5627bb15ac0eb86bbf6c83ea12e55eb79d7c662"
},
"downloads": -1,
"filename": "magazine-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "cb6b1585bcc68eecd15991c534cf9903",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">3.9",
"size": 291303,
"upload_time": "2024-11-20T19:05:56",
"upload_time_iso_8601": "2024-11-20T19:05:56.367212Z",
"url": "https://files.pythonhosted.org/packages/3a/d9/179048e01447be655069877dbe5e1a208b41b1dff051a116056e0bc68639/magazine-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-20 19:05:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mschroen",
"github_project": "magazine",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "magazine"
}