Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
568 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
exclude: tests/fixtures | ||
|
||
repos: | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v2.21.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
build: | ||
image: latest | ||
|
||
python: | ||
version: 3.8 | ||
pip_install: true | ||
extra_requirements: | ||
- docs,cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
21.x (2021-xx-xx) | ||
----------------- | ||
|
||
- Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
livehtml: | ||
sphinx-autobuild -b html . _build --ignore "api/reference/*" --watch ../ | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Data Bindings | ||
============= | ||
|
||
All the xsdata :ref:`XML <xsdata:XML Binding>` and :ref:`JSON <xsdata:JSON Binding>` | ||
bindings are available. There is an extra requirement to specify the class type of | ||
the data models to the :class:`~xsdata.formats.dataclass.context.XmlContext` that | ||
among other stuff also acts as a compatibility layer between :mod:`python:dataclasses` | ||
and :doc:`attrs <attrs:overview>`. | ||
|
||
|
||
|
||
Specify ClassType | ||
----------------- | ||
|
||
.. code-block:: python | ||
:emphasize-lines: 7 | ||
>>> from xsdata.formats.dataclass.parsers import XmlParser | ||
>>> from xsdata.formats.dataclass.parsers import JsonParser | ||
>>> from xsdata.formats.dataclass.serializers import XmlSerializer | ||
>>> from xsdata.formats.dataclass.serializers import JsonSerializer | ||
>>> from xsdata.formats.dataclass.context import XmlContext | ||
... | ||
>>> context = XmlContext(class_type="attrs") # Specify class type attrs | ||
>>> xml_parser = XmlParser(context=context) | ||
>>> xml_serializer = XmlSerializer(context=context) | ||
>>> json_parser = JsonParser(context=context) | ||
>>> json_serializer = JsonSerializer(context=context) | ||
Binding Shortcuts | ||
----------------- | ||
|
||
For convenience this plugin comes with subclasses for all the xsdata binding modules | ||
with the attrs context auto initialized.. | ||
|
||
.. code-block:: python | ||
>>> from xsdata_attrs.bindings import XmlContext | ||
>>> from xsdata_attrs.bindings import XmlParser | ||
>>> from xsdata_attrs.bindings import XmlSerializer | ||
>>> from xsdata_attrs.bindings import JsonParser | ||
>>> from xsdata_attrs.bindings import JsonSerializer | ||
>>> from xsdata_attrs.bindings import UserXmlParser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Changelog | ||
========= | ||
|
||
.. include:: ../CHANGES.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Code Generation | ||
=============== | ||
|
||
All the xsdata :ref:`cli <xsdata:Command Line>` features are available. You only need | ||
to specify **attrs** as the output format | ||
|
||
|
||
Example from Schema | ||
------------------- | ||
|
||
.. code:: console | ||
$ xsdata tests/fixtures/schemas/po.xsd --output attrs --package tests.fixtures.po.models --structure-style single-package | ||
Parsing schema po.xsd | ||
Compiling schema po.xsd | ||
Builder: 6 main and 1 inner classes | ||
Analyzer input: 6 main and 1 inner classes | ||
Analyzer output: 5 main and 1 inner classes | ||
Generating package: init | ||
Generating package: tests.fixtures.po.models | ||
Generated Models | ||
---------------- | ||
|
||
.. literalinclude:: /../tests/fixtures/po/models.py | ||
:language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
# -- Path setup -------------------------------------------------------------- | ||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
# import os | ||
# import sys | ||
# sys.path.insert(0, os.path.abspath('.')) | ||
# -- Project information ----------------------------------------------------- | ||
|
||
project = "xsdata-attrs" | ||
copyright = "2021, Christodoulos Tsoulloftas" | ||
author = "Christodoulos Tsoulloftas" | ||
|
||
# The full version, including alpha/beta/rc tags | ||
release = "21.7" | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.intersphinx", | ||
] | ||
|
||
intersphinx_mapping = { | ||
"python": ("https://docs.python.org/3", None), | ||
"lxml": ("https://lxml.de/apidoc/", None), | ||
"xsdata": ("https://xsdata.readthedocs.io/en/latest/", None), | ||
"attrs": ("https://www.attrs.org/en/stable/", None), | ||
} | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ["_templates"] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = "furo" | ||
html_favicon = "_static/favicon.png" | ||
html_logo = "_static/logo.svg" | ||
html_theme_options = { | ||
"sidebar_hide_name": True, | ||
} | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ["_static"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. include:: ../README.rst | ||
:start-line: 3 | ||
|
||
Why attrs? | ||
========== | ||
|
||
Attrs is the original python data class without boilerplate with a huge following. It | ||
comes with features not found in the stdlib dataclasses, that are worth exploring in | ||
the near future. | ||
|
||
It's so similar to dataclasses that also makes it the perfect candidate to test the | ||
xsdata's plugin hooks. | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:hidden: | ||
|
||
installation | ||
codegen | ||
bindings | ||
changelog | ||
GitHub Repository <https://github.com/tefra/xsdata-attrs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Installation | ||
============ | ||
|
||
Install using pip | ||
----------------- | ||
|
||
The recommended method is to use a virtual environment. | ||
|
||
.. code-block:: console | ||
$ pip install xsdata-attrs[cli] | ||
.. hint:: | ||
|
||
- Install the cli requirements for the code generator | ||
|
||
In order to use the latest updates you can also | ||
install directly from the git repo. | ||
|
||
.. code-block:: console | ||
$ pip install git+https://github.com/tefra/xsdata-attrs@master#egg=xsdata[cli] | ||
Install using conda | ||
------------------- | ||
|
||
.. code-block:: console | ||
$ conda install -c conda-forge xsdata-attrs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=. | ||
set BUILDDIR=_build | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.http://sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,6 @@ docs = | |
furo | ||
sphinx | ||
sphinx-autobuild | ||
sphinxcontrib-programoutput | ||
test = | ||
codecov | ||
lxml | ||
|
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from tests.fixtures.po.models import ( | ||
Items, | ||
PurchaseOrderType, | ||
Usaddress, | ||
Comment, | ||
PurchaseOrder, | ||
) | ||
|
||
__all__ = [ | ||
"Items", | ||
"PurchaseOrderType", | ||
"Usaddress", | ||
"Comment", | ||
"PurchaseOrder", | ||
] |
Oops, something went wrong.