3
3
Dogtail script for generating unhelpful help file.
5
Scours the UI of a program, and generates a parody of a help file for that
5
Scours the UI of a program, and generates a parody of a help file for that
8
8
The resulting DocBook file is simply a reading back of the program's UI to you.
10
The idea is to highlight a gripe of mine (and many other people):
10
The idea is to highlight a gripe of mine (and many other people):
11
11
documentation should be more than this!
13
13
This script is licensed under the GPL.
15
15
__author__ = 'David Malcolm <dmalcolm@redhat.com>'
17
17
from dogtail.tree import *
18
from dogtail.utils import *
20
21
def writePCDataElement(name, content):
21
print '\t\t<%s>%s</%s>'%(name, content, name) # FIXME: escape the content
22
print '\t\t<%s>%s</%s>'%(name, content, name) # FIXME: escape the content
24
25
def generateUnhelpfulHelp(appName):
25
app = root.application(appName)
26
print '<?xml version="1.0"?>'
27
print '<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">'
30
taggedAppName = '<application>%s</application>'%appName
33
print '\t<articleinfo>'
34
writePCDataElement("title", "The Totally Definitive No-Nonsense Unhelpful Complete Guide to %s for Mannequins in 40 Days - Unleashed!"%taggedAppName)
35
print '\t</articleinfo>'
37
# Guts of the article:
39
writePCDataElement("title", "Introduction")
40
writePCDataElement("caution", "<para>Do not take these instructions seriously. They are a parody of unhelpful help files found on many computer systems, and were autogenerated by <application>no-help-at-all</application></para>")
41
writePCDataElement("para", "You can start %s by opening a terminal and typing the <command>%s</command> command."%(taggedAppName, appName))
44
menus = app.findChildren(predicate.GenericPredicate(roleName="menu"))
47
writePCDataElement("title", "The <guimenu>%s</guimenu> menu"%menu.name)
48
writePCDataElement("para", "Use the <guimenu>%s</guimenu> menu to work with %ss"%(menu.name, menu.name.lower()))
49
items = menu.findChildren(predicate.GenericPredicate(roleName="menu item"), recursive=False)
55
writePCDataElement("title", "%sing a %s"%(verb.title(), noun.lower()))
56
writePCDataElement("para", "To %s a %s, choose <guimenu>%s</guimenu> > <guimenuitem>%s</guimenuitem>"%(verb.lower(), noun.lower(), menu.name, item.name))
27
app = root.application(appName)
30
print '<?xml version="1.0"?>'
31
print '<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">'
34
taggedAppName = '<application>%s</application>'%appName
37
print '\t<articleinfo>'
38
writePCDataElement("title", "The Totally Definitive No-Nonsense Unhelpful Complete Guide to %s for Mannequins in 40 Days - Unleashed!"%taggedAppName)
39
print '\t</articleinfo>'
41
# Guts of the article:
43
writePCDataElement("title", "Introduction")
44
writePCDataElement("caution", "<para>Do not take these instructions seriously. They are a parody of unhelpful help files found on many computer systems, and were autogenerated by <application>no-help-at-all</application></para>")
45
writePCDataElement("para", "You can start %s by opening a terminal and typing the <command>%s</command> command."%(taggedAppName, appName))
48
menus = app.findChildren(predicate.GenericPredicate(roleName="menu"))
51
writePCDataElement("title", "The <guimenu>%s</guimenu> menu"%menu.name)
52
writePCDataElement("para", "Use the <guimenu>%s</guimenu> menu to work with %ss"%(menu.name, menu.name.lower()))
53
items = menu.findChildren(predicate.GenericPredicate(roleName="menu item"), recursive=False)
59
writePCDataElement("title", "%sing a %s"%(verb.title(), noun.lower()))
60
writePCDataElement("para", "To %s a %s, choose <guimenu>%s</guimenu> > <guimenuitem>%s</guimenuitem>"%(verb.lower(), noun.lower(), menu.name, item.name))
62
66
if __name__=='__main__':
63
generateUnhelpfulHelp(sys.argv[1])
68
generateUnhelpfulHelp(sys.argv[1])
70
print "####################################"
71
print "please supply an application name on the cmdline"
72
print "####################################"