Why doesn't Python see the changes I make to the code?

I am trying to configure a parser / lexer to extend the httpdomain Sphinx domain name. I installed in this directory and added the directory to sys.path as indicated in the docs.

Then I compile the Sphinx document and the http will highlight correctly.

Now I need to make a small change to the extension. I started by accidentally modifying the httpdomain.py file inside the dir, which correctly gave an error for the invalid syntax.

Then I changed lexer, replacing the HTTP token with HTTTP (one extra T). My idea is to see if elements in a document containing HTTTP are highlighted instead of HTTP.

The problem is that nothing changes the result. HTTP continues to stain and HTTTP is ignored.

Here is the lexer section that contains my change:

tokens = {
    'root': [
        (r'(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE)( +)([^ ]+)( +)'
         r'(HTTTPS?)(/)(1\.[013])(\r?\n|$)',
         bygroups(Name.Function, Text, Name.Namespace, Text,
                  Keyword.Reserved, Operator, Number, Text),
         'headers'),
        (r'(HTTTPS?)(/)(1\.[013])( +)(\d{3})( +)([^\r\n]+)(\r?\n|$)',
         bygroups(Keyword.Reserved, Operator, Number, Text, Number,
                  Text, Name.Exception, Text),
         'headers'),

         (r'([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)', header_callback),
         (r'([\t ]+)([^\r\n]+)(\r?\n|$)', continuous_header_callback),
         (r'\r?\n', Text, 'content')
    ],
    'headers': [
        (r'([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)', header_callback),
        (r'([\t ]+)([^\r\n]+)(\r?\n|$)', continuous_header_callback),
        (r'\r?\n', Text, 'content')
    ],
    'content': [
        (r'.+', content_callback)
    ]
}

Please note that “HTTP” has been changed to “HTTTP”, so I expect that the entries in the document containing HTTTP will now be colored, but nothing has changed.

I made changes to the text of the document and saw that they were updated on the page, so there are no problems with the cache.

I also deleted the Python folder created under the name __pycache__, no change as a result. I am also trying to comment on all the tokens in the lexer, no changes. If I insert the wrong syntax, then it fails. If the syntax is correct, it seems that it uses the source code without my changes.

Is there any other cache I need to clear?

I am completely new to Python, so I got a little lost here.

PS: HTTTP - . , .

+4
2

, , lexer , Pygments html. : app.add_lexer('http', HTTPLexer()), , .

+1

*.pyc

-1

Source: https://habr.com/ru/post/1541325/


All Articles