Skip to content

Commit 00c605b

Browse files
author
Noah Petherbridge
committed
Reorganize Package and Improve Documentation
Reorganize the RiveScript package: rivescript.py becomes rivescript/__init__.py. Split the module into different files where it makes sense: Interactive Mode was moved to rivescript/interactive.py, and the Python object macro class was moved to rivescript/python.py. Add brain/python.rs as an example of a Python object macro that encodes text in Base64. Improve documentation by switching to EpyDocs. All documentation is now kept in the 'docs' folder.
1 parent bb08fbe commit 00c605b

39 files changed

Lines changed: 7775 additions & 369 deletions

Changes

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
Revision history for the Python package RiveScript.
22

3-
1.01 Mar 6 2013
3+
1.01 May 20 2013
44
- Small bugfix in _rot13 that caused crashes under certain circumstances.
5+
- Small bugfix regarding the {weight} tag and atomic triggers.
6+
- Restructure the RiveScript library (move rivescript.py into a package
7+
folder named 'rivescript', separate the interactive mode code into
8+
interactive.py)
59

610
1.00 Apr 22 2012
711
- Initial version of rivescript.py

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include setup.py
2-
include rivescript.py
2+
recursive-include rivescript *.py
33
include README.md
44
include LICENSE
55
recursive-include brain *.rs

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,37 @@ trigger/response pairs for building up a bot's intelligence.
1111
USAGE
1212
-----
1313

14-
The `rivescript.py` module can be executed as a stand-alone Python script, or
14+
The `rivescript` module can be executed as a stand-alone Python script, or
1515
included in other Python code. When executed directly, it launches an
16-
interactive chat session.
16+
interactive chat session:
17+
18+
python rivescript ./brain
1719

1820
When used as a library, the synopsis is as follows:
1921

20-
import rivescript
22+
from rivescript import RiveScript
2123

2224
bot = RiveScript()
2325
bot.load_directory("./brain")
2426
bot.sort_replies()
2527

26-
reply = bot.reply("localuser", "Hello, bot!")
28+
while True:
29+
msg = raw_input('You> ')
30+
if msg == '/quit':
31+
quit()
32+
33+
reply = bot.reply("localuser", msg)
34+
print 'Bot>', reply
2735

2836
JSON MODE
2937
---------
3038

31-
The `rivescript.py` module, when run stand-alone, supports "JSON Mode", where
39+
The `rivescript` package, when run stand-alone, supports "JSON Mode", where
3240
you communicate with the bot using JSON. This is useful for third-party
3341
programs that want to use RiveScript but don't have an interpreter in their
3442
native language.
3543

36-
Just run it like: `python rivescript.py --json /path/to/brain`
44+
Just run it like: `python rivescript --json /path/to/brain`
3745

3846
Print a JSON encoded data structure into the standard input. The format should
3947
look like this:

brain/python.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Example of a Python object macro.
2+
3+
! version = 2.0
4+
5+
> object base64 python
6+
import base64 as b64
7+
return b64.b64encode(" ".join(args))
8+
< object
9+
10+
+ encode * in base64
11+
- OK: <call>base64 <star></call>

docs/api-objects.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
rivescript rivescript-module.html
2+
rivescript.re_ws rivescript-module.html#re_ws
3+
rivescript.__credits__ rivescript-module.html#__credits__
4+
rivescript.rs_version rivescript-module.html#rs_version
5+
rivescript.__package__ rivescript-module.html#__package__
6+
rivescript.__maintainer__ rivescript-module.html#__maintainer__
7+
rivescript.re_nasties rivescript-module.html#re_nasties
8+
rivescript.re_equals rivescript-module.html#re_equals
9+
rivescript.re_wilds rivescript-module.html#re_wilds
10+
rivescript.re_inherit rivescript-module.html#re_inherit
11+
rivescript.re_weight rivescript-module.html#re_weight
12+
rivescript.re_objend rivescript-module.html#re_objend
13+
rivescript.re_rot13 rivescript-module.html#re_rot13
14+
rivescript.__status__ rivescript-module.html#__status__
15+
rivescript.__main__ rivescript.__main__-module.html
16+
rivescript.__main__.interactive_mode rivescript.interactive-module.html#interactive_mode
17+
rivescript.__main__.__package__ rivescript.__main__-module.html#__package__
18+
rivescript.interactive rivescript.interactive-module.html
19+
rivescript.interactive.__package__ rivescript.interactive-module.html#__package__
20+
rivescript.interactive.interactive_mode rivescript.interactive-module.html#interactive_mode
21+
rivescript.interactive.json_in rivescript.interactive-module.html#json_in
22+
rivescript.python rivescript.python-module.html
23+
rivescript.python.__package__ rivescript.python-module.html#__package__
24+
rivescript.RiveScript rivescript.RiveScript-class.html
25+
rivescript.RiveScript._depth rivescript.RiveScript-class.html#_depth
26+
rivescript.RiveScript._thats rivescript.RiveScript-class.html#_thats
27+
rivescript.RiveScript.stream rivescript.RiveScript-class.html#stream
28+
rivescript.RiveScript.thaw_uservars rivescript.RiveScript-class.html#thaw_uservars
29+
rivescript.RiveScript._lineage rivescript.RiveScript-class.html#_lineage
30+
rivescript.RiveScript._users rivescript.RiveScript-class.html#_users
31+
rivescript.RiveScript._dump rivescript.RiveScript-class.html#_dump
32+
rivescript.RiveScript.set_global rivescript.RiveScript-class.html#set_global
33+
rivescript.RiveScript._word_count rivescript.RiveScript-class.html#_word_count
34+
rivescript.RiveScript._find_trigger_by_inheritence rivescript.RiveScript-class.html#_find_trigger_by_inheritence
35+
rivescript.RiveScript._getreply rivescript.RiveScript-class.html#_getreply
36+
rivescript.RiveScript.check_syntax rivescript.RiveScript-class.html#check_syntax
37+
rivescript.RiveScript.__init__ rivescript.RiveScript-class.html#__init__
38+
rivescript.RiveScript.set_handler rivescript.RiveScript-class.html#set_handler
39+
rivescript.RiveScript._strict rivescript.RiveScript-class.html#_strict
40+
rivescript.RiveScript._debug rivescript.RiveScript-class.html#_debug
41+
rivescript.RiveScript.set_subroutine rivescript.RiveScript-class.html#set_subroutine
42+
rivescript.RiveScript._substitute rivescript.RiveScript-class.html#_substitute
43+
rivescript.RiveScript._subs rivescript.RiveScript-class.html#_subs
44+
rivescript.RiveScript.sort_replies rivescript.RiveScript-class.html#sort_replies
45+
rivescript.RiveScript._gvars rivescript.RiveScript-class.html#_gvars
46+
rivescript.RiveScript._person rivescript.RiveScript-class.html#_person
47+
rivescript.RiveScript._topic_triggers rivescript.RiveScript-class.html#_topic_triggers
48+
rivescript.RiveScript._init_sort_track rivescript.RiveScript-class.html#_init_sort_track
49+
rivescript.RiveScript._topics rivescript.RiveScript-class.html#_topics
50+
rivescript.RiveScript.reply rivescript.RiveScript-class.html#reply
51+
rivescript.RiveScript.load_file rivescript.RiveScript-class.html#load_file
52+
rivescript.RiveScript._initTT rivescript.RiveScript-class.html#_initTT
53+
rivescript.RiveScript.clear_uservars rivescript.RiveScript-class.html#clear_uservars
54+
rivescript.RiveScript.last_match rivescript.RiveScript-class.html#last_match
55+
rivescript.RiveScript._handlers rivescript.RiveScript-class.html#_handlers
56+
rivescript.RiveScript._sorted rivescript.RiveScript-class.html#_sorted
57+
rivescript.RiveScript.freeze_uservars rivescript.RiveScript-class.html#freeze_uservars
58+
rivescript.RiveScript.get_uservars rivescript.RiveScript-class.html#get_uservars
59+
rivescript.RiveScript.set_person rivescript.RiveScript-class.html#set_person
60+
rivescript.RiveScript._is_atomic rivescript.RiveScript-class.html#_is_atomic
61+
rivescript.RiveScript._sort_that_triggers rivescript.RiveScript-class.html#_sort_that_triggers
62+
rivescript.RiveScript.VERSION rivescript.RiveScript-class.html#VERSION
63+
rivescript.RiveScript._format_message rivescript.RiveScript-class.html#_format_message
64+
rivescript.RiveScript._logf rivescript.RiveScript-class.html#_logf
65+
rivescript.RiveScript.get_uservar rivescript.RiveScript-class.html#get_uservar
66+
rivescript.RiveScript._sort_trigger_set rivescript.RiveScript-class.html#_sort_trigger_set
67+
rivescript.RiveScript._rot13 rivescript.RiveScript-class.html#_rot13
68+
rivescript.RiveScript._sort_list rivescript.RiveScript-class.html#_sort_list
69+
rivescript.RiveScript._reply_regexp rivescript.RiveScript-class.html#_reply_regexp
70+
rivescript.RiveScript._objlangs rivescript.RiveScript-class.html#_objlangs
71+
rivescript.RiveScript._warn rivescript.RiveScript-class.html#_warn
72+
rivescript.RiveScript._strip_nasties rivescript.RiveScript-class.html#_strip_nasties
73+
rivescript.RiveScript._arrays rivescript.RiveScript-class.html#_arrays
74+
rivescript.RiveScript.set_substitution rivescript.RiveScript-class.html#set_substitution
75+
rivescript.RiveScript._get_topic_tree rivescript.RiveScript-class.html#_get_topic_tree
76+
rivescript.RiveScript.set_variable rivescript.RiveScript-class.html#set_variable
77+
rivescript.RiveScript._string_format rivescript.RiveScript-class.html#_string_format
78+
rivescript.RiveScript._bvars rivescript.RiveScript-class.html#_bvars
79+
rivescript.RiveScript.load_directory rivescript.RiveScript-class.html#load_directory
80+
rivescript.RiveScript._process_tags rivescript.RiveScript-class.html#_process_tags
81+
rivescript.RiveScript._includes rivescript.RiveScript-class.html#_includes
82+
rivescript.RiveScript.set_uservar rivescript.RiveScript-class.html#set_uservar
83+
rivescript.RiveScript._freeze rivescript.RiveScript-class.html#_freeze
84+
rivescript.RiveScript._parse rivescript.RiveScript-class.html#_parse
85+
rivescript.RiveScript._say rivescript.RiveScript-class.html#_say
86+
rivescript.python.PyRiveObjects rivescript.python.PyRiveObjects-class.html
87+
rivescript.python.PyRiveObjects.load rivescript.python.PyRiveObjects-class.html#load
88+
rivescript.python.PyRiveObjects._objects rivescript.python.PyRiveObjects-class.html#_objects
89+
rivescript.python.PyRiveObjects.call rivescript.python.PyRiveObjects-class.html#call
90+
rivescript.python.PyRiveObjects.__init__ rivescript.python.PyRiveObjects-class.html#__init__

docs/class-tree.html

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="ascii"?>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3+
"DTD/xhtml1-transitional.dtd">
4+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5+
<head>
6+
<title>Class Hierarchy</title>
7+
<link rel="stylesheet" href="epydoc.css" type="text/css" />
8+
<script type="text/javascript" src="epydoc.js"></script>
9+
</head>
10+
11+
<body bgcolor="white" text="black" link="blue" vlink="#204080"
12+
alink="#204080">
13+
<!-- ==================== NAVIGATION BAR ==================== -->
14+
<table class="navbar" border="0" width="100%" cellpadding="0"
15+
bgcolor="#a0c0ff" cellspacing="0">
16+
<tr valign="middle">
17+
<!-- Home link -->
18+
<th>&nbsp;&nbsp;&nbsp;<a
19+
href="rivescript-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20+
21+
<!-- Tree link -->
22+
<th bgcolor="#70b0f0" class="navbar-select"
23+
>&nbsp;&nbsp;&nbsp;Trees&nbsp;&nbsp;&nbsp;</th>
24+
25+
<!-- Index link -->
26+
<th>&nbsp;&nbsp;&nbsp;<a
27+
href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28+
29+
<!-- Help link -->
30+
<th>&nbsp;&nbsp;&nbsp;<a
31+
href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
32+
33+
<!-- Project homepage -->
34+
<th class="navbar" align="right" width="100%">
35+
<table border="0" cellpadding="0" cellspacing="0">
36+
<tr><th class="navbar" align="center"
37+
><a class="navbar" target="_top" href="https://github.com/kirsle/rivescript-python">RiveScript</a></th>
38+
</tr></table></th>
39+
</tr>
40+
</table>
41+
<table width="100%" cellpadding="0" cellspacing="0">
42+
<tr valign="top">
43+
<td width="100%">&nbsp;</td>
44+
<td>
45+
<table cellpadding="0" cellspacing="0">
46+
<!-- hide/show private -->
47+
<tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
48+
onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
49+
<tr><td align="right"><span class="options"
50+
>[<a href="frames.html" target="_top">frames</a
51+
>]&nbsp;|&nbsp;<a href="class-tree.html"
52+
target="_top">no&nbsp;frames</a>]</span></td></tr>
53+
</table>
54+
</td>
55+
</tr>
56+
</table>
57+
<center><b>
58+
[ <a href="module-tree.html">Module Hierarchy</a>
59+
| <a href="class-tree.html">Class Hierarchy</a> ]
60+
</b></center><br />
61+
<h1 class="epydoc">Class Hierarchy</h1>
62+
<ul class="nomargin-top">
63+
<li> <strong class="uidlink"><a href="rivescript.python.PyRiveObjects-class.html">rivescript.python.PyRiveObjects</a></strong>:
64+
<em class="summary">A RiveScript object handler for Python code.</em>
65+
</li>
66+
<li> <strong class="uidlink"><a href="rivescript.RiveScript-class.html" onclick="show_private();">rivescript.RiveScript</a></strong>:
67+
<em class="summary">A RiveScript interpreter for Python 2.</em>
68+
</li>
69+
</ul>
70+
<!-- ==================== NAVIGATION BAR ==================== -->
71+
<table class="navbar" border="0" width="100%" cellpadding="0"
72+
bgcolor="#a0c0ff" cellspacing="0">
73+
<tr valign="middle">
74+
<!-- Home link -->
75+
<th>&nbsp;&nbsp;&nbsp;<a
76+
href="rivescript-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
77+
78+
<!-- Tree link -->
79+
<th bgcolor="#70b0f0" class="navbar-select"
80+
>&nbsp;&nbsp;&nbsp;Trees&nbsp;&nbsp;&nbsp;</th>
81+
82+
<!-- Index link -->
83+
<th>&nbsp;&nbsp;&nbsp;<a
84+
href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
85+
86+
<!-- Help link -->
87+
<th>&nbsp;&nbsp;&nbsp;<a
88+
href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
89+
90+
<!-- Project homepage -->
91+
<th class="navbar" align="right" width="100%">
92+
<table border="0" cellpadding="0" cellspacing="0">
93+
<tr><th class="navbar" align="center"
94+
><a class="navbar" target="_top" href="https://github.com/kirsle/rivescript-python">RiveScript</a></th>
95+
</tr></table></th>
96+
</tr>
97+
</table>
98+
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
99+
<tr>
100+
<td align="left" class="footer">
101+
Generated by Epydoc 3.0.1 on Mon May 20 17:19:45 2013
102+
</td>
103+
<td align="right" class="footer">
104+
<a target="mainFrame" href="http://epydoc.sourceforge.net"
105+
>http://epydoc.sourceforge.net</a>
106+
</td>
107+
</tr>
108+
</table>
109+
110+
<script type="text/javascript">
111+
<!--
112+
// Private objects are initially displayed (because if
113+
// javascript is turned off then we want them to be
114+
// visible); but by default, we want to hide them. So hide
115+
// them unless we have a cookie that says to show them.
116+
checkCookie();
117+
// -->
118+
</script>
119+
</body>
120+
</html>

docs/crarr.png

340 Bytes
Loading

0 commit comments

Comments
 (0)