def upload_documentation(self, metadata, doc_dir):
self.check_credentials()<EOL>if not os.path.isdir(doc_dir):<EOL><INDENT>raise DistlibException('<STR_LIT>' % doc_dir)<EOL><DEDENT>fn = os.path.join(doc_dir, '<STR_LIT>')<EOL>if not os.path.exists(fn):<EOL><INDENT>raise DistlibException('<STR_LIT>' % fn)<EOL><DEDENT>metadata.validate()<EOL>name, version = metadata.name, metadata.version<EOL>zip_data = zip_dir(doc_dir).getvalue()<EOL>fields = [('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT:name>', name), ('<STR_LIT:version>', version)]<EOL>files = [('<STR_LIT:content>', name, zip_data)]<EOL>request = self.encode_request(fields, files)<EOL>return self.send_request(request)<EOL>
Upload documentation to the index.

:param metadata: A :class:`Metadata` instance defining at least a name
                 and version number for the documentation to be
                 uploaded.
:param doc_dir: The pathname of the directory which contains the
                documentation. This should be the directory that
                contains the ``index.html`` for the documentation.
:return: The HTTP response received from PyPI upon submission of the
        request.