Skip to content

Commit

Permalink
docs: Update docstrings (#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
tefra committed May 7, 2024
1 parent 052df9a commit 874a6d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 1 addition & 2 deletions tests/formats/dataclass/serializers/writers/test_lxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

from tests import fixtures_dir
from tests.fixtures.books.fixtures import books
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.serializers import TreeSerializer, XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig
from xsdata.formats.dataclass.serializers.tree import TreeSerializer
from xsdata.formats.dataclass.serializers.writers import (
LxmlEventWriter,
)
Expand Down
20 changes: 19 additions & 1 deletion xsdata/formats/dataclass/serializers/tree.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
from dataclasses import dataclass
from typing import Any, Dict, Optional

from lxml.etree import ElementTree

from xsdata.formats.dataclass.serializers.mixins import EventGenerator
from xsdata.formats.dataclass.serializers.writers.lxml import LxmlTreeBuilder
from xsdata.utils import namespaces


@dataclass
class TreeSerializer(EventGenerator):
def render(self, obj: Any, ns_map: Optional[Dict] = None):
"""Lxml tree serializer for data classes.
Args:
config: The serializer config instance
context: The models context instance
"""

def render(self, obj: Any, ns_map: Optional[Dict] = None) -> ElementTree:
"""Serialize the input model instance to a lxml etree instance.
Args:
obj: The input model instance to serialize
ns_map: A user defined namespace prefix-URI map
Returns:
The element tree instance.
"""
builder = LxmlTreeBuilder(
config=self.config,
ns_map=namespaces.clean_prefixes(ns_map) if ns_map else {},
Expand Down

0 comments on commit 874a6d2

Please sign in to comment.