~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/doc_generate/autodoc_rstx.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-07 16:05:27 UTC
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060607160527-2b3649154d0e2e84
more code cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
73
73
        cmd_help = cmd_object.help()
74
74
        if cmd_help:
75
75
            firstline = cmd_help.split('\n', 1)[0]
76
 
            usage = cmd_object._usage()
 
76
            usage = bzrlib.help.command_usage(cmd_object)
77
77
            tmp = '**%s**\n\t%s\n\n' % (usage, firstline)
78
78
            output = output + tmp
79
79
        else:
97
97
 
98
98
def format_command (params, cmd, name):
99
99
    """Provides long help for each public command"""
100
 
    usage = cmd._usage()
 
100
    usage = bzrlib.help.command_usage(cmd)
101
101
    subsection_header = """
102
102
%s
103
103
%s
104
104
::
105
105
""" % (usage, '-'*len(usage))
106
106
 
107
 
    docsplit = cmd.help().split('\n')
108
 
    doc = '\n'.join([' '*4+line for line in docsplit])
 
107
    docsplit = cmd.__doc__.split('\n')
 
108
    doc = '\n'.join([' '*4 + docsplit[0]] + docsplit[1:])
109
109
        
110
110
    option_str = ""
111
111
    options = cmd.options()
112
112
    if options:
113
113
        option_str = "\n    Options:\n"
114
114
        for option_name, option in sorted(options.items()):
115
 
            for name, short_name, argname, help in option.iter_switches():
116
 
                l = '    --' + name
117
 
                if argname is not None:
118
 
                    l += ' ' + argname
119
 
                if short_name:
120
 
                    assert len(short_name) == 1
121
 
                    l += ', -' + short_name
122
 
                l += (30 - len(l)) * ' ' + (help or '')
123
 
                # TODO: Split help over multiple lines with
124
 
                # correct indenting and wrapping.
125
 
                wrapped = textwrap.fill(l, initial_indent='',
126
 
                                        subsequent_indent=30*' ')
127
 
                option_str = option_str + wrapped + '\n'       
128
 
 
129
 
    aliases_str = ""
130
 
    if cmd.aliases:
131
 
        if len(cmd.aliases) > 1:
132
 
            aliases_str += '\n    Aliases: '
133
 
        else:
134
 
            aliases_str += '\n    Alias: '
135
 
        aliases_str += ', '.join(cmd.aliases)
136
 
        aliases_str += '\n'
137
 
 
138
 
    see_also_str = ""
139
 
    see_also = cmd.get_see_also()
140
 
    if see_also:
141
 
        see_also_str += '\n    See also: '
142
 
        see_also_str += ', '.join(see_also)
143
 
        see_also_str += '\n'
144
 
 
145
 
    return subsection_header + option_str + aliases_str + see_also_str + "\n" + doc + "\n"
 
115
            l = '        --' + option_name
 
116
            if option.type is not None:
 
117
                l += ' ' + option.argname.upper()
 
118
            short_name = option.short_name()
 
119
            if short_name:
 
120
                assert len(short_name) == 1
 
121
                l += ', -' + short_name
 
122
            l += (30 - len(l)) * ' ' + option.help
 
123
            # TODO: Split help over multiple lines with
 
124
            # correct indenting and wrapping.
 
125
            wrapped = textwrap.fill(l, initial_indent='',
 
126
                                    subsequent_indent=30*' ')
 
127
            option_str = option_str + wrapped + '\n'       
 
128
    return subsection_header + option_str + "\n" + doc + "\n"
146
129
 
147
130
 
148
131
##
155
138
.. Generation time: %(timestamp)s
156
139
 
157
140
=============================================
158
 
Man page for Bazaar (%(bzrcmd)s)
 
141
Man page for %(bzrcmd)s (bazaar-ng)
159
142
=============================================
160
143
 
161
144
:Date: %(datestamp)s
170
153
rstx_head = """\
171
154
Name
172
155
====
173
 
Bazaar (%(bzrcmd)s) - next-generation distributed version control
 
156
%(bzrcmd)s - bazaar-ng next-generation distributed version control
174
157
 
175
158
Synopsis
176
159
========
183
166
 
184
167
Description
185
168
===========
186
 
Bazaar (or **%(bzrcmd)s**) is a project of Canonical to develop
 
169
bazaar-ng (or **%(bzrcmd)s**) is a project of Canonical to develop
187
170
an open source distributed version control system that is powerful,
188
171
friendly, and scalable. Version control means a system
189
172
that keeps track of previous revisions of software source code
195
178
Environment
196
179
===========
197
180
**BZRPATH**
198
 
                Path where **%(bzrcmd)s** is to look for shell plugin external commands.
 
181
                Path where **%(bzrcmd)s** is to look for external command.
199
182
 
200
 
**BZR_EMAIL**
 
183
**BZREMAIL**
201
184
                E-Mail address of the user. Overrides default user config.
202
185
 
203
186
**EMAIL**
204
 
                E-Mail address of the user. Overrides default user config.
205
 
 
206
 
**BZR_EDITOR**
207
 
                Editor for editing commit messages
208
 
 
209
 
**EDITOR**
210
 
                Editor for editing commit messages
211
 
 
212
 
**BZR_PLUGIN_PATH**
213
 
                Paths where bzr should look for plugins
214
 
 
215
 
**BZR_HOME**
216
 
                Home directory for bzr
217
 
 
 
187
                E-Mail address of the user. Overriddes default user config.
218
188
 
219
189
Files
220
190
=====
221
191
 
222
 
**On Linux**:  ``~/.bazaar/bazaar.conf``
 
192
**On Linux**:  ``~/.bazaar/bazaar.conf/``
223
193
 
224
194
**On Windows**: ``C:\\Documents and Settings\\username\\Application Data\\bazaar\\2.0\\bazaar.conf``
225
195
 
226
 
Contains the user's default configuration. The section ``[DEFAULT]`` is
227
 
used to define general configuration that will be applied everywhere.
228
 
The section ``[ALIASES]`` can be used to create command aliases for
229
 
commonly used options.
230
 
 
231
 
A typical config file might look something like::
232
 
 
233
 
  [DEFAULT]
234
 
  email=John Doe <jdoe@isp.com>
235
 
 
236
 
  [ALIASES]
237
 
  commit = commit --strict
238
 
  log10 = log --short -r -10..-1
 
196
Contains the default user config. Only one section, ``[DEFAULT]`` is allowed.
 
197
A typical default config file may be similiar to::
 
198
 
 
199
    [DEFAULT]
 
200
    email=John Doe <jdoe@isp.com>
239
201
 
240
202
 
241
203
See also
245
207
--------------------
246
208
 
247
209
.. Contents::
248
 
    **Index**
 
210
        **Index**
249
211
"""