Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tefra committed Aug 3, 2021
1 parent 8e880f5 commit 44797c5
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 33 deletions.
25 changes: 0 additions & 25 deletions docs/_static/config.sample.xml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/api/codegen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Generator Config
The configuration offers more advance options to further tail the output to your needs,
like naming conventions and aliases.

.. literalinclude:: /_static/config.sample.xml
.. literalinclude:: /_build/config.sample.xml
:language: xml

.. currentmodule:: xsdata.models.config
Expand Down
43 changes: 43 additions & 0 deletions docs/faq.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
**************************
Frequently Asked Questions
**************************



Why are all properties marked as optional?
------------------------------------------

We rely on the fields ordering for all binding procedures and due to the following
limitation we have to mark even required fields as optional.

..
TypeError will be raised if a field without a default value follows a field
with a default value. This is true whether this occurs in a single class, or as
a result of class inheritance.

Source: :mod:`python:dataclasses`

In Python 3.10 dataclasses introduced a new directive `kw_only` that resolves the above
limitation and xsdata handling. Read :ref:`more <Dataclasses Features>`

If you can't update just yet please check the `attrs <https://pypi.org/project/xsdata-attrs/>`_ plugin!


Why are elements out of order?
------------------------------

There are a few cases when elements can appear in any order. The default simplified
models don't have a way to store the original order of the elements in a document.

Repeatable choice elements is one of them.

.. literalinclude:: /../tests/fixtures/compound/schema.xsd
:language: xml
:lines: 1-9

In order to maintain the original order between roundtrip conversions you need to
enable compound fields. Compound fields are group fields and can be used to wrap
mixed context elements, repeatable choice elements or complex sequential elements.

Read :ref:`more <Compound Fields>`
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
examples
data-types
api
faq
changelog


Expand Down
14 changes: 14 additions & 0 deletions docs/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,26 @@ Wildcards can have a normal uri namespace or use one of xml schema generics.
metadata={
"type": "Wildcard",
"namespace": "##any",
"choices": (
{
"name": "DSAKeyValue",
"type": DsakeyValue,
"namespace": "http://www.w3.org/2000/09/xmldsig#",
},
{
"name": "RSAKeyValue",
"type": RsakeyValue,
"namespace": "http://www.w3.org/2000/09/xmldsig#",
},
),
}
)
This type of field accepts any primitive value or an another dataclass instance or a
generic :class:`~xsdata.formats.dataclass.models.generics.AnyElement` instance.

This type optionally can have a list of acceptable elements similar to compound fields,
otherwise during binding the parsers will try to find a suitable model automatically.

Type: Attributes
~~~~~~~~~~~~~~~~
Expand Down
7 changes: 3 additions & 4 deletions tests/fixtures/stripe/.xsdata.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Config xmlns="http://pypi.org/project/xsdata" version="21.6">
<Config xmlns="http://pypi.org/project/xsdata" version="21.8">
<Output maxLineLength="79">
<Package>tests.fixtures.stripe.models.balance</Package>
<Format repr="true" eq="true" order="true" unsafeHash="false" frozen="true">dataclasses</Format>
<Format repr="true" eq="true" order="true" unsafeHash="false" frozen="true" slots="false" kwOnly="false">dataclasses</Format>
<Structure>single-package</Structure>
<DocstringStyle>reStructuredText</DocstringStyle>
<RelativeImports>true</RelativeImports>
Expand All @@ -15,6 +15,5 @@
<ModuleName case="snakeCase" safePrefix="mod"/>
<PackageName case="snakeCase" safePrefix="pkg"/>
</Conventions>
<Aliases>
</Aliases>
<Aliases/>
</Config>
3 changes: 1 addition & 2 deletions tests/integration/test_stripe.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import sys

from click.testing import CliRunner

Expand All @@ -15,9 +16,7 @@


def test_json_documents():

filepath = fixtures_dir.joinpath("stripe")
package = "tests.fixtures.series"
runner = CliRunner()
result = runner.invoke(
cli,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ basepython = python3.8
extras = docs,cli
changedir = docs
commands =
xsdata init-config _static/config.sample.xml
xsdata init-config _build/config.sample.xml
sphinx-build -b html . _build

[testenv:build]
Expand Down

0 comments on commit 44797c5

Please sign in to comment.