Merge lp:~allenap/commandant/readme-to-rest into lp:commandant

Proposed by Gavin Panella
Status: Merged
Approved by: Jamu Kakar
Approved revision: 44
Merged at revision: 43
Proposed branch: lp:~allenap/commandant/readme-to-rest
Merge into: lp:commandant
Diff against target: 335 lines (+53/-53)
1 file modified
README (+53/-53)
To merge this branch: bzr merge lp:~allenap/commandant/readme-to-rest
Reviewer Review Type Date Requested Status
Jamu Kakar Approve
Review via email: mp+109888@code.launchpad.net

Commit message

Ensure README is valid reST, and renders without warnings.

Description of the change

Fix README so that it's valid reST. I've already uploaded the README in the branch by hand to PyPI and confirmed it works okay there (see http://pypi.python.org/pypi/commandant).

To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :

This is great, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README'
--- README 2010-06-12 13:56:44 +0000
+++ README 2012-06-12 17:11:25 +0000
@@ -27,18 +27,18 @@
2751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.2751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2828
29On Ubuntu systems, the complete text of the GNU General Public29On Ubuntu systems, the complete text of the GNU General Public
30Version 2 License is in `/usr/share/common-licenses/GPL-2'.30Version 2 License is in ``/usr/share/common-licenses/GPL-2``.
3131
3232
33Using Commandant33Using Commandant
34================34================
3535
36Commandant can be used as a command runner. The bin/commandant36Commandant can be used as a command runner. The ``bin/commandant``
37program can present an application made up of commands and help37program can present an application made up of commands and help topics
38topics grouped together in a directory. The 'example' program38grouped together in a directory. The ``example`` program described in
39described in the following sections is available in the39the following sections is available in the ``example`` directory. You
40extras/example directory. You can try it out from the current40can try it out from the current directory by running the following
41directory by running the following commands.41commands::
4242
43 $ alias example="bin/commandant example"43 $ alias example="bin/commandant example"
44 $ source example/tab-completion.sh44 $ source example/tab-completion.sh
@@ -48,12 +48,12 @@
48---------------------------48---------------------------
4949
50Commands are grouped into Commandant programs. A Commandant program50Commands are grouped into Commandant programs. A Commandant program
51is made up of an arbitrary number of commands stored in a directory.51is made up of an arbitrary number of commands stored in a directory::
5252
53 $ mkdir -p ~/example53 $ mkdir -p ~/example
5454
55An alias can be used to provide a name that can used to run commands55An alias can be used to provide a name that can used to run commands
56in the Commandant program.56in the Commandant program::
5757
58 $ alias example="commandant ~/example"58 $ alias example="commandant ~/example"
5959
@@ -61,8 +61,8 @@
61Getting help61Getting help
62------------62------------
6363
64Commands provides builtin 'help' and 'version' commands. Running64Commands provides builtin ``help`` and ``version`` commands. Running
65the example program by itself shows basic help information.65the example program by itself shows basic help information::
6666
67 $ example67 $ example
68 Commandant -- a framework for building command-oriented tools68 Commandant -- a framework for building command-oriented tools
@@ -72,21 +72,21 @@
72 commandant help commands List all commands72 commandant help commands List all commands
73 commandant help topics List all help topics73 commandant help topics List all help topics
7474
75Passing the 'commands' topic to the 'help' command lists the75Passing the ``commands`` topic to the ``help`` command lists the
76commands that are available, with a short summary about each one.76commands that are available, with a short summary about each one::
7777
78 $ example help commands78 $ example help commands
79 help Show help about a command or topic.79 help Show help about a command or topic.
80 version Show version of commandant.80 version Show version of commandant.
8181
82Passing the 'topics' topic to the 'help' command lists the help82Passing the ``topics`` topic to the ``help`` command lists the help
83topics that are available, with a short summary about each one.83topics that are available, with a short summary about each one::
8484
85 $ example help topics85 $ example help topics
86 commands Basic help for all commands.86 commands Basic help for all commands.
87 topics Topics list.87 topics Topics list.
8888
89The 'version' command shows the version of Commandant being used.89The ``version`` command shows the version of Commandant being used::
9090
91 $ example version91 $ example version
92 commandant 0.192 commandant 0.1
@@ -96,13 +96,13 @@
96----------------------------96----------------------------
9797
98One of the easiest ways to add a command to a Commandant program is98One of the easiest ways to add a command to a Commandant program is
99by creating a shell script and making it executable.99by creating a shell script and making it executable::
100100
101 $ echo -e '#!/bin/sh\necho Hello, world!' > ~/example/hello101 $ echo -e '#!/bin/sh\necho Hello, world!' > ~/example/hello
102 $ chmod +x ~/example/hello102 $ chmod +x ~/example/hello
103103
104The new 'hello' command in the 'example' program is now registered104The new ``hello`` command in the ``example`` program is now registered
105and ready to use.105and ready to use::
106106
107 $ example help commands107 $ example help commands
108 hello108 hello
@@ -110,7 +110,7 @@
110 version Show version of commandant.110 version Show version of commandant.
111111
112You should see 'Hello, world!' printed to your screen when you run112You should see 'Hello, world!' printed to your screen when you run
113it.113it::
114114
115 $ example hello115 $ example hello
116 Hello, world!116 Hello, world!
@@ -120,13 +120,13 @@
120-------------------------------------------------120-------------------------------------------------
121121
122Commandant will pass all arguments beyond the command name to the122Commandant will pass all arguments beyond the command name to the
123executable for that command.123executable for that command::
124124
125 $ echo -e '#!/bin/sh\necho $*' > ~/example/echo125 $ echo -e '#!/bin/sh\necho $*' > ~/example/echo
126 $ chmod +x ~/example/echo126 $ chmod +x ~/example/echo
127127
128Again, just by putting an executable file in the command directory,128Again, just by putting an executable file in the command directory,
129the new 'echo' command has been added to the 'example' program.129the new ``echo`` command has been added to the ``example`` program::
130130
131 $ example help commands131 $ example help commands
132 echo132 echo
@@ -134,7 +134,7 @@
134 help Show help about a command or topic.134 help Show help about a command or topic.
135 version Show version of commandant.135 version Show version of commandant.
136136
137The new 'echo' command will repeat whatever we tell it.137The new ``echo`` command will repeat whatever we tell it::
138138
139 $ example echo Hello there!139 $ example echo Hello there!
140 Hello there!140 Hello there!
@@ -143,12 +143,12 @@
143Providing help for commands143Providing help for commands
144---------------------------144---------------------------
145145
146The commands in the 'example' program have been very easy to add,146The commands in the ``example`` program have been very easy to add,
147but they could be easier to use. Commandant's builtin help system147but they could be easier to use. Commandant's builtin help system
148can be extended to provide help topics for user-provided commands.148can be extended to provide help topics for user-provided commands.
149Files in the command directory with a .txt extension, and with the149Files in the command directory with a .txt extension, and with the
150same name as a command, will be treated as help content for that150same name as a command, will be treated as help content for that
151command. Adding help content for the 'hello' command is quite easy.151command. Adding help content for the ``hello`` command is quite easy::
152152
153 $ cat ~/example/hello.txt153 $ cat ~/example/hello.txt
154 Greet the world!154 Greet the world!
@@ -156,7 +156,7 @@
156 Print 'Hello, world!' to the screen.156 Print 'Hello, world!' to the screen.
157157
158The first line in a help topic is used as a short description. This158The first line in a help topic is used as a short description. This
159short description is used when listing commands.159short description is used when listing commands::
160160
161 $ example help commands161 $ example help commands
162 echo162 echo
@@ -164,9 +164,9 @@
164 help Show help about a command or topic.164 help Show help about a command or topic.
165 version Show version of commandant.165 version Show version of commandant.
166166
167Notice that the 'hello' command uses the short description from the167Notice that the ``hello`` command uses the short description from the
168help topic. The complete help text can be seen by passing the168help topic. The complete help text can be seen by passing the
169command name to the 'help' command.169command name to the ``help`` command::
170170
171 $ example help hello171 $ example help hello
172 Print 'Hello, world!' to the screen.172 Print 'Hello, world!' to the screen.
@@ -175,9 +175,9 @@
175Providing a custom splash page175Providing a custom splash page
176------------------------------176------------------------------
177177
178The stock help text shown when the 'help' command is run points178The stock help text shown when the ``help`` command is run points
179users to the list of commands and help topics. It can be overridden179users to the list of commands and help topics. It can be overridden
180by providing a file called basic.txt.180by providing a file called basic.txt::
181181
182 $ cat ~/example/basic.txt182 $ cat ~/example/basic.txt
183 example -- A collection of command examples that work with Commandant.183 example -- A collection of command examples that work with Commandant.
@@ -187,8 +187,8 @@
187 example help commands List all commands187 example help commands List all commands
188 example help topics List all help topics188 example help topics List all help topics
189189
190The contents of this file are shown when the 'help' command is run190The contents of this file are shown when the ``help`` command is run
191without a topic.191without a topic::
192192
193 $ example help193 $ example help
194 example -- A collection of command examples that work with Commandant.194 example -- A collection of command examples that work with Commandant.
@@ -206,7 +206,7 @@
206topics, not bound to any command name. Files in the command206topics, not bound to any command name. Files in the command
207directory with a .txt extension, and with a name that doesn't match207directory with a .txt extension, and with a name that doesn't match
208any command name, will be treated as help topics. Adding help to208any command name, will be treated as help topics. Adding help to
209describe a concept, for example, is quite easy.209describe a concept, for example, is quite easy::
210210
211 $ cat ~/example/greetings.txt211 $ cat ~/example/greetings.txt
212 Greetings are a way to initiate communication.212 Greetings are a way to initiate communication.
@@ -221,15 +221,15 @@
221221
222As with help files for commands, the first line contains a short222As with help files for commands, the first line contains a short
223summary with help text following. The topic will now appear in the223summary with help text following. The topic will now appear in the
224topics list.224topics list::
225225
226 $ example help topics226 $ example help topics
227 commands Basic help for all commands.227 commands Basic help for all commands.
228 greetings Greetings are a way to initiate communication.228 greetings Greetings are a way to initiate communication.
229 topics Topics list.229 topics Topics list.
230230
231The help text can be seen by passing the topic name to the 'help'231The help text can be seen by passing the topic name to the ``help``
232command.232command::
233233
234 $ example help greetings234 $ example help greetings
235 Greeting (also called accosting) is a way for human beings (as well235 Greeting (also called accosting) is a way for human beings (as well
@@ -252,7 +252,7 @@
252Commandant loads commands from the command directory it imports252Commandant loads commands from the command directory it imports
253Python commands from files with a .py extension. The commands in253Python commands from files with a .py extension. The commands in
254the files need to subclass the Command class and need to be named254the files need to subclass the Command class and need to be named
255using the cmd_<name> naming convention.255using the cmd_<name> naming convention::
256256
257 $ cat example/rock-fact.py257 $ cat example/rock-fact.py
258 from bzrlib.commands import Command258 from bzrlib.commands import Command
@@ -266,9 +266,9 @@
266 print >>self.outf, "Rocks are really hard."266 print >>self.outf, "Rocks are really hard."
267267
268Just like with executable commands, adding a Python command is as268Just like with executable commands, adding a Python command is as
269easy as adding a file to the command directory. An 'outf' attribute269easy as adding a file to the command directory. An ``outf`` attribute
270will be set on the command object when it's run and should be used270will be set on the command object when it's run and should be used
271when printing text.271when printing text::
272272
273 $ example help commands273 $ example help commands
274 echo274 echo
@@ -278,10 +278,10 @@
278 version Show version of commandant.278 version Show version of commandant.
279279
280The new command is available using the name of the class, without280The new command is available using the name of the class, without
281the 'cmd_' part, and with underscores converted to dashes. The281the ``cmd_`` part, and with underscores converted to dashes. The
282doctring is used to provide builtin help. The first line is used as282doctring is used to provide builtin help. The first line is used as
283the summary and the subsequent content is used as the help text,283the summary and the subsequent content is used as the help text,
284just like in help files for executable commands.284just like in help files for executable commands::
285285
286 $ example help rock-fact286 $ example help rock-fact
287 This command prints a fascinating fact about rocks.287 This command prints a fascinating fact about rocks.
@@ -296,7 +296,7 @@
296One of the main advantages of writing Python commands is being able296One of the main advantages of writing Python commands is being able
297to express command-line argument and option parameters. bzrlib uses297to express command-line argument and option parameters. bzrlib uses
298this data to automatically provide parsing and integration with the298this data to automatically provide parsing and integration with the
299help system.299help system::
300300
301 $ cat example/fortune.py301 $ cat example/fortune.py
302 from random import randint302 from random import randint
@@ -335,7 +335,7 @@
335Commandant has builtin support for writing commands that need to run335Commandant has builtin support for writing commands that need to run
336in a Twisted reactor. Simply subclass TwistedCommand and implement336in a Twisted reactor. Simply subclass TwistedCommand and implement
337a command as you normally would. It's run() method will be called337a command as you normally would. It's run() method will be called
338inside a running reactor.338inside a running reactor::
339339
340 $ cat example/get-page.py340 $ cat example/get-page.py
341 from twisted.internet import reactor341 from twisted.internet import reactor
@@ -390,7 +390,7 @@
390390
391The first step is to create an entry point which registers commands391The first step is to create an entry point which registers commands
392and help topics and then subsequently runs your program. The392and help topics and then subsequently runs your program. The
393CommandController is both a registry and dispatching device:393CommandController is both a registry and dispatching device::
394394
395 from commandant import builtins395 from commandant import builtins
396 from commandant.controller import CommandController396 from commandant.controller import CommandController
@@ -413,9 +413,9 @@
413 controller.run(argv[1:])413 controller.run(argv[1:])
414414
415The name, version, summary and URL are used in generated help text.415The name, version, summary and URL are used in generated help text.
416The 'builtins' module contains the builtin 'help' and 'version'416The ``builtins`` module contains the builtin ``help`` and ``version``
417commands, and the 'basic', 'commands', 'hidden-commands' and417commands, and the ``basic``, ``commands``, ``hidden-commands`` and
418'topics' help topics.418``topics`` help topics.
419419
420420
421Registering application commands421Registering application commands
@@ -423,10 +423,10 @@
423423
424Commands can be grouped in a module and registered with the command424Commands can be grouped in a module and registered with the command
425controller. Just like in the examples above, command classes should425controller. Just like in the examples above, command classes should
426be named using the 'cmd_command_name' naming convention and will be426be named using the ``cmd_command_name`` naming convention and will be
427loaded automatically when the module is registered. If all the427loaded automatically when the module is registered. If all the
428commands in the examples above were grouped in an example.commands428commands in the examples above were grouped in an example.commands
429module they could be registered just like the builtin commands:429module they could be registered just like the builtin commands::
430430
431 from example import commands431 from example import commands
432432
@@ -438,7 +438,7 @@
438438
439In the examples above, help topics are text files in a directory.439In the examples above, help topics are text files in a directory.
440When embedding Commandant in an application, its easier to use440When embedding Commandant in an application, its easier to use
441Python for help topics:441Python for help topics::
442442
443 from commandant.help_topics import DocstringHelpTopic443 from commandant.help_topics import DocstringHelpTopic
444444
@@ -456,7 +456,7 @@
456456
457Registering help topics is just like registering commands. They can457Registering help topics is just like registering commands. They can
458be grouped in a module and registered with the command controller.458be grouped in a module and registered with the command controller.
459Topics should use the 'topic_document_name' naming convention.459Topics should use the ``topic_document_name`` naming convention::
460460
461 from example import help_topics461 from example import help_topics
462462
@@ -466,7 +466,7 @@
466Providing a custom splash page466Providing a custom splash page
467------------------------------467------------------------------
468468
469The stock help text shown when the 'help' command is run points469The stock help text shown when the ``help`` command is run points
470users to the list of commands and help topics that have been470users to the list of commands and help topics that have been
471registered with the controller. If a 'topic_basic' help topic has471registered with the controller. If a ``topic_basic`` help topic has
472been registered it will be shown instead of the builtin splash page.472been registered it will be shown instead of the builtin splash page.

Subscribers

People subscribed via source and target branches