Skip to content

Commit

Permalink
* Added unittests.
Browse files Browse the repository at this point in the history
* Added documentation.
* Added stats to text generators methods in Generator
* Added generator methods in Generator, for multiple text generations
* Added stats-less text generators fuctions to module
  • Loading branch information
monkeython committed Aug 10, 2011
1 parent 753b354 commit 0039200
Show file tree
Hide file tree
Showing 11 changed files with 378 additions and 114 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.pyc
*.pyo
*.egg-info
build
*.DS_Store
dist
2 changes: 0 additions & 2 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
AUTHORS
=======
Luca De Vitis <luca at monkeython dot org>
James Hales <jhales dot perth at gmail dot com> (original code author)
2 changes: 0 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
History
=======
Most of the code of this module is taken from `lorem-ipsum-generator`_ by James
Hales. James stated that his package served his purpose and he was not
interested in further development, so I took it over (to serve my purpose).
Expand Down
2 changes: 0 additions & 2 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ Build
Install
=======

Deploy
======
21 changes: 9 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
Overview
========

You may import the :py:class:`Generator` class to instantiate your generator
with a sample text and a dictionary:
with your own sample text and a dictionary:

>>> from loremipsum import Generator
>>>
>>> sample = file('data/sample.txt').read()
>>> dictionary = file('data/dictionary.txt').read().split()
>>>
>>> g = Generator(sample, dictionary)
>>> g.generate_sentence(True)
...
>>> g.generate_sentence() #doctest: +ELLIPSIS
(...)
>>>

or just import any of :py:func:`generate_sentences`,
:py:func:`generate_paragraphs`, :py:func:`generate_words` which interface to a
module wide :py:class:`Generator` instance.
or just import :py:func:`get_sentences` or :py:func:`get_paragraphs`
which interface to a module wide :py:class:`Generator` instance.

>>> from loremipsum import generate_paragraphs, generate_sentences
>>> from loremipsum import get_paragraphs, get_sentences
>>>
>>> generate_sentences(5)
>>> get_sentences(5) #doctest: +ELLIPSIS
['...', '...', '...', '...', '...']
>>> generate_paragraphs(3)
>>> get_paragraphs(3) #doctest: +ELLIPSIS
['...', '...', '...']
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'sphinx.ext.coverage',
'sphinx.ext.autodoc']

autodoc_member_order = 'groupwise'
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand All @@ -48,7 +49,7 @@
master_doc = 'index'

# General information about the project.
project = u'Python musiXmatch'
project = u'Lorem Ipsum'
copyright = u'2011, Luca De Vitis'

# The version info for the project you're documenting, acts as replacement for
Expand Down
39 changes: 37 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,49 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. automodule:: loremipsum
loremipsum.py
=============

.. include:: ../INSTALL.rst
.. automodule:: loremipsum

Overview
========
.. include:: ../README.rst

API
===
.. autoexception:: loremipsum.SampleError

.. autoexception:: loremipsum.DictionaryError

.. autoclass:: loremipsum.Generator
:members:

.. autofunction:: generate_sentence

.. autofunction:: generate_sentences

.. autofunction:: generate_paragraph

.. autofunction:: generate_paragraphs

.. autofunction:: get_sentence

.. autofunction:: get_sentences

.. autofunction:: get_paragraph

.. autofunction:: get_paragraphs

.. include:: ../INSTALL.rst

History
=======
.. include:: ../HISTORY.rst

Changelog
=========

.. include:: ../CHANGES.rst

Indices and tables
Expand Down
Loading

0 comments on commit 0039200

Please sign in to comment.