当前位置: 首页>>代码示例>>Python>>正文


Python formatting.markup_description函数代码示例

本文整理汇总了Python中rest_framework.utils.formatting.markup_description函数的典型用法代码示例。如果您正苦于以下问题:Python markup_description函数的具体用法?Python markup_description怎么用?Python markup_description使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了markup_description函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_view_doc

def get_view_doc(view, html=True):
    """
    Build view documentation. Return in html format.
    If you want in markdown format, use html=False
    """
    try:
        description = view.__doc__ or ''
        description = formatting.dedent(smart_text(description))

        # include filters in description
        filter_fields = get_filter_fields(view)
        if filter_fields:
            filter_doc = ['\n\n\n## Filters', '']
            for f in filter_fields:
                filter_doc.append('- `%s`' % f)
            description += '\n'.join(filter_doc)

        # replace {api_url} by current base url
        api_url = "/api"
        description = description.replace('{api_url}', api_url)
        if html:
            description = formatting.markup_description(description)
        return description
    except:
        import traceback
        traceback.print_exc()
        raise
开发者ID:gustavosoares,项目名称:django_services,代码行数:27,代码来源:utils.py

示例2: get_view_description

def get_view_description(view_cls, html=False):
    """
    Given a view class, return a textual description to represent the view.
    This name is used in the browsable API, and in OPTIONS responses.

    This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting.
    """
    description = view_cls.__doc__ or ''
    description = formatting.dedent(smart_text(description))

    if hasattr(getattr(view_cls, 'serializer_class', 'None'), 'Meta'):
        doc_url = get_doc_url(
            'api',
            '{0}s'.format(
                view_cls.serializer_class.Meta.model.__name__.lower()
            )
        )
    else:
        doc_url = get_doc_url('api')

    if html:
        return (
            formatting.markup_description(description) +
            mark_safe(DOC_TEXT.format(doc_url))
        )
    return description
开发者ID:nijel,项目名称:weblate,代码行数:26,代码来源:views.py

示例3: get_view_description

 def get_view_description(self, html=False):
     description = self.__doc__ or """
     Returns a nested list of objects that would be also be deleted when
     this object is deleted.
     """
     description = formatting.dedent(description)
     if html:
         return formatting.markup_description(description)
     return description
开发者ID:Darriall,项目名称:editorsnotes,代码行数:9,代码来源:base.py

示例4: get_view_description

def get_view_description(view_cls, html=False):
    """
    Given a view class, return a textual description to represent the view.
    This name is used in the browsable API, and in OPTIONS responses.

    This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting.
    """
    description = view_cls.__doc__ or ''
    description = formatting.dedent(smart_text(description))
    if html:
        return formatting.markup_description(description)
    return description
开发者ID:fengsi,项目名称:django-rest-framework,代码行数:12,代码来源:views.py

示例5: format_docstring

 def format_docstring(self, view, method, docstring):
     macros = settings.BROWSABLE_DOCUMENT_MACROS
     if view:
         macros['FILTERS'] = get_filters(view)
         if '%(SERIALIZER)s' in docstring:
             macros['SERIALIZER'] = get_serializer(view, include_read_only=True)
         if '%(WRITABLE_SERIALIZER)s' in docstring:
             macros['WRITABLE_SERIALIZER'] = get_serializer(view, include_read_only=False)
     string = formatting.dedent(docstring)
     formatted = string % macros
     formatted = self.substitute_urls(view, method, formatted)
     string = smart_text(formatted)
     return formatting.markup_description(string)
开发者ID:ycheng-aa,项目名称:product-definition-center,代码行数:13,代码来源:renderers.py

示例6: get_view_description

def get_view_description(cls, html=False):
    description = ''
    if getattr(cls, 'get_description', None):
        cache_key = cls.__name__
        cached_description = cache.get(cache_key)
        if not cached_description:
            description = cls.get_description()
            description = formatting.dedent(smart_text(description))
            # Cache for 1 hour (if we update description, it will take 1 hour to show)
            cache.set(cache_key, description, 60*60)
        else:
            description = cached_description
    if html:
        return formatting.markup_description(description)
    return description
开发者ID:MTG,项目名称:freesound,代码行数:15,代码来源:apiv2_utils.py

示例7: get_view_description

def get_view_description(view_cls, html=False):
    from django_markwhat.templatetags.markup import restructuredtext
    description = view_cls.__doc__ or ''
    description = formatting.dedent(smart_text(description))
    if html:
        rst_doc = getattr(view_cls, 'rst_doc', None)
        if rst_doc:
            if isinstance(rst_doc, str):
                path = os.path.dirname(sys.modules[view_cls.__module__].__file__)
                path = os.path.join(path, rst_doc)
                with open(path) as rst:
                    return restructuredtext(rst.read())
            return restructuredtext(description)
        return formatting.markup_description(description)
    return description
开发者ID:miphreal,项目名称:drf-tweaks,代码行数:15,代码来源:renderers.py

示例8: get_view_description

def get_view_description(view, html=False):
    """
    Given a view class, return a textual description to represent the view.
    This name is used in the browsable API, and in OPTIONS responses.

    This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting.
    """
    # Description may be set by some Views, such as a ViewSet.
    description = getattr(view, 'description', None)
    if description is None:
        description = view.__class__.__doc__ or ''

    description = formatting.dedent(smart_text(description))
    if html:
        return formatting.markup_description(description)
    return description
开发者ID:jplaut,项目名称:django-rest-framework,代码行数:16,代码来源:views.py

示例9: format_docstring

 def format_docstring(self, view, method, docstring):
     macros = settings.BROWSABLE_DOCUMENT_MACROS
     if view:
         macros['FILTERS'] = get_filters(view)
         if 'list' == method:
             ordering_field = get_ordering_field(view, method)
             if ordering_field:
                 ordering_string = ORDERING_STRING + " %s ." % ordering_field
                 macros['FILTERS'] += ordering_string
         if '%(SERIALIZER)s' in docstring:
             macros['SERIALIZER'] = get_serializer(view, include_read_only=True)
         if '%(WRITABLE_SERIALIZER)s' in docstring:
             macros['WRITABLE_SERIALIZER'] = get_serializer(view, include_read_only=False)
         if hasattr(view, 'docstring_macros'):
             macros.update(view.docstring_macros)
     string = formatting.dedent(docstring)
     formatted = string % macros
     formatted = self.substitute_urls(view, method, formatted)
     string = smart_text(formatted)
     return formatting.markup_description(string)
开发者ID:product-definition-center,项目名称:product-definition-center,代码行数:20,代码来源:renderers.py

示例10: markdown

def markdown(value):
    return markup_description(value)
开发者ID:Anc813,项目名称:django-rest-framework-docs,代码行数:2,代码来源:drfdocs_filters.py

示例11: get_view_description

def get_view_description(cls, html=False):
    description = cls.__doc__ or ''
    description = formatting.dedent(smart_text(description))
    if html:
        return formatting.markup_description(description)
    return description
开发者ID:Bazzinga,项目名称:django_rest_learn,代码行数:6,代码来源:views.py

示例12: format_docstring

 def format_docstring(self, docstring):
     formatted = docstring % settings.BROWSABLE_DOCUMENT_MACROS
     string = formatting.dedent(smart_text(formatted))
     return formatting.markup_description(string)
开发者ID:erichuanggit,项目名称:product-definition-center,代码行数:4,代码来源:renderers.py


注:本文中的rest_framework.utils.formatting.markup_description函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。