Metadata-Version: 2.4
Name: autobasedoc
Version: 1.1.11
Summary: autobasedoc - convenience reportlab tool
Author-email: "Oliver Braun, Johannes Eckstein" <johannes.eckstein@nucos.de>
License: ## BSD-3-Clause
        
        Copyright 2017 Oliver Braun, Johannes Eckstein
        
        Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Keywords: reporting
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: reportlab
Requires-Dist: pdfrw
Requires-Dist: svglib
Requires-Dist: cycler
Requires-Dist: matplotlib>=3.5
Requires-Dist: img2pdf
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: coverage; extra == "test"
Requires-Dist: faker; extra == "test"
Requires-Dist: numpy; extra == "test"
Dynamic: license-file

# AutoBaseDoc

Automated PDF document generation on top of ReportLab with Matplotlib integration, reusable page templates, and helpers for tables, headers, footers, and table-of-contents handling.

![Documentation Status](https://readthedocs.org/projects/autobasedoc/badge/?version=latest)
![Current Version PyPI](https://img.shields.io/pypi/v/autobasedoc.svg)
![Python Version](https://img.shields.io/pypi/pyversions/autobasedoc.svg)
![License](https://img.shields.io/github/license/NuCOS/autobasedoc.svg)
![Test Coverage](./coverage.svg)

## Installation

```bash
pip install autobasedoc
```

Development setup:

```bash
git clone https://github.com/NuCOS/autobasedoc.git
cd autobasedoc
pip install -e .
pip install -e ".[test]"
```

Requirements:
- Python 3.7+
- ReportLab
- Matplotlib
- `svglib`, `pdfrw`, `img2pdf`

## Quick Start

```python
import os
from autobasedoc import autorpt as ar

outname = os.path.join(os.getcwd(), "MinimalExample.pdf")

doc = ar.AutoDocTemplate(
    outname,
    onFirstPage=ar.onFirstPage,
    onLaterPages=ar.onLaterPages,
    onLaterSPages=ar.onLaterSPages,
    leftMargin=0.5 * ar.cm,
    rightMargin=0.5 * ar.cm,
    topMargin=0.5 * ar.cm,
    bottomMargin=0.5 * ar.cm,
)

styles = ar.Styles()
styles.registerStyles()

content = []
content.append(ar.Paragraph("Minimal Example Title", styles.title))
content.append(ar.PageBreak())
content.append(ar.Paragraph("Table Of Contents", styles.h1))
content.append(ar.doTableOfContents())

doc.multiBuild(content)
```

## Matplotlib Integration

Use `autoPdfImg` when a plotting function should return a single ReportLab flowable:

```python
from autobasedoc import autoplot as ap

@ap.autoPdfImg
def create_chart(canvaswidth=5):
    fig, ax = ap.plt.subplots(figsize=(canvaswidth, canvaswidth))
    ax.plot([1, 2, 3, 4], [1, 4, 2, 3])
    ax.set_title("Sample Chart")
    return fig

content.append(create_chart())
```

Use `autoPdfImage` when the plot and legend should be placed independently in the document:

```python
@ap.autoPdfImage
def create_chart_with_legend(canvaswidth=5):
    fig, ax = ap.plt.subplots(figsize=(canvaswidth, canvaswidth))
    ax.plot([1, 2, 3, 4], [1, 4, 2, 3], label="series")
    handles, labels = ax.get_legend_handles_labels()
    legend_fig = ap.plt.figure(figsize=(canvaswidth, 0.4))
    legend = legend_fig.legend(handles, labels, loc="center", frameon=False)
    return fig, legend_fig, legend

plot_img, legend_img = create_chart_with_legend()
content.extend([legend_img, plot_img])
```

## Table Layouts

For plain ReportLab tables, the standard `ar.Table` works well. For AutoBaseDoc-specific layout helpers, use `StyledTable` and finish with `layoutStyledTable()`:

```python
from autobasedoc.styledtable import StyledTable

styled = StyledTable(gridded=True)
styled.setTableData([
    ["Product", "Q1", "Q2"],
    ["Widget A", "100", "120"],
    ["Widget B", "80", "95"],
])
styled.addTableStyleCommand(("ALIGN", (0, 0), (-1, -1), "CENTER"))

table = styled.layoutStyledTable(colWidths=[4, 3, 3], rowHeights=[1.0, 0.8, 0.8])
content.append(table)
```

## Examples and Documentation

- Example script: `tests/example.py`
- Larger document example: `tests/example_document.py`
- Sphinx docs source: `sphinx_doc/`
- API docs: Read the generated Sphinx reference or inspect module docstrings

## Testing

Install test dependencies and run the suite:

```bash
pip install -e ".[test]"
MPLBACKEND=Agg pytest -q
```

Coverage run:

```bash
MPLBACKEND=Agg pytest --cov=autobasedoc --cov-report=term-missing
```

## Release Notes

Version `1.1.11` includes the current packaging cleanup, documentation fixes, and `rowHeights` forwarding support for styled table layout helpers.

## License

This project is licensed under the BSD-3-Clause License. See [LICENSE.md](LICENSE.md).

## Links

- Homepage: https://github.com/NuCOS/autobasedoc
- Package: https://pypi.org/project/autobasedoc/
- Documentation: http://autobasedoc.readthedocs.io/
- Issues: https://github.com/NuCOS/autobasedoc/issues
