    ===========================
    PyAMS_utils pygments module
    ===========================

    PyAMS_utils "pygments" module can be used to add syntax highlighting to any source code,
    using the Pygments package.

        >>> from pyramid.testing import setUp, tearDown, DummyRequest
        >>> config = setUp(hook_zca=True)

        >>> from cornice import includeme as include_cornice
        >>> include_cornice(config)
        >>> from pyams_utils import includeme as include_utils
        >>> include_utils(config)

    Pygments styles
    ---------------

    A view is used to get CSS styles:

        >>> from pyams_utils.pygments import get_pygments_style_view
        >>> request = DummyRequest(if_modified_since=None)
        >>> get_pygments_style_view(request).body
        b'pre { line-height: 125%; }...'

        >>> from datetime import datetime
        >>> request = DummyRequest(if_modified_since=datetime.utcnow())
        >>> get_pygments_style_view(request).status_code
        304

    Pygments lexers vocabulary
    --------------------------

    A vocabulary provides all Pygments lexers:

        >>> from pyams_utils.pygments import PygmentsLexersVocabulary
        >>> vocabulary = PygmentsLexersVocabulary(None)
        >>> len(vocabulary) > 400
        True
        >>> vocabulary._terms[0].value
        'auto'
        >>> vocabulary._terms[0].title
        'Automatic detection'

        >>> vocabulary._terms[1].value
        'abap'
        >>> vocabulary._terms[1].title
        'ABAP (*.abap, *.ABAP)'

        >>> vocabulary._terms[-1].value
        'zig'
        >>> vocabulary._terms[-1].title
        'Zig (*.zig)'

    Pygments styles vocabulary
    --------------------------

        >>> from pyams_utils.pygments import PygmentsStylesVocabulary
        >>> vocabulary = PygmentsStylesVocabulary(None)
        >>> len(vocabulary) > 30
        True
        >>> vocabulary._terms[0].value
        'abap'
        >>> vocabulary._terms[1].value
        'algol'
        >>> vocabulary._terms[-1].value
        'zenburn'

    Source code rendering
    ---------------------

        >>> from pyams_utils.pygments import render_source, PygmentsCodeRendererSettings
        >>> settings = PygmentsCodeRendererSettings()
        >>> src = '''def test(value):
        ...     print('Getting value...')
        ...     return value + 1
        ... '''
        >>> render_source(src, settings)
        '

    1def test(value):\n2    print('Getting value...')\n3    return value + 1\n

    \n'

        >>> settings.lexer = 'python'
        >>> render_source(src, settings)
        '

    1def test(value):\n2    print('Getting value...')\n3    return value + 1\n

    \n'

        >>> settings.display_linenos = False

        >>> from zope.component import queryMultiAdapter
        >>> from pyams_utils.interfaces.text import IHTMLRenderer
        >>> renderer = queryMultiAdapter((src, request), IHTMLRenderer, name='source-code')
        >>> renderer.render()
        '

    1def test(value):\n2    print('Getting value...')\n3    return value + 1\n

\n' Tests cleanup: >>> tearDown()