Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 117 lines (90 sloc) 3.239 kb
7644159 @bigjason First real pass at documentation.
authored
1 -------
4079bdf @bigjason Added a README.
authored
2 Summary
3 -------
95cbd68 @bigjason Readme update.
authored
4 DataTree is a library for creating structured documents in python. Inspired by
5 `ruby builder`_ but with the goal of reducing the amount of line noise while
6 remaining "pythonic". As an added bonus the tree can be output
1f6d034 @bigjason Consolidation of BaseNode into Node. Some documentation.
authored
7 to to any structured format (with XML, JSON and YAML supported in the library).
8
95cbd68 @bigjason Readme update.
authored
9 .. note::
10 More documentation is coming soon but for now a very basic rough draft can be
11 found at `datatree.readthedocs.org <http://datatree.readthedocs.org/>`_.
3000d0d @bigjason Readme update
authored
12
1f6d034 @bigjason Consolidation of BaseNode into Node. Some documentation.
authored
13 ------------
14 Installation
15 ------------
16 You can install via `PyPi <http://pypi.python.org/pypi/datatree/>`_ or direct
912e565 @bigjason API and other updates related to work on adding namespaces.
authored
17 from the github_ repository.
1f6d034 @bigjason Consolidation of BaseNode into Node. Some documentation.
authored
18
19 To install with pip::
20
21 $ pip install datatree
22
23 To install with easy_install::
24
25 $ easy_install datatree
4079bdf @bigjason Added a README.
authored
26
6084bce @bigjason Final changes and document updates.
authored
27 ---------------------
28 About the 0.2.0 Alpha
29 ---------------------
30 Version 0.2.0 is about 70% complete. The remaining tasks are:
31
32 #. Implement xml namespaces.
33 #. Finish updating documentation to the new API.
34 #. Make the ``Node`` callable the same as the ``node`` method.
35
36 Installing the Alpha
37 --------------------
38 You can install the alpha with pip directly from github using the command::
39
5747c56 @bigjason README fix.
authored
40 $ pip install -e git://github.com/bigjason/datatree.git@v0.2.alpha.1#egg=datatree
6084bce @bigjason Final changes and document updates.
authored
41
7644159 @bigjason First real pass at documentation.
authored
42 -------
957b016 @bigjason Working version of the new pluggable renderer architecture.
authored
43 Example
44 -------
912e565 @bigjason API and other updates related to work on adding namespaces.
authored
45 A small example::
957b016 @bigjason Working version of the new pluggable renderer architecture.
authored
46
0e1ac90 @bigjason Fixed example
authored
47 from datatree import Tree, Node
957b016 @bigjason Working version of the new pluggable renderer architecture.
authored
48
7644159 @bigjason First real pass at documentation.
authored
49 tree = Tree()
f1e1766 @bigjason Documentation updates.
authored
50 with tree.node("author") as author:
51 author.node('name', 'Terry Pratchett')
52 author.node('genre', 'Fantasy/Comedy')
53 author.comment("Only 2 books listed")
54 with author.node('novels', count=2) as novels:
55 novels.node('novel', 'Small Gods', year=1992)
56 novels.node('novel', 'The Fifth Elephant', year=1999)
57 novels.node("novel", "Guards! Guards!", year=1989)
957b016 @bigjason Working version of the new pluggable renderer architecture.
authored
58
7644159 @bigjason First real pass at documentation.
authored
59 print tree(pretty=True)
957b016 @bigjason Working version of the new pluggable renderer architecture.
authored
60
7644159 @bigjason First real pass at documentation.
authored
61 Which produces the XML::
957b016 @bigjason Working version of the new pluggable renderer architecture.
authored
62
63 <author>
fd98a95 @bigjason Support for comments added to XmlRenderer
authored
64 <name>Terry Pratchett</name>
65 <genre>Fantasy/Comedy</genre>
66 <!-- Only 2 books listed -->
67 <novels count="2">
68 <novel year="1992">Small Gods</novel>
69 <novel year="1999">The Fifth Elephant</novel>
50f91eb @bigjason Updated example to show add operator
authored
70 <novel year="1989">Guards! Guards!</novel>
fd98a95 @bigjason Support for comments added to XmlRenderer
authored
71 </novels>
957b016 @bigjason Working version of the new pluggable renderer architecture.
authored
72 </author>
73
7644159 @bigjason First real pass at documentation.
authored
74 Or the JSON::
c2da8e1 @bigjason Fixed parameter problem with how the dictrenderer worked.
authored
75
76 {
15bc47c @bigjason Duplicates are now handled properly by the dict renderer and json
authored
77 "author": {
fd98a95 @bigjason Support for comments added to XmlRenderer
authored
78 "genre": "Fantasy/Comedy",
50f91eb @bigjason Updated example to show add operator
authored
79 "name": "Terry Pratchett",
15bc47c @bigjason Duplicates are now handled properly by the dict renderer and json
authored
80 "novels": [
81 "Small Gods",
50f91eb @bigjason Updated example to show add operator
authored
82 "The Fifth Elephant",
83 "Guards! Guards!"
15bc47c @bigjason Duplicates are now handled properly by the dict renderer and json
authored
84 ]
85 }
c2da8e1 @bigjason Fixed parameter problem with how the dictrenderer worked.
authored
86 }
87
7644159 @bigjason First real pass at documentation.
authored
88 Or the YAML::
fccd789 @bigjason Added optional yaml support
authored
89
90 author:
fd98a95 @bigjason Support for comments added to XmlRenderer
authored
91 genre: Fantasy/Comedy
fccd789 @bigjason Added optional yaml support
authored
92 name: Terry Pratchett
50f91eb @bigjason Updated example to show add operator
authored
93 novels: [Small Gods, The Fifth Elephant, Guards! Guards!]
fccd789 @bigjason Added optional yaml support
authored
94
95
4079bdf @bigjason Added a README.
authored
96 License
97 -------
bcfef57 @bigjason Changed license to Apache License, Version 2.0
authored
98 This work is licensed under the `Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0.html>`_.
4079bdf @bigjason Added a README.
authored
99
1f6d034 @bigjason Consolidation of BaseNode into Node. Some documentation.
authored
100 Souce Code
101 ----------
102 The source code can be found on github_.
103
4e6e368 @bigjason Small docs update
authored
104 Feedback
105 --------
106 I welcome any and all constructive feedback. Feel free to contact me (Jason Webb) at
f1e1766 @bigjason Documentation updates.
authored
107 `www.bigjason.com <http://www.bigjason.com/>`_ or (preferably) on twitter
4e6e368 @bigjason Small docs update
authored
108 `@bigjasonwebb <http://www.twitter.com/BigJasonWebb>`_.
109
dbaceac @bigjason Version bump and prep for 0.8.1 release
authored
110 Contributing
111 ------------
112 Contributions are welcome. Just fork on github_ and I will try to be as responsive
113 as possible.
114
1f6d034 @bigjason Consolidation of BaseNode into Node. Some documentation.
authored
115
116 .. _ruby builder: http://builder.rubyforge.org/
117 .. _github: https://github.com/bigjason/datatree
Something went wrong with that request. Please try again.