Skip to content

Commit

Permalink
Regenerated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Aug 3, 2018
1 parent ef07440 commit 5fb16ae
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
.PHONY: default

default:
make doc/plac.pdf doc/plac.html
doc/plac.pdf: doc/plac.rst doc/plac_core.rst doc/plac_adv.rst
cd doc; rst2pdf --footer=###Page### plac.rst
doc/plac.html:
cd doc; rst2html.py --stylesheet=../df.css plac.rst plac.html
cd doc && rst2html.py --stylesheet=../df.css plac.rst plac.html && rst2pdf --footer=###Page### plac.rst
dist:
python3 setup.py build sdist bdist_wheel
upload:
Expand Down
54 changes: 37 additions & 17 deletions doc/plac.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<title></title>
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>plac.rst</title>
<style type="text/css">

.first {
Expand Down Expand Up @@ -424,13 +424,13 @@ <h1><a class="toc-backref" href="#id15">Plac: Parsing the Command Line the Easy
</tr>
<tr class="field"><th class="field-name">E-mail:</th><td class="field-body"><a class="reference external" href="mailto:michele.simionato&#64;gmail.com">michele.simionato&#64;gmail.com</a></td>
</tr>
<tr class="field"><th class="field-name">Date:</th><td class="field-body">June 2016</td>
<tr class="field"><th class="field-name">Date:</th><td class="field-body">August 2018</td>
</tr>
<tr class="field"><th class="field-name">Download page:</th><td class="field-body"><a class="reference external" href="http://pypi.python.org/pypi/plac">http://pypi.python.org/pypi/plac</a></td>
</tr>
<tr class="field"><th class="field-name">Project page:</th><td class="field-body"><a class="reference external" href="https://github.com/micheles/plac">https://github.com/micheles/plac</a></td>
</tr>
<tr class="field"><th class="field-name">Requires:</th><td class="field-body">Python 2.6+</td>
<tr class="field"><th class="field-name">Requires:</th><td class="field-body">Python from 2.6 to 3.6</td>
</tr>
<tr class="field"><th class="field-name">Installation:</th><td class="field-body"><tt class="docutils literal">pip install plac</tt></td>
</tr>
Expand Down Expand Up @@ -1376,6 +1376,7 @@ <h2><a class="toc-backref" href="#id26">Final example: a shelve interface</a></h
finally:
sh.close()


main.add_help = False # there is a custom help, remove the default one
main.prefix_chars = '.' # use dot-prefixed commands

Expand Down Expand Up @@ -1660,7 +1661,9 @@ <h2><a class="toc-backref" href="#id33">Testing a plac application</a></h2>
<tt class="docutils literal">ishelve</tt> application by using <tt class="docutils literal">plac.call</tt> directly:</p>
<pre class="literal-block">
# test_ishelve.py
import plac, ishelve
import plac
import ishelve


def test():
assert plac.call(ishelve.main, ['.clear']) == ['cleared the shelve']
Expand All @@ -1669,6 +1672,7 @@ <h2><a class="toc-backref" href="#id33">Testing a plac application</a></h2>
assert plac.call(ishelve.main, ['.delete=a']) == ['deleted a']
assert plac.call(ishelve.main, ['a']) == ['a: not found']


if __name__ == '__main__':
test()

Expand Down Expand Up @@ -1883,43 +1887,54 @@ <h2><a class="toc-backref" href="#id36">Implementing subcommands</a></h2>
<p>The shelve interface can be rewritten in an object-oriented way as follows:</p>
<pre class="literal-block">
# ishelve2.py
import shelve, os, plac
import os
import shelve
import plac


class ShelveInterface(object):
&quot;A minimal interface over a shelve object.&quot;
commands = 'set', 'show', 'showall', 'delete'

&#64;plac.annotations(
configfile=('path name of the shelve', 'option'))
def __init__(self, configfile):
self.configfile = configfile or '~/conf.shelve'
self.fname = os.path.expanduser(self.configfile)
self.__doc__ += '\nOperating on %s.\nUse help to see '\
'the available commands.\n' % self.fname
self.__doc__ += ('\nOperating on %s.\nUse help to see '
'the available commands.\n' % self.fname)

def __enter__(self):
self.sh = shelve.open(self.fname)
return self

def __exit__(self, etype, exc, tb):
self.sh.close()

def set(self, name, value):
&quot;set name value&quot;
yield 'setting %s=%s' % (name, value)
self.sh[name] = value

def show(self, *names):
&quot;show given parameters&quot;
for name in names:
yield '%s = %s' % (name, self.sh[name]) # no error checking
yield '%s = %s' % (name, self.sh[name]) # no error checking

def showall(self):
&quot;show all parameters&quot;
for name in self.sh:
yield '%s = %s' % (name, self.sh[name])
def delete(self, name=None):

def delete(self, name=''):
&quot;delete given parameter (or everything)&quot;
if name is None:
if name == '':
yield 'deleting everything'
self.sh.clear()
else:
yield 'deleting %s' % name
del self.sh[name] # no error checking
del self.sh[name] # no error checking


if __name__ == '__main__':
plac.Interpreter(plac.call(ShelveInterface)).interact()
Expand Down Expand Up @@ -2354,38 +2369,44 @@ <h2><a class="toc-backref" href="#id40">A non class-based example</a></h2>
<pre class="literal-block">
&quot;A Fake Version Control System&quot;

import plac # this implementation also works with Python 2.4
import plac # this implementation also works with Python 2.4

commands = 'checkout', 'commit', 'status'


&#64;plac.annotations(url='url of the source code')
def checkout(url):
&quot;A fake checkout command&quot;
return ('checkout ', url)


&#64;plac.annotations(message=('commit message', 'option'))
def commit(message):
&quot;A fake commit command&quot;
return ('commit ', message)


&#64;plac.annotations(quiet=('summary information', 'flag', 'q'))
def status(quiet):
&quot;A fake status command&quot;
return ('status ', quiet)


def __missing__(name):
return ('Command %r does not exist' % name,)


def __exit__(etype, exc, tb):
&quot;Will be called automatically at the end of the intepreter loop&quot;
if etype in (None, GeneratorExit): # success
if etype in (None, GeneratorExit): # success
print('ok')

main = __import__(__name__) # the module imports itself!
main = __import__(__name__) # the module imports itself!

if __name__ == '__main__':
import plac
for out in plac.call(main): print(out)
for out in plac.call(main, version='0.1.0'):
print(out)

</pre>
<p>Notice that I have defined both an <tt class="docutils literal">__exit__</tt> hook and a <tt class="docutils literal">__missing__</tt>
Expand Down Expand Up @@ -2830,7 +2851,6 @@ <h2><a class="toc-backref" href="#id47">Parallel computing with plac</a></h2>
<tt class="docutils literal">mode</tt> option:</p>
<pre class="literal-block">
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from __future__ import with_statement
from __future__ import division
import math
Expand Down
Binary file modified doc/plac.pdf
Binary file not shown.

0 comments on commit 5fb16ae

Please sign in to comment.