Skip to content

Conversation

@tk0miya
Copy link
Member

@tk0miya tk0miya commented Aug 17, 2021

Feature or Bugfix

  • Bugfix

@hroncok
Copy link
Contributor

hroncok commented Aug 18, 2021

Thanks. This indeed fixes the problem with Pygments 2.10, I haven't checked with Pygments 2.9.

@hroncok
Copy link
Contributor

hroncok commented Aug 18, 2021

This seems to fail with Pygments 2.9:

============================= test session starts ==============================
platform linux -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
libraries: Sphinx-4.1.3+/06ec5b027, docutils-0.17.1
base tempdir: /tmp/pytest-of-churchyard/pytest-15
rootdir: .../sphinx, configfile: setup.cfg
plugins: cov-2.12.1
collected 49 items

tests/test_intl.py ............................................F....     [100%]

=================================== FAILURES ===================================
_________________ test_additional_targets_should_be_translated _________________

app = <SphinxTestApp buildername='html'>

    @sphinx_intl
    @pytest.mark.sphinx(
        'html',
        srcdir='test_additional_targets_should_be_translated',
        confoverrides={
            'language': 'xx', 'locale_dirs': ['.'],
            'gettext_compact': False,
            'gettext_additional_targets': [
                'index',
                'literal-block',
                'doctest-block',
                'raw',
                'image',
            ],
        }
    )
    def test_additional_targets_should_be_translated(app):
        app.build()
        # [literalblock.txt]
        result = (app.outdir / 'literalblock.html').read_text()
    
        # title should be translated
        expected_expr = 'CODE-BLOCKS'
        assert_count(expected_expr, result, 2)
    
        # ruby code block should be translated and be highlighted
        expected_expr = """<span class="s1">&#39;RESULT&#39;</span>"""
        assert_count(expected_expr, result, 1)
    
        # C code block without lang should be translated and *ruby* highlighted
        expected_expr = """<span class="c1">#include &lt;STDLIB.H&gt;</span>"""
        assert_count(expected_expr, result, 1)
    
        # C code block with lang should be translated and be *C* highlighted
        if pygments_version < (2, 10, 0):
            expected_expr = ("""<span class="cp">#include</span> """
                             """<span class="cpf">&lt;stdio.h&gt;</span>""")
        else:
            expected_expr = ("""<span class="cp">#include</span>"""
                             """<span class="w"> </span>"""
                             """<span class="cpf">&lt;STDIO.H&gt;</span>""")
>       assert_count(expected_expr, result, 1)

tests/test_intl.py:1156: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

expected_expr = '<span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span>'
result = '\n<!DOCTYPE html>\n\n<html lang="xx">\n  <head>\n    <meta charset="utf-8" />\n    <meta name="viewport" content="wid...="_sources/literalblock.txt"\n          rel="nofollow">Page source</a>\n    </div>\n\n    \n\n    \n  </body>\n</html>'
count = 1

    def assert_count(expected_expr, result, count):
        find_pair = (expected_expr, result)
>       assert len(re.findall(*find_pair)) == count, find_pair
E       AssertionError: ('<span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span>', '
E         <!DOCTYPE html>
E         
E         <html lang="xx">
E         ..."_sources/literalblock.txt"
E                   rel="nofollow">Page source</a>
E             </div>
E         
E             
E         
E             
E           </body>
E         </html>')
E       assert 0 == 1
E        +  where 0 = len([])
E        +    where [] = <function findall at 0x7f85949783a0>(*('<span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span>', '\n<!DOCTYPE html>\n\n<html lang="xx">\n..."_sources/literalblock.txt"\n          rel="nofollow">Page source</a>\n    </div>\n\n    \n\n    \n  </body>\n</html>'))
E        +      where <function findall at 0x7f85949783a0> = re.findall

tests/test_intl.py:93: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# language: xx
# locale_dirs: ['.']
# testroot: root
# builder: html
# srcdir: /tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated
# outdir: /tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/_build/html
# status: 
Running Sphinx v4.1.3+/06ec5b027
loading translations [xx]... done
building [mo]: targets for 27 po files that are out of date
writing output... [  3%] xx/LC_MESSAGES/admonitions.mo                         
writing output... [  7%] xx/LC_MESSAGES/refs_inconsistency.mo                  
writing output... [ 11%] xx/LC_MESSAGES/refs.mo                                
writing output... [ 14%] xx/LC_MESSAGES/versionchange.mo                       
writing output... [ 18%] xx/LC_MESSAGES/docfields.mo                           
writing output... [ 22%] xx/LC_MESSAGES/footnote.mo                            
writing output... [ 25%] xx/LC_MESSAGES/table.mo                               
writing output... [ 29%] xx/LC_MESSAGES/raw.mo                                 
writing output... [ 33%] xx/LC_MESSAGES/refs_python_domain.mo                  
writing output... [ 37%] xx/LC_MESSAGES/only.mo                                
writing output... [ 40%] xx/LC_MESSAGES/glossary_terms_inconsistency.mo        
writing output... [ 44%] xx/LC_MESSAGES/external_links.mo                      
writing output... [ 48%] xx/LC_MESSAGES/bom.mo                                 
writing output... [ 51%] xx/LC_MESSAGES/rubric.mo                              
writing output... [ 55%] xx/LC_MESSAGES/definition_terms.mo                    
writing output... [ 59%] xx/LC_MESSAGES/role_xref.mo                           
writing output... [ 62%] xx/LC_MESSAGES/index_entries.mo                       
writing output... [ 66%] xx/LC_MESSAGES/seealso.mo                             
writing output... [ 70%] xx/LC_MESSAGES/section.mo                             
writing output... [ 74%] xx/LC_MESSAGES/literalblock.mo                        
writing output... [ 77%] xx/LC_MESSAGES/figure.mo                              
writing output... [ 81%] xx/LC_MESSAGES/warnings.mo                            
writing output... [ 85%] xx/LC_MESSAGES/label_target.mo                        
writing output... [ 88%] xx/LC_MESSAGES/index.mo                               
writing output... [ 92%] xx/LC_MESSAGES/toctree.mo                             
writing output... [ 96%] xx/LC_MESSAGES/topic.mo                               
writing output... [100%] xx/LC_MESSAGES/glossary_terms.mo                      
building [html]: targets for 28 source files that are out of date
updating environment: [new config] 28 added, 0 changed, 0 removed
reading sources... [  3%] admonitions                                          
reading sources... [  7%] bom                                                  
reading sources... [ 10%] definition_terms                                     
reading sources... [ 14%] docfields                                            
reading sources... [ 17%] external_links                                       
reading sources... [ 21%] figure                                               
reading sources... [ 25%] footnote                                             
reading sources... [ 28%] glossary_terms                                       
reading sources... [ 32%] glossary_terms_inconsistency                         
reading sources... [ 35%] index                                                
reading sources... [ 39%] index_entries                                        
reading sources... [ 42%] label_target                                         
reading sources... [ 46%] literalblock                                         
reading sources... [ 50%] only                                                 
reading sources... [ 53%] raw                                                  
reading sources... [ 57%] refs                                                 
reading sources... [ 60%] refs_inconsistency                                   
reading sources... [ 64%] refs_python_domain                                   
reading sources... [ 67%] role_xref                                            
reading sources... [ 71%] rubric                                               
reading sources... [ 75%] section                                              
reading sources... [ 78%] seealso                                              
reading sources... [ 82%] subdir/index                                         
reading sources... [ 85%] table                                                
reading sources... [ 89%] toctree                                              
reading sources... [ 92%] topic                                                
reading sources... [ 96%] versionchange                                        
reading sources... [100%] warnings                                             
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [  3%] admonitions                                           
writing output... [  7%] bom                                                   
writing output... [ 10%] definition_terms                                      
writing output... [ 14%] docfields                                             
writing output... [ 17%] external_links                                        
writing output... [ 21%] figure                                                
writing output... [ 25%] footnote                                              
writing output... [ 28%] glossary_terms                                        
writing output... [ 32%] glossary_terms_inconsistency                          
writing output... [ 35%] index                                                 
writing output... [ 39%] index_entries                                         
writing output... [ 42%] label_target                                          
writing output... [ 46%] literalblock                                          
writing output... [ 50%] only                                                  
writing output... [ 53%] raw                                                   
writing output... [ 57%] refs                                                  
writing output... [ 60%] refs_inconsistency                                    
writing output... [ 64%] refs_python_domain                                    
writing output... [ 67%] role_xref                                             
writing output... [ 71%] rubric                                                
writing output... [ 75%] section                                               
writing output... [ 78%] seealso                                               
writing output... [ 82%] subdir/index                                          
writing output... [ 85%] table                                                 
writing output... [ 89%] toctree                                               
writing output... [ 92%] topic                                                 
writing output... [ 96%] versionchange                                         
writing output... [100%] warnings                                              
generating indices... genindex done
writing additional pages... contents search done
copying images... [ 50%] img.png                                               
copying images... [100%] i18n.png                                              
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 19 warnings.

The HTML pages are in ../../../../../tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/_build/html.

# warning: 
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/glossary_terms_inconsistency.txt:6: WARNING: inconsistent term references in translated message. original: [':term:`Some term`', ':term:`Some other term`'], translated: [':term:`SOME NEW TERM`']
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/label_target.txt:41: WARNING: Duplicate target name, cannot be used as a unique reference: "duplicated sub section".
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/literalblock.txt:13: WARNING: Literal block expected; none found.
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs.txt:16: WARNING: inconsistent references in translated message. original: ['`download Sphinx`_'], translated: ['`A3 DOWNLOAD SPHINX <download Sphinx_>`_', '`A3 DOWNLOAD SPHINX <download Sphinx_>`_']
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs.txt:32: WARNING: inconsistent references in translated message. original: ['`Translation Tips`_'], translated: ['`X TIPS <Translation Tips_>`_', '`X TIPS <Translation Tips_>`_']
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs.txt:34: WARNING: inconsistent references in translated message. original: ['`Translation Tips`_'], translated: ['`TRANS <X TIPS_>`_', '`LATION <X TIPS_>`_']
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs_inconsistency.txt:6: WARNING: inconsistent footnote references in translated message. original: ['[#]_'], translated: []
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs_inconsistency.txt:6: WARNING: inconsistent footnote references in translated message. original: ['[100]_'], translated: []
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs_inconsistency.txt:7: WARNING: inconsistent references in translated message. original: ['reference_'], translated: ['reference_', 'reference_']
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs_inconsistency.txt:8: WARNING: inconsistent references in translated message. original: [], translated: ['`I18N WITH REFS INCONSISTENCY`_']
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/warnings.txt:4:<translated>:1: WARNING: Inline literal start-string without end-string.
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/warnings.txt:4:<translated>:1: WARNING: Inline literal start-string without end-string.
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/admonitions.txt: WARNING: document isn't included in any toctree
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/label_target.txt: WARNING: document isn't included in any toctree
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs_python_domain.txt: WARNING: document isn't included in any toctree
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/rubric.txt: WARNING: document isn't included in any toctree
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/toctree.txt: WARNING: document isn't included in any toctree
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs_inconsistency.txt:11: WARNING: Citation [ref2] is not referenced.
/tmp/pytest-of-churchyard/pytest-15/test_additional_targets_should_be_translated/refs_inconsistency.txt:6: WARNING: citation not found: ref3

=========================== short test summary info ============================
FAILED tests/test_intl.py::test_additional_targets_should_be_translated - Ass...
========================= 1 failed, 48 passed in 6.08s =========================

@tk0miya tk0miya merged commit 9f46b1f into sphinx-doc:4.1.x Aug 21, 2021
@tk0miya tk0miya deleted the pygments branch August 21, 2021 12:02
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants