WebStack

Annotated apidocs.py

289:43e23cde36c2
2004-09-21 paulb [project @ 2004-09-21 17:59:03 by paulb] Fixed path field discovery by removing parameters with empty names. This may not be totally correct, however.
paulb@182 1
#!/usr/bin/env python
paulb@182 2
paulb@182 3
"Make the API documentation."
paulb@182 4
paulb@182 5
import pydoc
paulb@182 6
import os, sys
paulb@182 7
paulb@255 8
_apache = """
paulb@255 9
"Placeholder for the real _apache module exported within the server itself."
paulb@255 10
def log_error(s, x=None): pass
paulb@255 11
def config_tree(): pass
paulb@255 12
def server_root(): pass
paulb@255 13
def mpm_query(i): pass
paulb@255 14
def parse_qs(s, x): pass
paulb@255 15
def parse_qsl(s, x): pass
paulb@255 16
table = None
paulb@255 17
SERVER_RETURN = None
paulb@255 18
"""
paulb@255 19
paulb@255 20
http = """
paulb@255 21
"Placeholder for javax.servlet.http."
paulb@255 22
class Cookie:
paulb@255 23
    def __init__(self, *args):
paulb@255 24
        pass
paulb@255 25
"""
paulb@255 26
paulb@255 27
internet = """
paulb@255 28
"Placeholder for javax.mail.internet."
paulb@255 29
class MimeMessage:
paulb@255 30
    def __init__(self, *args):
paulb@255 31
        pass
paulb@255 32
"""
paulb@255 33
paulb@255 34
mail = """
paulb@255 35
"Placeholder for javax.mail."
paulb@255 36
class Session:
paulb@255 37
    pass
paulb@255 38
"""
paulb@255 39
paulb@255 40
util = """
paulb@255 41
"Placeholder for java.util."
paulb@255 42
class Properties:
paulb@255 43
    pass
paulb@255 44
"""
paulb@255 45
paulb@255 46
net = """
paulb@255 47
"Placeholder for java.net."
paulb@255 48
class URLDecoder:
paulb@255 49
    pass
paulb@255 50
"""
paulb@255 51
paulb@182 52
if __name__ == "__main__":
paulb@182 53
paulb@182 54
    # The list of packages should coincide with that found in setup.py.
paulb@182 55
paulb@182 56
    names = [
paulb@182 57
        "WebStack", "WebStack.__init__",
paulb@182 58
        "WebStack.BaseHTTPRequestHandler", "WebStack.CGI", "WebStack.Generic",
paulb@182 59
        "WebStack.JavaServlet", "WebStack.ModPython", "WebStack.Twisted",
paulb@255 60
        "WebStack.Webware", "WebStack.Zope",
paulb@182 61
        "WebStack.Adapters", "WebStack.Adapters.__init__",
paulb@182 62
        "WebStack.Adapters.BaseHTTPRequestHandler", "WebStack.Adapters.CGI",
paulb@255 63
        "WebStack.Adapters.JavaServlet", "WebStack.Adapters.ModPython",
paulb@255 64
        "WebStack.Adapters.Twisted", "WebStack.Adapters.Webware",
paulb@255 65
        "WebStack.Adapters.Zope",
paulb@182 66
        "WebStack.Helpers", "WebStack.Helpers.__init__",
paulb@182 67
        "WebStack.Helpers.Auth", "WebStack.Helpers.Environment",
paulb@182 68
        "WebStack.Helpers.Request", "WebStack.Helpers.Response",
paulb@255 69
        "WebStack.Helpers.Session",
paulb@182 70
        "WebStack.Resources", "WebStack.Resources.__init__",
paulb@182 71
        "WebStack.Resources.Login", "WebStack.Resources.LoginRedirect"
paulb@182 72
        ]
paulb@182 73
paulb@182 74
    dirname = "apidocs"
paulb@182 75
paulb@255 76
    # Set the PYTHONPATH to find the WebStack package and others.
paulb@182 77
paulb@182 78
    sys.path.insert(0, os.getcwd())
paulb@255 79
    sys.path.insert(1, os.path.join(os.path.abspath(".."), "Zope", "lib", "python"))
paulb@255 80
    sys.path.insert(2, os.path.join(os.path.abspath(".."), "Webware"))
paulb@182 81
paulb@182 82
    # Make the documentation directory if necessary.
paulb@182 83
paulb@182 84
    if not os.path.exists(dirname):
paulb@182 85
        print "Making", dirname
paulb@182 86
        os.mkdir(dirname)
paulb@182 87
paulb@182 88
    # Change into the directory - pydoc.writedoc depends on that.
paulb@182 89
paulb@182 90
    os.chdir(dirname)
paulb@182 91
paulb@255 92
    # Fake some modules.
paulb@255 93
paulb@255 94
    f = open("_apache.py", "w")
paulb@255 95
    f.write(_apache)
paulb@255 96
    f.close()
paulb@255 97
paulb@255 98
    os.mkdir("javax")
paulb@255 99
    f = open(os.path.join("javax", "__init__.py"), "w")
paulb@255 100
    f.close()
paulb@255 101
paulb@255 102
    os.mkdir(os.path.join("javax", "servlet"))
paulb@255 103
    f = open(os.path.join("javax", "servlet", "__init__.py"), "w")
paulb@255 104
    f.close()
paulb@255 105
    f = open(os.path.join("javax", "servlet", "http.py"), "w")
paulb@255 106
    f.write(http)
paulb@255 107
    f.close()
paulb@255 108
paulb@255 109
    os.mkdir(os.path.join("javax", "mail"))
paulb@255 110
    f = open(os.path.join("javax", "mail", "internet.py"), "w")
paulb@255 111
    f.write(internet)
paulb@255 112
    f.close()
paulb@255 113
    f = open(os.path.join("javax", "mail", "__init__.py"), "w")
paulb@255 114
    f.write(mail)
paulb@255 115
    f.close()
paulb@255 116
paulb@255 117
    os.mkdir("java")
paulb@255 118
    f = open(os.path.join("java", "__init__.py"), "w")
paulb@255 119
    f.close()
paulb@255 120
    f = open(os.path.join("java", "util.py"), "w")
paulb@255 121
    f.write(util)
paulb@255 122
    f.close()
paulb@255 123
    f = open(os.path.join("java", "net.py"), "w")
paulb@255 124
    f.write(net)
paulb@255 125
    f.close()
paulb@255 126
paulb@255 127
    # Add the faked modules to the path.
paulb@255 128
paulb@255 129
    sys.path.insert(0, os.getcwd())
paulb@255 130
paulb@182 131
    for name in names:
paulb@182 132
        pydoc.writedoc(name, forceload=1)
paulb@182 133
paulb@255 134
    # Remove the faked modules.
paulb@255 135
paulb@255 136
    os.remove("_apache.py")
paulb@255 137
    os.remove("_apache.pyc")
paulb@255 138
    os.remove(os.path.join("javax", "__init__.py"))
paulb@255 139
    os.remove(os.path.join("javax", "__init__.pyc"))
paulb@255 140
    os.remove(os.path.join("javax", "servlet", "__init__.py"))
paulb@255 141
    os.remove(os.path.join("javax", "servlet", "__init__.pyc"))
paulb@255 142
    os.remove(os.path.join("javax", "servlet", "http.py"))
paulb@255 143
    os.remove(os.path.join("javax", "servlet", "http.pyc"))
paulb@255 144
    os.remove(os.path.join("javax", "mail", "internet.py"))
paulb@255 145
    os.remove(os.path.join("javax", "mail", "internet.pyc"))
paulb@255 146
    os.remove(os.path.join("javax", "mail", "__init__.py"))
paulb@255 147
    os.remove(os.path.join("javax", "mail", "__init__.pyc"))
paulb@255 148
    os.remove(os.path.join("java", "__init__.py"))
paulb@255 149
    os.remove(os.path.join("java", "__init__.pyc"))
paulb@255 150
    os.remove(os.path.join("java", "util.py"))
paulb@255 151
    os.remove(os.path.join("java", "util.pyc"))
paulb@255 152
    os.remove(os.path.join("java", "net.py"))
paulb@255 153
    os.remove(os.path.join("java", "net.pyc"))
paulb@255 154
    os.rmdir(os.path.join("javax", "servlet"))
paulb@255 155
    os.rmdir(os.path.join("javax", "mail"))
paulb@255 156
    os.rmdir("javax")
paulb@255 157
    os.rmdir("java")
paulb@255 158
paulb@182 159
# vim: tabstop=4 expandtab shiftwidth=4