Improve documentation generation

This commit is contained in:
Vincent Jacques
2012-02-26 14:32:29 +00:00
parent f71bf13461
commit 37a62f4c6f
6 changed files with 45 additions and 37 deletions
+10 -15
View File
@@ -9,16 +9,16 @@ class BadGithubObjectException( Exception ):
pass
def InternalSimpleAttribute( attributeName ):
return InternalAttribute( attributeName, SimpleTypePolicy() )
return InternalAttribute( attributeName, SimpleTypePolicy( None ) )
def InternalSimpleAttributes( *attributeNames ):
return SeveralAttributePolicies( [ InternalSimpleAttribute( attributeName ) for attributeName in attributeNames ] )
return SeveralAttributePolicies( [ InternalSimpleAttribute( attributeName ) for attributeName in attributeNames ], "Attributes" )
def InternalObjectAttribute( attributeName, type ):
return InternalAttribute( attributeName, ObjectTypePolicy( type ) )
def ExternalSimpleAttribute( attributeName ):
return ExternalAttribute( attributeName, SimpleTypePolicy() )
def ExternalSimpleAttribute( attributeName, type ):
return ExternalAttribute( attributeName, SimpleTypePolicy( type ) )
def BaseUrl( baseUrl ):
return AttributeFromCallable( "_baseUrl", baseUrl )
@@ -26,20 +26,16 @@ def BaseUrl( baseUrl ):
def Identity( identity ):
return AttributeFromCallable( "_identity", identity )
class Editable( MethodFromCallable ):
def __init__( self, mandatoryParameters, optionalParameters ):
MethodFromCallable.__init__( self, "edit", mandatoryParameters, optionalParameters, self.__execute )
def __execute( self, obj, **data ):
def Editable( mandatoryParameters, optionalParameters ):
def __execute( obj, **data ):
attributes = obj._github._dataRequest( "PATCH", obj._baseUrl, None, data )
obj._updateAttributes( attributes )
return SeveralAttributePolicies( [ MethodFromCallable( "edit", mandatoryParameters, optionalParameters, __execute ) ], "Modification" )
class Deletable( MethodFromCallable ):
def __init__( self ):
MethodFromCallable.__init__( self, "delete", [], [], self.__execute )
def __execute( self, obj ):
def Deletable():
def __execute( obj ):
obj._github._statusRequest( "DELETE", obj._baseUrl, None, None )
return SeveralAttributePolicies( [ MethodFromCallable( "delete", [], [], __execute ) ], "Deletion" )
def GithubObject( className, *attributePolicies ):
class GithubObject:
@@ -107,7 +103,6 @@ def GithubObject( className, *attributePolicies ):
def _autoDocument( cls ):
doc = "Class `" + cls.__name__ + "`\n"
doc += "=" * ( len( cls.__name__ ) + 8 ) + "\n"
doc += "* Attributes: see [API]()\n"
for attributePolicy in cls.__attributePolicies:
doc += attributePolicy.autoDocument()
doc += "\n"