2014-02-13 4 views
5

Google Cloud Endpoints를 사용하여 개발 된 일련의 API가 있습니다. API 메소드는 다음과 유사합니다.Google Cloud Endpoints 방법에 대한 pydoc 문서를 생성하는 방법은 무엇입니까?

@endpoints.method(message_types.VoidMessage, SystemAboutResponse, name="about", http_method="GET") 
def about(self, request): 
    """ 
    Returns some simple information about the APIs. 

    Example: 
     ... 
    """ 
    return SystemAboutResponse(version=API_VERSION) 

이 방법이 포함 된 모듈에 대한 설명서를 생성하고 싶습니다. 그러나 이렇게 할 때 endpoints.method 데코레이터의 사용으로 인해 문서화 문자열이 보존되지 않습니다.

데코레이터를 작성할 때 functools.wraps (예 : Python decorator handling docstrings)를 사용하여 데코 레이팅 된 메소드의 문서화 문자열을 보존하는 방법을 보여주는 다른 질문에 대한 답변을 보았습니다. 이러한 데코레이터에 대한 코드를 제어 할 수 없기 때문에 Google Cloud Endpoints 데코레이터로이를 수행 할 수있는 방법이 있습니까?

답변

1

결국 엔드 포인트 라이브러리의 사본을 로컬 수정했습니다. 변경 사항은 api_config.py, 구체적으로 데코레이터의 apiserving_method_decorator 기능에 있습니다. 나는 apiserving_method_decorator에 포함 된 invoke_remote 함수에 @wraps 장식을 추가 :

def method(request_message=message_types.VoidMessage, 
      response_message=message_types.VoidMessage, 
      name=None, 
      path=None, 
      http_method='POST', 
      cache_control=None, 
      scopes=None, 
      audiences=None, 
      allowed_client_ids=None, 
      auth_level=None): 
    # ... 

    def apiserving_method_decorator(api_method): 
     # ... 

     @wraps(api_method) 
     def invoke_remote(service_instance, request): 
      # ... 

그때 내가 pydoc이를 실행할 때 엔드 포인트 라이브러리의 로컬 수정 사본 내 PYTHONPATH에 있는지 확인하십시오.

관련 문제