-
Notifications
You must be signed in to change notification settings - Fork 39
/
librarytemplate_howto.txt
174 lines (113 loc) · 5.1 KB
/
librarytemplate_howto.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
==================================================
How to package a generateDS.py generated library
==================================================
:author: Dave Kuhlman
:address: dkuhlman@rexx.com
http://www.rexx.com/~dkuhlman
.. version
:revision: 2.7c
.. version
:date: |date|
.. |date| date:: %B %d, %Y
Introduction
============
This document explains how to use the generateDS.py library
template to create a package enabling you to distribute a module
generated with generateDS.py. This package and the instructions
below will help you to create the following:
- A directory structure in which to hang things.
- A directory for sample scripts (sample_code/)
- A directory for sample XML instance documents
- A directory for schemas
- A (mostly empty file in which to place utility functions to help
with the use of your generated module
- A script (quick_start.py) that does a bit of name replacement
- A directory for documentation containing some boiler plate
material and also a set-up for generating document in various
formats (for example HTML, LaTeX, PDF) with Sphinx
The latest copy of these instructions is here:
http://www.rexx.com/~dkuhlman/librarytemplate_howto.html
and the template package itself is here:
http://www.rexx.com/~dkuhlman/librarytemplate0-1.0a.zip
These instructions assume the name "peach" as the name of the
schema. You should replace "peach" in these instructions with the
name of your schema.
Find out more about generateDS.py here:
http://www.rexx.com/~dkuhlman/generateDS.html
You will need to install Sphinx in order to build the documentation
in your package. Learn about Sphinx here: http://sphinx.pocoo.org/.
Details
=======
In the instructions that follow, I'll assume that the name of your
XML schema is "peach" and that the name of the module that you
generate using ``generateDS.py`` will be "peachlib".
Follow these steps:
1. Unroll the library template (librarytemplate-x.y.zip), for
example::
$ unzip librarytemplate-1.0a.zip
2. Rename the top-level directory created by the previous step, for
example:
$ mv librarytemplate-x.y peachlib-1.0a
Or, on MS Windows:
$ rename librarytemplate-x.y peachlib-1.0a
3. Go to the new directory. For example::
$ cd peachlib-1.0a
4. Copy your generated modules into this directory. Suggested name
is ``{schema_name}lib.py``. For example ``peachlib.py``.
5. Run ``quick_start.py`` (which is in the top level directory).
``quick_start.py`` makes changes in the boiler plate provided by
librarytemplate; it changes occurrences of "{{schema_name}}" to
the name of your schema, which is entered on the command line.
For example::
$ python quick_start.py --help
$ python quick_start.py --schema-name=peach
6. Add some more content to the documentation. It is likely that
you will want to make additions and changes in the following
files:
- README.txt
- docs/intro.txt
- sample_code/README.txt
7. Generate the documentation. This step requires Sphinx.
First, add the top-level directory of your distribution to your
PYTHONPATH environment variable. Sphinx needs to be able to
import your library module (peachlib.py). Then, go to
the ./docs/ directory and build the HTML documentation::
$ cd docs
$ make clean
$ make html
You also can build other forms of documentation, e.g. LaTeX and
PDF. See the Sphinx documentation, or type::
$ make help
By default, the generated documentation for the module includes
lists of the member functions for each class. You can change
this by removing the ``:members:`` and ``:undoc-members:``
options from the file ``docs/module_contents.txt``, and then
run::
$ make clean
$ make html
again.
8. Add some functionality and sample code. In particular:
- Add some helper functions in peachlibutils.py.
- Add example applications in directory sample_code/.
Suggestions: (1) Rename and add code to
sample_code/example01.txt. (2) Generate a subclass module
(using the "-s" command line option with ``generateDS.py``,
then add a bit of code to a few of the subclasses.
- List and describe any example applications that you add in the
file sample_code/README.txt.
9. It might be a good idea to include the XML schema from which you
generated your library module. You can copy the schema(s) to
the schemas/ directory, and/or add a link in file
schemas/README.txt that points to a location where it can be
found.
10. Create a distribution file. For example, use either::
$ tar czf peachlib-1.0a.tar.gz peachlib-1.0a
or::
$ zip -r peachlib-1.0a.zip peachlib-1.0a
In order to avoid including backup files and compiled Python
modules, you might want to use something like the following::
$ zip -r peachlib-1.0a.zip peachlib-1.0a -x \*~ -x \*.pyc
See the man page on zip for more on the -x command line option.
The backslash avoids the shell filename substitution. Adjust
this command for your needs. For example, you may need to use
"\*.bak" instead of "\*~".