88
99from functools import wraps
1010from requests .models import Response
11+ import os
1112
1213try : # (No coverage)
1314 # python2
1819
1920
2021def requires_auth (func ):
21- """Decorator to note which object methods require authorization.
22-
23- .. note::
24- This decorator causes the wrapped methods to lose their proper
25- signature. Please refer to the documentation for each of those.
26- """
27- #note = """.. note::
28- #The signature of this function may not appear correctly in
29- #documentation. Please adhere to the defined parameters and their
30- #types.
31- #"""
32- ## Append the above note to each function this is applied to
33- #func.__doc__ = '\n\n'.join([func.__doc__, note])
34-
22+ """Decorator to note which object methods require authorization."""
3523 @wraps (func )
3624 def auth_wrapper (self , * args , ** kwargs ):
3725 auth = False
@@ -53,20 +41,7 @@ def auth_wrapper(self, *args, **kwargs):
5341
5442def requires_basic_auth (func ):
5543 """Decorator to note which object methods require username/password
56- authorization and won't work with token based authorization.
57-
58- .. note::
59- This decorator causes the wrapped methods to lose their proper
60- signature. Please refer to the documentation for each of those.
61- """
62- #note = """.. note::
63- #The signature of this function may not appear correctly in
64- #documentation. Please adhere to the defined parameters and their
65- #types.
66- #"""
67- ## Append the above note to each function this is applied to
68- #func.__doc__ = '\n\n'.join([func.__doc__, note])
69-
44+ authorization and won't work with token based authorization."""
7045 @wraps (func )
7146 def auth_wrapper (self , * args , ** kwargs ):
7247 if hasattr (self , '_session' ) and self ._session .auth :
@@ -80,3 +55,8 @@ def auth_wrapper(self, *args, **kwargs):
8055 r .raw = StringIO ('{"message": "Requires username/password authentication"}' .encode ())
8156 raise GitHubError (r )
8257 return auth_wrapper
58+
59+ # Use mock decorators when generating documentation, so all functino signatures
60+ # are displayed correctly
61+ if os .environ .get ('GENERATING_DOCUMENTATION' , None ) == 'github3' :
62+ requires_auth = requires_basic_auth = lambda x : x
0 commit comments