__init__.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright 2015 ksyun.com, Inc. or its affiliates. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"). You
  4. # may not use this file except in compliance with the License. A copy of
  5. # the License is located at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # or in the "license" file accompanying this file. This file is
  10. # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  11. # ANY KIND, either express or implied. See the License for the specific
  12. # language governing permissions and limitations under the License.
  13. import os
  14. from kscore.docs.service import ServiceDocumenter
  15. def generate_docs(root_dir, session):
  16. """Generates the reference documentation for kscore
  17. This will go through every available KSYUN service and output ReSTructured
  18. text files documenting each service.
  19. :param root_dir: The directory to write the reference files to. Each
  20. service's reference documentation is loacated at
  21. root_dir/reference/services/service-name.rst
  22. """
  23. services_doc_path = os.path.join(root_dir, 'reference', 'services')
  24. if not os.path.exists(services_doc_path):
  25. os.makedirs(services_doc_path)
  26. # Generate reference docs and write them out.
  27. for service_name in session.get_available_services():
  28. docs = ServiceDocumenter(service_name, session).document_service()
  29. service_doc_path = os.path.join(
  30. services_doc_path, service_name + '.rst')
  31. with open(service_doc_path, 'wb') as f:
  32. f.write(docs)