<commit_before>"""Generates API documentation by introspection."""
import importlib
import rest_framework
from rest_framework import viewsets
from rest_framework.serializers import BaseSerializer
from rest_framework_swagger import SWAGGER_SETTINGS

from .introspectors import (
    APIViewIntrospector,
    BaseMethodIntrospector,
    IntrospectorHelper,
    ViewSetIntrospector,
    WrappedAPIViewIntrospector,
    get_data_type,
    get_default_value,
    get_primitive_type
)
from .compat import OrderedDict


class DocumentationGenerator(object):
    # Serializers defined in docstrings
    explicit_serializers = set()

    # Serializers defined in fields
    fields_serializers = set()

    # Response classes defined in docstrings
    explicit_response_types = dict()

    def __init__(self, for_user=None):

        # unauthenticated user is expected to be in the form 'module.submodule.Class' if a value is present
        unauthenticated_user = SWAGGER_SETTINGS.get('unauthenticated_user')

        # attempt to load unathenticated_user class from settings if a user is not supplied
        if not for_user and unauthenticated_user:
            module_name, class_name = unauthenticated_user.rsplit(".", 1)
            unauthenticated_user_class = getattr(importlib.import_module(module_name), class_name)
            for_user = unauthenticated_user_class()

        self.user = for_user

    def generate(self, apis):
        """
        Returns documentation for a list of APIs
        """
        api_docs = []
        for api in apis:

            operations = self.get_operations(api, apis)
            for operation in operations:
                if operation['method'] == 'post':
                    operations.remove(operation)

            api_docs.append({
                'description': IntrospectorHelper.get_summary(api['callback']),
                'path': api['path'],
                'operations': operations,
            })
<commit_msg>Print testing.<commit_after>"""Generates API documentation by introspection."""
import importlib
import rest_framework
from rest_framework import viewsets
from rest_framework.serializers import BaseSerializer
from rest_framework_swagger import SWAGGER_SETTINGS

from .introspectors import (
    APIViewIntrospector,
    BaseMethodIntrospector,
    IntrospectorHelper,
    ViewSetIntrospector,
    WrappedAPIViewIntrospector,
    get_data_type,
    get_default_value,
    get_primitive_type
)
from .compat import OrderedDict


class DocumentationGenerator(object):
    # Serializers defined in docstrings
    explicit_serializers = set()

    # Serializers defined in fields
    fields_serializers = set()

    # Response classes defined in docstrings
    explicit_response_types = dict()

    def __init__(self, for_user=None):

        # unauthenticated user is expected to be in the form 'module.submodule.Class' if a value is present
        unauthenticated_user = SWAGGER_SETTINGS.get('unauthenticated_user')

        # attempt to load unathenticated_user class from settings if a user is not supplied
        if not for_user and unauthenticated_user:
            module_name, class_name = unauthenticated_user.rsplit(".", 1)
            unauthenticated_user_class = getattr(importlib.import_module(module_name), class_name)
            for_user = unauthenticated_user_class()

        self.user = for_user

    def generate(self, apis):
        """
        Returns documentation for a list of APIs
        """
        api_docs = []
        for api in apis:

            operations = self.get_operations(api, apis)
            for operation in operations:
                if operation['method'] == 'post':
                    operations.remove(operation)

            print operations
            api_docs.append({
                'description': IntrospectorHelper.get_summary(api['callback']),
                'path': api['path'],
                'operations': operations,
            })

{'fraction_non_alphanumeric': 0.06900910010111223, 'fraction_numerical': 0.0005055611729019212, 'mean_word_length': 2.8908554572271385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3504577', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1033, 'n_words': 281}