mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Experiment with auto-documentation
This commit is contained in:
@@ -20,6 +20,9 @@ class AttributeFromCallable:
|
||||
def apply( self, cls ):
|
||||
cls._addAttribute( self.__name, AttributeFromCallable.AttributeDefinition( self.__name, self.__callable ) )
|
||||
|
||||
def autoDocument( self ):
|
||||
return "* `" + self.__name + "`\n"
|
||||
|
||||
### @todo include the ArgumentsChecker
|
||||
class MethodFromCallable:
|
||||
def __init__( self, name, callable ):
|
||||
@@ -29,6 +32,9 @@ class MethodFromCallable:
|
||||
def apply( self, cls ):
|
||||
cls._addMethod( self.__name, self.__callable )
|
||||
|
||||
def autoDocument( self ):
|
||||
return "* `" + self.__name + "( ... )`\n"
|
||||
|
||||
class InternalAttribute:
|
||||
class AttributeDefinition:
|
||||
def __init__( self, typePolicy ):
|
||||
@@ -55,6 +61,9 @@ class InternalAttribute:
|
||||
def apply( self, cls ):
|
||||
cls._addAttribute( self.__attributeName, InternalAttribute.AttributeDefinition( self.__typePolicy ) )
|
||||
|
||||
def autoDocument( self ):
|
||||
return "* `" + self.__attributeName + "`: `" + self.__typePolicy.documentTypeName() + "`\n"
|
||||
|
||||
class ExternalAttribute:
|
||||
def __init__( self, attributeName, typePolicy ):
|
||||
self.__attributeName = attributeName
|
||||
@@ -69,6 +78,9 @@ class ExternalAttribute:
|
||||
obj._github._dataRequest( "GET", obj._baseUrl + "/" + self.__attributeName, None, None )
|
||||
)
|
||||
|
||||
def autoDocument( self ):
|
||||
return "* `get_" + self.__attributeName + "()`: `" + self.__typePolicy.documentTypeName() + "`\n"
|
||||
|
||||
class SeveralAttributePolicies:
|
||||
def __init__( self, attributePolicies ):
|
||||
self.__attributePolicies = attributePolicies
|
||||
@@ -76,3 +88,6 @@ class SeveralAttributePolicies:
|
||||
def apply( self, cls ):
|
||||
for attributePolicy in self.__attributePolicies:
|
||||
attributePolicy.apply( cls )
|
||||
|
||||
def autoDocument( self ):
|
||||
return "".join( attributePolicy.autoDocument() for attributePolicy in self.__attributePolicies )
|
||||
|
||||
Reference in New Issue
Block a user