summaryrefslogtreecommitdiff
path: root/info/pstdoc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /info/pstdoc
Initial commit
Diffstat (limited to 'info/pstdoc')
-rw-r--r--info/pstdoc/README53
-rw-r--r--info/pstdoc/index.html17
-rwxr-xr-xinfo/pstdoc/parsehelp.py121
-rw-r--r--info/pstdoc/pstCommands.dbbin0 -> 162816 bytes
-rwxr-xr-xinfo/pstdoc/pstdoc.py88
-rw-r--r--info/pstdoc/psthelp.css44
-rw-r--r--info/pstdoc/screenshot.pngbin0 -> 60126 bytes
7 files changed, 323 insertions, 0 deletions
diff --git a/info/pstdoc/README b/info/pstdoc/README
new file mode 100644
index 0000000000..3b912a65e6
--- /dev/null
+++ b/info/pstdoc/README
@@ -0,0 +1,53 @@
+This package is distributed under the LaTeX Project Public License.
+
+It provides help with syntax and keywords associated with PSTricks commands. See the screenshot for typical output.
+
+Installation of pstdoc.
+
+Python 2.5 or more recent is required. The database file pstCommands.db must be in the same folder as the Python script pstdoc.py.
+
+Mac:
+1. Set up your Terminal Window so that it understands ANSI commands, by setting the following in ~/.profile or ~/.MacOSX/environment.plist.
+
+CLICOLOR=true
+TERM=xterm-color
+LSCOLORS=exfxcxdxbxegedabagacad
+
+2. Check that your version of Python is recent enough.
+
+3. Rename pstdoc.py to just pstdoc, and copy it to some folder in your PATH. I copied it to ~/bin, along with the SQLite database file pstCommands.db
+
+4. Enter, for example,
+pstdoc \psarc (or just pstdoc psarc)
+to get the syntax and all keywords that might apply. Arguments with yellow background are optional. A red double left arrow indicates a default replacement value. Output look better when the Terminal window is twice as wide as normal.
+
+Windows:
+
+Install Python (the MSI version) from ActiveState and restart Windows. You invoke it as
+
+python c:\mybin\pstdoc.py \psarc
+
+after installing pstdoc.py and pstCommands.db in some folder in your PATH---say, C:\mybin. A batch file pstdoc.bat in c:\mybin containing just the line
+
+python C:\mybin\pstdoc.py %1
+
+will allow it to be invoked with
+
+pstdoc \psarc
+
+The output has no color and no double left arrow character---a left pointing double-angle quote is used instead. The presence of this character indicates that the argument is optional, and spells out the default value.
+
+Linux:
+
+It should work if used in a terminal that understands ANSI color commands.
+
+Apache Web Server:
+
+This is the nicest interface, IMHO.
+
+In the Webserver folder:
+
+Documents <- pstCommands.db, psthelp.css, index.html
+CGI-Executables <- parsehelp.py
+
+I keep this running at all times on my Mac OS 10.6.7 (check Web Sharing in System Preferences/Sharing) so that help is available in the browser by browsing to http://localhost. \ No newline at end of file
diff --git a/info/pstdoc/index.html b/info/pstdoc/index.html
new file mode 100644
index 0000000000..f00afdec57
--- /dev/null
+++ b/info/pstdoc/index.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO8859-I" />
+<link type="css/text" rel="stylesheet" href="psthelp.css" />
+<title>PSTricks Help Page</title>
+</head>
+<body>
+<h1>PSTricks Command Help</h1>
+<form action="../../cgi-bin/parsehelp.py" method="get">
+ <p id="ask">Command: <input type="text" name="cmd" /><input type="submit" /></p>
+</form>
+Type part of a command name, or just press Submit to see list of all commands.
+</body>
+</html> \ No newline at end of file
diff --git a/info/pstdoc/parsehelp.py b/info/pstdoc/parsehelp.py
new file mode 100755
index 0000000000..af6b947dec
--- /dev/null
+++ b/info/pstdoc/parsehelp.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+import cgi, sys, sqlite3
+import cgitb; cgitb.enable()
+theform=cgi.FieldStorage()
+if not theform.has_key('cmd'):
+ thecmd = ''
+else:
+ thecmd = theform['cmd'].value
+pkgs=('pstricks','pst-plot','pst-node','pstricks-add','pst-nodeExtras','pst-3dplot','pst-tree','multido','pst-eps','pst-bspline','pst-grapha','pst-coil','pst-text')
+tab=u'\x09'
+bdelim=("{","(","[","")
+edelim=("}",")","]","")
+bgon='<span class="opt">'
+bgoff='</span>'
+print "Content-type: text/html\r\n"
+pagehead='''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO8859-I" />
+<link type="css/text" rel="stylesheet" href="../../psthelp.css" />
+<title>PSTricks Help Page</title></head>
+<body>
+<h1>PSTricks Command Help</h1>
+<form action="../../cgi-bin/parsehelp.py" method="get">
+ <p id="ask">Command: <input type="text" value="**thecmd**" name="cmd" /><input type="submit" /></p>
+</form>
+'''
+def cnv(s):
+ # convert < and > characters to html
+ ss=s.replace('<-','&larr;')
+ ss=ss.replace('<','&lt;')
+ ss=ss.replace('|','| ')
+ return ss.replace('>','&gt;')
+
+pagetail='</body></html>\n'
+pagebody=''
+if thecmd[0:1]<>'\\':
+ thecmd='\\'+thecmd
+print pagehead.replace('**thecmd**',thecmd)
+
+if thecmd:
+ conn = sqlite3.connect('/Library/Webserver/Documents/pstCommands.db')
+ c=conn.cursor()
+ t=(thecmd,)
+ c.execute('select cmdid, cmdname from Commands where cmdname=?',t)
+ x=c.fetchone()
+ cmdnum=0
+ while not (x is None):
+ if x[1]==thecmd:
+ cmdnum=int(x[0])
+ x=c.fetchone()
+ if cmdnum==0:
+ print "<p><b>Command not found</b></p> "
+ c.execute("select cmdname from Commands where cmdname LIKE '"+thecmd+"%' order by cmdname")
+ x=c.fetchone()
+ print '<p>Similar commands:</p><p>'
+ while not (x is None):
+ print ' <a href="../../cgi-bin/parsehelp.py?cmd=%5C'+x[0][1:]+'">',x[0],'</a> '
+ x=c.fetchone()
+ print '</p>'
+ else:
+ t=(cmdnum,)
+ c.execute('select * from Commands where cmdID=?',t)
+ x=c.fetchone()
+ #print x---there should be only one
+ cmdcat=int(x[1])
+ desc=x[6].split(tab)
+ isOpt=x[8]
+ ti=[]
+ ti.append(thecmd)
+ if x[2]==1:
+ ti.append(bgon+"*"+bgoff)
+ if x[9]==1:
+ ti.append(bgon+"[&lt;kwds&gt;]"+bgoff)
+ L=len(x[7]) # delimiters
+ delim=x[7]
+
+ for i in range(0,L):
+ k=int(delim[i])
+ s=bdelim[k]+desc[i].replace('<-','&larr;')+edelim[k]
+ s=cnv(s)
+ if isOpt[i]=='1':
+ s=bgon+s+bgoff
+ ti.append(s)
+ if x[10]==1:
+ ti.append("(&lt;coords&gt;)"+bgon+"..."+bgoff)
+ #ti.append("% "+x[5]+' ['+pkgs[x[11]]+']')
+ #print ""
+ print '<p id="syntax"><b>Syntax:</b>',''.join(ti),'</p>'
+ print '(Gray background indicates optional argument, "&larr;" shows default value, if omitted.)'
+ print '<p><strong>Synopsis:</strong> ['+pkgs[x[11]]+']',cnv(x[5])
+ if x[9]==1:
+ ss="select parName,parPat,parDefault,parDescription from Parameters where (parLimTo="+str(cmdnum)+") or ((parLimTo=0) and (parCat=0 or parCat="+str(x[1])+")) group by parName,parPat,parDefault,parDescription order by parname"
+ c.execute(ss)
+ print '<table>'
+ print '<caption><strong>Keywords for %s</strong></caption>'% thecmd
+ print '<tr><th>Keyword</th><th>Kind</th><th>Default</th><th>Description</th></tr>'
+ alt=0
+ for x in c:
+ if alt:
+ print '<tr class="cellcolor">'
+ else:
+ print '<tr>'
+ print '<td>'+x[0]+'</td><td>'+cnv(x[1])+'</td><td class="center">'+x[2]+'</td><td>'+cnv(x[3])+'</td></tr>'
+ alt=1-alt
+ print '</table></p>'
+ t=(cmdcat,cmdnum)
+ if (cmdcat>0) and (cmdcat<>26):
+ c.execute('select cmdID, cmdname from Commands where cmdCat=? and cmdID<>?',t)
+ x=c.fetchone()
+ if not (x is None):
+ print '<p>Similar commands: '
+ while not(x is None):
+ print ' <a href="../../cgi-bin/parsehelp.py?cmd=%5C'+x[1][1:]+'">',x[1],'</a> '
+ x=c.fetchone()
+ print '</p>'
+
+
+print pagetail
+
diff --git a/info/pstdoc/pstCommands.db b/info/pstdoc/pstCommands.db
new file mode 100644
index 0000000000..4ee365104a
--- /dev/null
+++ b/info/pstdoc/pstCommands.db
Binary files differ
diff --git a/info/pstdoc/pstdoc.py b/info/pstdoc/pstdoc.py
new file mode 100755
index 0000000000..25333da716
--- /dev/null
+++ b/info/pstdoc/pstdoc.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+# Michael Sharpe, June 30, 2009
+# msharpe at ucsd.edu
+# Display brief documentation of PSTricks commands, including keywords.
+# Eg, pstdoc \rput (or pstdoc rput) will display the syntax and a brief explanation.
+# The firat line may need to be changed for Linux, and some other mechanism used for Windows.
+import sys
+import os
+import sqlite3
+if len(sys.argv)==1:
+ print "You must supply the name of a PST command"
+ exit(2)
+
+tab=u'\x09'
+CSI=''
+bgon=''
+bgoff=''
+redon=''
+redoff=''
+pkgs=('pstricks','pst-plot','pst-node','pstricks-add','pst-nodeExtras','pst-3dplot','pst-tree','multido','pst-eps','pst-bspline','pst-grapha','pst-coil','pst-text')
+larrow=unichr(0x00ab) #u'\u21d0 ' # "<-"
+bdelim=("{","(","[","")
+edelim=("}",")","]","")
+if sys.platform[:3]<>'win':
+ CSI=u'\x1B['
+ bgon=CSI+"43m"
+ bgoff=CSI+"00m"
+ redon=CSI+"31m"
+ redoff=CSI+"30m"
+ larrow=redon+u'\u21d0'+redoff+" "
+
+def main(argv):
+ conn = sqlite3.connect(os.path.dirname( os.path.realpath( __file__ ) )+'/pstCommands.db')
+ c=conn.cursor()
+ if argv[0:1]<>'\\':
+ argv='\\'+argv
+ t=(argv,)
+ c.execute('select cmdid, cmdname from Commands where cmdname=?',t)
+ x=c.fetchone()
+ cmdnum=0
+ while not (x is None):
+ if x[1]==argv:
+ cmdnum=int(x[0])
+ x=c.fetchone()
+ if cmdnum==0:
+ print "Command not found: ",argv
+ c.execute("select cmdname from Commands where cmdname LIKE '"+argv+"%' order by cmdname")
+ x=c.fetchone()
+ print "Similar commands:"
+ while not (x is None):
+ print x[0]
+ x=c.fetchone()
+ else:
+ t=(cmdnum,)
+ c.execute('select * from Commands where cmdID=?',t)
+ x=c.fetchone()
+ #print x---there should be only one
+ desc=x[6].split(tab)
+ isOpt=x[8]
+ ti=[]
+ ti.append(argv)
+ if x[2]==1:
+ ti.append(bgon+"*"+bgoff)
+ if x[9]==1:
+ ti.append(bgon+"[<kwds>]"+bgoff)
+ L=len(x[7]) # delimiters
+ delim=x[7]
+
+ for i in range(0,L):
+ k=int(delim[i])
+ s=bdelim[k]+desc[i].replace('<-',larrow)+edelim[k]
+ if isOpt[i]=='1':
+ s=bgon+s+bgoff
+ ti.append(s)
+ if x[10]==1:
+ ti.append("(<coords>)"+bgon+"..."+bgoff)
+ ti.append("% "+x[5]+' ['+pkgs[x[11]]+']')
+ print ""
+ print ''.join(ti)
+ if x[9]==1:
+ print "Keywords:"
+ ss="select parName,parPat,parDefault,parDescription from Parameters where (parLimTo="+str(cmdnum)+") or ((parLimTo=0) and (parCat=0 or parCat="+str(x[1])+")) group by parName,parPat,parDefault,parDescription order by parname"
+ c.execute(ss)
+ for x in c:
+ print redon+x[0]+redoff+" "+x[1]+redon+larrow+redoff+x[2]+" % "+x[3]
+
+if __name__ == "__main__":
+ main(sys.argv[1]) \ No newline at end of file
diff --git a/info/pstdoc/psthelp.css b/info/pstdoc/psthelp.css
new file mode 100644
index 0000000000..38e18aa556
--- /dev/null
+++ b/info/pstdoc/psthelp.css
@@ -0,0 +1,44 @@
+body {font-size: medium;
+}
+h1, h2 {font-weight: normal;
+ color: #cc6600;
+ border-bottom: thin dotted #888888;
+}
+h1 {
+ font-size: 170%;
+}
+h2 {
+ font-size: 130%;
+}
+table {
+ margin-left: 10px;
+ margin-right: 10px;
+ border: thin dotted gray;
+ border-collapse: collapse;
+}
+th, td {
+ border: thin dotted gray;
+ padding: 4px;
+}
+th {
+ background-color: #cc6600;
+}
+.cellcolor {
+ background-color: #fcba7a;
+}
+.opt {
+ background-color: silver;
+}
+#syntax {
+ font: "Courier New";
+ font-size: large;
+}
+.center {
+ text-align: center;
+}
+.right {
+ text-align: right;
+}
+#ask {
+ text-align: right;
+} \ No newline at end of file
diff --git a/info/pstdoc/screenshot.png b/info/pstdoc/screenshot.png
new file mode 100644
index 0000000000..6cc4bac51f
--- /dev/null
+++ b/info/pstdoc/screenshot.png
Binary files differ