mirror of
https://github.com/vale981/recommonmark
synced 2025-03-04 17:41:38 -05:00
Add tests for checking that pygments will still highlight the code. This requires a newer version sphinx as well.
This commit is contained in:
parent
40a82ef39d
commit
0eee19e600
8 changed files with 117 additions and 3 deletions
|
@ -237,7 +237,6 @@ def reference(block):
|
|||
ref_node['refuri'] = block.destination
|
||||
else:
|
||||
ref_node['refname'] = label
|
||||
# self.document.note_refname(ref_node)
|
||||
|
||||
if block.title:
|
||||
ref_node['title'] = block.title
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
commonmark<=0.5.4
|
||||
docutils>=0.11
|
||||
sphinx==1.3.1
|
||||
sphinx>=1.3.1
|
||||
pytest==2.7.2
|
||||
|
|
22
tests/sphinx_code_block/conf.py
Normal file
22
tests/sphinx_code_block/conf.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
|
||||
templates_path = ['_templates']
|
||||
source_suffix = '.md'
|
||||
source_parsers = { '.md': CommonMarkParser }
|
||||
master_doc = 'index'
|
||||
project = u'sphinxproj'
|
||||
copyright = u'2015, rtfd'
|
||||
author = u'rtfd'
|
||||
version = '0.1'
|
||||
release = '0.1'
|
||||
highlight_language = 'python'
|
||||
language = None
|
||||
exclude_patterns = ['_build']
|
||||
pygments_style = 'sphinx'
|
||||
todo_include_todos = False
|
||||
html_theme = 'alabaster'
|
||||
html_static_path = ['_static']
|
||||
htmlhelp_basename = 'sphinxproj'
|
11
tests/sphinx_code_block/index.md
Normal file
11
tests/sphinx_code_block/index.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
Header
|
||||
======
|
||||
|
||||
A paragraph
|
||||
```
|
||||
def f():
|
||||
pass
|
||||
```
|
||||
Another paragraph
|
||||
|
||||
|
22
tests/sphinx_indented_code/conf.py
Normal file
22
tests/sphinx_indented_code/conf.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
|
||||
templates_path = ['_templates']
|
||||
source_suffix = '.md'
|
||||
source_parsers = { '.md': CommonMarkParser }
|
||||
master_doc = 'index'
|
||||
project = u'sphinxproj'
|
||||
copyright = u'2015, rtfd'
|
||||
author = u'rtfd'
|
||||
version = '0.1'
|
||||
release = '0.1'
|
||||
language = None
|
||||
exclude_patterns = ['_build']
|
||||
highlight_language = 'python'
|
||||
pygments_style = 'sphinx'
|
||||
todo_include_todos = False
|
||||
html_theme = 'alabaster'
|
||||
html_static_path = ['_static']
|
||||
htmlhelp_basename = 'sphinxproj'
|
10
tests/sphinx_indented_code/index.md
Normal file
10
tests/sphinx_indented_code/index.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
Header
|
||||
======
|
||||
|
||||
A paragraph
|
||||
|
||||
def f():
|
||||
pass
|
||||
|
||||
Another paragraph
|
||||
|
48
tests/test_sphinx.py
Normal file
48
tests/test_sphinx.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
import os
|
||||
import io
|
||||
import sys
|
||||
import shutil
|
||||
import unittest
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
|
||||
|
||||
class SphinxIntegrationTests(unittest.TestCase):
|
||||
|
||||
def _run_test(self, test_dir, test_file, test_string):
|
||||
os.chdir('tests/{0}'.format(test_dir))
|
||||
try:
|
||||
app = Sphinx(
|
||||
srcdir='.',
|
||||
confdir='.',
|
||||
outdir='_build/text',
|
||||
doctreedir='_build/.doctrees',
|
||||
buildername='html',
|
||||
verbosity=1,
|
||||
)
|
||||
app.build(force_all=True)
|
||||
with io.open(test_file, encoding='utf-8') as fin:
|
||||
text = fin.read().strip()
|
||||
self.assertIn(test_string, text)
|
||||
finally:
|
||||
shutil.rmtree('_build')
|
||||
os.chdir('../..')
|
||||
|
||||
class CodeBlockTests(SphinxIntegrationTests):
|
||||
|
||||
def test_integration(self):
|
||||
self._run_test(
|
||||
'sphinx_code_block',
|
||||
'_build/text/index.html',
|
||||
'<div class="highlight">'
|
||||
)
|
||||
|
||||
|
||||
class IndentedCodeTests(SphinxIntegrationTests):
|
||||
|
||||
def test_integration(self):
|
||||
self._run_test(
|
||||
'sphinx_indented_code',
|
||||
'_build/text/index.html',
|
||||
'<div class="highlight">'
|
||||
)
|
4
tox.ini
4
tox.ini
|
@ -10,7 +10,9 @@ commands =
|
|||
py.test {posargs}
|
||||
|
||||
[testenv:docs]
|
||||
deps = {[testenv]deps}
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
sphinx_rtd_theme
|
||||
changedir = {toxinidir}/docs
|
||||
commands =
|
||||
sphinx-build -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
|
||||
|
|
Loading…
Add table
Reference in a new issue