mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Experiment with auto-documentation
This commit is contained in:
@@ -47,9 +47,11 @@ def GithubObject( className, *attributePolicies ):
|
||||
class GithubObject:
|
||||
__attributeDefinitions = dict()
|
||||
__methodDefinitions = dict()
|
||||
__attributePolicies = list()
|
||||
|
||||
@staticmethod
|
||||
def _addAttributePolicy( attributePolicy ):
|
||||
GithubObject.__attributePolicies.append( attributePolicy )
|
||||
attributePolicy.apply( GithubObject )
|
||||
|
||||
@staticmethod
|
||||
@@ -103,6 +105,15 @@ def GithubObject( className, *attributePolicies ):
|
||||
attributeDefinition = GithubObject.__attributeDefinitions[ attributeName ]
|
||||
attributeDefinition.updateAttributes( self )
|
||||
|
||||
@classmethod
|
||||
def _autoDocument( cls ):
|
||||
doc = "Class `" + cls.__name__ + "`\n"
|
||||
doc += "=" * ( len( cls.__name__ ) + 8 ) + "\n"
|
||||
for attributePolicy in cls.__attributePolicies:
|
||||
doc += attributePolicy.autoDocument()
|
||||
doc += "\n"
|
||||
return doc
|
||||
|
||||
GithubObject.__name__ = className
|
||||
GithubObject._addAttributePolicy( SeveralAttributePolicies( attributePolicies ) )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user