Example #1
0
    def _makeDocStructure(self):
        # Some trivial caching
        global namespaces
        global subdirs
        context = zope.app.appsetup.appsetup.getConfigContext()
        namespaces, subdirs = docutils.makeDocStructures(context)

        # Empty keys are not so good for a container
        if namespaces.has_key(''):
            namespaces['ALL'] = namespaces['']
            del namespaces['']
def _makeDocStructure():
    # Some trivial caching
    global namespaces
    global subdirs
    if namespaces is not None and subdirs is not None:
        return

    context = zope.app.appsetup.appsetup.getConfigContext()
    assert context is not None
    namespaces, subdirs = docutils.makeDocStructures(context)

    # Empty keys are not so good for a container
    if '' in namespaces:
        namespaces['ALL'] = namespaces['']
        del namespaces['']
Example #3
0
def main():

    dom = getDOMImplementation()

    namespaces, subdirs = makeDocStructures(getConfigContext())
    common = namespaces.pop('', ())

    for ns, directives in namespaces.items():
        filename = quoteNS(ns) + '.xsd'
        file = open(filename, 'w')
        doc = dom.createDocument(xsns, 'xs:schema', None)
        root = doc.documentElement

        root.setAttribute('xmlns:xs', xsns)
        root.setAttribute('xs:targetNamespace', ns)

        directives.update(common)

        for directive in directives:
            el = doc.createElement('xs:element')
            el.setAttribute('name', directive)

            type = doc.createElement('xs:complexType')

            schema = directives[directive][0]

            if schema.__doc__:
                addDoc(doc, type, schema.__doc__)

            for name, field in getFieldsInOrder(schema):
                if name.endswith('_') and iskeyword(name[:-1]):
                    name = name[:-1]
                attr = doc.createElement('xs:attribute')
                attr.setAttribute('name', name)
                attr.setAttribute('type', 'string')

                if field.__doc__:
                    addDoc(doc, attr, field.__doc__)

                type.appendChild(attr)

            el.appendChild(type)
            root.appendChild(el)

        doc.writexml(file, addindent='\t', newl='\n')
Example #4
0
def makedocs(target_dir, zcml_file):
    """Generate the documentation tree.

    All we need for this is a starting ZCML file and a directory in which to
    put the documentation.
    """
    context = xmlconfig.file(zcml_file, execute=False)
    namespaces, subdirs = makeDocStructures(context)

    for namespace, directives in namespaces.items():
        ns_dir = os.path.join(target_dir, namespace.split('/')[-1])
        # Create a directory for the namespace, if necessary
        if not os.path.exists(ns_dir):
            os.mkdir(ns_dir)

        # Create a file for each directive
        for name, (schema, handler, info) in directives.items():
            dir_file = os.path.join(ns_dir, name+'.stx')
            text = _directiveDocs(name, schema, handler, info)
            text += _subDirectiveDocs(subdirs, namespace, name)
            open(dir_file, 'w').write(text)
Example #5
0
 def _callFUT(self, *args, **kw):
     from zope.configuration.docutils import makeDocStructures
     return makeDocStructures(*args, **kw)
Example #6
0
 def _callFUT(self, *args, **kw):
     from zope.configuration.docutils import makeDocStructures
     return makeDocStructures(*args, **kw)