Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
20 changes: 8 additions & 12 deletions _unittests/ut_pycode/test_check_pep8_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""
import os
import unittest

from pyquickhelper.loghelper import fLOG
import sys
from pyquickhelper.pycode import check_pep8, ExtTestCase
from pyquickhelper.pycode.utils_tests_helper import PEP8Exception

Expand All @@ -23,21 +22,18 @@ def unused_var(self):
def undeclared_var(self):
aa + 5 # pylint: disable=E0602, W0104

@unittest.skipIf(sys.version_info[:2] <= (3, 6),
reason="pylint not available in the last version")
def test_unused_variable(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")

this = os.path.abspath(os.path.dirname(__file__))

def check_pep8_one_file():
check_pep8(this, fLOG=fLOG, max_line_length=150, recursive=False,
check_pep8(this, max_line_length=150, recursive=False,
neg_pattern="##",
pattern="test_check_pep8_sample.py")

def check_pep8_error_file():
check_pep8(this, fLOG=fLOG, recursive=False,
check_pep8(this, recursive=False,
pylint_ignore=('C0111', 'R0201', 'C0103'),
pattern="test_check_pep8_sample.py",
neg_pattern="##",
Expand All @@ -49,12 +45,12 @@ def check_pep8_error_file():
self.assertRaise(check_pep8_one_file, PEP8Exception,
"F[ECL1] line too long (link) 169 > 150")

check_pep8(this, fLOG=fLOG, max_line_length=170, recursive=False,
pylint_ignore=('C0111', 'R0201', 'C0103'),
check_pep8(this, max_line_length=170, recursive=False,
pylint_ignore=('C0111', 'C0103'),
pattern="test_check_pep8_sample.py",
neg_pattern="##",
skip=["test_check_pep8_sample.py:373: [E731]",
"test_check_pep8_sample.py:36",
"test_check_pep8_sample.py:35",
"test_check_pep8_sample.py:39",
"test_check_pep8_sample.py:11",
"test_check_pep8_sample.py:40: E0602",
Expand Down
7 changes: 6 additions & 1 deletion _unittests/ut_sphinxext/test_builders_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TestBuildersMissing(ExtTestCase):
def test_builders_missing(self):
from docutils import nodes as skip_
from sphinx.builders.latex.util import ExtBabel
from sphinx.builders.latex.theming import Theme

context = {'sphinxpkgoptions': '', 'latex_engine': 'pdflatex',
'fontenc': [], 'babel': [],
Expand Down Expand Up @@ -68,7 +69,11 @@ def get(self, name): # pylint: disable=R1711
document = dummy()

for cl in cls:
inst = cl(document, builder)
if cl == EnhancedLaTeXTranslator:
theme = Theme('manual')
inst = cl(document, builder, theme)
else:
inst = cl(document, builder)
inst._footnote = 'nofootnote'
inst.rst_image_dest = ''
if hasattr(inst, 'visit_table'):
Expand Down
14 changes: 1 addition & 13 deletions _unittests/ut_sphinxext/test_simpleimage_extension.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
@brief test log(time=4s)
@brief test log(time=6s)
@author Xavier Dupre
"""
import sys
Expand All @@ -10,8 +10,6 @@
import shutil
from io import StringIO
from docutils.parsers.rst import directives

from pyquickhelper.loghelper.flog import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase, is_travis_or_appveyor
from pyquickhelper.helpgen import rst2html
from pyquickhelper.sphinxext import SimpleImageDirective
Expand All @@ -23,19 +21,9 @@
class TestSimpleImageExtension(ExtTestCase):

def test_post_parse_sn(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")

directives.register_directive("video", SimpleImageDirective)

def test_simpleimage(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")

from docutils import nodes as skip_

this = os.path.abspath(os.path.dirname(__file__))
Expand Down
13 changes: 12 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ jobs:
matrix:
Python310:
python.version: '3.10'
sphinx.version: ''
require.version: ''
Python310-4:
python.version: '3.10'
sphinx.version: '==4.5.0'
require.version: ''
Python36:
python.version: '3.6'
sphinx.version: ''
require.version: '-3.6'
maxParallel: 3

steps:
Expand All @@ -29,14 +37,16 @@ jobs:
displayName: 'Install Graphviz'
- script: python -m pip install --upgrade pip setuptools wheel
displayName: 'Install tools'
- script: pip install -r requirements.txt
- script: pip install -r requirements$(require.version).txt
displayName: 'Install Requirements'
- script: python -m pip install scikit-learn
displayName: 'Install scipy scikit-learn'
- script: python -m pip install tkinterquickhelper --no-deps
displayName: 'Install tkinterquickhelper'
- script: pip uninstall -y pyquickhelper
displayName: 'uninstall pyquickhelper'
- script: python -m pip install "sphinx$(sphinx.version)"
displayName: 'Install Sphinx'
- script: export PYTHONPATH=src
displayName: 'PYTHONPATH=src'
- script: |
Expand All @@ -50,6 +60,7 @@ jobs:
# - script: python -u setup.py build_sphinx
# displayName: 'Builds Documentation'
- task: PublishPipelineArtifact@0
condition: eq('$(sphinx.version)', '')
inputs:
artifactName: 'wheel-linux-$(python.version)'
targetPath: 'dist'
Expand Down
59 changes: 59 additions & 0 deletions requirements-3.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
autopep8
bokeh
cairosvg>=2.5.0
cffi
codecov
coverage>=5.0
cryptography
docformatter
fastapi
fire
git-pandas
gitdb
img2pdf
ipython>=7.0.0
jinja2==3.0.3
js2py
jupyter
jupyter-client
jupyter-sphinx>=0.2.0
jyquickhelper>=0.3.128
keyring
keyrings.alt
keyrings.cryptfile
Mako
matplotlib
mistune
nbconvert>=6.0.7,!=6.3.0,!=6.4.0,!=6.4.1,!=6.4.2,!=6.5.0
nbformat
notebook>=6.0.0
numpy>=1.19
numpydoc
openpyxl
pandas>=1.0
pandocfilters
pillow
psutil
pycodestyle>=2.0.0
pycryptodomex
pydocstyle
pyinstrument
pylint
pylzma
pyquicksetup
pysftp
python-jenkins>=1.0.0
PyYAML
scipy
semantic_version
setuptools
Sphinx>=3.0
sphinx-gallery
sphinxcontrib-imagesvg
sphinx_rtd_theme
tabulate
tqdm
traitlets
unify
virtualenv
wheel
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pycodestyle>=2.0.0
pycryptodomex
pydocstyle
pyinstrument
pylint
pylint>=2.14.0
pylzma
pyquicksetup
pysftp
Expand Down
66 changes: 12 additions & 54 deletions src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,12 @@ def translate(self):
# visitor = self.builder.create_translator(self.document, self.builder)
# automatically adds methods visit_ and depart_ for translator
# based on the list of registered extensions. Might be worth using it.
visitor = self.translator_class(self.document, self.builder)
theme = self.builder.themes.get('manual')
if theme is None:
raise RuntimeError( # pragma: no cover
"theme cannot be None.")
visitor = self.translator_class(
self.document, self.builder, theme=theme)
self.document.walkabout(visitor)
self.output = visitor.body

Expand Down Expand Up @@ -1043,13 +1048,7 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername="memoryhtml"

# delayed import to speed up time
from sphinx.application import builtin_extensions
try:
from sphinx.application import CONFIG_FILENAME, Config, Tags
sphinx_version = 2 # pragma: no cover
except ImportError:
# Sphinx 3.0.0
from sphinx.config import CONFIG_FILENAME, Config, Tags
sphinx_version = 3
from sphinx.config import CONFIG_FILENAME, Config, Tags

# read config
self.tags = Tags(tags)
Expand All @@ -1076,11 +1075,6 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername="memoryhtml"
self.sphinx__display_version__ = __display_version__

# create the environment
if sphinx_version == 2: # pragma: no cover
with warnings.catch_warnings():
warnings.simplefilter(
"ignore", (DeprecationWarning, PendingDeprecationWarning, ImportWarning))
self.config.check_unicode()
self.config.pre_init_values()

# set up translation infrastructure
Expand Down Expand Up @@ -1356,12 +1350,7 @@ def add_builder(self, builder, override=False):
self._added_objects.append(('builder', builder))
if builder.name not in self.registry.builders:
self.debug('[_CustomSphinx] adding builder: %r', builder)
try:
# Sphinx >= 1.8
self.registry.add_builder(builder, override=override)
except TypeError: # pragma: no cover
# Sphinx < 1.8
self.registry.add_builder(builder)
self.registry.add_builder(builder, override=override)
else:
self.debug('[_CustomSphinx] already added builder: %r', builder)

Expand Down Expand Up @@ -1409,27 +1398,11 @@ def run(self):

obj.run = run

try:
# Sphinx >= 1.8
Sphinx.add_directive(self, name, obj, content=content, # pylint: disable=E1123
arguments=arguments,
override=override, **options)
except TypeError:
# Sphinx >= 3.0.0
Sphinx.add_directive(self, name, obj, override=override, **options)
except ExtensionError: # pragma: no cover
# Sphinx < 1.8
Sphinx.add_directive(self, name, obj, content=content, # pylint: disable=E1123
arguments=arguments, **options)
Sphinx.add_directive(self, name, obj, override=override, **options)

def add_domain(self, domain, override=True):
self._added_objects.append(('domain', domain))
try:
# Sphinx >= 1.8
Sphinx.add_domain(self, domain, override=override)
except TypeError: # pragma: no cover
# Sphinx < 1.8
Sphinx.add_domain(self, domain)
Sphinx.add_domain(self, domain, override=override)
# For some reason, the directives are missing from the main catalog
# in docutils.
for k, v in domain.directives.items():
Expand All @@ -1443,15 +1416,6 @@ def add_domain(self, domain, override=True):
# We add the role without the domain name as a prefix.
self.add_role(k, v)

def override_domain(self, domain):
self._added_objects.append(('domain-over', domain))
try:
Sphinx.override_domain(self, domain)
except AttributeError: # pragma: no cover
# Sphinx==3.0.0
raise AttributeError(
"override_domain not available in sphinx==3.0.0")

def add_role(self, name, role, override=True):
self._added_objects.append(('role', name))
self.debug('[_CustomSphinx] adding role: %r', (name, role))
Expand Down Expand Up @@ -1514,14 +1478,8 @@ def add_config_value(self, name, default, rebuild, types_=()): # pylint: disabl
def add_directive_to_domain(self, domain, name, obj, has_content=None, # pylint: disable=W0221,W0237
argument_spec=None, override=False, **option_spec):
self._added_objects.append(('directive_to_domain', domain, name))
try:
Sphinx.add_directive_to_domain(self, domain, name, obj, # pylint: disable=E1123
has_content=has_content, argument_spec=argument_spec,
override=override, **option_spec)
except TypeError: # pragma: no cover
# Sphinx==3.0.0
Sphinx.add_directive_to_domain(self, domain, name, obj,
override=override, **option_spec)
Sphinx.add_directive_to_domain(self, domain, name, obj,
override=override, **option_spec)

def add_role_to_domain(self, domain, name, role, override=False):
self._added_objects.append(('roles_to_domain', domain, name))
Expand Down
Loading