Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Fixes #198, #199, documentation, and fixes for the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Oct 14, 2018
1 parent e6ecdb0 commit 8fbd6fb
Show file tree
Hide file tree
Showing 135 changed files with 238 additions and 856 deletions.
2 changes: 0 additions & 2 deletions HISTORY.rst
@@ -1,5 +1,4 @@


.. _l-HISTORY:

=======
Expand Down Expand Up @@ -128,4 +127,3 @@ current - 2018-10-06 - 0.00Mb

1.5.2275 - 2017-11-28 - 0.50Mb
==============================

4 changes: 2 additions & 2 deletions _doc/sphinxdoc/source/api/helpgen.rst
Expand Up @@ -13,11 +13,11 @@ configuration
conversion
++++++++++

.. autosignature:: pyquickhelper.helpgen.sphinxm_convert_doc_helper.docstring2html
.. autosignature:: pyquickhelper.helpgen.rst_converters.docstring2html

.. autosignature:: pyquickhelper.helpgen.pandoc_helper.latex2rst

.. autosignature:: pyquickhelper.helpgen.sphinxm_convert_doc_helper.rst2html
.. autosignature:: pyquickhelper.helpgen.rst_converters.rst2html

specific
++++++++
Expand Down
7 changes: 0 additions & 7 deletions _doc/sphinxdoc/source/api/jupyter.rst
Expand Up @@ -29,13 +29,6 @@ controls

.. autosignature:: pyquickhelper.ipythonhelper.interact.StaticInteract

extensions
++++++++++

.. autosignature:: pyquickhelper.ipythonhelper.cython_helper.ipython_cython_extension

.. autosignature:: pyquickhelper.ipythonhelper.helper_in_notebook.load_extension

kernels
+++++++

Expand Down
2 changes: 1 addition & 1 deletion _doc/sphinxdoc/source/api/pycode.rst
Expand Up @@ -51,7 +51,7 @@ virtual environments

.. autosignature:: pyquickhelper.pycode.venv_helper.check_readme_syntax

.. autosignature:: pyquickhelper.pycode.venv_helper.compare_module_version
.. autosignature:: pyquickhelper.texthelper.version_helper.compare_module_version

.. autosignature:: pyquickhelper.pycode.venv_helper.create_virtual_env

Expand Down
2 changes: 1 addition & 1 deletion _doc/sphinxdoc/source/documentation_example.rst
Expand Up @@ -45,4 +45,4 @@ example with a running script
a predefined link
-----------------

:epkg:`XD`
:epkg:`pep8`
6 changes: 3 additions & 3 deletions _doc/sphinxdoc/source/tutorial/sphinx.rst
Expand Up @@ -322,7 +322,7 @@ directory.
ax.plot([0, 1], [0, 1], '--')
fig.savefig(os.path.join(__WD__, "oo.png"))

text = ".. image:: oo.png\\n :width: 200px"
text = ".. image:: oo.png\\n :width: 202px"
print(text)

The image needs to be save in the same folder than
Expand All @@ -336,7 +336,7 @@ the *rst* file.
ax.plot([0, 1], [0, 1], '--')
fig.savefig(os.path.join(__WD__, "oo.png"))

text = ".. image:: oo.png\\n :width: 200px"
text = ".. image:: oo.png\\n :width: 201px"
print(text)

Option ``:toggle:`` can hide the code or the output or both
Expand Down Expand Up @@ -714,7 +714,7 @@ to use files. I finally decided to spend some time on Sphinx
to be able to run it to convert a RST into HTML and RST.
That's the purpose of the next function:

.. autosignature:: pyquickhelper.helpgen.sphinxm_convert_doc_helper.rst2html
.. autosignature:: pyquickhelper.helpgen.rst_converters.rst2html

The HTML conversion is quite difficult to read:

Expand Down
2 changes: 1 addition & 1 deletion _doc/sphinxdoc/source/tutorial/unittest.rst
Expand Up @@ -11,7 +11,7 @@ as :epkg:`pyquickhelper`:
all names are prefixed by ``ut_``.
* Tests files starts with ``test_``.
* Unit test must inherits from :*py:`unittest:TestCase` or
:class:`ExtTestCase <pyquickhelper.pycode.unittestclass.ExtTestCase>`
:py:class:`ExtTestCase <pyquickhelper.pycode.unittestclass.ExtTestCase>`
which adds a couple of *assert* methods.

One function is used to prints information but is disabled
Expand Down
7 changes: 2 additions & 5 deletions _unittests/ut_sphinxext/test_blocref_extension.py
Expand Up @@ -230,8 +230,7 @@ def test_blocreflist(self):
tives = [("blocref", BlocRef, blocref_node,
visit_blocref_node, depart_blocref_node)]

html = rst2html(content, fLOG=fLOG,
writer="html", keep_warnings=True,
html = rst2html(content, writer="html", keep_warnings=True,
directives=tives)

temp = get_temp_folder(__file__, "temp_blocreflist")
Expand All @@ -252,6 +251,4 @@ def test_blocreflist(self):


if __name__ == "__main__":
TestBlocRefExtension().test_post_parse_blocref()
TestBlocRefExtension().test_blocref_rst()
# unittest.main()
unittest.main()
3 changes: 3 additions & 0 deletions _unittests/ut_sphinxext/test_cmdref_extension.py
Expand Up @@ -162,6 +162,9 @@ def test_cmdreflist(self):
if t1 not in html:
raise Exception(html)

if 'freg0"></a>' in html:
raise Exception(html)

def test_cmdref_rename(self):
fLOG(
__file__,
Expand Down
2 changes: 0 additions & 2 deletions src/pyquickhelper/__init__.py
Expand Up @@ -92,8 +92,6 @@ def get_insetup_functions():
Returns function used when a module includes C++ parts.
@return tuple of functions
.. versionadded:: 1.5
"""
from .pycode.insetup_helper import must_build, run_build_ext
return must_build, run_build_ext
8 changes: 3 additions & 5 deletions src/pyquickhelper/benchhelper/benchmark.py
@@ -1,8 +1,6 @@
"""
@file
@brief Helpers to benchmark something
.. versionadded:: 1.5
"""
import os
import sys
Expand Down Expand Up @@ -238,10 +236,10 @@ def fLOG(self, *l, **p):
if self._fLOG:
self._fLOG(*l, **p)
if hasattr(self, "_progressbars") and self._progressbars and len(self._progressbars) > 0:
bar = self._progressbars[-1]
bar.set_description(fLOGFormat(
br = self._progressbars[-1]
br.set_description(fLOGFormat(
"\n", *l, **p).strip("\n").split("\n")[0])
bar.refresh()
br.refresh()

def run(self, params_list):
"""
Expand Down
10 changes: 0 additions & 10 deletions src/pyquickhelper/cli/cli_helper.py
@@ -1,8 +1,6 @@
"""
@file
@brief Automate the creation of a parser based on a function.
.. versionadded:: 1.5
"""
from __future__ import print_function
import argparse
Expand All @@ -21,8 +19,6 @@ def clean_documentation_for_cli(doc, cleandoc):
@param cleandoc a string which tells how to clean,
or a function which takes a function and
returns a string
.. versionadded:: 1.6.2290
"""
for st in ('.. versionchanged::', '.. versionadded'):
if st in doc:
Expand Down Expand Up @@ -74,9 +70,6 @@ def create_cli_parser(f, prog=None, layout="sphinx", skip_parameters=('fLOG',),
If an annotation offers mutiple types,
the first one will be used for the command line.
.. versionchanged:: 1.6.2290
Parameters *options*, *cleandoc* were added.
"""
docf = clean_documentation_for_cli(f.__doc__, cleandoc)
doctree = docstring2html(docf, writer="doctree",
Expand Down Expand Up @@ -224,9 +217,6 @@ def flog(*l):
r = rows[0][0]
if not r.startswith("usage: mycommand_line ..."):
raise Exception(r)
.. versionchanged:: 1.6.2290
Parameters *options*, *cleandoc* were added.
"""
if parser is None:
parser = create_cli_parser(
Expand Down
12 changes: 2 additions & 10 deletions src/pyquickhelper/cli/encryption_cli.py
@@ -1,16 +1,14 @@
"""
@file
@brief encrypt and decrypt command lines
.. versionadded:: 1.3
"""
from __future__ import print_function
import os
import argparse
import sys


def get_parser(encrypt):
def get_parser(encrypt): # pylint: disable=W0621
"""
Defines the way to parse the magic command ``%encrypt`` and ``%decrypt``.
Expand Down Expand Up @@ -53,7 +51,7 @@ def get_parser(encrypt):
return parser


def do_main(source, dest, password, encrypt,
def do_main(source, dest, password, encrypt, # pylint: disable=W0621
crypt_file, crypt_map, regex=None, fLOG=None):
"""
Encrypts or decrypts a folder, see @see cl EncryptedBackup.
Expand Down Expand Up @@ -126,9 +124,6 @@ def encrypt(fLOG=print, args=None):
:cmd: pyquickhelper.cli.encryption_cli:encrypt
Encrypts a string from the command line.
.. versionchanged:: 1.5
Parameter *args* was added.
"""
parser = get_parser(True)
if args is not None and args == ['--help']:
Expand Down Expand Up @@ -161,9 +156,6 @@ def decrypt(fLOG=print, args=None):
:cmd: pyquickhelper.cli.encryption_cli:decrypt
Decrypts an encrypted string from the command line.
.. versionchanged:: 1.5
Parameter *args* was added.
"""
parser = get_parser(False)
if args is not None and args == ['--help']:
Expand Down
8 changes: 0 additions & 8 deletions src/pyquickhelper/cli/encryption_file_cli.py
@@ -1,8 +1,6 @@
"""
@file
@brief encrypt and decrypt command lines for just a file
.. versionadded:: 1.3
"""
from __future__ import print_function
import os
Expand Down Expand Up @@ -81,9 +79,6 @@ def encrypt_file(fLOG=print, args=None):
:cmd: pyquickhelper.cli.encryption_file_cli:encrypt_file
Encrypt a file from the command line.
.. versionchanged:: 1.5
Parameter *args* was added.
"""
parser = get_parser(True)
try:
Expand Down Expand Up @@ -111,9 +106,6 @@ def decrypt_file(fLOG=print, args=None):
:cmd: pyquickhelper.cli.encryption_file_cli:decrypt_file
Decrypt a file from the command line.
.. versionchanged:: 1.5
Parameter *args* was added.
"""
parser = get_parser(False)
try:
Expand Down
2 changes: 0 additions & 2 deletions src/pyquickhelper/cli/pyq_sync_cli.py
@@ -1,8 +1,6 @@
"""
@file
@brief Wrapper function @see fn synchronize_folder into a command line.
.. versionadded:: 1.5
"""
from __future__ import print_function
import os
Expand Down
9 changes: 1 addition & 8 deletions src/pyquickhelper/filehelper/anyfhelper.py
@@ -1,8 +1,6 @@
"""
@file
@brief Various helpers about files
.. versionadded:: 1.1
"""

import os
Expand Down Expand Up @@ -152,12 +150,7 @@ def read_content_ufs(file_url_stream, encoding="utf8", asbytes=False, add_source
* *SB*: BytesIO
* *SBb*: BytesIO, return bytes
.. versionchanged:: 1.3
Parameter *asbytes* was added. The function can return bytes.
.. versionchanged:: 1.4
Parameter *add_source* was added.
The returned *source* is not reliable on Python 2.7.
The function can return bytes.
"""
if isinstance(file_url_stream, str # unicode#
):
Expand Down
12 changes: 2 additions & 10 deletions src/pyquickhelper/filehelper/download_helper.py
@@ -1,8 +1,6 @@
"""
@file
@brief A function to download the content of a url.
.. versionadded:: 1.1
"""
import sys
import socket
Expand Down Expand Up @@ -52,12 +50,6 @@ def get_url_content_timeout(url, timeout=10, output=None, encoding="utf8", raise
format, it will decompress it.
The function raises the exception @see cl InternetException.
.. versionadded:: 1.1
It comes from `pyrsslocal <http://www.xavierdupre.fr/app/pyrsslocal/helpsphinx/index.html>`_.
.. versionadded:: 1.4
Parameters *chunk*, *fLOG* were added.
"""
def save_content(content, append=False):
"local function"
Expand Down Expand Up @@ -92,7 +84,7 @@ def save_content(content, append=False):
def _local_loop(ur):
while True:
res = ur.read(chunk)
size[0] += len(res)
size[0] += len(res) # pylint: disable=E1137
if fLOG is not None:
fLOG("[get_url_content_timeout] downloaded",
size, "bytes")
Expand All @@ -102,7 +94,7 @@ def _local_loop(ur):
save_content(res, app)
else:
break
app[0] = True
app[0] = True # pylint: disable=E1137

if timeout != -1:
with urllib_request.urlopen(url, timeout=timeout) as ur:
Expand Down
4 changes: 0 additions & 4 deletions src/pyquickhelper/filehelper/encrypted_backup.py
@@ -1,8 +1,6 @@
"""
@file
@brief Keeps an encrypted of personal data
.. versionadded:: 1.3
"""
import re
import os
Expand Down Expand Up @@ -90,8 +88,6 @@ class EncryptedBackup:
dest=os.path.join(this, "_temp")
enc.retrieve_all(dest)
.. versionadded:: 1.3
"""

def __init__(self, key, file_tree_node, transfer_api,
Expand Down
8 changes: 2 additions & 6 deletions src/pyquickhelper/filehelper/encryption.py
Expand Up @@ -2,7 +2,7 @@
@file
@brief Encryption functionalities.
Inspired from `AES encryption of files in Python withPyCrypto
Inspired from `AES encryption of files in Python with PyCrypto
<http://eli.thegreenplace.net/2010/06/25/aes-encryption-of-files-in-python-with-pycrypto>`_
"""
import random
Expand Down Expand Up @@ -163,8 +163,6 @@ def encrypt_stream(key, filename, out_filename=None, chunksize=2 ** 18, algo="AE
@param algo AES (PyCryptodomex) of or fernet (cryptography)
@return filename or bytes
.. versionadded:: 1.3
"""

in_size, in_close, in_stream, out_close, out_return, out_stream = open_input_output(
Expand Down Expand Up @@ -205,11 +203,9 @@ def decrypt_stream(key, filename, out_filename=None, chunksize=3 * 2 ** 13, algo
sizes can be faster for some files and machines.
chunksize must be divisible by 16.
@param algo AES (PyCryptodomex) of or fernet (cryptography)
@param algo AES (:epkg:`pycryptodomex`) of or fernet (cryptography)
@return filename or bytes
.. versionadded:: 1.3
"""
in_size, in_close, in_stream, out_close, out_return, out_stream = open_input_output(
filename, out_filename)
Expand Down

0 comments on commit 8fbd6fb

Please sign in to comment.