Merge pull request #617 from waketzheng/project-section
feat: use project section
This commit is contained in:
commit
f96b0b6413
4
.github/workflows/codestyle.yml
vendored
4
.github/workflows/codestyle.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.9', '3.10', '3.11','3.12','3.13']
|
||||
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
@ -22,4 +22,4 @@ jobs:
|
||||
run: |
|
||||
pip install flake8
|
||||
# stop the build if there are code styling problems. The GitHub editor is 127 chars wide.
|
||||
flake8 . --count --max-line-length=127 --show-source --statistics
|
||||
flake8 . --count --max-line-length=127 --show-source --statistics
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
0.20.2 *(Unreleased)*
|
||||
-------------------
|
||||
- Move docxcompose to optional dependency (Thanks to Waket Zheng)
|
||||
|
||||
0.20.1 (2025-07-15)
|
||||
-------------------
|
||||
- Fix and improve get_undeclared_template_variables() method (Thanks to Pablo Esteban)
|
||||
|
||||
@ -286,6 +286,8 @@ Please see tests/inline_image.py for an example.
|
||||
Sub-documents
|
||||
-------------
|
||||
|
||||
> Need to install with the subdoc extra: `pip install "docxtpl[subdoc]"`
|
||||
|
||||
A template variable can contain a complex subdoc object and be built from scratch using python-docx document methods.
|
||||
To do so, first, get the sub-document object from your template object, then use it by treating it as a python-docx document object.
|
||||
See example in `tests/subdoc.py`.
|
||||
|
||||
@ -4,11 +4,15 @@ Created : 2015-03-12
|
||||
|
||||
@author: Eric Lapouyade
|
||||
"""
|
||||
|
||||
__version__ = "0.20.1"
|
||||
|
||||
# flake8: noqa
|
||||
from .inline_image import InlineImage
|
||||
from .listing import Listing
|
||||
from .richtext import RichText, R, RichTextParagraph, RP
|
||||
from .subdoc import Subdoc
|
||||
from .template import DocxTemplate
|
||||
try:
|
||||
from .subdoc import Subdoc
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@ -6,8 +6,7 @@ Created : 2015-03-12
|
||||
"""
|
||||
|
||||
from os import PathLike
|
||||
from typing import Any, Optional, IO, Union, Dict, Set
|
||||
from .subdoc import Subdoc
|
||||
from typing import TYPE_CHECKING, Any, Optional, IO, Union, Dict, Set
|
||||
import functools
|
||||
import io
|
||||
from lxml import etree
|
||||
@ -29,6 +28,9 @@ import binascii
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .subdoc import Subdoc
|
||||
|
||||
|
||||
class DocxTemplate(object):
|
||||
"""Class for managing docx files as they were jinja2 templates"""
|
||||
@ -610,7 +612,9 @@ class DocxTemplate(object):
|
||||
self.docx_ids_index += 1
|
||||
elt.attrib["id"] = str(self.docx_ids_index)
|
||||
|
||||
def new_subdoc(self, docpath=None):
|
||||
def new_subdoc(self, docpath=None) -> Subdoc:
|
||||
from .subdoc import Subdoc
|
||||
|
||||
self.init_docx()
|
||||
return Subdoc(self, docpath)
|
||||
|
||||
|
||||
1579
poetry.lock
generated
1579
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,22 +1,70 @@
|
||||
[tool.poetry]
|
||||
[project]
|
||||
name = "docxtpl"
|
||||
version = "0.17.0"
|
||||
dynamic = ["version"]
|
||||
description = "Python docx template engine"
|
||||
authors = ["Eric Lapouyade"]
|
||||
authors = [{name="Eric Lapouyade", email="elapouya@proton.me"}]
|
||||
readme = "README.rst"
|
||||
requires-python = ">=3.7"
|
||||
license = {text="LGPL-2.1-only"}
|
||||
classifiers=[
|
||||
"Intended Audience :: Developers",
|
||||
"Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
]
|
||||
keywords = ["jinja2"]
|
||||
dependencies = [
|
||||
"python-docx",
|
||||
"jinja2",
|
||||
"lxml",
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
python-docx = "^1.1.2"
|
||||
docxcompose = "^1.4.0"
|
||||
jinja2 = "^3.1.4"
|
||||
black = "^24.4.2"
|
||||
twine = "^6.1.0"
|
||||
[project.optional-dependencies]
|
||||
subdoc = ["docxcompose"]
|
||||
docs = ["Sphinx", "sphinxcontrib-napoleon"]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"mypy >=1.18.2; python_version >= '3.9'",
|
||||
"lxml-stubs >=0.5.1; python_version >= '3.9'",
|
||||
"flake8 >=7.3.0; python_version >= '3.9'"
|
||||
]
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
flake8 = "^7.1.0"
|
||||
[project.urls]
|
||||
homepage = "https://github.com/elapouya/python-docx-template"
|
||||
repository = "https://github.com/elapouya/python-docx-template.git"
|
||||
document = "https://docxtpl.readthedocs.org"
|
||||
|
||||
[tool.poetry]
|
||||
version = "0.0.0"
|
||||
|
||||
[tool.poetry.requires-plugins]
|
||||
poetry-dynamic-versioning = { version = ">=1.0.0,<2.0.0", extras = ["plugin"] }
|
||||
|
||||
[tool.poetry-dynamic-versioning]
|
||||
enable = true
|
||||
|
||||
[tool.poetry-dynamic-versioning.from-file]
|
||||
source = "docxtpl/__init__.py"
|
||||
pattern = '__version__ = "(.+)"'
|
||||
|
||||
[tool.mypy]
|
||||
pretty = true
|
||||
python_version = "3.9"
|
||||
check_untyped_defs = true
|
||||
warn_unused_ignores = true
|
||||
exclude = ["docs", "build", "setup.py"]
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = ["docxcompose.*"]
|
||||
ignore_missing_imports = true
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
requires = ["poetry-core", "poetry-dynamic-versioning >=1.0.0,<2.0.0"]
|
||||
build-backend = "poetry_dynamic_versioning.backend"
|
||||
|
||||
8
setup.py
8
setup.py
@ -1,8 +1,9 @@
|
||||
from setuptools import setup
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
# To register onto Pypi :
|
||||
# python setup.py sdist bdist_wheel upload
|
||||
|
||||
@ -61,6 +62,7 @@ setup(
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
],
|
||||
keywords="jinja2",
|
||||
url="https://github.com/elapouya/python-docx-template",
|
||||
@ -68,8 +70,8 @@ setup(
|
||||
license="LGPL-2.1-only",
|
||||
license_files=[],
|
||||
packages=["docxtpl"],
|
||||
install_requires=["python-docx>=1.1.1", "docxcompose", "jinja2", "lxml"],
|
||||
extras_require={"docs": ["Sphinx", "sphinxcontrib-napoleon"]},
|
||||
install_requires=["python-docx>=1.1.1", "jinja2", "lxml"],
|
||||
extras_require={"docs": ["Sphinx", "sphinxcontrib-napoleon"], "subdoc": ["docxcompose"]},
|
||||
eager_resources=["docs"],
|
||||
zip_safe=False,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user