Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
`Sphinx <http://sphinx-doc.org/>`_ documentation:

* `imagesvg <https://pypi.python.org/pypi/sphinxcontrib-imagesvg/>`_: to include svg figures
* `jsdemo <https://pypi.python.org/pypi/sphinxcontrib-imagesvg/>`_: to demo javascript and HTML

.. demo::

Expand Down
1 change: 0 additions & 1 deletion _unittests/ut_sphinxext/test_style_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_docstyle(self):
extensions = [_ for _ in extensions if "matplotlib" not in _ and
"images" not in _ and "IPython" not in _ and
"nbsphinx" not in _ and "jupyter" not in _ and
"jsdemo" not in _ and
"inheritance_diagram" not in _]
external_docnames = [
"_modules/src/pyquickhelper/helpgen/_fake_function_to_documentation"]
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ PyYAML
scipy
semantic_version
setuptools
Sphinx>=3.0,<4.0
Sphinx>=3.0
sphinx-gallery
sphinxcontrib-imagesvg
sphinxcontrib-jsdemo
sphinx_rtd_theme
tabulate
tqdm
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
'pysftp',
"requests",
"semantic_version",
"sphinx>=3.0,<4.0",
"sphinx>=3.0",
"sphinx-gallery",
"sphinxcontrib-imagesvg",
"traitlets>=5.0",
Expand Down
8 changes: 0 additions & 8 deletions src/pyquickhelper/helpgen/default_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,6 @@ def set_sphinx_variables(fileconf, module_name, author, year, theme, theme_path,
# matplotlib is not installed.
pass

try:
import sphinxcontrib.jsdemo
assert sphinxcontrib.jsdemo is not None
extensions.append('sphinxcontrib.jsdemo')
except ImportError: # pragma: no cover
# No module sphinxcontrib.jsdemo.
pass

if use_lunrsearch: # pragma: no cover
extensions.append('sphinxcontrib.lunrsearch')

Expand Down
53 changes: 30 additions & 23 deletions src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
from sphinx.project import Project
from sphinx.errors import ApplicationError
from sphinx.util.logging import getLogger
from ..sphinxext.sphinx_doctree_builder import DocTreeBuilder, DocTreeWriter, DocTreeTranslator
from ..sphinxext.sphinx_doctree_builder import (
DocTreeBuilder, DocTreeWriter, DocTreeTranslator)
from ..sphinxext.sphinx_md_builder import MdBuilder, MdWriter, MdTranslator
from ..sphinxext.sphinx_latex_builder import EnhancedLaTeXBuilder, EnhancedLaTeXWriter, EnhancedLaTeXTranslator
from ..sphinxext.sphinx_latex_builder import (
EnhancedLaTeXBuilder, EnhancedLaTeXWriter, EnhancedLaTeXTranslator)
from ..sphinxext.sphinx_rst_builder import RstBuilder, RstWriter, RstTranslator
from ._single_file_html_builder import CustomSingleFileHTMLBuilder

Expand Down Expand Up @@ -171,8 +173,8 @@ class HTMLTranslatorWithCustomDirectives(_AdditionalVisitDepart, HTMLTranslator)
See @see cl HTMLWriterWithCustomDirectives.
"""

def __init__(self, builder, *args, **kwds):
HTMLTranslator.__init__(self, builder, *args, **kwds)
def __init__(self, document, builder, *args, **kwds):
HTMLTranslator.__init__(self, document, builder, *args, **kwds)
_AdditionalVisitDepart.__init__(self, 'html')
nodes_list = getattr(builder, '_function_node', None)
if nodes_list is not None:
Expand Down Expand Up @@ -201,11 +203,11 @@ class RSTTranslatorWithCustomDirectives(_AdditionalVisitDepart, RstTranslator):
See @see cl HTMLWriterWithCustomDirectives.
"""

def __init__(self, builder, *args, **kwds):
def __init__(self, document, builder, *args, **kwds):
"""
constructor
"""
RstTranslator.__init__(self, builder, *args, **kwds)
RstTranslator.__init__(self, document, builder, *args, **kwds)
_AdditionalVisitDepart.__init__(self, 'rst')
for name, f1, f2 in builder._function_node:
setattr(self.__class__, "visit_" + name, f1)
Expand All @@ -218,11 +220,11 @@ class MDTranslatorWithCustomDirectives(_AdditionalVisitDepart, MdTranslator):
See @see cl HTMLWriterWithCustomDirectives.
"""

def __init__(self, builder, *args, **kwds):
def __init__(self, document, builder, *args, **kwds):
"""
constructor
"""
MdTranslator.__init__(self, builder, *args, **kwds)
MdTranslator.__init__(self, document, builder, *args, **kwds)
_AdditionalVisitDepart.__init__(self, 'md')
for name, f1, f2 in builder._function_node:
setattr(self.__class__, "visit_" + name, f1)
Expand All @@ -235,11 +237,11 @@ class DocTreeTranslatorWithCustomDirectives(DocTreeTranslator):
See @see cl HTMLWriterWithCustomDirectives.
"""

def __init__(self, builder, *args, **kwds):
def __init__(self, document, builder, *args, **kwds):
"""
constructor
"""
DocTreeTranslator.__init__(self, builder, *args, **kwds)
DocTreeTranslator.__init__(self, document, builder, *args, **kwds)
self.base_class = DocTreeTranslator


Expand All @@ -248,7 +250,7 @@ class LatexTranslatorWithCustomDirectives(_AdditionalVisitDepart, EnhancedLaTeXT
See @see cl LatexWriterWithCustomDirectives.
"""

def __init__(self, builder, document, *args, **kwds):
def __init__(self, document, builder, *args, **kwds):
"""
constructor
"""
Expand All @@ -258,7 +260,7 @@ def __init__(self, builder, document, *args, **kwds):
raise TypeError( # pragma: no cover
"Builder has no config: {} - {}".format(type(builder), type(document)))
EnhancedLaTeXTranslator.__init__(
self, builder, document, *args, **kwds)
self, document, builder, *args, **kwds)
_AdditionalVisitDepart.__init__(self, 'md')
for name, f1, f2 in builder._function_node:
setattr(self.__class__, "visit_" + name, f1)
Expand Down Expand Up @@ -319,9 +321,6 @@ def write(self, document, destination):

Normally not overridden or extended in subclasses.
"""
# trans = self.builder.create_translator(self.builder, document)
# if not isinstance(trans, HTMLTranslatorWithCustomDirectives):
# raise TypeError("The translator is not of a known type but '{0}'".format(type(trans)))
self.base_class.write(self, document, destination)


Expand All @@ -347,7 +346,7 @@ def __init__(self, builder=None, app=None): # pylint: disable=W0231

def translate(self):
self.visitor = visitor = self.translator_class(
self.builder, self.document)
self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.astext()
for attr in ('head_prefix', 'stylesheet', 'head', 'body_prefix',
Expand All @@ -374,7 +373,7 @@ def __init__(self, builder=None, app=None): # pylint: disable=W0231
self, RstWriter, RSTTranslatorWithCustomDirectives, app)

def translate(self):
visitor = self.translator_class(self.builder, self.document)
visitor = self.translator_class(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.body

Expand All @@ -394,7 +393,7 @@ def __init__(self, builder=None, app=None): # pylint: disable=W0231
self, MdWriter, MDTranslatorWithCustomDirectives, app)

def translate(self):
visitor = self.translator_class(self.builder, self.document)
visitor = self.translator_class(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.body

Expand All @@ -414,7 +413,7 @@ def __init__(self, builder=None, app=None): # pylint: disable=W0231
self, DocTreeWriter, DocTreeTranslatorWithCustomDirectives, app)

def translate(self):
visitor = self.translator_class(self.builder, self.document)
visitor = self.translator_class(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.body

Expand All @@ -441,10 +440,10 @@ def translate(self):
raise TypeError( # pragma: no cover
"Builder has no config: {}".format(type(self.builder)))
# The instruction
# visitor = self.builder.create_translator(self.builder, self.document)
# 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.builder, self.document)
visitor = self.translator_class(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.body

Expand Down Expand Up @@ -1208,7 +1207,7 @@ def _citems():

# create the project
self.project = Project(self.srcdir, self.config.source_suffix)
# create the builder
# create the builder, initializes _MemoryBuilder
self.builder = self.create_builder(buildername)
# set up the build environment
self._init_env(freshenv)
Expand All @@ -1221,9 +1220,17 @@ def _citems():

# addition
self._extended_init_()

# verification
self._check_init_()

def _check_init_(self):
pass

def _init_env(self, freshenv):
if freshenv:
ENV_PICKLE_FILENAME = 'environment.pickle'
filename = os.path.join(self.doctreedir, ENV_PICKLE_FILENAME)
if freshenv or not os.path.exists(filename):
self.env = _CustomBuildEnvironment(self)
self.env.setup(self)
if self.srcdir is not None and self.srcdir != "IMPOSSIBLE:TOFIND":
Expand Down
8 changes: 0 additions & 8 deletions src/pyquickhelper/sphinxext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,4 @@ def get_default_standard_extensions(use_mathjax=False):
'matplotlib.sphinxext.plot_directive',
]

try:
import sphinxcontrib.jsdemo
assert sphinxcontrib.jsdemo is not None
extensions.append('sphinxcontrib.jsdemo')
except ImportError: # pragma: no cover
# No module sphinxcontrib.jsdemo.
pass

return extensions
4 changes: 2 additions & 2 deletions src/pyquickhelper/sphinxext/sphinx_doctree_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DocTreeTranslator(nodes.NodeVisitor, CommonSphinxWriterHelpers):
Defines a translator for doctree
"""

def __init__(self, builder, document):
def __init__(self, document, builder):
if not hasattr(builder, 'config'):
raise TypeError( # pragma: no cover
"Unexpected type for builder {0}".format(type(builder)))
Expand Down Expand Up @@ -262,7 +262,7 @@ def __init__(self, builder):
self.builder = builder

def translate(self):
visitor = self.builder.create_translator(self.builder, self.document)
visitor = self.builder.create_translator(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.body

Expand Down
6 changes: 3 additions & 3 deletions src/pyquickhelper/sphinxext/sphinx_latex_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EnhancedLaTeXTranslator(LaTeXTranslator):
and modifies a few functions.
"""

def __init__(self, builder, document):
def __init__(self, document, builder):
if not hasattr(builder, 'config'):
raise TypeError(
"Unexpected type for builder {0}".format(type(builder)))
Expand Down Expand Up @@ -183,7 +183,7 @@ def __init__(self, builder):
LaTeXWriter.__init__(self, builder)

def translate(self):
visitor = self.builder.create_translator(self.builder, self.document)
visitor = self.builder.create_translator(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.astext()

Expand Down Expand Up @@ -259,8 +259,8 @@ def write(self, *ignored):
docname, toctree_only,
appendices=((docclass != 'howto') and self.config.latex_appendices or []))
doctree['tocdepth'] = tocdepth
self.apply_transforms(doctree)
self.post_process_images(doctree)

self.logger.info(__("writing... "), nonl=1)
doctree.settings = docsettings
doctree.settings.author = author
Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/sphinxext/sphinx_md_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MdTranslator(TextTranslator, CommonSphinxWriterHelpers):
Defines a :epkg:`MD` translator.
"""

def __init__(self, builder, document):
def __init__(self, document, builder):
if not hasattr(builder, "config"):
raise TypeError( # pragma: no cover
"Builder has no config: {}".format(type(builder)))
Expand Down Expand Up @@ -1101,7 +1101,7 @@ def __init__(self, builder):
self.builder = builder

def translate(self):
visitor = self.builder.create_translator(self.builder, self.document)
visitor = self.builder.create_translator(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.body

Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/sphinxext/sphinx_rst_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RstTranslator(TextTranslator, CommonSphinxWriterHelpers):
"""
sectionchars = '*=-~"+`'

def __init__(self, builder, document):
def __init__(self, document, builder):
if not hasattr(builder, "config"):
raise TypeError("Builder has no config: {}".format(type(builder)))
TextTranslator.__init__(self, document, builder)
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def __init__(self, builder):
self.builder = builder

def translate(self):
visitor = self.builder.create_translator(self.builder, self.document)
visitor = self.builder.create_translator(self.document, self.builder)
self.document.walkabout(visitor)
self.output = visitor.body

Expand Down